Example usage for java.awt.geom NoninvertibleTransformException getMessage

List of usage examples for java.awt.geom NoninvertibleTransformException getMessage

Introduction

In this page you can find the example usage for java.awt.geom NoninvertibleTransformException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:DefaultGraphics2D.java

/**
 * Renders an image, applying a transform from image space into user space
 * before drawing. The transformation from user space into device space is
 * done with the current <code>Transform</code> in the
 * <code>Graphics2D</code>. The specified transformation is applied to the
 * image before the transform attribute in the <code>Graphics2D</code>
 * context is applied. The rendering attributes applied include the
 * <code>Clip</code>, <code>Transform</code>, and <code>Composite</code>
 * attributes. Note that no rendering is done if the specified transform is
 * noninvertible.//w w  w.  ja  va  2 s . co  m
 * 
 * @param img
 *          the <code>Image</code> to be rendered
 * @param xform
 *          the transformation from image space into user space
 * @param obs
 *          the {@link ImageObserver} to be notified as more of the
 *          <code>Image</code> is converted
 * @return <code>true</code> if the <code>Image</code> is fully loaded and
 *         completely rendered; <code>false</code> if the <code>Image</code>
 *         is still being loaded.
 * @see #transform
 * @see #setTransform
 * @see #setComposite
 * @see #clip
 * @see #setClip(Shape)
 */
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
    boolean retVal = true;

    if (xform.getDeterminant() != 0) {
        AffineTransform inverseTransform = null;
        try {
            inverseTransform = xform.createInverse();
        } catch (NoninvertibleTransformException e) {
            // Should never happen since we checked the
            // matrix determinant
            throw new Error(e.getMessage());
        }

        gc.transform(xform);
        retVal = drawImage(img, 0, 0, null);
        gc.transform(inverseTransform);
    } else {
        AffineTransform savTransform = new AffineTransform(gc.getTransform());
        gc.transform(xform);
        retVal = drawImage(img, 0, 0, null);
        gc.setTransform(savTransform);
    }

    return retVal;

}