Overview | Package | Class | Tree | Index | Help NetCharts Pro (Applets) 7.0
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

netcharts.graphics
Class NFLabel

java.lang.Object
  |
  +--netcharts.graphics.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:


Field Summary
static int CENTER
          Multi-line align center
static int LEFT
          Multi-line align left
static int RIGHT
          Multi-line align right
 
Constructor Summary
NFLabel()
          Create a new label using all defaults.
NFLabel(java.awt.Component comp, java.awt.Graphics g, java.lang.String lbl, java.awt.Font font, java.awt.Color color, int x, int y, double angle, NFRegion region)
          Create a new label with the given font and color, centered at the given location.
NFLabel(java.awt.Component comp, java.awt.Graphics g, java.lang.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).
NFLabel(NFLabel label)
          Create a new label from the attributes of the given label.
 
Method Summary
void draw()
          Draw the label using all current attributes.
void draw(java.applet.Applet app, java.awt.Graphics g)
          Draw the label using all current attributes, in the given graphics context.
void draw(java.awt.Component comp, java.awt.Graphics g)
          Draw the label using all current attributes, in the given graphics context.
void draw(java.awt.Component comp, java.awt.Graphics g, NFLabel top, NFLabel bottom)
          Draw the label using all current attributes, in the given graphics context.
void draw(java.awt.Component comp, java.awt.Graphics g, java.lang.String lbl, java.awt.Font font, java.awt.Color color, double x, double y, int justify, double 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.
void draw(double x, double y)
          Draw the current label, centered on (x, y) using the current attributes.
void draw(java.awt.Graphics g)
          Draw the label using all current attributes, in the given graphics context.
void draw(java.awt.Graphics g, double x, double y)
          Draw the current label, centered on (x, y) using the current attributes, in the given graphics context.
void draw(java.awt.Graphics g, double x, double y, java.awt.Font font, java.awt.Color color)
          Draw the given label, centered on (x, y) using the current attributes.
void draw(java.awt.Graphics g, double x, double y, java.lang.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.
void draw(java.lang.String lbl)
          Draw the given label, using the current attributes.
void draw(java.lang.String lbl, double x, double y)
          Draw the given label, centered on (x, y) using the current attributes.
void draw(java.lang.String lbl, double x, double y, int justify)
          Draw the given label, centered on (x, y) using the current attributes.
NFActiveLabel getActiveLabel()
          Get the ActiveLabel displayed over this label
java.awt.Dimension getBounds(java.awt.Graphics g)
          Returns a bounding box for the current label, including any associated region and any angle of rotation.
java.awt.Dimension getBounds(java.awt.Graphics g, java.awt.Dimension d, NFRegionBorder b)
          Returns a bounding box for the current label, including any associated region and any angle of rotation.
java.awt.geom.Rectangle2D getClipRectangle()
          Returns the current clip rectangle setting
java.awt.Color getColor()
          Get the color.
int getDecoration()
          Get the text decoration.
boolean getExtendedWidth()
          Get the extend label width flag.
int getExternalJustify()
          Get the external label justification.
java.awt.Font getFont()
          Get the font.
int getGap()
          Returns the current pixel spacing between lines and around the edge of the label.
int getJustify()
          Get the internal label justification.
java.lang.String getLabel()
          Get the label string.
java.awt.geom.Rectangle2D getParentBounds()
          Returns the bounding box for the label to be displayed in.
NFRegion getRegion()
          Get the underlying region.
double getX()
          Get the center position for the string.
double getY()
          Get the center position for the string.
static void loadParams(NFLabel label, java.util.Vector v, int offset)
          Load the attributes from the given vector into the given label object, starting at the given offset.
static void loadParams(NFLabel label, java.util.Vector v, int offset, boolean justify)
          Load the attributes from the given vector into the given label object, starting at the given offset.
static void loadParams(NFLabel label, java.util.Vector v, int offset, boolean justify, boolean externalJustify)
          Load the attributes from the given vector into the given label object, starting at the given offset.
static void loadParams(NFLabel label, java.util.Vector v, int offset, boolean angle, boolean justify, boolean externalJustify)
          Load the attributes from the given vector into the given label object, starting at the given offset.
static void loadParams(NFLabel label, java.util.Vector v, int offset, boolean angle, boolean justify, boolean externalJustify, boolean extend)
          Load the attributes from the given vector into the given label object, starting at the given offset.
static NFLabel loadParams(NFParam p, java.lang.Object val)
          Build a label using the value vector provided by the parser.
static NFLabel loadParams(NFParam p, java.lang.Object val, boolean justify)
          Build a label using the value vector provided by the parser.
static NFLabel loadParams(NFParam p, java.lang.Object val, int offset)
          Build a label object, using the attributes stored in the given vector, starting at the given offset.
static NFLabel loadParams(NFParam p, java.lang.Object val, int offset, boolean justify)
          Build a label object, using the attributes stored in the given vector, starting at the given offset.
static NFLabel loadParams(NFParam p, java.lang.Object val, int offset, boolean justify, boolean externalJustify)
          Build a label object, using the attributes stored in the given vector, starting at the given offset.
static NFLabel loadParams(NFParam p, java.lang.Object val, int offset, boolean angle, boolean justify, boolean externalJustify)
          Build a label object, using the attributes stored in the given vector, starting at the given offset.
static NFLabel loadParams(NFParam p, java.lang.Object val, int offset, boolean angle, boolean justify, boolean externalJustify, boolean extend)
          Build a label object, using the attributes stored in the given vector, starting at the given offset.
void loadParams(NFParam p, java.lang.String name)
          Load the parameter with the given name into the current label
void loadParams(java.util.Vector v)
          Load the attributes from the given vector into the current label object
void setActiveLabel(NFActiveLabel l)
          Set the ActiveLabel displayed over this label
void setAngle(double angle)
          Set the label rotation.
void setBackgroundPos(java.awt.Rectangle rect, int orientation)
          Set the background position for the string.
void setClipRectangle(java.awt.geom.Rectangle2D r)
          Sets a bounding box for the label to be displayed in.
void setColor(java.awt.Color color)
          Set the color.
void setComponent(java.awt.Component comp)
          Set the component to use for label rotation.
void setDecoration(int decoration)
          Set the text decoration.
void setExtendedWidth(boolean eWidth)
          Set the label background width extension flag.
void setExternalJustify(int ejustify)
          Set the external label justification.
void setFont(java.awt.Font font)
          Set the font.
void setGap(int gap)
          Sets the pixel spacing between lines and around the edge of the label.
void setGraphics(java.awt.Graphics g)
          Set the graphics context.
void setJustify(int justify)
          Set the internal label justification.
void setLabel(java.lang.String lbl)
          Set the label string.
void setParentBounds(java.awt.geom.Rectangle2D r)
          Sets a bounding box for the label to be displayed in.
void setPos(double x, double y)
          Set the center position for the string.
void setRegion(NFRegion region)
          Set the underlying region.
void setScale(double scale)
          Sets the scale factor to be used when drawing labels.
 

Field Detail

LEFT

public static final int LEFT
Multi-line align left

CENTER

public static final int CENTER
Multi-line align center

RIGHT

public static final int RIGHT
Multi-line align right
Constructor Detail

NFLabel

public NFLabel(java.awt.Component comp,
               java.awt.Graphics g,
               java.lang.String lbl,
               java.awt.Font font,
               java.awt.Color color,
               int x,
               int y,
               double 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.
Parameters:
comp - The component to use for Label rotation.
g - The Graphics to draw on.
lbl - The text of the label.
font - The font of the label.
color - The font color of the label.
x - The X coordinate of the label.
y - The Y coordinate of the label.
angle - The angle to rotate the label by.
region - The region to use as the label's background.

NFLabel

public NFLabel(java.awt.Component comp,
               java.awt.Graphics g,
               java.lang.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).
Parameters:
comp - The component to use for Label rotation.
g - The Graphics to draw on.
lbl - The text of the label.
x - The X coordinate of the label.
y - The Y coordinate of the label.

NFLabel

public NFLabel()
Create a new label using all defaults.

NFLabel

public NFLabel(NFLabel label)
Create a new label from the attributes of the given label.
Parameters:
label - The label to copy attributes from.
Method Detail

setComponent

public void setComponent(java.awt.Component comp)
Set the component to use for label rotation.
Parameters:
comp - The component.

setGraphics

public void setGraphics(java.awt.Graphics g)
Set the graphics context.
Parameters:
g - The Graphics.

setJustify

public void setJustify(int justify)
Set the internal label justification.
Parameters:
justify - LEFT, RIGHT, or CENTER.

getJustify

public int getJustify()
Get the internal label justification.
Returns:
LEFT, RIGHT, or CENTER.

setExtendedWidth

public void setExtendedWidth(boolean eWidth)
Set the label background width extension flag.
Parameters:
ON, - OFF.

setExternalJustify

public void setExternalJustify(int ejustify)
Set the external label justification.
Parameters:
justify - LEFT, RIGHT, CENTER, BOTTOM or TOP.

getExtendedWidth

public boolean getExtendedWidth()
Get the extend label width flag.
Returns:
ON, OFF.

getExternalJustify

public int getExternalJustify()
Get the external label justification.
Returns:
LEFT, RIGHT, or CENTER.

setLabel

public void setLabel(java.lang.String lbl)
Set the label string.
Parameters:
lbl - The text of the label.

setAngle

public void setAngle(double 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.
Parameters:
angle - The angle of rotation.

getLabel

public java.lang.String getLabel()
Get the label string.
Returns:
The label text.

setScale

public void setScale(double scale)
Sets the scale factor to be used when drawing labels. If scale less than or equal to 0.0, then scaling is disabled.
Parameters:
scale - The scale factor.

setFont

public void setFont(java.awt.Font font)
Set the font.
Parameters:
font - The font to set.

getFont

public java.awt.Font getFont()
Get the font.
Returns:
The label font.

setColor

public void setColor(java.awt.Color color)
Set the color.
Parameters:
color - The font color.

getColor

public java.awt.Color getColor()
Get the color.
Returns:
The font color.

setDecoration

public void setDecoration(int decoration)
Set the text decoration.
Parameters:
decoration - An int with DECORATION constants or'ed together.

getDecoration

public int getDecoration()
Get the text decoration.
Returns:
The text decoration.

setBackgroundPos

public void setBackgroundPos(java.awt.Rectangle rect,
                             int orientation)
Set the background position for the string.
Parameters:
rect - The Background rect area.
orientation - The position of the label (TOP/BOTTOM/LEFT/RIGHT).

setPos

public void setPos(double x,
                   double y)
Set the center position for the string.
Parameters:
x - The X coordinate.
y - The Y coordinate.

getX

public double getX()
Get the center position for the string.
Returns:
The X coordinate.

getY

public double getY()
Get the center position for the string.
Returns:
The Y coordinate.

setRegion

public void setRegion(NFRegion region)
Set the underlying region. A null value means no underlying region.
Parameters:
region - The background region.

getRegion

public NFRegion getRegion()
Get the underlying region. A null value means no underlying region.
Returns:
The background region.

setGap

public void setGap(int gap)
Sets the pixel spacing between lines and around the edge of the label. The default is 6
Parameters:
gap - The gap to use.

getGap

public int getGap()
Returns the current pixel spacing between lines and around the edge of the label.
Returns:
The gap.

getParentBounds

public java.awt.geom.Rectangle2D getParentBounds()
Returns the bounding box for the label to be displayed in.
Returns:
The bounding box.

setParentBounds

public void setParentBounds(java.awt.geom.Rectangle2D r)
Sets a bounding box for the label to be displayed in. If the label would be partially or completely "out-of-bounds", it is adjusted to bring it back in bounds.
Parameters:
r - The bounding box.

setClipRectangle

public void setClipRectangle(java.awt.geom.Rectangle2D r)
Sets a bounding box for the label to be displayed in. If the label would be completely "out-of-bounds", it is not drawn at all, and any active label is effectively disabled.
Parameters:
r - The clipping box.

getClipRectangle

public java.awt.geom.Rectangle2D getClipRectangle()
Returns the current clip rectangle setting
Returns:
The clipping box.

getBounds

public java.awt.Dimension getBounds(java.awt.Graphics g)
Returns a bounding box for the current label, including any associated region and any angle of rotation.
Parameters:
g - The Graphics to use to retreive font metrics information.
Returns:
The bounds.

getBounds

public java.awt.Dimension getBounds(java.awt.Graphics g,
                           java.awt.Dimension d,
                           NFRegionBorder b)
Returns a bounding box for the current label, including any associated region and any angle of rotation.

The values are returned in the given object, instead of creating a new object. If <d> is null, then a new object is created anyway.

If <b> is non-null, it will be used as temp storage while determining the label bounds, instead of creating a new object.

Parameters:
g - The Graphics to use to retreive font metrics information.
d - The Dimension to store the result in.
b - The border surrounding the background region.
Returns:
The bounds.

draw

public void draw()
Draw the label using all current attributes.

draw

public void draw(java.awt.Graphics g)
Draw the label using all current attributes, in the given graphics context.
Parameters:
g - The Graphics to draw on.

draw

public void draw(java.awt.Component comp,
                 java.awt.Graphics g,
                 NFLabel top,
                 NFLabel bottom)
Draw the label using all current attributes, in the given graphics context.
Parameters:
comp - The Component to use for label rotation.
g - The Graphics to draw on.

draw

public void draw(java.awt.Component comp,
                 java.awt.Graphics g)
Draw the label using all current attributes, in the given graphics context.
Parameters:
comp - The Component to use for label rotation.
g - The Graphics to draw on.

draw

public void draw(java.applet.Applet app,
                 java.awt.Graphics g)
Draw the label using all current attributes, in the given graphics context.
Parameters:
app - Applet used for label rotation.
g - The Graphics to draw on.

draw

public void draw(java.lang.String lbl)
Draw the given label, using the current attributes.
Parameters:
lbl - The text of the label.

draw

public void draw(java.lang.String lbl,
                 double x,
                 double y)
Draw the given label, centered on (x, y) using the current attributes.
Parameters:
lbl - The text of the label.
x - The X coordinate of the label.
y - The Y coordinate of the label.

draw

public void draw(java.awt.Graphics g,
                 double x,
                 double y,
                 java.awt.Font font,
                 java.awt.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.
Parameters:
g - The Graphics to draw on.
x - The X coordinate of the label.
y - The Y coordinate of the label.
font - The font of the label.
color - The color of the label text.

draw

public void draw(java.lang.String lbl,
                 double x,
                 double 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.
Parameters:
lbl - The text of the label.
x - The X coordinate of the label.
y - The Y coordinate of the label.
justify - The justification of the label.

draw

public void draw(double x,
                 double y)
Draw the current label, centered on (x, y) using the current attributes.
Parameters:
x - The X coordinate of the label.
y - The Y coordinate of the label.

draw

public void draw(java.awt.Graphics g,
                 double x,
                 double y)
Draw the current label, centered on (x, y) using the current attributes, in the given graphics context.
Parameters:
g - The Graphics to draw on.
x - The X coordinate of the label.
y - The Y coordinate of the label.

draw

public void draw(java.awt.Graphics g,
                 double x,
                 double y,
                 java.lang.String lbl)
Draw the current label, centered on (x, y) using the current attributes, in the given graphics context.
Parameters:
g - The Graphics to draw on.
lbl - The text of the label.
x - The X coordinate of the label.
y - The Y coordinate of the label.

draw

public void draw(NFRegion region)
Draw the current label with the given underlying region. If null is given, no region is drawn.
Parameters:
region - The background region of the label.

draw

public void draw(java.awt.Component comp,
                 java.awt.Graphics g,
                 java.lang.String lbl,
                 java.awt.Font font,
                 java.awt.Color color,
                 double x,
                 double y,
                 int justify,
                 double 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.
Parameters:
comp - The Component to use for label rotation.
g - The Graphics to draw on.
lbl - The text of the label.
font - The font of the label.
color - The color of the label text.
x - The X coordinate of the label.
y - The Y coordinate of the label.
angle - The angle to rotate the label.
region - The background region of the label.

loadParams

public static NFLabel loadParams(NFParam p,
                                 java.lang.Object val)
Build a label using the value vector provided by the parser.
Parameters:
p - The NFParam object to load parameters from.
val - The value of the parameter to load.
Returns:
The resulting NFLabel object.

loadParams

public static NFLabel loadParams(NFParam p,
                                 java.lang.Object val,
                                 boolean justify)
Build a label using the value vector provided by the parser.
Parameters:
p - The NFParam object to load parameters from.
val - The value of the parameter to load.
justify - Whether to try to parse a justification.
Returns:
The resulting NFLabel object.

loadParams

public static NFLabel loadParams(NFParam p,
                                 java.lang.Object val,
                                 int offset)
Build a label object, using the attributes stored in the given vector, starting at the given offset.
Parameters:
p - The NFParam object to load parameters from.
val - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
Returns:
The resulting NFLabel object.

loadParams

public static NFLabel loadParams(NFParam p,
                                 java.lang.Object val,
                                 int offset,
                                 boolean justify)
Build a label object, using the attributes stored in the given vector, starting at the given offset.
Parameters:
p - The NFParam object to load parameters from.
val - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
justify - Whether to try to parse a justification.
Returns:
The resulting NFLabel object.

loadParams

public static NFLabel loadParams(NFParam p,
                                 java.lang.Object val,
                                 int offset,
                                 boolean justify,
                                 boolean externalJustify)
Build a label object, using the attributes stored in the given vector, starting at the given offset.
Parameters:
p - The NFParam object to load parameters from.
val - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
justify - Whether to try to parse a justification.
externalJustify - Whether to try to parse an external justification.
Returns:
The resulting NFLabel object.

loadParams

public static NFLabel loadParams(NFParam p,
                                 java.lang.Object val,
                                 int offset,
                                 boolean angle,
                                 boolean justify,
                                 boolean externalJustify)
Build a label object, using the attributes stored in the given vector, starting at the given offset.
Parameters:
p - The NFParam object to load parameters from.
val - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
angle - Whether to try to parse the angle
justify - Whether to try to parse a justification.
externalJustify - Whether to try to parse an external justification.
Returns:
The resulting NFLabel object.

loadParams

public static NFLabel loadParams(NFParam p,
                                 java.lang.Object val,
                                 int offset,
                                 boolean angle,
                                 boolean justify,
                                 boolean externalJustify,
                                 boolean extend)
Build a label object, using the attributes stored in the given vector, starting at the given offset.
Parameters:
p - The NFParam object to load parameters from.
val - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
angle - Whether to try to parse the angle
justify - Whether to try to parse a justification.
externalJustify - Whether to try to parse an external justification.
extend - Whether to try to parse an extend.
Returns:
The resulting NFLabel object.

loadParams

public static void loadParams(NFLabel label,
                              java.util.Vector v,
                              int offset)
Load the attributes from the given vector into the given label object, starting at the given offset.
Parameters:
label - The NFLabel to modify.
v - The value of the parameter to load.
offset - The offset of the label parameters in the given value.

loadParams

public static void loadParams(NFLabel label,
                              java.util.Vector v,
                              int offset,
                              boolean justify)
Load the attributes from the given vector into the given label object, starting at the given offset.
Parameters:
label - The NFLabel to modify.
v - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
justify - Whether to try to parse a justification.

loadParams

public static void loadParams(NFLabel label,
                              java.util.Vector v,
                              int offset,
                              boolean justify,
                              boolean externalJustify)
Load the attributes from the given vector into the given label object, starting at the given offset.
Parameters:
label - The NFLabel to modify.
v - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
justify - Whether to try to parse a justification.
externalJustify - Whether to try to parse an external justification.

loadParams

public static void loadParams(NFLabel label,
                              java.util.Vector v,
                              int offset,
                              boolean angle,
                              boolean justify,
                              boolean externalJustify)
Load the attributes from the given vector into the given label object, starting at the given offset.
Parameters:
label - The NFLabel to modify.
v - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
angle - Whether to try to parse the angle
justify - Whether to try to parse a justification.
externalJustify - Whether to try to parse an external justification.

loadParams

public static void loadParams(NFLabel label,
                              java.util.Vector v,
                              int offset,
                              boolean angle,
                              boolean justify,
                              boolean externalJustify,
                              boolean extend)
Load the attributes from the given vector into the given label object, starting at the given offset.
Parameters:
label - The NFLabel to modify.
v - The value of the parameter to load.
offset - The offset of the label parameters in the given value.
angle - Whether to try to parse the angle
justify - Whether to try to parse a justification.
externalJustify - Whether to try to parse an external justification.
extend - Whether to try to parse an extend.

loadParams

public void loadParams(NFParam p,
                       java.lang.String name)
               throws java.lang.Exception
Load the parameter with the given name into the current label
Parameters:
p - The NFParam object to load parameters from.
name - The parameter name.
Throws:
java.lang.Exception - If there was an error loading parameters.

loadParams

public void loadParams(java.util.Vector v)
Load the attributes from the given vector into the current label object
Parameters:
v - The value of the parameter to load.

setActiveLabel

public void setActiveLabel(NFActiveLabel l)
Set the ActiveLabel displayed over this label
Parameters:
l - The ActiveLabel to set.

getActiveLabel

public NFActiveLabel getActiveLabel()
Get the ActiveLabel displayed over this label
Returns:
The ActiveLabel of this label.

Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD


Visual Mining, Inc.
2099 Gaither Grove Rd.
Suite 220
Rockville, MD 20850
800.308.0731
301.947.8293 FAX

Copyright © Visual Mining, Inc. 1996 - 2010
All Rights Reserved.

NetCharts ProTM is a registered trademark of Visual Mining, Inc. Other brands and their products are trademarks of their respective holders.

Last Modified: Jun 29, 2010