net.xoetrope.xui
Class XTextRenderer

java.lang.Object
  extended by net.xoetrope.xui.XTextRenderer

public class XTextRenderer
extends java.lang.Object

    

A mixin class for rendering multiline text.

Copyright: Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt $Revision: 2.9 $


Field Summary
static int CENTER
          Center the text
static int LEFT
          Left align the text
static int RIGHT
          Right align the text
 
Constructor Summary
XTextRenderer()
           
 
Method Summary
 void drawString(java.awt.Graphics g, java.lang.String str, int x, int y)
          If a XTextDecorator is set for this instance of the XTextRenderer, pass it the same parameters so that it can apply the decoration
 int getAlignment()
          Get the alignment value for this renderer
 java.awt.Dimension getPreferredSize(java.awt.Component comp, java.lang.String text)
          Gets the preferred size of this component.
 void paintText(java.awt.Component comp, java.awt.Graphics g, java.lang.String text)
          Paints the text on behalf of a component
 void setAlignment(int b)
          Sets the alignment of the text.
 void setTextDecorator(XTextDecorator decorator)
          Add a text decorator
 void setTransparent(boolean b)
          Sets the transparency 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

CENTER

public static final int CENTER
Center the text

See Also:
Constant Field Values
Constructor Detail

XTextRenderer

public XTextRenderer()
Method Detail

setTextDecorator

public void setTextDecorator(XTextDecorator 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.

drawString

public void drawString(java.awt.Graphics g,
                       java.lang.String str,
                       int x,
                       int y)
If a XTextDecorator is set for this instance of the XTextRenderer, 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

setAlignment

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

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

getAlignment

public int getAlignment()
Get the alignment value for this renderer

Returns:
the 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