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

The following examples show how to use java.awt.geom.AffineTransform#getMatrix() . 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
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
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 Project: coming   File: NPEfix_00172_s.java    License: 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 4
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 5
Source Project: coming   File: NPEfix_00173_s.java    License: 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 6
Source Project: coming   File: NPEfix_00167_t.java    License: 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 Project: coming   File: NPEfix_00160_t.java    License: 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 Project: Bytecoder   File: PSPrinterJob.java    License: 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 9
Source Project: coming   File: NPEfix_00161_t.java    License: 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 10
Source Project: coming   File: NPEfix_00165_t.java    License: 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 Project: coming   File: NPEfix_00163_t.java    License: 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 Project: coming   File: NPEfix_00174_t.java    License: 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 Project: astor   File: Line.java    License: 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 14
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 Project: sambox   File: PDPageContentStream.java    License: 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 16
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 17
Source Project: gcs   File: PDAbstractPattern.java    License: 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 18
Source Project: gcs   File: PDPageContentStream.java    License: 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 19
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
@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;
    }