Java Code Examples for java.awt.geom.AffineTransform#TYPE_IDENTITY

The following examples show how to use java.awt.geom.AffineTransform#TYPE_IDENTITY . 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: SVGGraphics2D.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected String getRenderingStyle( Object key )
{
	Object value = renderingHints.get( key );
	if ( key.equals( RenderingHints.KEY_TEXT_ANTIALIASING ) )
	{
		if ( value.equals( RenderingHints.VALUE_TEXT_ANTIALIAS_OFF ) )
		{
			// Adobe SVG viewer 3 bug. Rotated text with optimizelegibility
			// disappears. Replace
			// with optimizespeed for rotated text.
			if ( transforms.getType( ) != AffineTransform.TYPE_IDENTITY )
				return "text-rendering:optimizeSpeed;";//$NON-NLS-1$ 
			else
				return "text-rendering:optimizeLegibility;";//$NON-NLS-1$ 
		}
		else
			// SVG always turns on antialias
			return ""; //$NON-NLS-1$ 
	}
	return "";//$NON-NLS-1$ 	
}
 
Example 2
Source File: FontRenderContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 3
Source File: FontRenderContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 4
Source File: FontRenderContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 5
Source File: FontRenderContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 6
Source File: FontRenderContext.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 7
Source File: Treeline.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void transformData(final AffineTransform aff) {
	switch (aff.getType()) {
		case AffineTransform.TYPE_IDENTITY:
		case AffineTransform.TYPE_TRANSLATION:
			// Radius doesn't change
			return;
		default:
			// Scale the radius as appropriate
			final double[] fp = new double[]{x, y, x + r, y};
			aff.transform(fp, 0, fp, 0, 2);
			r = (float)Math.sqrt(Math.pow(fp[2] - fp[0], 2) + Math.pow(fp[3] - fp[1], 2));
	}
}
 
Example 8
Source File: FontRenderContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 9
Source File: FontRenderContext.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 10
Source File: FontRenderContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 11
Source File: FontRenderContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 12
Source File: FontRenderContext.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the integer type of the affine transform for this
 * <code>FontRenderContext</code> as specified by
 * {@link java.awt.geom.AffineTransform#getType()}
 * @return the type of the transform.
 * @see AffineTransform
 * @since 1.6
 */
public int getTransformType() {
    if (!defaulting) {
        if (tx == null) {
            return AffineTransform.TYPE_IDENTITY;
        } else {
            return tx.getType();
        }
    } else {
        return getTransform().getType();
    }
}
 
Example 13
Source File: SunGraphics2D.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected void invalidateTransform() {
    int type = transform.getType();
    int origTransformState = transformState;
    if (type == AffineTransform.TYPE_IDENTITY) {
        transformState = TRANSFORM_ISIDENT;
        transX = transY = 0;
    } else if (type == AffineTransform.TYPE_TRANSLATION) {
        double dtx = transform.getTranslateX();
        double dty = transform.getTranslateY();
        transX = (int) Math.floor(dtx + 0.5);
        transY = (int) Math.floor(dty + 0.5);
        if (dtx == transX && dty == transY) {
            transformState = TRANSFORM_INT_TRANSLATE;
        } else {
            transformState = TRANSFORM_ANY_TRANSLATE;
        }
    } else if ((type & (AffineTransform.TYPE_FLIP |
                        AffineTransform.TYPE_MASK_ROTATION |
                        AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0)
    {
        transformState = TRANSFORM_TRANSLATESCALE;
        transX = transY = 0;
    } else {
        transformState = TRANSFORM_GENERIC;
        transX = transY = 0;
    }

    if (transformState >= TRANSFORM_TRANSLATESCALE ||
        origTransformState >= TRANSFORM_TRANSLATESCALE)
    {
        /* Its only in this case that the previous or current transform
         * was more than a translate that font info is invalidated
         */
        cachedFRC = null;
        this.validFontInfo = false;
        this.fontMetrics = null;
        this.glyphVectorFontInfo = null;

        if (transformState != origTransformState) {
            invalidatePipe();
        }
    }
    if (strokeState != STROKE_CUSTOM) {
        validateBasicStroke((BasicStroke) stroke);
    }
}
 
Example 14
Source File: SunGraphics2D.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void invalidateTransform() {
    int type = transform.getType();
    int origTransformState = transformState;
    if (type == AffineTransform.TYPE_IDENTITY) {
        transformState = TRANSFORM_ISIDENT;
        transX = transY = 0;
    } else if (type == AffineTransform.TYPE_TRANSLATION) {
        double dtx = transform.getTranslateX();
        double dty = transform.getTranslateY();
        transX = (int) Math.floor(dtx + 0.5);
        transY = (int) Math.floor(dty + 0.5);
        if (dtx == transX && dty == transY) {
            transformState = TRANSFORM_INT_TRANSLATE;
        } else {
            transformState = TRANSFORM_ANY_TRANSLATE;
        }
    } else if ((type & (AffineTransform.TYPE_FLIP |
                        AffineTransform.TYPE_MASK_ROTATION |
                        AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0)
    {
        transformState = TRANSFORM_TRANSLATESCALE;
        transX = transY = 0;
    } else {
        transformState = TRANSFORM_GENERIC;
        transX = transY = 0;
    }

    if (transformState >= TRANSFORM_TRANSLATESCALE ||
        origTransformState >= TRANSFORM_TRANSLATESCALE)
    {
        /* Its only in this case that the previous or current transform
         * was more than a translate that font info is invalidated
         */
        cachedFRC = null;
        this.validFontInfo = false;
        this.fontMetrics = null;
        this.glyphVectorFontInfo = null;

        if (transformState != origTransformState) {
            invalidatePipe();
        }
    }
    if (strokeState != STROKE_CUSTOM) {
        validateBasicStroke((BasicStroke) stroke);
    }
}
 
Example 15
Source File: SunGraphics2D.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void invalidateTransform() {
    int type = transform.getType();
    int origTransformState = transformState;
    if (type == AffineTransform.TYPE_IDENTITY) {
        transformState = TRANSFORM_ISIDENT;
        transX = transY = 0;
    } else if (type == AffineTransform.TYPE_TRANSLATION) {
        double dtx = transform.getTranslateX();
        double dty = transform.getTranslateY();
        transX = (int) Math.floor(dtx + 0.5);
        transY = (int) Math.floor(dty + 0.5);
        if (dtx == transX && dty == transY) {
            transformState = TRANSFORM_INT_TRANSLATE;
        } else {
            transformState = TRANSFORM_ANY_TRANSLATE;
        }
    } else if ((type & (AffineTransform.TYPE_FLIP |
                        AffineTransform.TYPE_MASK_ROTATION |
                        AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0)
    {
        transformState = TRANSFORM_TRANSLATESCALE;
        transX = transY = 0;
    } else {
        transformState = TRANSFORM_GENERIC;
        transX = transY = 0;
    }

    if (transformState >= TRANSFORM_TRANSLATESCALE ||
        origTransformState >= TRANSFORM_TRANSLATESCALE)
    {
        /* Its only in this case that the previous or current transform
         * was more than a translate that font info is invalidated
         */
        cachedFRC = null;
        this.validFontInfo = false;
        this.fontMetrics = null;
        this.glyphVectorFontInfo = null;

        if (transformState != origTransformState) {
            invalidatePipe();
        }
    }
    if (strokeState != STROKE_CUSTOM) {
        validateBasicStroke((BasicStroke) stroke);
    }
}
 
Example 16
Source File: SunGraphics2D.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
protected void invalidateTransform() {
    int type = transform.getType();
    int origTransformState = transformState;
    if (type == AffineTransform.TYPE_IDENTITY) {
        transformState = TRANSFORM_ISIDENT;
        transX = transY = 0;
    } else if (type == AffineTransform.TYPE_TRANSLATION) {
        double dtx = transform.getTranslateX();
        double dty = transform.getTranslateY();
        transX = (int) Math.floor(dtx + 0.5);
        transY = (int) Math.floor(dty + 0.5);
        if (dtx == transX && dty == transY) {
            transformState = TRANSFORM_INT_TRANSLATE;
        } else {
            transformState = TRANSFORM_ANY_TRANSLATE;
        }
    } else if ((type & (AffineTransform.TYPE_FLIP |
                        AffineTransform.TYPE_MASK_ROTATION |
                        AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0)
    {
        transformState = TRANSFORM_TRANSLATESCALE;
        transX = transY = 0;
    } else {
        transformState = TRANSFORM_GENERIC;
        transX = transY = 0;
    }

    if (transformState >= TRANSFORM_TRANSLATESCALE ||
        origTransformState >= TRANSFORM_TRANSLATESCALE)
    {
        /* Its only in this case that the previous or current transform
         * was more than a translate that font info is invalidated
         */
        cachedFRC = null;
        this.validFontInfo = false;
        this.fontMetrics = null;
        this.glyphVectorFontInfo = null;

        if (transformState != origTransformState) {
            invalidatePipe();
        }
    }
    if (strokeState != STROKE_CUSTOM) {
        validateBasicStroke((BasicStroke) stroke);
    }
}
 
Example 17
Source File: SVGGraphics2D.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected Element createText( String text )
{
	// #232718 to support bidi
	boolean bRtl = false;

	if ( text.length( ) > 0 )
	{
		int iEnd = text.length( );
		if ( chPDF == text.charAt( text.length( ) - 1 ) )
		{
			iEnd--;
		}

		if ( chRLE == text.charAt( 0 ) )
		{
			bRtl = true;
			text = text.substring( 1, iEnd );
		}
	}

	Element elem = dom.createElement( "text" ); //$NON-NLS-1$
	elem.appendChild( dom.createTextNode( text ) );
	switch ( getFont( ).getStyle( ) )
	{
		case Font.BOLD :
			elem.setAttribute( "font-weight", "bold" ); //$NON-NLS-1$ //$NON-NLS-2$
			break;
		case Font.ITALIC :
			elem.setAttribute( "font-style", "italic" ); //$NON-NLS-1$ //$NON-NLS-2$
			break;
		case ( Font.BOLD + Font.ITALIC ) :
			elem.setAttribute( "font-style", "italic" ); //$NON-NLS-1$ //$NON-NLS-2$
			elem.setAttribute( "font-weight", "bold" ); //$NON-NLS-1$ //$NON-NLS-2$
			break;
	}
	String textDecorator = null;
	Map<TextAttribute, ?> attributes = getFont( ).getAttributes( );
	if ( attributes.get( TextAttribute.UNDERLINE ) == TextAttribute.UNDERLINE_ON )
	{
		textDecorator = "underline"; //$NON-NLS-1$ 
	}
	if ( attributes.get( TextAttribute.STRIKETHROUGH ) == TextAttribute.STRIKETHROUGH_ON )
	{
		if ( textDecorator == null )
			textDecorator = "line-through"; //$NON-NLS-1$
		else
			textDecorator += ",line-through"; //$NON-NLS-1$
	}
	if ( textDecorator != null )
		elem.setAttribute( "text-decoration", textDecorator ); //$NON-NLS-1$

	// for now just preserve space for text elements Bug 182159
	elem.setAttribute( "xml:space", "preserve" ); //$NON-NLS-1$ //$NON-NLS-2$
	elem.setAttribute( "stroke", "none" ); //$NON-NLS-1$ //$NON-NLS-2$

	// Here we still use Font.getName() as font-family for SVG instead of
	// Font.getFaimly(), since if current code is running on linux and there
	// isn't a valid font family to fit the font setting in chart model,
	// the call of Font.getFamily() will get a default 'Dialog' font family,
	// it will caused that the svg in client system can't correct display
	// mulitple-characters text(Chinese, Jpanese and so on).
	// We just need to set the original font family setting of chart model
	// into svg document, if the font family is valid in client system
	// and can support current text character, it will correct display.
	elem.setAttribute( "font-family", getFont( ).getName( ) ); //$NON-NLS-1$
	elem.setAttribute( "font-size", Integer.toString( getFont( ).getSize( ) ) ); //$NON-NLS-1$
	String style = getRenderingStyle( RenderingHints.KEY_TEXT_ANTIALIASING );
	if ( color != null )
	{
		String alpha = alphaToString( color );
		if ( alpha != null )
			style += "fill-opacity:" + alpha + ";"; //$NON-NLS-1$ //$NON-NLS-2$
		style += "fill:" + serializeToString( color ) + ";"; //$NON-NLS-1$ //$NON-NLS-2$ 
	}
	if ( bRtl )
	{
		style += sStyleBidi;

	}
	elem.setAttribute( "style", style ); //$NON-NLS-1$
	if ( transforms.getType( ) != AffineTransform.TYPE_IDENTITY )
	{
		double[] matrix = new double[6];
		transforms.getMatrix( matrix );
		elem.setAttribute( "transform", "matrix(" + toString( matrix, ',' ) + ")" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	}

	return elem;
}
 
Example 18
Source File: SunGraphics2D.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void invalidateTransform() {
    int type = transform.getType();
    int origTransformState = transformState;
    if (type == AffineTransform.TYPE_IDENTITY) {
        transformState = TRANSFORM_ISIDENT;
        transX = transY = 0;
    } else if (type == AffineTransform.TYPE_TRANSLATION) {
        double dtx = transform.getTranslateX();
        double dty = transform.getTranslateY();
        transX = (int) Math.floor(dtx + 0.5);
        transY = (int) Math.floor(dty + 0.5);
        if (dtx == transX && dty == transY) {
            transformState = TRANSFORM_INT_TRANSLATE;
        } else {
            transformState = TRANSFORM_ANY_TRANSLATE;
        }
    } else if ((type & (AffineTransform.TYPE_FLIP |
                        AffineTransform.TYPE_MASK_ROTATION |
                        AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0)
    {
        transformState = TRANSFORM_TRANSLATESCALE;
        transX = transY = 0;
    } else {
        transformState = TRANSFORM_GENERIC;
        transX = transY = 0;
    }

    if (transformState >= TRANSFORM_TRANSLATESCALE ||
        origTransformState >= TRANSFORM_TRANSLATESCALE)
    {
        /* Its only in this case that the previous or current transform
         * was more than a translate that font info is invalidated
         */
        cachedFRC = null;
        this.validFontInfo = false;
        this.fontMetrics = null;
        this.glyphVectorFontInfo = null;

        if (transformState != origTransformState) {
            invalidatePipe();
        }
    }
    if (strokeState != STROKE_CUSTOM) {
        validateBasicStroke((BasicStroke) stroke);
    }
}
 
Example 19
Source File: SunGraphics2D.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void invalidateTransform() {
    int type = transform.getType();
    int origTransformState = transformState;
    if (type == AffineTransform.TYPE_IDENTITY) {
        transformState = TRANSFORM_ISIDENT;
        transX = transY = 0;
    } else if (type == AffineTransform.TYPE_TRANSLATION) {
        double dtx = transform.getTranslateX();
        double dty = transform.getTranslateY();
        transX = (int) Math.floor(dtx + 0.5);
        transY = (int) Math.floor(dty + 0.5);
        if (dtx == transX && dty == transY) {
            transformState = TRANSFORM_INT_TRANSLATE;
        } else {
            transformState = TRANSFORM_ANY_TRANSLATE;
        }
    } else if ((type & (AffineTransform.TYPE_FLIP |
                        AffineTransform.TYPE_MASK_ROTATION |
                        AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0)
    {
        transformState = TRANSFORM_TRANSLATESCALE;
        transX = transY = 0;
    } else {
        transformState = TRANSFORM_GENERIC;
        transX = transY = 0;
    }

    if (transformState >= TRANSFORM_TRANSLATESCALE ||
        origTransformState >= TRANSFORM_TRANSLATESCALE)
    {
        /* Its only in this case that the previous or current transform
         * was more than a translate that font info is invalidated
         */
        cachedFRC = null;
        this.validFontInfo = false;
        this.fontMetrics = null;
        this.glyphVectorFontInfo = null;

        if (transformState != origTransformState) {
            invalidatePipe();
        }
    }
    if (strokeState != STROKE_CUSTOM) {
        validateBasicStroke((BasicStroke) stroke);
    }
}
 
Example 20
Source File: SunGraphics2D.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected void invalidateTransform() {
    int type = transform.getType();
    int origTransformState = transformState;
    if (type == AffineTransform.TYPE_IDENTITY) {
        transformState = TRANSFORM_ISIDENT;
        transX = transY = 0;
    } else if (type == AffineTransform.TYPE_TRANSLATION) {
        double dtx = transform.getTranslateX();
        double dty = transform.getTranslateY();
        transX = (int) Math.floor(dtx + 0.5);
        transY = (int) Math.floor(dty + 0.5);
        if (dtx == transX && dty == transY) {
            transformState = TRANSFORM_INT_TRANSLATE;
        } else {
            transformState = TRANSFORM_ANY_TRANSLATE;
        }
    } else if ((type & (AffineTransform.TYPE_FLIP |
                        AffineTransform.TYPE_MASK_ROTATION |
                        AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0)
    {
        transformState = TRANSFORM_TRANSLATESCALE;
        transX = transY = 0;
    } else {
        transformState = TRANSFORM_GENERIC;
        transX = transY = 0;
    }

    if (transformState >= TRANSFORM_TRANSLATESCALE ||
        origTransformState >= TRANSFORM_TRANSLATESCALE)
    {
        /* Its only in this case that the previous or current transform
         * was more than a translate that font info is invalidated
         */
        cachedFRC = null;
        this.validFontInfo = false;
        this.fontMetrics = null;
        this.glyphVectorFontInfo = null;

        if (transformState != origTransformState) {
            invalidatePipe();
        }
    }
    if (strokeState != STROKE_CUSTOM) {
        validateBasicStroke((BasicStroke) stroke);
    }
}