Example usage for java.awt Graphics2D setTransform

List of usage examples for java.awt Graphics2D setTransform

Introduction

In this page you can find the example usage for java.awt Graphics2D setTransform.

Prototype

public abstract void setTransform(AffineTransform Tx);

Source Link

Document

Overwrites the Transform in the Graphics2D context.

Usage

From source file:Main.java

public void paint(Graphics g) {
    Shape shape = new Rectangle2D.Float(100, 50, 80, 80);

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = AffineTransform.getRotateInstance(-Math.PI / 6, -Math.PI / 6);

    g2.setTransform(at);
    g2.draw(shape);/*  w  w  w .  j  a  v  a2  s.  co  m*/

}

From source file:Main.java

public void paint(Graphics g) {
    Shape shape = new Rectangle2D.Float(100, 50, 80, 80);

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = new AffineTransform();
    at.rotate(0.3, 0.2, 0.5, 0.3);/*from  w ww.j a  v  a  2s  . c  om*/

    g2.setTransform(at);
    g2.draw(shape);

}

From source file:AffineTransformGetRotateInstance.java

public void paint(Graphics g) {
    AffineTransform atrans = null;

    Graphics2D g2d = (Graphics2D) g;
    atrans = AffineTransform.getRotateInstance(Math.PI / 4, 50, 50);

    if (atrans != null)
        g2d.setTransform(atrans);

    g2d.fillRect(50, 50, 100, 50);//from w ww .  j av a  2s  . c  o  m
}

From source file:Main.java

public void paint(Graphics g) {
    Shape shape = new Rectangle2D.Float(100, 50, 80, 80);

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = AffineTransform.getRotateInstance(0.2, -Math.PI / 6, -Math.PI / 6);

    g2.setTransform(at);
    g2.draw(shape);/*ww  w . j  ava 2  s  . c  o  m*/

}

From source file:Draw2DRotate.java

public void paint(Graphics graphics) {
    Graphics2D g = (Graphics2D) graphics;
    AffineTransform transform = AffineTransform.getRotateInstance(Math.PI / 16.0d);
    g.setTransform(transform);
    Line2D.Double shape = new Line2D.Double(0.0, 0.0, 300.0, 300.0);
    g.draw(shape);/*from   w w w .j a  va2s. co m*/
    g.setFont(new Font("Helvetica", Font.BOLD, 24));
    String text = ("Java2s");
    g.drawString(text, 300, 50);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = toolkit.getImage("image1.gif");
    g.drawImage(image, 100, 150, this);
}

From source file:Main.java

public void paint(Graphics g) {
    Shape shape = new Rectangle2D.Float(100, 50, 80, 80);

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = new AffineTransform();
    at.setToQuadrantRotation(2, 0.5, 0.5);

    g2.setTransform(at);
    g2.draw(shape);//w  w w  . j  av a  2s.  c  o m

}

From source file:Main.java

public void paint(Graphics g) {
    Shape shape = new Rectangle2D.Float(100, 50, 80, 80);

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = AffineTransform.getRotateInstance(0.2, 0.2, -Math.PI / 6, -Math.PI / 6);

    g2.setTransform(at);
    g2.draw(shape);//from w  w w.  jav  a 2s  .co m

}

From source file:Main.java

public void paint(Graphics g) {
    Shape shape = new Rectangle2D.Float(100, 50, 80, 80);

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = new AffineTransform();
    at.setToScale(Math.PI / 6, Math.PI / 6);

    g2.setTransform(at);
    g2.draw(shape);//from www  .  ja  v  a 2s .c  om

}

From source file:Main.java

public void paint(Graphics g) {
    Shape shape = new Rectangle2D.Float(100, 50, 80, 80);

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = new AffineTransform();
    at.setToShear(Math.PI / 6, Math.PI / 6);

    g2.setTransform(at);
    g2.draw(shape);/*from  w  ww. j a  v a  2s  .c om*/

}

From source file:Shear.java

public void paint(Graphics g) {
    super.paint(g);

    Graphics2D g2d = (Graphics2D) g;

    AffineTransform tx1 = new AffineTransform();
    tx1.translate(50, 90);// w w  w  . j  av  a 2s . c  o m

    g2d.setTransform(tx1);
    g2d.setColor(Color.green);
    g2d.drawRect(0, 0, 80, 50);

    AffineTransform tx2 = new AffineTransform();
    tx2.translate(50, 90);
    tx2.shear(0, 1);

    g2d.setTransform(tx2);
    g2d.setColor(Color.blue);

    g2d.draw(new Rectangle(0, 0, 80, 50));

}