FileDocCategorySizeDatePackage
GraphicAttribute.javaAPI DocAndroid 1.5 API6219Wed May 06 22:41:54 BST 2009java.awt.font

GraphicAttribute

public abstract class GraphicAttribute extends Object
The GraphicAttribute abstract class provides an opportunity to insert graphical elements in printed text.
since
Android 1.0

Fields Summary
public static final int
TOP_ALIGNMENT
The Constant TOP_ALIGNMENT indicates using the top line to calculate placement of graphics.
public static final int
BOTTOM_ALIGNMENT
The Constant BOTTOM_ALIGNMENT indicates using the bottom line to calculate placement of graphics.
public static final int
ROMAN_BASELINE
The Constant ROMAN_BASELINE indicates the placement of the roman baseline with respect to the graphics origin.
public static final int
CENTER_BASELINE
The Constant CENTER_BASELINE indicates the placement of the center baseline with respect to the graphics origin.
public static final int
HANGING_BASELINE
The Constant HANGING_BASELINE indicates the placement of the hanging baseline with respect to the graphics origin.
private int
alignment
The alignment.
Constructors Summary
protected GraphicAttribute(int align)
Instantiates a new graphic attribute with the specified alignment.

param
align the specified alignment.


                                   
       
        if ((align < BOTTOM_ALIGNMENT) || (align > HANGING_BASELINE)) {
            // awt.198=Illegal alignment argument
            throw new IllegalArgumentException(Messages.getString("awt.198")); //$NON-NLS-1$
        }
        this.alignment = align;
    
Methods Summary
public abstract voiddraw(java.awt.Graphics2D graphics, float x, float y)
Draws the GraphicAttribute at the specified location.

param
graphics the Graphics.
param
x the X coordinate of GraphicAttribute location.
param
y the Y coordinate of GraphicAttribute location.

public abstract floatgetAdvance()
Gets the GraphicAttribute's advance. It's the distance from the point at which the graphic is rendered and the point where the next character or graphic is rendered.

return
the GraphicAttribute's advance.

public final intgetAlignment()
Gets the alignment of this GraphicAttribute.

return
the alignment of this GraphicAttribute.

        return this.alignment;
    
public abstract floatgetAscent()
Gets the ascent of this GraphicAttribute.

return
the ascent of this GraphicAttribute.

public java.awt.geom.Rectangle2DgetBounds()
Gets the bounds of this GraphicAttribute.

return
the bounds of this GraphicAttribute.

        float ascent = getAscent();
        float advance = getAdvance();
        float descent = getDescent();

        // Default implementation - see API documentation.
        return new Rectangle2D.Float(0, -ascent, advance, ascent + descent);
    
public abstract floatgetDescent()
Gets the descent of this GraphicAttribute.

return
the descent of this GraphicAttribute.

public java.awt.font.GlyphJustificationInfogetJustificationInfo()
Gets the GlyphJustificationInfo of this GraphicAttribute.

return
the GlyphJustificationInfo of this GraphicAttribute.


        /*
         * Default implementation. Since documentation doesn't describe default
         * values, they were calculated based on 1.5 release behavior and can be
         * obtained using next test sample: // Create GraphicAttribute class
         * implementation public class MyGraphicAttribute extends
         * GraphicAttribute { protected MyGraphicAttribute(int align) {
         * super(align); } public float getDescent() { return 0; } public float
         * getAdvance() { return 1; } public void draw(Graphics2D g2, float x,
         * float y) { } public float getAscent() { return 0; } }
         * MyGraphicAttribute myGA = gat.new MyGraphicAttribute(0); // print
         * justification parameters
         * System.out.println(myGA.getJustificationInfo().growAbsorb);
         * System.out.println(myGA.getJustificationInfo().shrinkAbsorb);
         * System.out.println(myGA.getJustificationInfo().growLeftLimit);
         * System.out.println(myGA.getJustificationInfo().growPriority);
         * System.out.println(myGA.getJustificationInfo().growRightLimit);
         * System.out.println(myGA.getJustificationInfo().shrinkLeftLimit);
         * System.out.println(myGA.getJustificationInfo().shrinkPriority);
         * System.out.println(myGA.getJustificationInfo().shrinkRightLimit);
         * System.out.println(myGA.getJustificationInfo().weight);
         */
        float advance = getAdvance();
        return new GlyphJustificationInfo(advance, false,
                GlyphJustificationInfo.PRIORITY_INTERCHAR, advance / 3, advance / 3, false,
                GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, 0);