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

The following examples show how to use java.awt.geom.AffineTransform#TYPE_IDENTITY . 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
Source Project: birt   File: SVGGraphics2D.java    License: 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
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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 Project: JDKSourceCode1.8   File: FontRenderContext.java    License: 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 7
/**
 * 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 8
Source Project: TrakEM2   File: Treeline.java    License: 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 9
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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
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
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
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
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 Project: Bytecoder   File: SunGraphics2D.java    License: 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 18
Source Project: birt   File: SVGGraphics2D.java    License: 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 19
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
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);
    }
}