java.awt.font
Class ShapeGraphicAttribute

java.lang.Object
  extended by java.awt.font.GraphicAttribute
      extended by java.awt.font.ShapeGraphicAttribute

public final class ShapeGraphicAttribute
extends GraphicAttribute

This is an implementation of GraphicAttribute that draws shapes in a TextLayout.


Field Summary
static boolean FILL
          True if the shape should be filled.
static boolean STROKE
          True if the shape should be stroked with a 1-pixel wide stroke.
 
Fields inherited from class java.awt.font.GraphicAttribute
BOTTOM_ALIGNMENT, CENTER_BASELINE, HANGING_BASELINE, ROMAN_BASELINE, TOP_ALIGNMENT
 
Constructor Summary
ShapeGraphicAttribute(Shape shape, int alignment, boolean stroke)
          Constructor.
 
Method Summary
 void draw(Graphics2D graphics, float x, float y)
          Draws the graphic at the given location.
 boolean equals(Object obj)
          Compares this ShapeGraphicAttribute to obj.
 boolean equals(ShapeGraphicAttribute rhs)
          Compares this ShapeGraphicAttribute to rhs.
 float getAdvance()
          Gets the distance from the origin of its Shape to the right side of the bounds of its Shape.
 float getAscent()
          Gets the positive distance from the origin of its Shape to the top of bounds.
 Rectangle2D getBounds()
          Returns a Rectangle2D that encloses all of the bits drawn by this shape.
 float getDescent()
          Gets the distance from the origin of its Shape to the bottom of the bounds.
 int hashCode()
          Gets the hash code.
 
Methods inherited from class java.awt.font.GraphicAttribute
getAlignment, getJustificationInfo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILL

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

See Also:
Constant Field Values

STROKE

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

See Also:
Constant Field Values
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.

Specified by:
draw in class GraphicAttribute
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.

Overrides:
equals in class Object
Parameters:
obj - - the object to compare.
Returns:
whether this Object is semantically equal to another
See Also:
Object.hashCode()

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.

Specified by:
getAdvance in class GraphicAttribute
Returns:
the advance

getAscent

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

Specified by:
getAscent in class GraphicAttribute
Returns:
the ascent

getDescent

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

Specified by:
getDescent in class GraphicAttribute
Returns:
the descent

getBounds

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

Overrides:
getBounds in class GraphicAttribute
Returns:
the bounds of the shape.

hashCode

public int hashCode()
Gets the hash code.

Overrides:
hashCode in class Object
Returns:
the hash code.
See Also:
Object.equals(Object), System.identityHashCode(Object)