Java Code Examples for java.awt.geom.AffineTransform#shear()

The following examples show how to use java.awt.geom.AffineTransform#shear() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static AffineTransform makeRandomTransform(int numops) {
    AffineTransform at = new AffineTransform();
    while (--numops >= 0) {
        switch (rand.nextInt(4)) {
        case 0:
            at.scale(rand.nextDouble() * 5 - 2.5,
                     rand.nextDouble() * 5 - 2.5);
            break;
        case 1:
            at.shear(rand.nextDouble() * 5 - 2.5,
                     rand.nextDouble() * 5 - 2.5);
            break;
        case 2:
            at.rotate(rand.nextDouble() * Math.PI * 2);
            break;
        case 3:
            at.translate(rand.nextDouble() * 50 - 25,
                         rand.nextDouble() * 50 - 25);
            break;
        default:
            throw new InternalError("bad case!");
        }
    }
    return at;
}
 
Example 2
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 3
Source Project: pumpernickel   File: AbstractGraphics2D.java    License: MIT License 5 votes vote down vote up
/** Calls <code>transform(AffineTransform)</code> */
@Override
public void shear(double shx, double shy) {
	AffineTransform t = new AffineTransform();
	t.shear(shx, shy);
	transform(t);
}
 
Example 4
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 5
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 6
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 7
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 8
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 9
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 10
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 11
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 12
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 13
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 14
public void test(AffineTransform init, Tester next, boolean full) {
    double shears[] = (full ? fullvals : abbrevvals);
    for (int i = 0; i < shears.length; i += 2) {
        AffineTransform at2 = new AffineTransform(init);
        at2.shear(shears[i], shears[i+1]);
        if (verbose) System.out.println("*Shear("+shears[i]+", "+
                                        shears[i+1]+") = "+at2);
        next.test(at2, full);
    }
}
 
Example 15
public static AffineTransform makeRandomAT() {
    AffineTransform at = new AffineTransform();
    at.scale(Math.random() * -10.0, Math.random() * 100.0);
    at.rotate(Math.random() * Math.PI);
    at.shear(Math.random(), Math.random());
    at.translate(Math.random() * 300.0, Math.random() * -20.0);
    return at;
}
 
Example 16
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 17
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 18
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 19
Source Project: dsworkbench   File: LayerOrderPanel.java    License: Apache License 2.0 5 votes vote down vote up
private BufferedImage getLayerImage(boolean active, boolean visible, boolean marker) {
    BufferedImage img = ImageUtils.createCompatibleBufferedImage(100, 100, BufferedImage.TRANSLUCENT);
    Graphics2D g2 = img.createGraphics();
    AffineTransform sat = AffineTransform.getTranslateInstance(10, 10);
    sat.shear(0, -.5);
    g2.setTransform(sat);

    if (!active && visible) {
        g2.setColor(Color.DARK_GRAY);
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f));
    } else if (!active && !visible) {
        if (marker) {
            g2.setColor(Color.DARK_GRAY);
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .3f));
        } else {
            g2.setColor(Color.LIGHT_GRAY);
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .2f));
        }
    } else {
        g2.setColor(Color.decode("#F0E68C"));
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
    }
    g2.fillRect(0, 30, 50, 40);
    g2.setColor(Color.BLACK);
    g2.drawRect(0, 30, 50, 40);
    g2.dispose();
    return img;
}
 
Example 20
Source Project: pumpernickel   File: Graphics2DContext.java    License: MIT License 4 votes vote down vote up
/**
 * @see java.awt.Graphics2D#shear(double, double)
 */
public void shear(double shx, double shy) {
	AffineTransform tx = getTransform();
	tx.shear(shx, shy);
	setTransform(tx);
}