当前位置: 首页>>代码示例>>Java>>正文


Java AffineTransform.getType方法代码示例

本文整理汇总了Java中java.awt.geom.AffineTransform.getType方法的典型用法代码示例。如果您正苦于以下问题:Java AffineTransform.getType方法的具体用法?Java AffineTransform.getType怎么用?Java AffineTransform.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.AffineTransform的用法示例。


在下文中一共展示了AffineTransform.getType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkBug4418285

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static void checkBug4418285() {
    AffineTransform id =
        new AffineTransform ();
    AffineTransform translate0 =
        AffineTransform.getTranslateInstance (0, 0);
    if (id.isIdentity() != translate0.isIdentity() ||
        id.getType() != translate0.getType())
    {
        numerrors++;
        if (verbose) {
            System.err.println("id=        " + id         +
                               ", isIdentity()=" +
                               id.isIdentity());
            System.err.println("translate0=" + translate0 +
                               ", isIdentity()=" +
                               translate0.isIdentity());
            System.err.println("equals="     + id.equals (translate0));
            System.err.println();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:GetTypeOptimization.java

示例2: needToCopyBgColorImage

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Return true if drawing {@code img} will
 * invoke a Java2D bug (#4258675). The bug in question
 * occurs when a draw image call with a background color
 * parameter tries to render a sheared
 * or rotated image. The portions of the bounding
 * rectangle not covered by the sheared image
 * are incorrectly drawn with the background color.
 */
private boolean needToCopyBgColorImage(Image img) {

    boolean needToCopy;

    AffineTransform transform = getTransform();

    return (transform.getType()
            & (AffineTransform.TYPE_GENERAL_ROTATION
               | AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ProxyGraphics2D.java

示例3: isScaledGraphics

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static boolean isScaledGraphics(Graphics g) {
    if (g instanceof Graphics2D) {
        AffineTransform tx = ((Graphics2D) g).getTransform();
        return (tx.getType() & ~(TYPE_TRANSLATION | TYPE_FLIP)) != 0;
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:SwingUtilities2.java

示例4: needToCopyBgColorImage

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Return true if drawing <code>img</code> will
 * invoke a Java2D bug (#4258675). The bug in question
 * occurs when a draw image call with a background color
 * parameter tries to render a sheared
 * or rotated image. The portions of the bounding
 * rectangle not covered by the sheared image
 * are incorrectly drawn with the background color.
 */
private boolean needToCopyBgColorImage(Image img) {

    boolean needToCopy;

    AffineTransform transform = getTransform();

    return (transform.getType()
            & (AffineTransform.TYPE_GENERAL_ROTATION
               | AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:ProxyGraphics2D.java

示例5: getModifiedType

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static int getModifiedType(AffineTransform at) {
    int type = at.getType();
    // Some of the vector methods can introduce a tiny uniform scale
    // at some angles...
    if ((type & ANY_SCALE_MASK) != 0) {
        maxulps = Math.max(maxulps, ulps(at.getDeterminant(), 1.0));
        if (ulps(at.getDeterminant(), 1.0) <= MAX_ULPS) {
            // Really tiny - we will ignore it
            type &= ~ ANY_SCALE_MASK;
        }
    }
    return type;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TestInvertMethods.java

示例6: deviceFillRect

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
@Override
protected void deviceFillRect(int x, int y, int width, int height,
                              Color color) {
    /*
     * Transform to device coordinates
     */
    AffineTransform deviceTransform = getTransform();

    /* check if rotated or sheared */
    int transformType = deviceTransform.getType();
    boolean usePath =  ((transformType &
                           (AffineTransform.TYPE_GENERAL_ROTATION |
                            AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0);
    if (usePath) {
        fill(new Rectangle2D.Float(x, y, width, height));
        return;
    }

    Point2D.Float tlc_pos = new Point2D.Float(x, y);
    deviceTransform.transform(tlc_pos, tlc_pos);

    Point2D.Float brc_pos = new Point2D.Float(x+width, y+height);
    deviceTransform.transform(brc_pos, brc_pos);

    float deviceWidth = (float) (brc_pos.getX() - tlc_pos.getX());
    float deviceHeight = (float)(brc_pos.getY() - tlc_pos.getY());

    WPrinterJob wPrinterJob = (WPrinterJob) getPrinterJob();
    wPrinterJob.fillRect((float)tlc_pos.getX(), (float)tlc_pos.getY(),
                         deviceWidth, deviceHeight, color);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:WPathGraphics.java

示例7: transformShape

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
protected static Shape transformShape(AffineTransform tx, Shape clip) {
    if (clip == null) {
        return null;
    }

    if (clip instanceof Rectangle2D &&
        (tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0)
    {
        Rectangle2D rect = (Rectangle2D) clip;
        double matrix[] = new double[4];
        matrix[0] = rect.getX();
        matrix[1] = rect.getY();
        matrix[2] = matrix[0] + rect.getWidth();
        matrix[3] = matrix[1] + rect.getHeight();
        tx.transform(matrix, 0, matrix, 0, 2);
        fixRectangleOrientation(matrix, rect);
        return new Rectangle2D.Double(matrix[0], matrix[1],
                                      matrix[2] - matrix[0],
                                      matrix[3] - matrix[1]);
    }

    if (tx.isIdentity()) {
        return cloneShape(clip);
    }

    return tx.createTransformedShape(clip);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:SunGraphics2D.java

示例8: isIntegerTranslation

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Returns true if the given AffineTransform is an integer
 * translation.
 */
private static boolean isIntegerTranslation(AffineTransform xform) {
    if (xform.isIdentity()) {
        return true;
    }
    if (xform.getType() == AffineTransform.TYPE_TRANSLATION) {
        double tx = xform.getTranslateX();
        double ty = xform.getTranslateY();
        return (tx == (int)tx && ty == (int)ty);
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:SunGraphics2D.java

示例9: getNativePointSize

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private int getNativePointSize() {
    /* Make a copy of the glyphTX in which we will store the
     * font transform, inverting the devTx if necessary
     */
    double[] mat = new double[4];
    desc.glyphTx.getMatrix(mat);
    fontTx = new AffineTransform(mat);

    /* Now work backwards to get the font transform */
    if (!desc.devTx.isIdentity() &&
        desc.devTx.getType() != AffineTransform.TYPE_TRANSLATION) {
        try {
            invertDevTx = desc.devTx.createInverse();
            fontTx.concatenate(invertDevTx);
        } catch (NoninvertibleTransformException e) {
            e.printStackTrace();
        }
    }

    /* At this point the fontTx may be a simple +ve scale, or it
     * may be something more complex.
     */
    Point2D.Float pt = new Point2D.Float(1f,1f);
    fontTx.deltaTransform(pt, pt);
    double ptSize = Math.abs(pt.y);
    int ttype = fontTx.getType();
    if ((ttype & ~AffineTransform.TYPE_UNIFORM_SCALE) != 0 ||
        fontTx.getScaleY() <= 0) {
        /* We need to create an inverse transform that doesn't
         * include the point size (strictly the uniform scale)
         */
        fontTx.scale(1/ptSize, 1/ptSize);
    } else {
        fontTx = null; // no need
    }
    return (int)ptSize;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:NativeStrike.java

示例10: isTransformQuadrantRotated

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static boolean isTransformQuadrantRotated(AffineTransform tr) {
    return ((tr.getType() & (AffineTransform.TYPE_GENERAL_ROTATION |
             AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:XRUtils.java

示例11: 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);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:66,代码来源:PiscesRenderingEngine.java

示例12: userSpaceLineWidth

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private final double userSpaceLineWidth(AffineTransform at, double lw) {

        double widthScale;

        if (at == null) {
            widthScale = 1.0d;
        } else 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.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 = Math.sqrt(widthsquared);
        }

        return (lw / widthScale);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:68,代码来源:DMarlinRenderingEngine.java


注:本文中的java.awt.geom.AffineTransform.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。