All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.awt.WrappingLabel

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----symantec.itools.awt.WrappingLabel

public class WrappingLabel
extends Canvas
implements AlignStyle
This class implements a multiple-line text label. It displays text on one or more lines, wrapping text as needed to fit in the available horizontal space.


Variable Index

 o align
The current text alignment.
 o baseline
The maximum ascent of the font used to display text.
 o fm
The metrics of the font used to display text.
 o text
The text string being displayed.

Constructor Index

 o WrappingLabel()
Constructs a default wrapping label.
 o WrappingLabel(String)
Constructs a wrapping label that displays the specified string.
 o WrappingLabel(String, int)
Constructs wrapping label with the specified text and alignment.

Method Index

 o drawAlignedString(Graphics, String, int, int, int)
This helper method draws a string aligned the requested way.
 o getAlignStyle()
Gets the current text alignment setting.
 o getText()
Gets the current label text.
 o paint(Graphics)
Paints this component using the given graphics context.
 o paramString()
Returns an empty string.
 o reshape(int, int, int, int)
Moves and/or resizes this component.
 o resize(int, int)
Resizes this component.
 o setAlignStyle(int)
Sets the text alignment.
 o setText(String)
Sets the label text.

Variables

 o text
  protected String text
The text string being displayed.

 o align
  protected int align
The current text alignment. One of ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT.

See Also:
AlignStyle, ALIGN_LEFT, ALIGN_CENTERED, ALIGN_RIGHT
 o baseline
  protected int baseline
The maximum ascent of the font used to display text.

 o fm
  protected FontMetrics fm
The metrics of the font used to display text.

Constructors

 o WrappingLabel
  public WrappingLabel()
Constructs a default wrapping label. Default values are an empty text string and left alignment.

 o WrappingLabel
  public WrappingLabel(String s)
Constructs a wrapping label that displays the specified string. The label will default to left alignment.

Parameters:
s - string to be displayed in label
 o WrappingLabel
  public WrappingLabel(String s,
                       int a)
Constructs wrapping label with the specified text and alignment.

Parameters:
s - the string to be displayed in label
a - the alignment, one of ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
See Also:
AlignStyle, ALIGN_LEFT, ALIGN_CENTERED, ALIGN_RIGHT

Methods

 o getAlignStyle
  public int getAlignStyle()
Gets the current text alignment setting.

Returns:
the current alignment, one of ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
See Also:
setAlignStyle, AlignStyle, ALIGN_LEFT, ALIGN_CENTERED, ALIGN_RIGHT
 o setAlignStyle
  public void setAlignStyle(int a)
Sets the text alignment.

Parameters:
a - the new alignment style, one of ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
See Also:
getAlignStyle, AlignStyle, ALIGN_LEFT, ALIGN_CENTERED, ALIGN_RIGHT
 o getText
  public String getText()
Gets the current label text.

Returns:
the label's text string
See Also:
setText
 o setText
  public void setText(String s)
Sets the label text.

Parameters:
s - the new label text
See Also:
getText
 o paramString
  public String paramString()
Returns an empty string. This is a standard Java AWT method which typically returns a string representing the state of this object.

Returns:
the empty string
Overrides:
paramString in class Component
 o reshape
  public synchronized void reshape(int x,
                                   int y,
                                   int width,
                                   int height)
Moves and/or resizes this component. This is a standard Java AWT method which gets called to move and/or resize this component. Components that are in containers with layout managers should not call this method, but rely on the layout manager instead. It is overridden here to re-wrap the text as necessary.

Parameters:
x - horizontal position in the parent's coordinate space
y - vertical position in the parent's coordinate space
width - the new width
height - the new height
Overrides:
reshape in class Component
 o resize
  public synchronized void resize(int width,
                                  int height)
Resizes this component. This is a standard Java AWT method which gets called to resize this component. Components that are in containers with layout managers should not call this method, but rely on the layout manager instead. It is overridden here to re-wrap the text as necessary.

Parameters:
width - the new width, in pixels
height - the new height, in pixels
Overrides:
resize in class Component
 o paint
  public void paint(Graphics g)
Paints this component using the given graphics context. This is a standard Java AWT method which typically gets called by the AWT to handle painting this component. It paints this component using the given graphics context. The graphics context clipping region is set to the bounding rectangle of this component and its <0,0> coordinate is this component's top-left corner.

Parameters:
g - the graphics context used for painting
Overrides:
paint in class Canvas
See Also:
repaint, update
 o drawAlignedString
  protected void drawAlignedString(Graphics g,
                                   String s,
                                   int x,
                                   int y,
                                   int width)
This helper method draws a string aligned the requested way.

Parameters:
g - the graphics context used for painting
s - the string to draw
x - the point to start drawing from, x coordinate
y - the point to start drawing from, y coordinate
width - the width of the area to draw in, in pixels

All Packages  Class Hierarchy  This Package  Previous  Next  Index