java.awt.font
Class GraphicAttribute

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.font.GraphicAttribute
Direct Known Subclasses:
ImageGraphicAttribute sample code for java.awt.font.ImageGraphicAttribute definition code for java.awt.font.ImageGraphicAttribute , ShapeGraphicAttribute sample code for java.awt.font.ShapeGraphicAttribute definition code for java.awt.font.ShapeGraphicAttribute

public abstract class GraphicAttribute
extends Object sample code for java.lang.Object definition code for java.lang.Object

This class is used with the CHAR_REPLACEMENT attribute.

The GraphicAttribute class represents a graphic embedded in text. Clients subclass this class to implement their own char replacement graphics. Clients wishing to embed shapes and images in text need not subclass this class. Instead, clients can use the ShapeGraphicAttribute sample code for java.awt.font.ShapeGraphicAttribute definition code for java.awt.font.ShapeGraphicAttribute and ImageGraphicAttribute sample code for java.awt.font.ImageGraphicAttribute definition code for java.awt.font.ImageGraphicAttribute classes.

Subclasses must ensure that their objects are immutable once they are constructed. Mutating a GraphicAttribute that is used in a TextLayout sample code for java.awt.font.TextLayout definition code for java.awt.font.TextLayout results in undefined behavior from the TextLayout.


Field Summary
static int BOTTOM_ALIGNMENT sample code for java.awt.font.GraphicAttribute.BOTTOM_ALIGNMENT definition code for java.awt.font.GraphicAttribute.BOTTOM_ALIGNMENT
          Aligns bottom of graphic to bottom of line.
static int CENTER_BASELINE sample code for java.awt.font.GraphicAttribute.CENTER_BASELINE definition code for java.awt.font.GraphicAttribute.CENTER_BASELINE
          Aligns origin of graphic to center baseline of line.
static int HANGING_BASELINE sample code for java.awt.font.GraphicAttribute.HANGING_BASELINE definition code for java.awt.font.GraphicAttribute.HANGING_BASELINE
          Aligns origin of graphic to hanging baseline of line.
static int ROMAN_BASELINE sample code for java.awt.font.GraphicAttribute.ROMAN_BASELINE definition code for java.awt.font.GraphicAttribute.ROMAN_BASELINE
          Aligns origin of graphic to roman baseline of line.
static int TOP_ALIGNMENT sample code for java.awt.font.GraphicAttribute.TOP_ALIGNMENT definition code for java.awt.font.GraphicAttribute.TOP_ALIGNMENT
          Aligns top of graphic to top of line.
 
Constructor Summary
protected GraphicAttribute sample code for java.awt.font.GraphicAttribute.GraphicAttribute(int) definition code for java.awt.font.GraphicAttribute.GraphicAttribute(int) (int alignment)
          Constructs a GraphicAttribute.
 
Method Summary
abstract  void draw sample code for java.awt.font.GraphicAttribute.draw(java.awt.Graphics2D, float, float) definition code for java.awt.font.GraphicAttribute.draw(java.awt.Graphics2D, float, float) (Graphics2D sample code for java.awt.Graphics2D definition code for java.awt.Graphics2D  graphics, float x, float y)
          Renders this GraphicAttribute at the specified location.
abstract  float getAdvance sample code for java.awt.font.GraphicAttribute.getAdvance() definition code for java.awt.font.GraphicAttribute.getAdvance() ()
          Returns the advance of this GraphicAttribute.
 int getAlignment sample code for java.awt.font.GraphicAttribute.getAlignment() definition code for java.awt.font.GraphicAttribute.getAlignment() ()
          Returns the alignment of this GraphicAttribute.
abstract  float getAscent sample code for java.awt.font.GraphicAttribute.getAscent() definition code for java.awt.font.GraphicAttribute.getAscent() ()
          Returns the ascent of this GraphicAttribute.
 Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D getBounds sample code for java.awt.font.GraphicAttribute.getBounds() definition code for java.awt.font.GraphicAttribute.getBounds() ()
          Returns a Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D that encloses all of the bits drawn by this GraphicAttribute relative to the rendering position.
abstract  float getDescent sample code for java.awt.font.GraphicAttribute.getDescent() definition code for java.awt.font.GraphicAttribute.getDescent() ()
          Returns the descent of this GraphicAttribute.
 GlyphJustificationInfo sample code for java.awt.font.GlyphJustificationInfo definition code for java.awt.font.GlyphJustificationInfo getJustificationInfo sample code for java.awt.font.GraphicAttribute.getJustificationInfo() definition code for java.awt.font.GraphicAttribute.getJustificationInfo() ()
          Returns the justification information for this GraphicAttribute.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

TOP_ALIGNMENT sample code for java.awt.font.GraphicAttribute.TOP_ALIGNMENT

public static final int TOP_ALIGNMENT
Aligns top of graphic to top of line.

See Also:
Constant Field Values

BOTTOM_ALIGNMENT sample code for java.awt.font.GraphicAttribute.BOTTOM_ALIGNMENT

public static final int BOTTOM_ALIGNMENT
Aligns bottom of graphic to bottom of line.

See Also:
Constant Field Values

ROMAN_BASELINE sample code for java.awt.font.GraphicAttribute.ROMAN_BASELINE

public static final int ROMAN_BASELINE
Aligns origin of graphic to roman baseline of line.

See Also:
Constant Field Values

CENTER_BASELINE sample code for java.awt.font.GraphicAttribute.CENTER_BASELINE

public static final int CENTER_BASELINE
Aligns origin of graphic to center baseline of line.

See Also:
Constant Field Values

HANGING_BASELINE sample code for java.awt.font.GraphicAttribute.HANGING_BASELINE

public static final int HANGING_BASELINE
Aligns origin of graphic to hanging baseline of line.

See Also:
Constant Field Values
Constructor Detail

GraphicAttribute sample code for java.awt.font.GraphicAttribute(int) definition code for java.awt.font.GraphicAttribute(int)

protected GraphicAttribute(int alignment)
Constructs a GraphicAttribute. Subclasses use this to define the alignment of the graphic.

Parameters:
alignment - an int representing one of the GraphicAttribute alignment fields
Method Detail

getAscent sample code for java.awt.font.GraphicAttribute.getAscent() definition code for java.awt.font.GraphicAttribute.getAscent()

public abstract float getAscent()
Returns the ascent of this GraphicAttribute. A graphic can be rendered above its ascent.

Returns:
the ascent of this GraphicAttribute.
See Also:
getBounds() sample code for java.awt.font.GraphicAttribute.getBounds() definition code for java.awt.font.GraphicAttribute.getBounds()

getDescent sample code for java.awt.font.GraphicAttribute.getDescent() definition code for java.awt.font.GraphicAttribute.getDescent()

public abstract float getDescent()
Returns the descent of this GraphicAttribute. A graphic can be rendered below its descent.

Returns:
the descent of this GraphicAttribute.
See Also:
getBounds() sample code for java.awt.font.GraphicAttribute.getBounds() definition code for java.awt.font.GraphicAttribute.getBounds()

getAdvance sample code for java.awt.font.GraphicAttribute.getAdvance() definition code for java.awt.font.GraphicAttribute.getAdvance()

public abstract float getAdvance()
Returns the advance of this GraphicAttribute. The GraphicAttribute object's advance is the distance from the point at which the graphic is rendered and the point where the next character or graphic is rendered. A graphic can be rendered beyond its advance

Returns:
the advance of this GraphicAttribute.
See Also:
getBounds() sample code for java.awt.font.GraphicAttribute.getBounds() definition code for java.awt.font.GraphicAttribute.getBounds()

getBounds sample code for java.awt.font.GraphicAttribute.getBounds() definition code for java.awt.font.GraphicAttribute.getBounds()

public Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D  getBounds()
Returns a Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D that encloses all of the bits drawn by this GraphicAttribute relative to the rendering position. A graphic may be rendered beyond its origin, ascent, descent, or advance; but if it is, this method's implementation must indicate where the graphic is rendered. Default bounds is the rectangle (0, -ascent, advance, ascent+descent).

Returns:
a Rectangle2D that encloses all of the bits rendered by this GraphicAttribute.

draw sample code for java.awt.font.GraphicAttribute.draw(java.awt.Graphics2D, float, float) definition code for java.awt.font.GraphicAttribute.draw(java.awt.Graphics2D, float, float)

public abstract void draw(Graphics2D sample code for java.awt.Graphics2D definition code for java.awt.Graphics2D  graphics,
                          float x,
                          float y)
Renders this GraphicAttribute at the specified location.

Parameters:
graphics - the Graphics2D sample code for java.awt.Graphics2D definition code for java.awt.Graphics2D into which to render the graphic
x, y - the user-space coordinates where the graphic is rendered

getAlignment sample code for java.awt.font.GraphicAttribute.getAlignment() definition code for java.awt.font.GraphicAttribute.getAlignment()

public final int getAlignment()
Returns the alignment of this GraphicAttribute. Alignment can be to a particular baseline, or to the absolute top or bottom of a line.

Returns:
the alignment of this GraphicAttribute.

getJustificationInfo sample code for java.awt.font.GraphicAttribute.getJustificationInfo() definition code for java.awt.font.GraphicAttribute.getJustificationInfo()

public GlyphJustificationInfo sample code for java.awt.font.GlyphJustificationInfo definition code for java.awt.font.GlyphJustificationInfo  getJustificationInfo()
Returns the justification information for this GraphicAttribute. Subclasses can override this method to provide different justification information.

Returns:
a GlyphJustificationInfo sample code for java.awt.font.GlyphJustificationInfo definition code for java.awt.font.GlyphJustificationInfo object that contains the justification information for this GraphicAttribute.