本文整理匯總了Java中java.awt.geom.AffineTransform.getScaleX方法的典型用法代碼示例。如果您正苦於以下問題:Java AffineTransform.getScaleX方法的具體用法?Java AffineTransform.getScaleX怎麽用?Java AffineTransform.getScaleX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.geom.AffineTransform
的用法示例。
在下文中一共展示了AffineTransform.getScaleX方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deltaTransformConsumer
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
DPathConsumer2D deltaTransformConsumer(DPathConsumer2D out,
AffineTransform at)
{
if (at == null) {
return out;
}
double mxx = at.getScaleX();
double mxy = at.getShearX();
double myx = at.getShearY();
double myy = at.getScaleY();
if (mxy == 0.0d && myx == 0.0d) {
if (mxx == 1.0d && myy == 1.0d) {
return out;
} else {
return dt_DeltaScaleFilter.init(out, mxx, myy);
}
} else {
return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy);
}
}
示例2: inverseDeltaTransformConsumer
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
public static PathConsumer2D
inverseDeltaTransformConsumer(PathConsumer2D out,
AffineTransform at)
{
if (at == null) {
return out;
}
float Mxx = (float) at.getScaleX();
float Mxy = (float) at.getShearX();
float Myx = (float) at.getShearY();
float Myy = (float) at.getScaleY();
if (Mxy == 0f && Myx == 0f) {
if (Mxx == 1f && Myy == 1f) {
return out;
} else {
return new DeltaScaleFilter(out, 1.0f/Mxx, 1.0f/Myy);
}
} else {
float det = Mxx * Myy - Mxy * Myx;
return new DeltaTransformFilter(out,
Myy / det,
-Mxy / det,
-Myx / det,
Mxx / det);
}
}
示例3: setBounds
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
@Override
public void setBounds(int x, int y, int width, int height, int op) {
sysX = x;
sysY = y;
sysW = width;
sysH = height;
int cx = x + width / 2;
int cy = y + height / 2;
GraphicsConfiguration current = getGraphicsConfiguration();
GraphicsConfiguration other = SwingUtilities2.getGraphicsConfigurationAtPoint(current, cx, cy);
if (!current.equals(other)) {
AffineTransform tx = other.getDefaultTransform();
double otherScaleX = tx.getScaleX();
double otherScaleY = tx.getScaleY();
initScales();
if (scaleX != otherScaleX || scaleY != otherScaleY) {
x = (int) Math.floor(x * otherScaleX / scaleX);
y = (int) Math.floor(y * otherScaleY / scaleY);
}
}
super.setBounds(x, y, width, height, op);
}
示例4: testScale
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private static void testScale(double scaleX, double scaleY) {
Dialog dialog = new Dialog((Frame) null, true) {
@Override
public void paint(Graphics g) {
super.paint(g);
AffineTransform tx = ((Graphics2D) g).getTransform();
dispose();
if (scaleX != tx.getScaleX() || scaleY != tx.getScaleY()) {
throw new RuntimeException(String.format("Wrong scale:"
+ "[%f, %f] instead of [%f, %f].",
tx.getScaleX(), tx.getScaleY(), scaleX, scaleY));
}
}
};
dialog.setSize(200, 300);
dialog.setVisible(true);
}
示例5: initScreenBounds
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
static void initScreenBounds() {
GraphicsDevice[] devices = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getScreenDevices();
screenBounds = new Rectangle[devices.length];
scales = new double[devices.length][2];
for (int i = 0; i < devices.length; i++) {
GraphicsConfiguration gc = devices[i].getDefaultConfiguration();
screenBounds[i] = gc.getBounds();
AffineTransform tx = gc.getDefaultTransform();
scales[i][0] = tx.getScaleX();
scales[i][1] = tx.getScaleY();
}
for (int i = 0; i < devices.length; i++) {
for (int j = i + 1; j < devices.length; j++) {
if (scales[i][0] != scales[j][0] || scales[i][1] != scales[j][1]) {
screen1 = i;
screen2 = j;
}
}
}
}
示例6: applyShape
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
* Applies the shape to the native component window.
* @since 1.7
*/
@Override
public void applyShape(Region shape) {
if (shapeLog.isLoggable(PlatformLogger.Level.FINER)) {
shapeLog.finer("*** INFO: Setting shape: PEER: " + this
+ "; TARGET: " + target
+ "; SHAPE: " + shape);
}
if (shape != null) {
AffineTransform tx = winGraphicsConfig.getDefaultTransform();
double scaleX = tx.getScaleX();
double scaleY = tx.getScaleY();
if (scaleX != 1 || scaleY != 1) {
shape = shape.getScaledRegion(scaleX, scaleY);
}
setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
(shape.isRectangular() ? null : shape));
} else {
setRectangularShape(0, 0, 0, 0, null);
}
}
示例7: TestFrame
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
public TestFrame(GraphicsConfiguration gc, Rectangle rect) throws HeadlessException {
super(gc);
setBounds(rect);
mrImage = new TestMultiResolutionImage(rect.width, rect.height);
JPanel panel = new JPanel(new FlowLayout()) {
@Override
public void paint(Graphics g) {
super.paint(g);
AffineTransform tx = ((Graphics2D) g).getTransform();
mrImage.scaleX = tx.getScaleX();
mrImage.scaleY = tx.getScaleY();
Insets insets = getInsets();
g.drawImage(mrImage, insets.left, insets.bottom, null);
}
};
JButton button = new JButton("Move to another display");
button.addActionListener((e) -> {
GraphicsConfiguration config = getGraphicsConfiguration();
GraphicsDevice[] devices = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getScreenDevices();
int index = devices[screen1].getDefaultConfiguration().equals(config)
? screen2 : screen1;
Rectangle r = getCenterRect(screenBounds[index]);
frame.setBounds(r);
});
panel.add(button);
add(panel);
}
示例8: isPixelsCopying
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private boolean isPixelsCopying(JComponent c, Graphics g) {
AffineTransform tx = getTransform(g);
GraphicsConfiguration gc = c.getGraphicsConfiguration();
if (tx == null || gc == null
|| !SwingUtilities2.isFloatingPointScale(tx)) {
return false;
}
AffineTransform gcTx = gc.getDefaultTransform();
return gcTx.getScaleX() == tx.getScaleX()
&& gcTx.getScaleY() == tx.getScaleY();
}
示例9: fillRectangle
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
public void fillRectangle(SunGraphics2D sg2d,
double rx, double ry,
double rw, double rh)
{
double px, py;
double dx1, dy1, dx2, dy2;
AffineTransform txform = sg2d.transform;
dx1 = txform.getScaleX();
dy1 = txform.getShearY();
dx2 = txform.getShearX();
dy2 = txform.getScaleY();
px = rx * dx1 + ry * dx2 + txform.getTranslateX();
py = rx * dy1 + ry * dy2 + txform.getTranslateY();
dx1 *= rw;
dy1 *= rw;
dx2 *= rh;
dy2 *= rh;
if (adjustfill &&
sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM &&
sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE)
{
double newx = normalize(px);
double newy = normalize(py);
dx1 = normalize(px + dx1) - newx;
dy1 = normalize(py + dy1) - newy;
dx2 = normalize(px + dx2) - newx;
dy2 = normalize(py + dy2) - newy;
px = newx;
py = newy;
}
outrenderer.fillParallelogram(sg2d, rx, ry, rx+rw, ry+rh,
px, py, dx1, dy1, dx2, dy2);
}
示例10: transformConsumer
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
public static PathConsumer2D
transformConsumer(PathConsumer2D out,
AffineTransform at)
{
if (at == null) {
return out;
}
float Mxx = (float) at.getScaleX();
float Mxy = (float) at.getShearX();
float Mxt = (float) at.getTranslateX();
float Myx = (float) at.getShearY();
float Myy = (float) at.getScaleY();
float Myt = (float) at.getTranslateY();
if (Mxy == 0f && Myx == 0f) {
if (Mxx == 1f && Myy == 1f) {
if (Mxt == 0f && Myt == 0f) {
return out;
} else {
return new TranslateFilter(out, Mxt, Myt);
}
} else {
if (Mxt == 0f && Myt == 0f) {
return new DeltaScaleFilter(out, Mxx, Myy);
} else {
return new ScaleFilter(out, Mxx, Myy, Mxt, Myt);
}
}
} else if (Mxt == 0f && Myt == 0f) {
return new DeltaTransformFilter(out, Mxx, Mxy, Myx, Myy);
} else {
return new TransformFilter(out, Mxx, Mxy, Mxt, Myx, Myy, Myt);
}
}
示例11: matchTX
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private static boolean matchTX(double[] lhs, AffineTransform rhs) {
return
lhs[0] == rhs.getScaleX() &&
lhs[1] == rhs.getShearY() &&
lhs[2] == rhs.getShearX() &&
lhs[3] == rhs.getScaleY();
}
示例12: main
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
public static void main(String[] args) {
GraphicsConfiguration gc =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration();
AffineTransform normTransform = gc.getNormalizingTransform();
int dpiX = Toolkit.getDefaultToolkit().getScreenResolution();
int normDpiX = (int)(normTransform.getScaleX() * 72.0);
if (dpiX != normDpiX) {
throw new RuntimeException(
"Test FAILED. Toolkit.getScreenResolution()=" + dpiX +
" GraphicsConfiguration.getNormalizingTransform()="+normDpiX);
}
System.out.println("Test PASSED. DPI="+normDpiX);
}
示例13: getPixelColor
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
* Returns the color of a pixel at the given screen coordinates.
* @param x X position of pixel
* @param y Y position of pixel
* @return Color of the pixel
*/
public synchronized Color getPixelColor(int x, int y) {
AffineTransform tx = GraphicsEnvironment.
getLocalGraphicsEnvironment().getDefaultScreenDevice().
getDefaultConfiguration().getDefaultTransform();
x = (int) (x * tx.getScaleX());
y = (int) (y * tx.getScaleY());
Color color = new Color(peer.getRGBPixel(x, y));
return color;
}
示例14: userSpaceLineWidth
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private final float userSpaceLineWidth(AffineTransform at, float lw) {
float widthScale;
if (at == null) {
widthScale = 1.0f;
} else if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM |
AffineTransform.TYPE_GENERAL_SCALE)) != 0) {
widthScale = (float)Math.sqrt(at.getDeterminant());
} else {
// First calculate the "maximum scale" of this transform.
double A = at.getScaleX(); // m00
double C = at.getShearX(); // m01
double B = at.getShearY(); // m10
double D = at.getScaleY(); // m11
/*
* Given a 2 x 2 affine matrix [ A B ] such that
* [ C D ]
* v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to
* find the maximum magnitude (norm) of the vector v'
* with the constraint (x^2 + y^2 = 1).
* The equation to maximize is
* |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2)
* or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2).
* Since sqrt is monotonic we can maximize |v'|^2
* instead and plug in the substitution y = sqrt(1 - x^2).
* Trigonometric equalities can then be used to get
* rid of most of the sqrt terms.
*/
double EA = A*A + B*B; // x^2 coefficient
double EB = 2.0d * (A*C + B*D); // xy coefficient
double EC = C*C + D*D; // y^2 coefficient
/*
* There is a lot of calculus omitted here.
*
* Conceptually, in the interests of understanding the
* terms that the calculus produced we can consider
* that EA and EC end up providing the lengths along
* the major axes and the hypot term ends up being an
* adjustment for the additional length along the off-axis
* angle of rotated or sheared ellipses as well as an
* adjustment for the fact that the equation below
* averages the two major axis lengths. (Notice that
* the hypot term contains a part which resolves to the
* difference of these two axis lengths in the absence
* of rotation.)
*
* In the calculus, the ratio of the EB and (EA-EC) terms
* ends up being the tangent of 2*theta where theta is
* the angle that the long axis of the ellipse makes
* with the horizontal axis. Thus, this equation is
* calculating the length of the hypotenuse of a triangle
* along that axis.
*/
double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC));
// sqrt omitted, compare to squared limits below.
double widthsquared = ((EA + EC + hypot) / 2.0d);
widthScale = (float)Math.sqrt(widthsquared);
}
return (lw / widthScale);
}
示例15: userSpaceLineWidth
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private float userSpaceLineWidth(AffineTransform at, float lw) {
double widthScale;
if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM |
AffineTransform.TYPE_GENERAL_SCALE)) != 0) {
widthScale = Math.sqrt(at.getDeterminant());
} else {
/* First calculate the "maximum scale" of this transform. */
double A = at.getScaleX(); // m00
double C = at.getShearX(); // m01
double B = at.getShearY(); // m10
double D = at.getScaleY(); // m11
/*
* Given a 2 x 2 affine matrix [ A B ] such that
* [ C D ]
* v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to
* find the maximum magnitude (norm) of the vector v'
* with the constraint (x^2 + y^2 = 1).
* The equation to maximize is
* |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2)
* or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2).
* Since sqrt is monotonic we can maximize |v'|^2
* instead and plug in the substitution y = sqrt(1 - x^2).
* Trigonometric equalities can then be used to get
* rid of most of the sqrt terms.
*/
double EA = A*A + B*B; // x^2 coefficient
double EB = 2*(A*C + B*D); // xy coefficient
double EC = C*C + D*D; // y^2 coefficient
/*
* There is a lot of calculus omitted here.
*
* Conceptually, in the interests of understanding the
* terms that the calculus produced we can consider
* that EA and EC end up providing the lengths along
* the major axes and the hypot term ends up being an
* adjustment for the additional length along the off-axis
* angle of rotated or sheared ellipses as well as an
* adjustment for the fact that the equation below
* averages the two major axis lengths. (Notice that
* the hypot term contains a part which resolves to the
* difference of these two axis lengths in the absence
* of rotation.)
*
* In the calculus, the ratio of the EB and (EA-EC) terms
* ends up being the tangent of 2*theta where theta is
* the angle that the long axis of the ellipse makes
* with the horizontal axis. Thus, this equation is
* calculating the length of the hypotenuse of a triangle
* along that axis.
*/
double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC));
/* sqrt omitted, compare to squared limits below. */
double widthsquared = ((EA + EC + hypot)/2.0);
widthScale = Math.sqrt(widthsquared);
}
return (float) (lw / widthScale);
}