Example usage for java.awt Graphics2D draw

List of usage examples for java.awt Graphics2D draw

Introduction

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

Prototype

public abstract void draw(Shape s);

Source Link

Document

Strokes the outline of a Shape using the settings of the current Graphics2D context.

Usage

From source file:FontShow.java

private void drawLine(Graphics2D g2, double x0, double y0, double x1, double y1) {
    Shape line = new java.awt.geom.Line2D.Double(x0, y0, x1, y1);
    g2.draw(line);
}

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);/*from  w  ww  .  ja v  a  2s. com*/

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

}

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);/*from w ww  .  ja v a 2  s.c o m*/
    g2.draw(shape);

}

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 o  m

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

}

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);// w w w .  ja  v  a2s.  c om
    g2.draw(shape);

}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    BasicStroke stroke = new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.1F);

    g2.setPaint(Color.black);//from   w w w. java2  s.c  o m
    g2.draw(stroke.createStrokedShape(new Rectangle2D.Float(10, 10, 20, 20)));
}

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);/*  ww  w.j  a  v a2s  . c  o m*/
    g2.draw(shape);

}

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);/*from   www . j  a  v  a  2s . c  o m*/
    g2.draw(shape);

}

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);/*from w ww. j  a v  a2 s  . c o  m*/
    g2.draw(shape);

}

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);/*  w w w .ja  v a  2 s.c om*/
    g2.draw(shape);

}