Last Updated: 3/4/97
Class NFLabel
Class NFLabel
public class NFLabel
The NFLabel class supports the display of multi-line labels with
or without a corresponding background region, as defined by
NFRegion. If a region is defined, it is automatically sized to
fit around the label, regardless of the number of lines required
by the label.
Within an HTML file, the following parameters (as supported by
NFParam) can be used to specify the attributes of a label:
"Label" - The string value of the label. Newlines
may be used to define multi-line labels.
Color - Color of text. See NFColor for values.
"FontName" - Font name for label.
FontSize - Numeric font size
Angle - Numeric angle of rotation (in degrees).
For non-zero angles, the label will be
rotated counter-clockwise.
Final Variables
|
Type |
|
Name |
|
Description |
|
int |
|
CENTER |
|
Multi-line align center |
|
int |
|
LEFT |
|
Multi-line align left |
|
int |
|
RIGHT |
|
Multi-line align right |
Constructors
- NFLabel ()
- NFLabel (Component comp, Graphics g, String lbl, Font font, Color color, int x, int y, int angle, NFRegion region)
- NFLabel (Component comp, Graphics g, String lbl, int x, int y)
Methods
- defineLabel (NFParam p, String param)
- defineLabel (NFParam p, String param, Vector v)
- draw ()
- draw (Applet app, Graphics g)
- draw (Component comp, Graphics g)
- draw (Component comp, Graphics g, String lbl, Font font, Color color, int x, int y, int justify, int angle, NFRegion region)
- draw (Graphics g)
- draw (Graphics g, int x, int y)
- draw (Graphics g, int x, int y, Font font, Color color)
- draw (Graphics g, int x, int y, String lbl)
- draw (NFRegion region)
- draw (String lbl)
- draw (String lbl, int x, int y)
- draw (String lbl, int x, int y, int justify)
- draw (int x, int y)
- getBounds (Graphics g)
- getFont ()
- getLabel ()
- getRegion ()
- loadParams (NFLabel label, Vector v, int offset)
- loadParams (NFParam p, Object val)
- loadParams (NFParam p, Object val, int offset)
- loadParams (NFParam p, String name) throws Exception
- loadParams (Vector v)
- setAngle (int angle)
- setColor (Color color)
- setComponent (Component comp)
- setFont (Font font)
- setGraphics (Graphics g)
- setJustify (int justify)
- setLabel (String lbl)
- setPos (int x, int y)
- setRegion (NFRegion region)
- stringBounds (Graphics g, String str)
- stringBounds(String str, FontMetrics fm)
NFLabel ()
-
Create a new label using all defaults.
-
NFLabel (Component comp,
Graphics g,
String lbl,
Font font,
Color color,
int x,
int y,
int angle,
NFRegion region)
-
Create a new label with the given font and color,
centered at the given location. If <region> is non-null,
then a NFRegion will be displayed around the label, using
the current attributes assigned to that region.
-
NFLabel (Component comp,
Graphics g,
String lbl,
int x,
int y)
-
Create a new label centered at (x, y), using the default
font (TimesRoman-14), color (BLACK) and region (NONE).
-
static NFParamDef defineLabel (NFParam p,
String param)
-
Create a parser definition for a label.
-
static int defineLabel (NFParam p,
String param,
Vector v)
-
Append the parser elements for a label to the given vector.
This method returns the number of elements appended.
-
void draw ()
-
Draw the label using all current attributes.
-
void draw (Applet app,
Graphics g)
-
Draw the label using all current attributes, in the given graphics
context.
-
void draw (Component comp,
Graphics g)
-
Draw the label using all current attributes, in the given graphics
context.
-
void draw (Component comp,
Graphics g,
String lbl,
Font font,
Color color,
int x,
int y,
int justify,
int angle,
NFRegion region)
-
Draw the given label, in the given graphics context, using
the given font and color, centered at (x, y), on top of the
given region. If <region> is null, no region is drawn.
-
void draw (Graphics g)
-
Draw the label using all current attributes, in the given graphics
context.
-
void draw (Graphics g,
int x,
int y)
-
Draw the current label, centered on (x, y) using the current
attributes, in the given graphics context.
-
void draw (Graphics g,
int x,
int y,
Font font,
Color color)
-
Draw the given label, centered on (x, y) using the current
attributes. Note that if font or color is null, the current
font and color in the graphics object will be used. This is
helpful if you wish to optimize the label draw performance.
-
void draw (Graphics g,
int x,
int y,
String lbl)
-
Draw the current label, centered on (x, y) using the current
attributes, in the given graphics context.
-
void draw (NFRegion region)
-
Draw the current label with the given underlying region.
If null is given, no region is drawn.
-
void draw (String lbl)
-
Draw the given label, using the current attributes.
-
void draw (String lbl,
int x,
int y)
-
Draw the given label, centered on (x, y) using the current
attributes.
-
void draw (String lbl,
int x,
int y,
int justify)
-
Draw the given label, centered on (x, y) using the current
attributes. The justify parameter is only used for
multi-line labels.
-
void draw (int x,
int y)
-
Draw the current label, centered on (x, y) using the current
attributes.
-
Dimension getBounds (Graphics g)
-
Returns a bounding box for the current label,
including any associated region and any angle
of rotation.
-
Font getFont ()
-
Get the font.
-
String getLabel ()
-
Get the label string.
-
NFRegion getRegion ()
-
Get the underlying region. A null value means no underlying
region.
-
static void loadParams (NFLabel label,
Vector v,
int offset)
-
Load the attributes from the given vector into the
given label object, starting at the given offset.
-
static NFLabel loadParams (NFParam p,
Object val)
-
Build a label using the value vector provided by the parser.
-
static NFLabel loadParams (NFParam p,
Object val,
int offset)
-
Build a label object, using the attributes stored in the
given vector, starting at the given offset.
-
void loadParams (NFParam p,
String name) throws Exception
-
Load the parameter with the given name into the current label
-
void loadParams (Vector v)
-
Load the attributes from the given vector into the
current label object
-
void setAngle (int angle)
-
Set the label rotation. Currently, only the following
angles are supported: 0, 90, 180, 270. All other non-zero
angles will be truncated to the nearest 90 degrees.
-
void setColor (Color color)
-
Set the color.
-
void setComponent (Component comp)
-
Set the component to use for image rotation.
-
void setFont (Font font)
-
Set the font.
-
void setGraphics (Graphics g)
-
Set the graphics context.
-
void setJustify (int justify)
-
Set the label justification.
-
void setLabel (String lbl)
-
Set the label string.
-
void setPos (int x,
int y)
-
Set the center position for the string.
-
void setRegion (NFRegion region)
-
Set the underlying region. A null value means no underlying
region.
-
private static Dimension stringBounds (Graphics g,
String str)
-
Determine the bounds for the given string and font,
compensating for newlines and rotation.
-
private static Dimension stringBounds(String str,
FontMetrics fm)
-
Determine the bounds for the given string and font,
compensating for newlines and rotation.
-