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

The following examples show how to use java.awt.geom.AffineTransform#shear() . 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
Source File: GetTypeOptimization.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: GraphicsTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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 3
Source File: LayerOrderPanel.java    From dsworkbench with 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 4
Source File: GraphicsTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: GraphicsTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: GraphicsTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: TestRotateMethods.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 8
Source File: TestInvertMethods.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 9
Source File: GraphicsTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 10
Source File: GraphicsTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: GraphicsTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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 12
Source File: GraphicsTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: GraphicsTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 14
Source File: GraphicsTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 15
Source File: GraphicsTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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 16
Source File: GraphicsTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: GraphicsTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: GraphicsTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 File: AbstractGraphics2D.java    From pumpernickel with 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 20
Source File: Graphics2DContext.java    From pumpernickel with 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);
}