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

The following examples show how to use java.awt.geom.AffineTransform#getMatrix() . 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: 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 3
Source File: Line.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 4
Source File: NPEfix_00172_s.java    From coming with MIT License 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 5
Source File: PSPrinterJob.java    From openjdk-jdk8u 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 6
Source File: NPEfix_00173_s.java    From coming with MIT License 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 7
Source File: NPEfix_00167_t.java    From coming with MIT License 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 8
Source File: NPEfix_00160_t.java    From coming with MIT License 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 9
Source File: PSPrinterJob.java    From Bytecoder with Apache License 2.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: NPEfix_00161_t.java    From coming with MIT License 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 11
Source File: NPEfix_00165_t.java    From coming with MIT License 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 12
Source File: NPEfix_00163_t.java    From coming with MIT License 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 13
Source File: NPEfix_00174_t.java    From coming with MIT License 6 votes vote down vote up
/** Build an affine line transform from a n {@code AffineTransform}.
 * @param transform transform to use (must be invertible otherwise
 * the {@link LineTransform#apply(Hyperplane)} method would work
 * only for some lines, and fail for other ones)
 * @exception MathIllegalArgumentException if the transform is non invertible
 */
public LineTransform(final AffineTransform transform) throws MathIllegalArgumentException {

    final double[] m = new double[6];
    transform.getMatrix(m);
    cXX = m[0];
    cXY = m[2];
    cX1 = m[4];
    cYX = m[1];
    cYY = m[3];
    cY1 = m[5];

    c1Y = cXY * cY1 - cYY * cX1;
    c1X = cXX * cY1 - cYX * cX1;
    c11 = cXX * cYY - cYX * cXY;

    if (FastMath.abs(c11) < 1.0e-20) {
        throw new MathIllegalArgumentException(LocalizedFormats.NON_INVERTIBLE_TRANSFORM);
    }

}
 
Example 14
Source File: DuctusRenderingEngine.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static float[] getTransformMatrix(AffineTransform transform) {
    float matrix[] = new float[4];
    double dmatrix[] = new double[6];
    transform.getMatrix(dmatrix);
    for (int i = 0; i < 4; i++) {
        matrix[i] = (float) dmatrix[i];
    }
    return matrix;
}
 
Example 15
Source File: PDPageContentStream.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Writes an AffineTransform to the content stream as an array.
 */
private void writeAffineTransform(AffineTransform transform) throws IOException
{
    double[] values = new double[6];
    transform.getMatrix(values);
    for (double v : values)
    {
        writeOperand((float) v);
    }
}
 
Example 16
Source File: PDAbstractPattern.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets the optional Matrix entry for the Pattern.
 * @param transform the transformation matrix
 */
public void setMatrix(AffineTransform transform)
{
    COSArray matrix = new COSArray();
    double[] values = new double[6];
    transform.getMatrix(values);
    for (double v : values)
    {
        matrix.add(new COSFloat((float)v));
    }
    getCOSObject().setItem(COSName.MATRIX, matrix);
}
 
Example 17
Source File: DuctusRenderingEngine.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static float[] getTransformMatrix(AffineTransform transform) {
    float matrix[] = new float[4];
    double dmatrix[] = new double[6];
    transform.getMatrix(dmatrix);
    for (int i = 0; i < 4; i++) {
        matrix[i] = (float) dmatrix[i];
    }
    return matrix;
}
 
Example 18
Source File: PDPageContentStream.java    From sambox with Apache License 2.0 5 votes vote down vote up
/**
 * Writes an AffineTransform to the content stream as an array.
 */
private void writeAffineTransform(AffineTransform transform) throws IOException
{
    double[] values = new double[6];
    transform.getMatrix(values);
    for (double v : values)
    {
        writeOperand((float) v);
    }
}
 
Example 19
Source File: DuctusRenderingEngine.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static float[] getTransformMatrix(AffineTransform transform) {
    float matrix[] = new float[4];
    double dmatrix[] = new double[6];
    transform.getMatrix(dmatrix);
    for (int i = 0; i < 4; i++) {
        matrix[i] = (float) dmatrix[i];
    }
    return matrix;
}
 
Example 20
Source File: ImageFileAssistantPage2.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public Component createPageComponent() {
        GridBagConstraints gbc = new GridBagConstraints();
        final JPanel panel = new JPanel(new GridBagLayout());

        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridy = 0;
        gbc.gridx = 0;
        gbc.weighty = 0.0;
        gbc.weightx = 1.0;
        gbc.insets = new Insets(4, 0, 4, 2);

        double[] flatmatrix = new double[6];
        numberFields = new JTextField[flatmatrix.length];
        AffineTransform transform = (AffineTransform) getContext().getPropertyValue(
                ImageFileLayerSource.PROPERTY_NAME_WORLD_TRANSFORM);
        transform.getMatrix(flatmatrix);

// see http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=17489
        String[] labels = new String[]{
                "X-dimension of a pixel in map units: ",
                "Rotation parameter for row: ",
                "Rotation parameter for column: ",
                "Negative of Y-dimension of a pixel in map units: ",
                "X-coordinate of center of upper left pixel: ",
                "Y-coordinate of centre of upper left pixel: "
        };
        numberFields[0] = addRow(panel, labels[0], gbc);
        numberFields[0].setText(String.valueOf(flatmatrix[0]));
        numberFields[1] = addRow(panel, labels[1], gbc);
        numberFields[1].setText(String.valueOf(flatmatrix[1]));
        numberFields[2] = addRow(panel, labels[2], gbc);
        numberFields[2].setText(String.valueOf(flatmatrix[2]));
        numberFields[3] = addRow(panel, labels[3], gbc);
        numberFields[3].setText(String.valueOf(flatmatrix[3]));

        numberFields[4] = addRow(panel, labels[4], gbc);
        numberFields[4].setText(String.valueOf(flatmatrix[4]));

        numberFields[5] = addRow(panel, labels[5], gbc);
        numberFields[5].setText(String.valueOf(flatmatrix[5]));

        return panel;
    }