Search in sources :

Example 1 with NoninvertibleTransformException

use of java.awt.geom.NoninvertibleTransformException in project android_frameworks_base by ParanoidAndroid.

the class Matrix_Delegate method native_invert.

@LayoutlibDelegate
static /*package*/
boolean native_invert(int native_object, int inverse) {
    Matrix_Delegate d = sManager.getDelegate(native_object);
    if (d == null) {
        return false;
    }
    Matrix_Delegate inv_mtx = sManager.getDelegate(inverse);
    if (inv_mtx == null) {
        return false;
    }
    try {
        AffineTransform affineTransform = d.getAffineTransform();
        AffineTransform inverseTransform = affineTransform.createInverse();
        inv_mtx.mValues[0] = (float) inverseTransform.getScaleX();
        inv_mtx.mValues[1] = (float) inverseTransform.getShearX();
        inv_mtx.mValues[2] = (float) inverseTransform.getTranslateX();
        inv_mtx.mValues[3] = (float) inverseTransform.getScaleX();
        inv_mtx.mValues[4] = (float) inverseTransform.getShearY();
        inv_mtx.mValues[5] = (float) inverseTransform.getTranslateY();
        return true;
    } catch (NoninvertibleTransformException e) {
        return false;
    }
}
Also used : NoninvertibleTransformException(java.awt.geom.NoninvertibleTransformException) AffineTransform(java.awt.geom.AffineTransform) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 2 with NoninvertibleTransformException

use of java.awt.geom.NoninvertibleTransformException in project hid-serial by rayshobby.

the class GAbstractControl method calcTransformedOrigin.

/**
	 * This method takes a position px, py and calculates the equivalent
	 * position [ox,oy] as if no transformations have taken place and
	 * the origin is the top-left corner of the control.
	 * @param px
	 * @param py
	 */
protected void calcTransformedOrigin(float px, float py) {
    AffineTransform aff = new AffineTransform();
    aff = getTransform(aff);
    temp[0] = px;
    temp[1] = py;
    try {
        aff.inverseTransform(temp, 0, temp, 0, 1);
        ox = (float) temp[0] + halfWidth;
        oy = (float) temp[1] + halfHeight;
    } catch (NoninvertibleTransformException e) {
    }
}
Also used : NoninvertibleTransformException(java.awt.geom.NoninvertibleTransformException) AffineTransform(java.awt.geom.AffineTransform)

Example 3 with NoninvertibleTransformException

use of java.awt.geom.NoninvertibleTransformException in project android_frameworks_base by DirtyUnicorns.

the class Matrix_Delegate method native_invert.

@LayoutlibDelegate
static /*package*/
boolean native_invert(long native_object, long inverse) {
    Matrix_Delegate d = sManager.getDelegate(native_object);
    if (d == null) {
        return false;
    }
    Matrix_Delegate inv_mtx = sManager.getDelegate(inverse);
    if (inv_mtx == null) {
        return false;
    }
    try {
        AffineTransform affineTransform = d.getAffineTransform();
        AffineTransform inverseTransform = affineTransform.createInverse();
        inv_mtx.mValues[0] = (float) inverseTransform.getScaleX();
        inv_mtx.mValues[1] = (float) inverseTransform.getShearX();
        inv_mtx.mValues[2] = (float) inverseTransform.getTranslateX();
        inv_mtx.mValues[3] = (float) inverseTransform.getScaleX();
        inv_mtx.mValues[4] = (float) inverseTransform.getShearY();
        inv_mtx.mValues[5] = (float) inverseTransform.getTranslateY();
        return true;
    } catch (NoninvertibleTransformException e) {
        return false;
    }
}
Also used : NoninvertibleTransformException(java.awt.geom.NoninvertibleTransformException) AffineTransform(java.awt.geom.AffineTransform) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 4 with NoninvertibleTransformException

use of java.awt.geom.NoninvertibleTransformException in project android_frameworks_base by ResurrectionRemix.

the class Matrix_Delegate method native_invert.

@LayoutlibDelegate
static /*package*/
boolean native_invert(long native_object, long inverse) {
    Matrix_Delegate d = sManager.getDelegate(native_object);
    if (d == null) {
        return false;
    }
    Matrix_Delegate inv_mtx = sManager.getDelegate(inverse);
    if (inv_mtx == null) {
        return false;
    }
    try {
        AffineTransform affineTransform = d.getAffineTransform();
        AffineTransform inverseTransform = affineTransform.createInverse();
        inv_mtx.mValues[0] = (float) inverseTransform.getScaleX();
        inv_mtx.mValues[1] = (float) inverseTransform.getShearX();
        inv_mtx.mValues[2] = (float) inverseTransform.getTranslateX();
        inv_mtx.mValues[3] = (float) inverseTransform.getScaleX();
        inv_mtx.mValues[4] = (float) inverseTransform.getShearY();
        inv_mtx.mValues[5] = (float) inverseTransform.getTranslateY();
        return true;
    } catch (NoninvertibleTransformException e) {
        return false;
    }
}
Also used : NoninvertibleTransformException(java.awt.geom.NoninvertibleTransformException) AffineTransform(java.awt.geom.AffineTransform) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 5 with NoninvertibleTransformException

use of java.awt.geom.NoninvertibleTransformException in project EnrichmentMapApp by BaderLab.

the class AbstractChartLayer method draw.

@Override
public void draw(final Graphics2D g, final Shape shape, final CyNetworkView networkView, final View<? extends CyIdentifiable> view) {
    // Give JFreeChart a larger area to draw into, so the proportions of the chart elements looks better
    final double scale = 2.0;
    Rectangle2D newBounds = new Rectangle2D.Double(bounds.getX() * scale, bounds.getY() * scale, bounds.getWidth() * scale, bounds.getHeight() * scale);
    // Of course, we also have to ask Graphics2D to apply the inverse transformation
    final double invScale = 1.0 / scale;
    final AffineTransform at = new AffineTransform();
    at.scale(invScale, invScale);
    g.transform(at);
    // Check to see if we have a current alpha composite
    Composite comp = g.getComposite();
    if (comp instanceof AlphaComposite) {
        float alpha = ((AlphaComposite) comp).getAlpha();
        JFreeChart fc = getChart();
        Plot plot = fc.getPlot();
        plot.setForegroundAlpha(alpha);
        fc.draw(g, newBounds);
    } else {
        getChart().draw(g, newBounds);
    }
    // Make sure Graphics2D is "back to normal" before returning
    try {
        at.invert();
    } catch (NoninvertibleTransformException e) {
        e.printStackTrace();
    }
    g.transform(at);
}
Also used : NoninvertibleTransformException(java.awt.geom.NoninvertibleTransformException) AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Plot(org.jfree.chart.plot.Plot) Rectangle2D(java.awt.geom.Rectangle2D) AffineTransform(java.awt.geom.AffineTransform) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

NoninvertibleTransformException (java.awt.geom.NoninvertibleTransformException)19 AffineTransform (java.awt.geom.AffineTransform)17 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)5 BufferedImage (java.awt.image.BufferedImage)3 AlphaComposite (java.awt.AlphaComposite)2 BasicStroke (java.awt.BasicStroke)2 Composite (java.awt.Composite)2 Rectangle (java.awt.Rectangle)2 Shape (java.awt.Shape)2 TexturePaint (java.awt.TexturePaint)2 FontRenderContext (java.awt.font.FontRenderContext)2 Point2D (java.awt.geom.Point2D)2 RenderedImage (java.awt.image.RenderedImage)2 RenderContext (java.awt.image.renderable.RenderContext)2 Graphics2DDelegate (com.intellij.ui.Graphics2DDelegate)1 Color (java.awt.Color)1 GradientPaint (java.awt.GradientPaint)1 Graphics2D (java.awt.Graphics2D)1 LinearGradientPaint (java.awt.LinearGradientPaint)1 Paint (java.awt.Paint)1