JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart
Class JCChartLabel

java.lang.Object
  |
  +--com.klg.jclass.chart.TrackChange
        |
        +--com.klg.jclass.chart.JCChartLabel
All Implemented Interfaces:
Changeable, Changeable, Serializable

public class JCChartLabel
extends TrackChange
implements Serializable

JCChartLabel manages and renders a floating label attached somewhere on the chart.

See Also:
Serialized Form

Field Summary
protected  int anchor
          Instance variables.
static int ATTACH_COORD
           
static int ATTACH_DATACOORD
           
static int ATTACH_DATAINDEX
           
static int ATTACH_NONE
           
protected  com.klg.jclass.chart.JCDataIndex attachDataIndex
           
protected  int attachMethod
           
protected  Point attachPoint
           
protected  int attachX
           
protected  int attachY
           
static int AUTO
           
static int CENTER
           
protected  JComponent component
           
protected  boolean connected
           
protected  double dataAttachX
           
protected  double dataAttachY
           
protected  com.klg.jclass.chart.ChartDataView dataView
           
protected  String defaultText
           
protected  int dwellDelay
           
protected  boolean dwellLabel
           
static int EAST
           
protected  com.klg.jclass.chart.JCChartLabelLine line
           
static int NORTH
           
static int NORTHEAST
           
static int NORTHWEST
           
protected  int offsetX
           
protected  int offsetY
           
protected  com.klg.jclass.chart.JCChartLabelManager parent
           
static int SOUTH
           
static int SOUTHEAST
           
static int SOUTHWEST
           
protected  String text
           
static int WEST
           
 
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
JCChartLabel()
          Default constructor for JCChartLabel, required by JavaBeans.
JCChartLabel(String contents)
          Constructor for JCChartLabel.
 
Method Summary
protected  void addConnectedLine()
          Adds the JCChartLabel line component associated with this chart label to the chart at the appropriate position, right after the component associated with this chart label.
protected  boolean calcConnectingLine(Point linePoint)
          Calculates the connecting line.
protected  void calcLineBounds(com.klg.jclass.chart.JCChartLabelLine thisLine)
          Calculates the connector between the attach point and this chart label.
 void drawConnector(Graphics g)
          For internal use only.
 int getAnchor()
          Gets the Anchor property.
 int getAttachMethod()
          Gets the Attachment Method of the label.
protected  Point getAttachPoint()
          Gets the point on the chart that this label is attached to.
 JComponent getComponent()
          Gets the component portion of this chart label.
 Point getCoord()
          Gets the coordinates that the label is attached to.
 com.klg.jclass.chart.JCDataCoord getDataCoord()
          Gets the data coordinates that the label is attached to, if the label's attachMethod is ATTACH_DATACOORD.
 com.klg.jclass.chart.JCDataIndex getDataIndex()
          Gets the data item that the label is attached to.
 com.klg.jclass.chart.ChartDataView getDataView()
          Gets the data view specified with the setDataView() method.
protected  void getDefaultLabel()
           
 String getDefaultText()
          Internal use only.
 com.klg.jclass.chart.ChartDataView getEffectiveDataView()
          Gets the effective data view, that is the data view that will be used to determine the correct attachment axes for this label.
 Point getOffset()
          Gets the adjustment to the location of the label relative to the position determined by the attachMethod.
 com.klg.jclass.chart.JCChart getParentChart()
          Returns the parent chart to this chart label.
 com.klg.jclass.chart.JCChartLabelManager getParentManager()
          Returns the manager chart to this chart label.
 com.klg.jclass.chart.ChartDataView getSetDataView()
          Internal use only.
 String getSetText()
          Internal use only.
 boolean isConnected()
          Gets a value indicating if this is a label that is connected or not.
 boolean isDwellLabel()
          Gets the value indicating if this is a dwell label or not.
 void recalc()
          Determines the correct location of the label and moves there.
protected  void removeConnectedLine()
          Removes the JCChartLabel line component associated with this chart label from the chart.
 void setAnchor(int a)
          Sets the Anchor property.
 void setAttachMethod(int newMethod)
          Sets the Attachment Method of the label.
 void setChanged(boolean c, int cf)
          Sets the value of the Changed property and updates the parent object.
 void setChanged(boolean n, int cf, boolean updateParent)
          Sets the value of the Changed property.
 void setComponent(JComponent comp)
          Sets the component portion of this chart label.
 void setConnected(boolean b)
          Determines whether a line is drawn from the chart label to the attachment position.
 void setCoord(Point p)
          Sets the coordinates that the label is attached to.
 void setDataCoord(com.klg.jclass.chart.JCDataCoord p)
          Sets the data coordinates that the label is attached to, if the label's attachMethod is ATTACH_DATACOORD.
 void setDataIndex(com.klg.jclass.chart.JCDataIndex di)
          Sets the data item that the label is attached to.
 void setDataView(com.klg.jclass.chart.ChartDataView dv)
          Sets the current data view for this label.
 void setDwellLabel(boolean b)
          Sets this label to always display, or to display only when the cursor is over the data to which the label is attached.
 void setOffset(Point point)
          Sets the Offset to adjust the location of the label relative to the position determined by the attachMethod.
 void setParentManager(com.klg.jclass.chart.JCChartLabelManager manager)
          Sets the parent manager of this chart label.
 void setText(String s)
          Convenience method for setting text.
 boolean shouldPopupHere(com.klg.jclass.chart.JCDataIndex di)
          Determines if the label is attached to the specified data index.
 
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, toString, wait, wait, wait
 

Field Detail

NORTHEAST

public static final int NORTHEAST
See Also:
Constant Field Values

NORTH

public static final int NORTH
See Also:
Constant Field Values

NORTHWEST

public static final int NORTHWEST
See Also:
Constant Field Values

EAST

public static final int EAST
See Also:
Constant Field Values

WEST

public static final int WEST
See Also:
Constant Field Values

SOUTHEAST

public static final int SOUTHEAST
See Also:
Constant Field Values

SOUTH

public static final int SOUTH
See Also:
Constant Field Values

SOUTHWEST

public static final int SOUTHWEST
See Also:
Constant Field Values

CENTER

public static final int CENTER
See Also:
Constant Field Values

AUTO

public static final int AUTO
See Also:
Constant Field Values

ATTACH_NONE

public static final int ATTACH_NONE
See Also:
Constant Field Values

ATTACH_COORD

public static final int ATTACH_COORD
See Also:
Constant Field Values

ATTACH_DATACOORD

public static final int ATTACH_DATACOORD
See Also:
Constant Field Values

ATTACH_DATAINDEX

public static final int ATTACH_DATAINDEX
See Also:
Constant Field Values

anchor

protected int anchor
Instance variables.


attachMethod

protected int attachMethod

attachX

protected int attachX

attachY

protected int attachY

dataAttachX

protected double dataAttachX

dataAttachY

protected double dataAttachY

offsetX

protected int offsetX

offsetY

protected int offsetY

attachDataIndex

protected com.klg.jclass.chart.JCDataIndex attachDataIndex

dataView

protected com.klg.jclass.chart.ChartDataView dataView

dwellLabel

protected boolean dwellLabel

dwellDelay

protected int dwellDelay

connected

protected boolean connected

component

protected JComponent component

line

protected com.klg.jclass.chart.JCChartLabelLine line

text

protected String text

defaultText

protected String defaultText

parent

protected com.klg.jclass.chart.JCChartLabelManager parent

attachPoint

protected Point attachPoint
Constructor Detail

JCChartLabel

public JCChartLabel(String contents)
Constructor for JCChartLabel.

Parameters:
contents - the text to be displayed in the label

JCChartLabel

public JCChartLabel()
Default constructor for JCChartLabel, required by JavaBeans.

Method Detail

setComponent

public void setComponent(JComponent comp)
Sets the component portion of this chart label. The component portion is the object derived from JComponent that actually draws on the chart.

Parameters:
comp - the component portion of the chart label

getComponent

public JComponent getComponent()
Gets the component portion of this chart label. The component portion is the object derived from JComponent that actually draws on the chart.

Returns:
the component portion of the chart label

setText

public void setText(String s)
Convenience method for setting text. If the component property is null, a JLabel will be created with the specified text. If a component already exists and it is a JLabel, that instance will be set with the specified text. Otherwise, nothing will happen.

Parameters:
s - The text to set. If the text is null, text will automatically be generated.

getSetText

public String getSetText()
Internal use only. Returns the value of the internal text variable that is set with the setText() method. The return value may be null if default text is being used.


getDefaultText

public String getDefaultText()
Internal use only. Returns the value of the internal default text variable that contains the last calculated instance of default text.


getParentChart

public com.klg.jclass.chart.JCChart getParentChart()
Returns the parent chart to this chart label.

Returns:
parent chart

getParentManager

public com.klg.jclass.chart.JCChartLabelManager getParentManager()
Returns the manager chart to this chart label.

Returns:
manager chart

setParentManager

public void setParentManager(com.klg.jclass.chart.JCChartLabelManager manager)
Sets the parent manager of this chart label.

Parameters:
manager - parent manager

recalc

public void recalc()
Determines the correct location of the label and moves there.

Specified by:
recalc in class TrackChange

getAttachPoint

protected Point getAttachPoint()
Gets the point on the chart that this label is attached to.

Returns:
the point the label is attached to

drawConnector

public void drawConnector(Graphics g)
For internal use only. Draws the connector between the attach point and this chart label. Used only with dwell labels, since for dwell labels the component and it's line are not actually added to the parent chart.

Parameters:
g -

calcLineBounds

protected void calcLineBounds(com.klg.jclass.chart.JCChartLabelLine thisLine)
Calculates the connector between the attach point and this chart label. Used only with non-dwell labels, since for them the component and the line are actually added to the parent chart.

Parameters:
thisLine -

calcConnectingLine

protected boolean calcConnectingLine(Point linePoint)
Calculates the connecting line. Returns true if line is to be drawn and the endpoint will be returned in the provided Point object. Returns false and doesn't modify the provided point object if line is not to be drawn.

Parameters:
linePoint -
Returns:
true if the line is to be drawn and the endpoint will be returned in the provided Point object; false otherwise.

setAnchor

public void setAnchor(int a)
Sets the Anchor property. This property determines the position of the label relative to the its attachment location.

Parameters:
a - one of NORTH, SOUTH, EAST, WEST, NORTHWEST, SOUTHWEST, NORTHEAST, or SOUTHEAST
Throws:
IllegalArgumentException - If the anchor value is not one of NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST, CENTER or AUTO.

getAnchor

public int getAnchor()
Gets the Anchor property. This property determines the position of the label relative to the its attachment location.

Returns:
one of NORTH, SOUTH, EAST, WEST, NORTHWEST, SOUTHWEST, NORTHEAST, SOUTHEAST, CENTER or AUTO.

setAttachMethod

public void setAttachMethod(int newMethod)
Sets the Attachment Method of the label.

Parameters:
newMethod - one of ATTACH_NONE, ATTACH_COORD, ATTACH_DATACOORD, or ATTACH_DATAINDEX.
ATTACH_NONE means the label is not shown.
ATTACH_COORD means the label is attached is screen (pixel) coordinates relative to the chart.
ATTACH_DATACOORD means the label is attached in axis coordinates relative to the associated data view.
ATTACH_DATAINDEX means the label is attached to a data item.
Throws:
IllegalArgumentException - If the anchor value is not one of ATTACH_NONE, ATTACH_COORD, ATTACH_DATACOORD, ATTACH_DATAINDEX.

getAttachMethod

public int getAttachMethod()
Gets the Attachment Method of the label.

Returns:
one of ATTACH_NONE, ATTACH_COORD, ATTACH_DATACOORD, or ATTACH_DATAINDEX

setCoord

public void setCoord(Point p)
Sets the coordinates that the label is attached to. This is used when the label's attachMethod is ATTACH_COORD.

Parameters:
p - the point in chart pixel coordinates where the label is attached

getCoord

public Point getCoord()
Gets the coordinates that the label is attached to.

Returns:
p the point in chart pixel coordinates where the label is attached

setDataView

public void setDataView(com.klg.jclass.chart.ChartDataView dv)
Sets the current data view for this label. The property specifies the data view that labels using the ATTACH_DATACOORD AttachMethod will be attached to. It also specifies the backup data view to use when a label using the ATTACH_DATAINDEX AttachMethod does not specify an AttachDataIndex or does not specify a data view within the AttachDataIndex. Data views used to determine the correct axes against which to position the label.

Parameters:
dv - the ChartDataView relative to which the label is attached

getDataView

public com.klg.jclass.chart.ChartDataView getDataView()
Gets the data view specified with the setDataView() method. If no data view has been previously set the effective data view from getEffectiveDataView() will be returned.

Returns:
the ChartDataView relative to which the label is attached

getSetDataView

public com.klg.jclass.chart.ChartDataView getSetDataView()
Internal use only. Contains the actual value of the DataView property set with the setDataView() method. The value of this property may be null.

Returns:
the ChartDataView previously set by calling setDataView. This value may be null.

getEffectiveDataView

public com.klg.jclass.chart.ChartDataView getEffectiveDataView()
Gets the effective data view, that is the data view that will be used to determine the correct attachment axes for this label. The value will change depending on the value of the AttachMethod and AttachDataIndex properties. The returned value may be null. If the label is using an AttachMethod of ATTACH_DATAINDEX, the effective data view is the data view specified in the AttachDataIndex property. If this data view is null or if the label is using another AttachMethod, the effective data view is the data view previously set with the setDataView() method. If this value is also null, the effective data view is the first data view of the parent chart.

Returns:
the ChartDataView currently being used to attach this label. The value may be null.

setDataCoord

public void setDataCoord(com.klg.jclass.chart.JCDataCoord p)
Sets the data coordinates that the label is attached to, if the label's attachMethod is ATTACH_DATACOORD.

Parameters:
p - the coordinate in chart axis coordinates where the label is attached

getDataCoord

public com.klg.jclass.chart.JCDataCoord getDataCoord()
Gets the data coordinates that the label is attached to, if the label's attachMethod is ATTACH_DATACOORD.

Returns:
p the coordinate in chart axis coordinates where the label is attached

setDataIndex

public void setDataIndex(com.klg.jclass.chart.JCDataIndex di)
Sets the data item that the label is attached to. This is used when the label's attachMethod is ATTACH_DATAINDEX.

Parameters:
di - the data index the label is attached to

getDataIndex

public com.klg.jclass.chart.JCDataIndex getDataIndex()
Gets the data item that the label is attached to.

Returns:
di the data index the label is attached to

setOffset

public void setOffset(Point point)
Sets the Offset to adjust the location of the label relative to the position determined by the attachMethod.

Parameters:
point - the x and y adjustments applied to the calculated location

getOffset

public Point getOffset()
Gets the adjustment to the location of the label relative to the position determined by the attachMethod.

Returns:
the x and y corrections applied to the calculated location

setConnected

public void setConnected(boolean b)
Determines whether a line is drawn from the chart label to the attachment position. Works only if the attachment method is either ATTACH_DATACOORD or ATTACH_DATAINDEX.

Parameters:
b - if true, a line is drawn from the chart label to the attachement position; if false, the line will not be drawn

isConnected

public boolean isConnected()
Gets a value indicating if this is a label that is connected or not.

Returns:
true if this is a connected label; false if this is not a connected label

setDwellLabel

public void setDwellLabel(boolean b)
Sets this label to always display, or to display only when the cursor is over the data to which the label is attached.

Parameters:
b - if true, this is a transient label which will be displayed only when the mouse is over the data item; if false, the label will always be displayed

isDwellLabel

public boolean isDwellLabel()
Gets the value indicating if this is a dwell label or not.

Returns:
true if this is a transient label; false if this is a 'permanent' label

shouldPopupHere

public boolean shouldPopupHere(com.klg.jclass.chart.JCDataIndex di)
Determines if the label is attached to the specified data index. Used by JCChart to determine when the mouse is over a dwell label.

Parameters:
di -
Returns:
whether or not the given point cooresponds to the attachment of this label

addConnectedLine

protected void addConnectedLine()
Adds the JCChartLabel line component associated with this chart label to the chart at the appropriate position, right after the component associated with this chart label.


removeConnectedLine

protected void removeConnectedLine()
Removes the JCChartLabel line component associated with this chart label from the chart.


setChanged

public void setChanged(boolean c,
                       int cf)
Sets the value of the Changed property and updates the parent object.

The Changed property determines whether the object needs to be recalculated.

Specified by:
setChanged in interface Changeable
Overrides:
setChanged in class TrackChange
Parameters:
c - new value for Changed
cf -

setChanged

public void setChanged(boolean n,
                       int cf,
                       boolean updateParent)
Description copied from class: TrackChange
Sets the value of the Changed property. The Changed property determines whether the object needs to be recalculated.

Specified by:
setChanged in interface Changeable
Overrides:
setChanged in class TrackChange
Parameters:
n - new value for Changed
cf - the value with which to update the changed flag
updateParent - if true, the parent is updated; otherwise, the parent is not updated (the "update" semantics are up to the implementor)

getDefaultLabel

protected void getDefaultLabel()

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