Java Platform 1.2
Beta 4

Class java.awt.font.GraphicAttribute

java.lang.Object
  |
  +--java.awt.font.GraphicAttribute
Direct Known Subclasses:
ImageGraphicAttribute, ShapeGraphicAttribute

public abstract class GraphicAttribute
extends Object
This class is used with the CHAR_REPLACEMENT attribute.

This represents a graphic embedded in text. Clients subclass this to implement their own char replacement graphics. Clients wishing to embed Shapes and Images in text need not subclass this class; they can use the ShapeGraphicAttribute and ImageGraphicAttribute classes instead.

Subclasses should ensure that their subclasses are immutable (that is, that the class does not change once it has been constructed). Mutating a GraphicAttribute which is used in a TextLayout results in undefined behavior from the TextLayout.


Field Summary
static int BOTTOM_ALIGNMENT
          Align bottom of graphic to bottom of line.
static int CENTER_BASELINE
          Align origin of graphic to center baseline of line.
static int HANGING_BASELINE
          Align origin of graphic to hanging baseline of line.
static int ROMAN_BASELINE
          Align origin of graphic to roman baseline of line.
static int TOP_ALIGNMENT
          Align top of graphic to top of line.
 
Constructor Summary
GraphicAttribute(int alignment)
          Construct a graphic attribute.
 
Method Summary
abstract  void draw(Graphics2D graphics, float x, float y)
          Draw the graphic at the given location.
abstract  float getAdvance()
          Return the advance of this graphic.
 int getAlignment()
          Return the alignment of this graphic.
abstract  float getAscent()
          Return the ascent of this graphic.
 Rectangle2D getBounds()
          Returns a rectangle which encloses all of the bits drawn by this graphic (relative to the drawing position, of course).
abstract  float getDescent()
          Return the descent of this graphic.
 GlyphJustificationInfo getJustificationInfo()
          Return the justification information for this graphic.
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Field Detail

TOP_ALIGNMENT

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

BOTTOM_ALIGNMENT

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

ROMAN_BASELINE

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

CENTER_BASELINE

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

HANGING_BASELINE

public static final int HANGING_BASELINE
Align origin of graphic to hanging baseline of line.
Constructor Detail

GraphicAttribute

protected GraphicAttribute(int alignment)
Construct a graphic attribute. Subclasses use this to define the alignment of the graphic.
Method Detail

getAscent

public abstract float getAscent()
Return the ascent of this graphic. A graphic can draw above its ascent (see getBounds).
Returns:
the ascent of this graphic

getDescent

public abstract float getDescent()
Return the descent of this graphic. A graphic can draw below its descent (see getBounds).
Returns:
the descent of this graphic

getAdvance

public abstract float getAdvance()
Return the advance of this graphic. The graphic's advance is the distance from the point at which the graphic is drawn and the point where the next character or graphic will be drawn. A graphic can draw beyond its advance (see getBounds).
Returns:
the advance of this graphic

getBounds

public Rectangle2D getBounds()
Returns a rectangle which encloses all of the bits drawn by this graphic (relative to the drawing position, of course). A graphic may draw beyond its origin, ascent, descent, or advance; but if it does, this method's implementation should indicate where the graphic draws. Default bounds is the rectangle (0, -ascent, advance, ascent+descent).
Returns:
a Rectangle2D which encloses all of the bits drawn by this graphic.

draw

public abstract void draw(Graphics2D graphics,
                          float x,
                          float y)
Draw the graphic at the given location.
Parameters:
graphics - the Graphics2D into which to draw the graphic
x - the x-coordinate (in user space) where the graphic is drawn
y - the y-coordinate (in user space) where the graphic is drawn

getAlignment

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

getJustificationInfo

public GlyphJustificationInfo getJustificationInfo()
Return the justification information for this graphic. Subclasses can override to provide different justification information.

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.