Example usage for java.awt.geom AffineTransform getType

List of usage examples for java.awt.geom AffineTransform getType

Introduction

In this page you can find the example usage for java.awt.geom AffineTransform getType.

Prototype

public int getType() 

Source Link

Document

Retrieves the flag bits describing the conversion properties of this transform.

Usage

From source file:ExtendedGeneralPath.java

/**
 * Delegates to the enclosed <code>GeneralPath</code>.
 *///from   w  w w  .ja v a2s  .  c om
public void transform(AffineTransform at) {
    if (at.getType() != AffineTransform.TYPE_IDENTITY)
        throw new IllegalArgumentException("ExtendedGeneralPaths can not be transformed");
}

From source file:org.jcurl.core.base.CurveTransformedTest.java

public void testAffineTransformRotate() {
    final Rock v0 = new RockDouble(1, 1.5, 0.3);
    final double[] d = { v0.getY(), -v0.getX(), v0.getX(), v0.getY(), 0, 0 };
    final AffineTransform at = new AffineTransform(d);
    final double v = v0.distance(0, 0);
    at.scale(1 / v, 1 / v);//from w  ww  .  ja  va 2s  . c  o  m
    assertEquals(AffineTransform.TYPE_GENERAL_ROTATION, at.getType());
    assertEquals("", 1.0, at.getDeterminant(), 1e-9);
    assertEquals("", 0.8320502943378437, at.getScaleX(), 1e-9);
    assertEquals("", at.getScaleX(), at.getScaleY(), 1e-9);
    assertEquals("", 0.5547001962252291, at.getShearX(), 1e-9);
    assertEquals("", -at.getShearX(), at.getShearY(), 1e-9);
    assertEquals("", 0.0, at.getTranslateX(), 1e-9);
    assertEquals("", 0.0, at.getTranslateY(), 1e-9);
    Point2D p = null;
    p = at.transform(new Point2D.Double(1, 0), null);
    assertEquals("Point2D.Double[0.8320502943378437, -0.5547001962252291]", p.toString());
    assertEquals("", 1.0, p.distanceSq(0, 0), 1e-9);
    p = at.transform(new Point2D.Double(0, 1), null);
    assertEquals("Point2D.Double[0.5547001962252291, 0.8320502943378437]", p.toString());
    assertEquals("", 1.0, p.distanceSq(0, 0), 1e-9);
    p = at.transform(new Point2D.Double(0.75, 1.5), null);
    assertEquals("Point2D.Double[1.4560880150912265, 0.8320502943378438]", p.toString());
    p = at.transform(new Point2D.Double(1.5, 3.0), null);
    assertEquals("Point2D.Double[2.912176030182453, 1.6641005886756877]", p.toString());
}

From source file:org.jcurl.core.base.CurveTransformedTest.java

/**
 * Test the transformation from a Rock Coordinates (rc) System at wc(3,3.5)
 * with positive y axis along wc(2,4.2) into World Coordinates (wc). Uses a
 * Point rc(5,1.3) = wc(8,2.5)./*from   w  w w .ja v  a  2  s.  c  o  m*/
 */
public void testAffineTransformRotateShift() {
    final Point2D p0_wc = new Point2D.Double(3, 3.5);
    final Rock v0_wc = new RockDouble(2, 4.2, 0.3);
    final double v = v0_wc.distance(0, 0);
    final double[] d = { v0_wc.getY(), -v0_wc.getX(), v0_wc.getX(), v0_wc.getY(), 0, 0 };
    final AffineTransform at = new AffineTransform(d);
    at.scale(1 / v, 1 / v);
    assertEquals(AffineTransform.TYPE_GENERAL_ROTATION + AffineTransform.TYPE_UNIFORM_SCALE, at.getType());
    assertEquals(1.0, at.getDeterminant());
    assertEquals(0.9028605188239303, at.getScaleX());
    assertEquals(at.getScaleX(), at.getScaleY());
    assertEquals(0.42993358039234775, at.getShearX());
    assertEquals(-at.getShearX(), at.getShearY());
    assertEquals(0, at.getTranslateX());
    assertEquals(0, at.getTranslateY());
    Point2D p = null;
    p = at.transform(new Point2D.Double(5, 1.3), null);
    assertEquals("Point2D.Double[5.073216248629703, -0.9759492274906292]", p.toString());

    at.preConcatenate(AffineTransform.getTranslateInstance(p0_wc.getX(), p0_wc.getY()));
    assertEquals(AffineTransform.TYPE_GENERAL_ROTATION + AffineTransform.TYPE_TRANSLATION
            + AffineTransform.TYPE_UNIFORM_SCALE, at.getType());
    assertEquals(1.0, at.getDeterminant());
    assertEquals(0.9028605188239303, at.getScaleX());
    assertEquals(at.getScaleX(), at.getScaleY());
    assertEquals(0.42993358039234775, at.getShearX());
    assertEquals(-at.getShearX(), at.getShearY());
    assertEquals(p0_wc.getX(), at.getTranslateX());
    assertEquals(p0_wc.getY(), at.getTranslateY());

    p = at.transform(new Point2D.Double(5, 1.3), null);
    assertEquals("Point2D.Double[8.073216248629702, 2.524050772509371]", p.toString());
}

From source file:org.jcurl.core.base.CurveTransformedTest.java

/**
 * Test the transformation from a Rock Coordinates (rc) System at wc(3,3.5)
 * with positive y axis along wc(2,4.2) into World Coordinates (wc). Uses a
 * Point rc(5,1.3) = wc(8,2.5)./*from   w w w.  j  ava 2s  .  c  o  m*/
 * 
 * @see CurveTransformed#createRc2Wc(AffineTransform, Point2D, Point2D)
 */
public void testCreateRc2Wc() {
    final Point2D p0_wc = new Point2D.Double(3, 3.5);
    final Rock v0_wc = new RockDouble(2, 4.2, 0.3);
    final AffineTransform at = CurveTransformed.createRc2Wc(null, p0_wc, v0_wc);
    assertEquals(AffineTransform.TYPE_GENERAL_ROTATION + AffineTransform.TYPE_TRANSLATION, at.getType());
    assertEquals(1.0, at.getDeterminant());
    assertEquals(0.9028605188239303, at.getScaleX());
    assertEquals(at.getScaleX(), at.getScaleY());
    assertEquals(0.42993358039234775, at.getShearX());
    assertEquals(-at.getShearX(), at.getShearY());
    assertEquals(p0_wc.getX(), at.getTranslateX());
    assertEquals(p0_wc.getY(), at.getTranslateY());

    final Point2D rc = new Point2D.Double(5, 1.3);
    final Point2D wc = at.transform(rc, null);
    assertEquals("Point2D.Double[8.073216248629704, 2.524050772509371]", wc.toString());

    // angle in rc:
    double ang = Math.atan2(rc.getY(), rc.getX());
    assertEquals(14.574216198038739, rad2deg(ang));

    // wc rotation:
    ang = Math.atan2(at.getShearY(), at.getScaleY());
    assertEquals(-25.463345061871614, rad2deg(ang));
    final double[] d = new double[6];
    at.getMatrix(d);
    ang = Math.atan2(-d[2], d[3]);
    assertEquals(-25.463345061871614, rad2deg(ang));

    // angle in wc:
    ang = Math.atan2(wc.getY(), wc.getX());
    assertEquals(17.36159358309492, rad2deg(ang));
}