APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt.font

public final Class ShapeGraphicAttribute

extends GraphicAttribute
Class Inheritance
Imports
java.awt.Shape, .Graphics, .Rectangle, .Graphics2D, .Shape, java.awt.geom.AffineTransform, .Rectangle2D

The ShapeGraphicAttribute class is an implementation of GraphicAttribute that draws shapes in a TextLayout.
See Also
GraphicAttribute

Field Summary

Modifier and TypeField and Description
public static final boolean
FILL

A key indicating the shape should be filled.

private Shape
private Rectangle2D
private boolean
public static final boolean
STROKE

A key indicating the shape should be stroked with a 1-pixel wide stroke.

Inherited from java.awt.font.GraphicAttribute:
BOTTOM_ALIGNMENTCENTER_BASELINEHANGING_BASELINEROMAN_BASELINETOP_ALIGNMENT

Constructor Summary

AccessConstructor and Description
public
ShapeGraphicAttribute(Shape
the Shape to render. The Shape is rendered with its origin at the origin of this ShapeGraphicAttribute in the host TextLayout. This object maintains a reference to shape.
shape
,
int
one of the alignments from this ShapeGraphicAttribute.
alignment
,
boolean
true if the Shape should be stroked; false if the Shape should be filled.
stroke
)

Constructs a ShapeGraphicAttribute for the specified Shape.

Method Summary

Modifier and TypeMethod and Description
public void
draw(Graphics2D graphics, float x, float y)

Implements abstract java.awt.font.GraphicAttribute.draw.

Renders this GraphicAttribute at the specified location.

public boolean

Returns:

true if this ShapeGraphicAttribute equals rhs; false otherwise.
equals
(Object
the Object to compare for equality
rhs
)

Overrides java.lang.Object.equals.

Compares this ShapeGraphicAttribute to the specified Object.

public boolean

Returns:

true if this ShapeGraphicAttribute equals rhs; false otherwise.
equals
(ShapeGraphicAttribute
the ShapeGraphicAttribute to compare for equality
rhs
)

Compares this ShapeGraphicAttribute to the specified ShapeGraphicAttribute.

public float

Returns:

the advance of this ShapeGraphicAttribute.
getAdvance
()

Implements abstract java.awt.font.GraphicAttribute.getAdvance.

Returns the advance of this ShapeGraphicAttribute.

public float

Returns:

the ascent of this ShapeGraphicAttribute.
getAscent
()

Implements abstract java.awt.font.GraphicAttribute.getAscent.

Returns the ascent of this ShapeGraphicAttribute.

public Rectangle2D

Returns:

a Rectangle2D that encloses all of the bits rendered by this ShapeGraphicAttribute.
getBounds
()

Overrides java.awt.font.GraphicAttribute.getBounds.

Returns a Rectangle2D that encloses all of the bits drawn by this ShapeGraphicAttribute relative to the rendering position.

public float

Returns:

the descent of this ShapeGraphicAttribute.
getDescent
()

Implements abstract java.awt.font.GraphicAttribute.getDescent.

Returns the descent of this ShapeGraphicAttribute.

public Shape

Returns:

the Shape representing this graphic attribute, suitable for stroking or filling.
getOutline
(AffineTransform
an optional AffineTransform to apply to the this ShapeGraphicAttribute. This can be null.
tx
)

Overrides java.awt.font.GraphicAttribute.getOutline.

Return a java.awt.Shape that represents the region that this ShapeGraphicAttribute renders.

public int

Returns:

a hash code value for this ShapeGraphicAttribute.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this ShapeGraphicAttribute.

Inherited from java.awt.font.GraphicAttribute:
getAlignmentgetJustificationInfo

Field Detail

FILLback to summary
public static final boolean FILL

A key indicating the shape should be filled.

fShapeback to summary
private Shape fShape
fShapeBoundsback to summary
private Rectangle2D fShapeBounds
fStrokeback to summary
private boolean fStroke
STROKEback to summary
public static final boolean STROKE

A key indicating the shape should be stroked with a 1-pixel wide stroke.

Constructor Detail

ShapeGraphicAttributeback to summary
public ShapeGraphicAttribute(Shape shape, int alignment, boolean stroke)

Constructs a ShapeGraphicAttribute for the specified Shape.

Parameters
shape:Shape

the Shape to render. The Shape is rendered with its origin at the origin of this ShapeGraphicAttribute in the host TextLayout. This object maintains a reference to shape.

alignment:int

one of the alignments from this ShapeGraphicAttribute.

stroke:boolean

true if the Shape should be stroked; false if the Shape should be filled.

Method Detail

drawback to summary
public void draw(Graphics2D graphics, float x, float y)

Implements abstract java.awt.font.GraphicAttribute.draw.

Doc from java.awt.font.GraphicAttribute.draw.

Renders this GraphicAttribute at the specified location.

equalsback to summary
public boolean equals(Object rhs)

Overrides java.lang.Object.equals.

Compares this ShapeGraphicAttribute to the specified Object.

Parameters
rhs:Object

the Object to compare for equality

Returns:boolean

true if this ShapeGraphicAttribute equals rhs; false otherwise.

equalsback to summary
public boolean equals(ShapeGraphicAttribute rhs)

Compares this ShapeGraphicAttribute to the specified ShapeGraphicAttribute.

Parameters
rhs:ShapeGraphicAttribute

the ShapeGraphicAttribute to compare for equality

Returns:boolean

true if this ShapeGraphicAttribute equals rhs; false otherwise.

getAdvanceback to summary
public float getAdvance()

Implements abstract java.awt.font.GraphicAttribute.getAdvance.

Returns the advance of this ShapeGraphicAttribute. The advance of a ShapeGraphicAttribute is the distance from the origin of its Shape to the right side of the bounds of its Shape.

Returns:float

the advance of this ShapeGraphicAttribute.

getAscentback to summary
public float getAscent()

Implements abstract java.awt.font.GraphicAttribute.getAscent.

Returns the ascent of this ShapeGraphicAttribute. The ascent of a ShapeGraphicAttribute is the positive distance from the origin of its Shape to the top of bounds of its Shape.

Returns:float

the ascent of this ShapeGraphicAttribute.

getBoundsback to summary
public Rectangle2D getBounds()

Overrides java.awt.font.GraphicAttribute.getBounds.

Returns a Rectangle2D that encloses all of the bits drawn by this ShapeGraphicAttribute relative to the rendering position. A graphic can be rendered beyond its origin, ascent, descent, or advance; but if it does, this method's implementation should indicate where the graphic is rendered.

Returns:Rectangle2D

a Rectangle2D that encloses all of the bits rendered by this ShapeGraphicAttribute.

getDescentback to summary
public float getDescent()

Implements abstract java.awt.font.GraphicAttribute.getDescent.

Returns the descent of this ShapeGraphicAttribute. The descent of a ShapeGraphicAttribute is the distance from the origin of its Shape to the bottom of the bounds of its Shape.

Returns:float

the descent of this ShapeGraphicAttribute.

getOutlineback to summary
public Shape getOutline(AffineTransform tx)

Overrides java.awt.font.GraphicAttribute.getOutline.

Return a java.awt.Shape that represents the region that this ShapeGraphicAttribute renders. This is used when a TextLayout is requested to return the outline of the text. The (untransformed) shape must not extend outside the rectangular bounds returned by getBounds.

Parameters
tx:AffineTransform

an optional AffineTransform to apply to the this ShapeGraphicAttribute. This can be null.

Returns:Shape

the Shape representing this graphic attribute, suitable for stroking or filling.

Since
1.6
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this ShapeGraphicAttribute.

Returns:int

a hash code value for this ShapeGraphicAttribute.