java.awt.font

Class ShapeGraphicAttribute

public final class ShapeGraphicAttribute extends GraphicAttribute

This is an implementation of GraphicAttribute that draws shapes in a TextLayout.
Field Summary
static booleanFILL
True if the shape should be filled.
static booleanSTROKE
True if the shape should be stroked with a 1-pixel wide stroke.
Constructor Summary
ShapeGraphicAttribute(Shape shape, int alignment, boolean stroke)
Constructor.
Method Summary
voiddraw(Graphics2D graphics, float x, float y)
Draws the graphic at the given location.
booleanequals(Object obj)
Compares this ShapeGraphicAttribute to obj.
booleanequals(ShapeGraphicAttribute rhs)
Compares this ShapeGraphicAttribute to rhs.
floatgetAdvance()
Gets the distance from the origin of its Shape to the right side of the bounds of its Shape.
floatgetAscent()
Gets the positive distance from the origin of its Shape to the top of bounds.
Rectangle2DgetBounds()
Returns a Rectangle2D that encloses all of the bits drawn by this shape.
floatgetDescent()
Gets the distance from the origin of its Shape to the bottom of the bounds.
inthashCode()
Gets the hash code.

Field Detail

FILL

public static final boolean FILL
True if the shape should be filled.

STROKE

public static final boolean STROKE
True if the shape should be stroked with a 1-pixel wide stroke.

Constructor Detail

ShapeGraphicAttribute

public ShapeGraphicAttribute(Shape shape, int alignment, boolean stroke)
Constructor.

Parameters: shape - the Shape to render. The Shape is rendered with its origin. alignment - the alignment stroke - true if the Shape should be stroked; false if the Shape should be filled.

Method Detail

draw

public void draw(Graphics2D graphics, float x, float y)
Draws the graphic at the given location.

Parameters: graphics - the graphics to use. x - the x location to draw at. y - the y location to draw at.

equals

public boolean equals(Object obj)
Compares this ShapeGraphicAttribute to obj.

Parameters: obj - the object to compare.

equals

public boolean equals(ShapeGraphicAttribute rhs)
Compares this ShapeGraphicAttribute to rhs.

Parameters: rhs - the ShapeGraphicAttribute to compare.

getAdvance

public float getAdvance()
Gets the distance from the origin of its Shape to the right side of the bounds of its Shape.

Returns: the advance

getAscent

public float getAscent()
Gets the positive distance from the origin of its Shape to the top of bounds.

Returns: the ascent

getBounds

public Rectangle2D getBounds()
Returns a Rectangle2D that encloses all of the bits drawn by this shape.

Returns: the bounds of the shape.

getDescent

public float getDescent()
Gets the distance from the origin of its Shape to the bottom of the bounds.

Returns: the descent

hashCode

public int hashCode()
Gets the hash code.

Returns: the hash code.