JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart
Class ChartText

java.lang.Object
  |
  +--com.klg.jclass.chart.TrackChange
        |
        +--com.klg.jclass.chart.ChartInteriorRegion
              |
              +--com.klg.jclass.chart.ChartText
All Implemented Interfaces:
Changeable, Changeable, com.klg.jclass.chart.Drawable, com.klg.jclass.util.JCName, Serializable
Direct Known Subclasses:
JCAxisTitle

public class ChartText
extends ChartInteriorRegion
implements Serializable

Any label that appears on a JClass Chart. A ChartText can be rotated by increments of 90 degrees. The 2D API is used to rotate the drawn text.

See Also:
Serialized Form

Field Summary
protected  int adjust
           
protected  Image buffer
           
static int CENTER
           
static int DEG_0
           
static int DEG_180
           
static int DEG_270
           
static int DEG_90
           
static int DEG_OTHER
           
protected  boolean isHTML
           
static int LEFT
           
protected  com.klg.jclass.chart.JCAxis parentAxis
           
protected  com.klg.jclass.util.swing.TextRenderer rendComp
           
static int RIGHT
           
protected  int rotation
           
protected  String text
           
 
Fields inherited from class com.klg.jclass.chart.ChartInteriorRegion
background, dimIsDefaultChangedToTrue, font, foreground, groupingUsed, height, insets, inUpdate, left, name, needsRepaint, numberLocalization, parentChart, parentRegion, top, transparent, updateParent, visible, width
 
Fields inherited from class com.klg.jclass.chart.TrackChange
changed, changedFlag
 
Fields inherited from interface com.klg.jclass.chart.Changeable
BASIC_CHANGE_MASK, NOTIFY_AXES_RECALC, NOTIFY_AXES_REDRAW, NOTIFY_CA_RECALC, NOTIFY_CA_REDRAW, NOTIFY_LEGEND_RECALC, NOTIFY_LEGEND_REDRAW
 
Fields inherited from interface com.klg.jclass.util.Changeable
LAYOUT, NO_CHANGE, NOTIFY_PARENT_LAYOUT, RECALC, REDRAW
 
Constructor Summary
ChartText()
          Public constructor for ChartText.
ChartText(com.klg.jclass.chart.JCChart p, String lab, com.klg.jclass.chart.ChartRegion cr)
          A smart ChartText constructor; it knows how to deal with String and ChartText objects passed in.
ChartText(com.klg.jclass.chart.JCChart p, String lab, com.klg.jclass.chart.JCAxis axis)
          A smart ChartText constructor; it knows how to deal with String and ChartText objects passed in.
 
Method Summary
 Dimension calcLineSize()
          Attempts to calculate the size of one line of a multi-line piece of text.
protected  Dimension calcSize()
          Calculates the size needed to display the existing text in this object.
 void draw(Graphics gc)
          Renders the chart label using the provided graphics context.
 int getAdjust()
          Gets the Adjust property, which determines how text is justified (positioned) in the label.
 Color getBackground()
          Calculates the desired background color of this ChartText object.
 Font getFont()
          Caculates the desired font of this ChartText object.
 FontMetrics getFontMetrics(Font f)
          Gets the font metrics of the font passed in.
 Color getForeground()
          Calculates the desired foreground color of this ChartText object.
 int getRotation()
          Gets the value of the Rotation property, which specifies the rotation (counterclockwise) of the label.
 String getText()
          Gets the value of the Text property.
 Dimension preferredSize()
          Gets the preferred size of this ChartText object.
 void recalc()
          Recalculates the contents of the chart region.
protected  void recalc(boolean forceRecalc)
          Recalculates the extents of the label.
 void setAdjust(int justify)
          Sets the Adjust property, which determines how text is justified (positioned) in the label.
 void setParentChart(com.klg.jclass.chart.JCChart p)
          Connects the chart region to a JCChart.
 void setRotation(int rot)
          Sets the Rotation property, which specifies the rotation (counterclockwise) of the label.
 void setText(String nc)
          Sets the Text property.
 void setText(String nc, boolean isVisible)
          Sets the Text property.
 String toString()
          Gets a String version of this object, which is just the ChartText's text if it is not null.
 
Methods inherited from class com.klg.jclass.chart.ChartInteriorRegion
getDrawingArea, getDrawingArea, getGraphics, getGroupingUsed, getHeight, getHeightIsDefault, getInsets, getLeft, getLeftIsDefault, getName, getNumberFormatter, getNumberLocalization, getParentChart, getParentRegion, getSize, getTop, getTopIsDefault, getWidth, getWidthIsDefault, hide, insets, inside, isVisible, location, repaint, setBackground, setBounds, setChanged, setChanged, setFont, setForeground, setGroupingUsed, setHeight, setHeightIsDefault, setInsets, setLeft, setLeftIsDefault, setLocation, setName, setNumberFormatterLocale, setNumberLocalization, setParentRegion, setSize, setTop, setTopIsDefault, setVisible, setWidth, setWidthIsDefault, show, size, sizeChanged, updateParent
 
Methods inherited from class com.klg.jclass.chart.TrackChange
getChanged, getChanged, isBatched, isChanged, isChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

adjust

protected int adjust

rotation

protected int rotation

text

protected String text

parentAxis

protected com.klg.jclass.chart.JCAxis parentAxis

isHTML

protected boolean isHTML

rendComp

protected com.klg.jclass.util.swing.TextRenderer rendComp

buffer

protected transient Image buffer

LEFT

public static final int LEFT
See Also:
Constant Field Values

CENTER

public static final int CENTER
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

DEG_0

public static final int DEG_0
See Also:
Constant Field Values

DEG_90

public static final int DEG_90
See Also:
Constant Field Values

DEG_180

public static final int DEG_180
See Also:
Constant Field Values

DEG_270

public static final int DEG_270
See Also:
Constant Field Values

DEG_OTHER

public static final int DEG_OTHER
See Also:
Constant Field Values
Constructor Detail

ChartText

public ChartText()
Public constructor for ChartText. Creates a parentless ChartText that can be attached to any JCChart component.


ChartText

public ChartText(com.klg.jclass.chart.JCChart p,
                 String lab,
                 com.klg.jclass.chart.JCAxis axis)
A smart ChartText constructor; it knows how to deal with String and ChartText objects passed in.

Parameters:
p - the parent chart
lab - the text to be used for this ChartText object
axis - the parent axis

ChartText

public ChartText(com.klg.jclass.chart.JCChart p,
                 String lab,
                 com.klg.jclass.chart.ChartRegion cr)
A smart ChartText constructor; it knows how to deal with String and ChartText objects passed in.

Parameters:
p - the parent chart
lab - the text to be used for this ChartText object
cr - the parent chart region
Method Detail

getFontMetrics

public FontMetrics getFontMetrics(Font f)
Gets the font metrics of the font passed in.

Parameters:
f - the font whose font metrics are required
Returns:
the font metrics of the passed in font (null on error)

draw

public void draw(Graphics gc)
Renders the chart label using the provided graphics context.

Specified by:
draw in interface com.klg.jclass.chart.Drawable
Overrides:
draw in class ChartInteriorRegion
Parameters:
gc - graphics context

setRotation

public void setRotation(int rot)
Sets the Rotation property, which specifies the rotation (counterclockwise) of the label.

Parameters:
rot - one of DEG_90, DEG_180, DEG_270, or DEG_0
Throws:
IllegalArgumentException - If the rotation is not one of DEG_0, DEG_90, DEG_180, or DEG_270.

getRotation

public int getRotation()
Gets the value of the Rotation property, which specifies the rotation (counterclockwise) of the label.

Returns:
one of DEG_0, DEG_90, DEG_180, or DEG_270

getAdjust

public int getAdjust()
Gets the Adjust property, which determines how text is justified (positioned) in the label.

Returns:
one of LEFT, CENTER, or RIGHT

setAdjust

public void setAdjust(int justify)
Sets the Adjust property, which determines how text is justified (positioned) in the label.

Parameters:
justify - one of LEFT, CENTER, or RIGHT
Throws:
IllegalArgumentException - If the text justification is not one of LEFT, CENTER, or RIGHT

getText

public String getText()
Gets the value of the Text property. A ChartText can render plain text.

Returns:
returns a String instance if the ChartText is rendering plain text, or returns null if the ChartText has no text

setText

public void setText(String nc)
Sets the Text property.

Parameters:
nc - new String contents of the ChartText instance; otherwise, the raw text is used in the label

setText

public void setText(String nc,
                    boolean isVisible)
Sets the Text property.

Parameters:
nc - new String contents of the ChartText instance.
isVisible - if true, visible indication is set to true

recalc

protected void recalc(boolean forceRecalc)
Recalculates the extents of the label.

Parameters:
forceRecalc - force a recalculation

recalc

public void recalc()
Description copied from class: ChartInteriorRegion
Recalculates the contents of the chart region. Not used in the base class.

Overrides:
recalc in class ChartInteriorRegion

setParentChart

public void setParentChart(com.klg.jclass.chart.JCChart p)
Connects the chart region to a JCChart.

Overrides:
setParentChart in class ChartInteriorRegion
Parameters:
p - parent chart

calcSize

protected Dimension calcSize()
Calculates the size needed to display the existing text in this object.

Returns:
the calculated size

calcLineSize

public Dimension calcLineSize()
Attempts to calculate the size of one line of a multi-line piece of text. If this is just straight text, it can only be one line anyways, so we just return the ascent from the font metrics. If this object contains HTML encoded text, however, we try to make a guess at the height of the first line by counting line breaks. If the text uses different font sizes on multiple lines, this calculation will be off.
Note: A full recalc should have been done on this object first.

Returns:
the calculated line size

getForeground

public Color getForeground()
Calculates the desired foreground color of this ChartText object. If no foreground color has been set, we can take the color of the parent region, the parent axis, or the parent chart.

Overrides:
getForeground in class ChartInteriorRegion
Returns:
the calculated foreground color

getBackground

public Color getBackground()
Calculates the desired background color of this ChartText object. If no background color has been set, we can take the color of the parent axis or the parent chart, if it is not opaque.

Overrides:
getBackground in class ChartInteriorRegion
Returns:
the calculated background color

getFont

public Font getFont()
Caculates the desired font of this ChartText object. If no font has been set, we can take the font of the parent axis or the parent chart.

Overrides:
getFont in class ChartInteriorRegion
Returns:
the calculated font

preferredSize

public Dimension preferredSize()
Gets the preferred size of this ChartText object.

Overrides:
preferredSize in class ChartInteriorRegion
Returns:
the preferred size

toString

public String toString()
Gets a String version of this object, which is just the ChartText's text if it is not null.

Overrides:
toString in class Object
Returns:
a String version of this object

Copyright © 2004 Quest Software Inc..
All rights reserved.