com.arsdigita.toolbox.rebop
Class FormattedText

java.lang.Object
  extended bycom.arsdigita.toolbox.rebop.FormattedText
Direct Known Subclasses:
WrappedRun

public class FormattedText
extends Object

Represents a "run" of text with a single set of style attributes. Includes logic for word-wrapping the text within a given area.

Author:
Gavin Doughtie
See Also:
StyledText

Field Summary
static String versionId
           
 
Constructor Summary
FormattedText()
           
FormattedText(Font font, Color color, String string)
          Creates a new FormattedText instance.
FormattedText(String text)
           
 
Method Summary
 void draw(Graphics g, int x, int y, int width, int height)
          Allows a FormattedText object to be used as a component's Drawable object.
static void drawWrappedText(Graphics g, String text, Dimension size, int leftMargin, boolean measureOnly, Point startPoint, Dimension preferredDimension, Vector wrappedRuns)
          Draws and/or measures text wrapped within a set of constraints.
 Color getColor()
           
 Font getFont()
           
 String getString()
           
 void setColor(Color color)
           
 void setFont(Font font)
           
 void setString(String string)
           
 void updateGraphics(Graphics g)
          Updates a Graphics object with font and color, if set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

FormattedText

public FormattedText()

FormattedText

public FormattedText(String text)

FormattedText

public FormattedText(Font font,
                     Color color,
                     String string)
Creates a new FormattedText instance.

Parameters:
font - Text will be drawn using this font, or the current font of the passed-in Graphics object if font is set to null.
color - Text will be drawn in this color, or the current color of the passed-in Graphics object if color is set to null.
string - Text to draw
Method Detail

updateGraphics

public void updateGraphics(Graphics g)
Updates a Graphics object with font and color, if set

Parameters:
g - Graphics to update

getString

public String getString()

setString

public void setString(String string)

getFont

public Font getFont()

setFont

public void setFont(Font font)

getColor

public Color getColor()

setColor

public void setColor(Color color)

draw

public void draw(Graphics g,
                 int x,
                 int y,
                 int width,
                 int height)
Allows a FormattedText object to be used as a component's Drawable object.


drawWrappedText

public static void drawWrappedText(Graphics g,
                                   String text,
                                   Dimension size,
                                   int leftMargin,
                                   boolean measureOnly,
                                   Point startPoint,
                                   Dimension preferredDimension,
                                   Vector wrappedRuns)
Draws and/or measures text wrapped within a set of constraints.

Parameters:
g - Graphics context to draw the wrapped text upon.
text - to draw
size - text will be wrapped within the width of this Dimension. Text will not be drawn below the bottom of this size, but if the measureOnly flag is set, the max height WILL be calculated.
leftMargin - new lines after the first line will begin at this horizontal offset in the current coordinate system.
startPoint - The location in the current coordinate system to begin drawing the first line of text
preferredDimension - @out if all the text were to be drawn, this dimension would be required to hold it. Only valid if measureOnly is set.
measureOnly - if true, calculate preferredDimension but do not draw.
wrappedRuns - if non-null, store cached runs here


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC