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

The following examples show how to use java.awt.geom.AffineTransform#equals() . 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: PSPrinterJob.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
void emitTransform(AffineTransform transform) {

            if (transform != null && transform.equals(mTransform) == false) {
                double[] matrix = new double[6];
                transform.getMatrix(matrix);
                mPSStream.println("[" + (float)matrix[0]
                                  + " " + (float)matrix[1]
                                  + " " + (float)matrix[2]
                                  + " " + (float)matrix[3]
                                  + " " + (float)matrix[4]
                                  + " " + (float)matrix[5]
                                  + "] concat");

                mTransform = transform;
            }
        }
 
Example 2
Source File: RasterPrinterJob.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
synchronized void setGraphicsConfigInfo(AffineTransform at,
                                        double pw, double ph) {
    Point2D.Double pt = new Point2D.Double(pw, ph);
    at.transform(pt, pt);

    if (pgConfig == null ||
        defaultDeviceTransform == null ||
        !at.equals(defaultDeviceTransform) ||
        deviceWidth != (int)pt.getX() ||
        deviceHeight != (int)pt.getY()) {

            deviceWidth = (int)pt.getX();
            deviceHeight = (int)pt.getY();
            defaultDeviceTransform = at;
            pgConfig = null;
    }
}
 
Example 3
Source File: TransformSetGet.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
Example 4
Source File: RasterPrinterJob.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
synchronized void setGraphicsConfigInfo(AffineTransform at,
                                        double pw, double ph) {
    Point2D.Double pt = new Point2D.Double(pw, ph);
    at.transform(pt, pt);

    if (pgConfig == null ||
        defaultDeviceTransform == null ||
        !at.equals(defaultDeviceTransform) ||
        deviceWidth != (int)pt.getX() ||
        deviceHeight != (int)pt.getY()) {

            deviceWidth = (int)pt.getX();
            deviceHeight = (int)pt.getY();
            defaultDeviceTransform = at;
            pgConfig = null;
    }
}
 
Example 5
Source File: TransformSetGet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
Example 6
Source File: PSPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void emitTransform(AffineTransform transform) {

            if (transform != null && transform.equals(mTransform) == false) {
                double[] matrix = new double[6];
                transform.getMatrix(matrix);
                mPSStream.println("[" + (float)matrix[0]
                                  + " " + (float)matrix[1]
                                  + " " + (float)matrix[2]
                                  + " " + (float)matrix[3]
                                  + " " + (float)matrix[4]
                                  + " " + (float)matrix[5]
                                  + "] concat");

                mTransform = transform;
            }
        }
 
Example 7
Source File: TransformSetGet.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
Example 8
Source File: TransformSetGet.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
Example 9
Source File: PSPrinterJob.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
void emitTransform(AffineTransform transform) {

            if (transform != null && transform.equals(mTransform) == false) {
                double[] matrix = new double[6];
                transform.getMatrix(matrix);
                mPSStream.println("[" + (float)matrix[0]
                                  + " " + (float)matrix[1]
                                  + " " + (float)matrix[2]
                                  + " " + (float)matrix[3]
                                  + " " + (float)matrix[4]
                                  + " " + (float)matrix[5]
                                  + "] concat");

                mTransform = transform;
            }
        }
 
Example 10
Source File: RasterPrinterJob.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
synchronized void setGraphicsConfigInfo(AffineTransform at,
                                        double pw, double ph) {
    Point2D.Double pt = new Point2D.Double(pw, ph);
    at.transform(pt, pt);

    if (pgConfig == null ||
        defaultDeviceTransform == null ||
        !at.equals(defaultDeviceTransform) ||
        deviceWidth != (int)pt.getX() ||
        deviceHeight != (int)pt.getY()) {

            deviceWidth = (int)pt.getX();
            deviceHeight = (int)pt.getY();
            defaultDeviceTransform = at;
            pgConfig = null;
    }
}
 
Example 11
Source File: TransformSetGet.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
Example 12
Source File: RasterPrinterJob.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
synchronized void setGraphicsConfigInfo(AffineTransform at,
                                        double pw, double ph) {
    Point2D.Double pt = new Point2D.Double(pw, ph);
    at.transform(pt, pt);

    if (pgConfig == null ||
        defaultDeviceTransform == null ||
        !at.equals(defaultDeviceTransform) ||
        deviceWidth != (int)pt.getX() ||
        deviceHeight != (int)pt.getY()) {

            deviceWidth = (int)pt.getX();
            deviceHeight = (int)pt.getY();
            defaultDeviceTransform = at;
            pgConfig = null;
    }
}
 
Example 13
Source File: TransformSetGet.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
Example 14
Source File: PSPrinterJob.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void emitTransform(AffineTransform transform) {

            if (transform != null && transform.equals(mTransform) == false) {
                double[] matrix = new double[6];
                transform.getMatrix(matrix);
                mPSStream.println("[" + (float)matrix[0]
                                  + " " + (float)matrix[1]
                                  + " " + (float)matrix[2]
                                  + " " + (float)matrix[3]
                                  + " " + (float)matrix[4]
                                  + " " + (float)matrix[5]
                                  + "] concat");

                mTransform = transform;
            }
        }
 
Example 15
Source File: RasterPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
synchronized void setGraphicsConfigInfo(AffineTransform at,
                                        double pw, double ph) {
    Point2D.Double pt = new Point2D.Double(pw, ph);
    at.transform(pt, pt);

    if (pgConfig == null ||
        defaultDeviceTransform == null ||
        !at.equals(defaultDeviceTransform) ||
        deviceWidth != (int)pt.getX() ||
        deviceHeight != (int)pt.getY()) {

            deviceWidth = (int)pt.getX();
            deviceHeight = (int)pt.getY();
            defaultDeviceTransform = at;
            pgConfig = null;
    }
}
 
Example 16
Source File: TransformSetGet.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
Example 17
Source File: RasterPrinterJob.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
synchronized void setGraphicsConfigInfo(AffineTransform at,
                                        double pw, double ph) {
    Point2D.Double pt = new Point2D.Double(pw, ph);
    at.transform(pt, pt);

    if (pgConfig == null ||
        defaultDeviceTransform == null ||
        !at.equals(defaultDeviceTransform) ||
        deviceWidth != (int)pt.getX() ||
        deviceHeight != (int)pt.getY()) {

            deviceWidth = (int)pt.getX();
            deviceHeight = (int)pt.getY();
            defaultDeviceTransform = at;
            pgConfig = null;
    }
}
 
Example 18
Source File: CircuitComponent.java    From Digital with GNU General Public License v3.0 5 votes vote down vote up
/**
 * maximizes the circuit shown
 */
public void fitCircuit() {
    GraphicMinMax gr = new GraphicMinMax();
    getCircuit().drawTo(gr);

    AffineTransform newTrans = new AffineTransform();
    if (gr.getMin() != null && getWidth() != 0 && getHeight() != 0) {
        Vector delta = gr.getMax().sub(gr.getMin());
        int pad = circuitScrollPanel.getBarWidth();
        double sx = ((double) getWidth() - pad) / (delta.x + SIZE * 2);
        double sy = ((double) getHeight() - pad) / (delta.y + SIZE * 2);
        double s = Math.min(sx, sy);


        newTrans.setToScale(s, s);  // set Scaling

        Vector center = gr.getMin().add(gr.getMax()).div(2);
        newTrans.translate(-center.x, -center.y);  // move drawing center to (0,0)

        Vector dif = new Vector(getWidth(), getHeight()).div(2);
        newTrans.translate(dif.x / s, dif.y / s);  // move drawing center to frame center
        isManualScale = false;
    } else {
        isManualScale = true;
    }
    if (!newTrans.equals(transform)) {
        transform = newTrans;
        if (circuitScrollPanel != null)
            circuitScrollPanel.transformChanged(transform);
        graphicHasChanged();
    }
}
 
Example 19
Source File: TransformationStep.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public boolean isIdentical(final History.Step<?> step) {
	if (step.getClass() != TransformationStep.class) return false;
	final HashMap<Displayable,AffineTransform> m = ((TransformationStep)step).ht;
	// cheap test:
	if (m.size() != this.ht.size()) return false;
	// Check each:
	for (final Map.Entry<Displayable,AffineTransform> e : m.entrySet()) {
		final AffineTransform aff = this.ht.get(e.getKey());
		if (null == aff) return false; // at least one Displayable is missing
		if (!aff.equals(e.getValue())) return false; // at least one Displayable has a different AffineTransform
	}
	return true;
}
 
Example 20
Source File: VolatileSurfaceManager.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Called from SunGraphicsEnv when there has been a display mode change.
 * Note that we simply invalidate hardware surfaces here; we do not
 * attempt to recreate or re-render them.  This is to avoid threading
 * conflicts with the native toolkit and associated threads.  Instead,
 * we just nullify the old surface data object and wait for a future
 * method in the rendering process to recreate the surface.
 */
public void displayChanged() {
    lostSurface = true;
    if (sdAccel != null) {
        // First, nullify the software surface.  This guards against
        // using a SurfaceData that was created in a different
        // display mode.
        sdBackup = null;
        // Now, invalidate the old hardware-based SurfaceData
        // Note that getBackupSurface may set sdAccel to null so we have to invalidate it before
        SurfaceData oldData = sdAccel;
        sdAccel = null;
        oldData.invalidate();
        sdCurrent = getBackupSurface();
    }
    // Update graphicsConfig for the vImg in case it changed due to
    // this display change event
    vImg.updateGraphicsConfig();

    // Compare the Graphics configuration transforms to determine
    // whether the software backed surface needs to be invalidated.
    AffineTransform atUpdated = vImg.getGraphicsConfig()
                                    .getDefaultTransform();
    if (!isAccelerationEnabled()) {
        if (!atUpdated.equals(atCurrent)) {
            // Ideally there is no need to re-create a software surface.
            // But some OSs allow changes to display state at runtime. Such
            // a provision would cause mismatch in graphics configuration of
            // the display and the surface. Hence we re-create the software
            // surface as well.
            sdBackup = null;
            sdCurrent = getBackupSurface();
        } else {
            // Software backed surface was not invalidated.
            lostSurface = false;
        }
    }

    // Update the AffineTransformation backing the volatile image
    atCurrent = atUpdated;
}