Example usage for java.awt.geom AffineTransform shear

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

Introduction

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

Prototype

public void shear(double shx, double shy) 

Source Link

Document

Concatenates this transform with a shearing transformation.

Usage

From source file:BasicShapes.java

public static void main(String[] args) {
    AffineTransform tx = new AffineTransform();
    tx.shear(1, 1);
    Rectangle shape = new Rectangle(1, 1, 1, 1);
    Shape newShape = tx.createTransformedShape(shape);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    BufferedImage bufferedImage = new BufferedImage(200, 200, BufferedImage.TYPE_BYTE_INDEXED);

    AffineTransform tx = new AffineTransform();
    tx.shear(2, 3);

    AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
    bufferedImage = op.filter(bufferedImage, null);
}

From source file:Main.java

public static void main(String[] args) {
    AffineTransform tx = new AffineTransform();
    tx.shear(1, 1);
    Rectangle shape = new Rectangle(1, 1, 1, 1);
    Shape newShape = tx.createTransformedShape(shape);

    System.out.println("done");

}

From source file:MainClass.java

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

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = new AffineTransform();
    at.shear(-.5, 0);

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

}

From source file:FontDerivation.java

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

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Create a 1-point font.
    Font font = new Font("Serif", Font.PLAIN, 1);
    float x = 20, y = 20;

    Font font24 = font.deriveFont(24.0f);
    g2.setFont(font24);// w  w  w.j  av a 2  s. c  o  m
    g2.drawString("font.deriveFont(24.0f)", x, y += 30);

    Font font24italic = font24.deriveFont(Font.ITALIC);
    g2.setFont(font24italic);
    g2.drawString("font24.deriveFont(Font.ITALIC)", x, y += 30);

    AffineTransform at = new AffineTransform();
    at.shear(.2, 0);
    Font font24shear = font24.deriveFont(at);
    g2.setFont(font24shear);
    g2.drawString("font24.deriveFont(at)", x, y += 30);

    Hashtable attributes = new Hashtable();
    attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
    Font font24bold = font24.deriveFont(attributes);
    g2.setFont(font24bold);
    g2.drawString("font24.deriveFont(attributes)", x, y += 30);
}

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);//from   www  .  j a v  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));

}

From source file:BasicDraw.java

public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    AffineTransform tx = new AffineTransform();

    double shiftx = .1;
    double shifty = .3;
    tx.shear(shiftx, shifty);

    g2d.setTransform(tx);/*w  w w  . java  2s  .c  om*/
    g2d.drawImage(new ImageIcon("a.png").getImage(), tx, this);
}

From source file:FontRenderContextRenderingHints.java

public void paint(Graphics g) {
    Graphics2D g2D = (Graphics2D) g;
    int w = getSize().width;
    int h = getSize().height;

    RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2D.setRenderingHints(qualityHints);

    AffineTransform at = new AffineTransform();
    at.setToTranslation(-300, -400);//from ww  w  .  j  av  a2s  .com
    at.shear(-0.5, 0.0);
    FontRenderContext frc = new FontRenderContext(at, false, false);
    TextLayout tl = new TextLayout("World!", font, frc);
    Shape outline = tl.getOutline(null);
    g2D.setColor(Color.blue);

    BasicStroke wideStroke = new BasicStroke(2.0f);
    g2D.setStroke(wideStroke);
    g2D.draw(outline);

}

From source file:TransformShear.java

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

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);//from  w  ww  .j  av a2  s.  c o m

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    AffineTransform sat = AffineTransform.getTranslateInstance(150, 0);
    sat.shear(-.5, 0);
    g2.transform(sat);

    // Draw the "new" shapes in dashed.
    g2.transform(AffineTransform.getTranslateInstance(75, 75));

    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:JXTransformer.java

public void shear(double sx, double sy) {
    AffineTransform transform = getTransform();
    transform.shear(sx, sy);
    setTransform(transform);/*from  ww  w.  ja  v a 2  s . c  o m*/
}