Example usage for java.awt.geom Path2D transform

List of usage examples for java.awt.geom Path2D transform

Introduction

In this page you can find the example usage for java.awt.geom Path2D transform.

Prototype

public abstract void transform(AffineTransform at);

Source Link

Document

Transforms the geometry of this path using the specified AffineTransform .

Usage

From source file:org.jfree.graphics2d.demo.ImageTest.java

private static void drawArcTest(Graphics2D g2) {
    g2.setPaint(Color.GREEN);//w w w . j  a v  a 2 s  .  co  m
    g2.drawRect(0, 20, 70, 50);
    g2.setPaint(Color.RED);
    Path2D path1 = new Path2D.Double();
    double[] pts = calculateReferenceArc(90);
    path1.moveTo(pts[0], pts[1]);
    path1.curveTo(pts[2], pts[3], pts[4], pts[5], pts[6], pts[7]);
    AffineTransform t = new AffineTransform();
    t.translate(35, 45);
    t.scale(35, 25);
    t.rotate(Math.PI / 4);
    path1.transform(t);
    g2.draw(path1);

    Path2D path2 = new Path2D.Double();
    path2.moveTo(pts[0], pts[1]);
    path2.curveTo(pts[2], pts[3], pts[4], pts[5], pts[6], pts[7]);
    AffineTransform t2 = new AffineTransform();
    t2.rotate(3 * Math.PI / 4);
    t2.scale(35, 25);
    t2.translate(35, 35);
    path2.transform(t2);
    //g2.draw(path2);
    Path2D arc = new Path2D.Double();
    arc.append(path1, false);
    arc.append(path2, false);
    //g2.draw(arc);
    //g2.draw(path1);
    //g2.transform(t);
    g2.setPaint(Color.BLUE);
    g2.drawArc(0, 20, 70, 50, 0, -270);
    //Arc2D arc2d = new Arc2D.Double(0d, 20d, 70d, 50d, 0d, 90, Arc2D.OPEN);
    //g2.draw(arc2d);
}