org.formaria.aria
Class TextRenderer

java.lang.Object
  extended by org.formaria.aria.TextRenderer

public class TextRenderer
extends java.lang.Object

A mixin class for rendering multiline text.

Copyright: Copyright (c) Formaria Ltd., 2008
License: see license.txt $Revision: 2.9 $


Field Summary
static int BOTTOM
          Bottom align the text
static int CENTER
          Center the text
static int LEFT
          Left align the text
static int RIGHT
          Right align the text
static int TOP
          Top align the text
 
Constructor Summary
TextRenderer()
           
 
Method Summary
 void drawString(java.awt.Graphics g, java.lang.String str, int x, int y)
          If a TextDecorator is set for this instance of the TextRenderer, pass it the same parameters so that it can apply the decoration
 int getHorizontalAlignment()
          Get the horizontal alignment value for this renderer
 java.awt.Dimension getPreferredSize(java.awt.Component comp, java.lang.String text)
          Gets the preferred size of this component.
 int getVerticalAlignment()
          Get the vertical alignment value for this renderer
 void paintText(java.awt.Component comp, java.awt.Graphics g, java.awt.Insets insets, java.lang.String text)
          Paints the text on behalf of a component
 void paintText(java.awt.Component comp, java.awt.Graphics g, java.lang.String text)
          Paints the text on behalf of a component
 void setHorizontalAlignment(int b)
          Sets the horizontal alignment of the text.
 void setTextDecorator(TextDecorator decorator)
          Add a text decorator
 void setTransparent(boolean b)
          Sets the transparency of the text.
 void setVerticalAlignment(int b)
          Sets the vertical alignment of the text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
Left align the text

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Right align the text

See Also:
Constant Field Values

TOP

public static final int TOP
Top align the text

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Bottom align the text

See Also:
Constant Field Values

CENTER

public static final int CENTER
Center the text

See Also:
Constant Field Values
Constructor Detail

TextRenderer

public TextRenderer()
Method Detail

setTextDecorator

public void setTextDecorator(TextDecorator decorator)
Add a text decorator

Parameters:
decorator - the decorator

paintText

public void paintText(java.awt.Component comp,
                      java.awt.Graphics g,
                      java.lang.String text)
Paints the text on behalf of a component

Parameters:
comp - the owner component
g - the graphics context
text - the text to render.

paintText

public void paintText(java.awt.Component comp,
                      java.awt.Graphics g,
                      java.awt.Insets insets,
                      java.lang.String text)
Paints the text on behalf of a component

Parameters:
comp - the owner component
g - the graphics context
text - the text to render.

drawString

public void drawString(java.awt.Graphics g,
                       java.lang.String str,
                       int x,
                       int y)
If a TextDecorator is set for this instance of the TextRenderer, pass it the same parameters so that it can apply the decoration

Parameters:
g - The Graphics Object to which the string is to be painted
str - The String to be painted
x - The x coordinate at which to start painting
y - The y coordinate at which to start painting

setHorizontalAlignment

public void setHorizontalAlignment(int b)
Sets the horizontal alignment of the text.

Parameters:
b - RIGHT to right align the text, LEFT for left alignment or CENTERED for centered text

getHorizontalAlignment

public int getHorizontalAlignment()
Get the horizontal alignment value for this renderer

Returns:
the horizontal alignment value

setVerticalAlignment

public void setVerticalAlignment(int b)
Sets the vertical alignment of the text.

Parameters:
b - BOTTOM to bottom align the text, TOP for top alignment or CENTERED for centered text

getVerticalAlignment

public int getVerticalAlignment()
Get the vertical alignment value for this renderer

Returns:
the vertical alignment value

setTransparent

public void setTransparent(boolean b)
Sets the transparency of the text.

Parameters:
b - true to make text transparent

getPreferredSize

public java.awt.Dimension getPreferredSize(java.awt.Component comp,
                                           java.lang.String text)
Gets the preferred size of this component.

Parameters:
comp - The component whose FontMetrics are used
text - The text which is to be drawn
Returns:
a dimension object indicating this component's preferred size
See Also:
#getMinimumSize, LayoutManager