|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.chart.event.ChartCrossHair
public class ChartCrossHair
This class can be used to track the mouse position as it moves along a trace.
Here is a screenshot, where the ChartCrossHair is shown in red:
When the model property is not set, the class tracks the nearest point from all available models. When the model property is set, the points are limited to points from that model.
Note: This class used to be called ChartValueFocus
but was renamed to avoid
overloading the term focus
ChartValueReporter
Field Summary | |
---|---|
static String |
PROPERTY_CHART
The propertyName of the PropertyChangeEvent that is fired when the chart property changes |
static String |
PROPERTY_CIRCLE_DIAMETER
The propertyName of the PropertyChangeEvent that is fired when the circleDiameter property changes |
static String |
PROPERTY_COLOR
The propertyName of the PropertyChangeEvent that is fired when the color property changes |
static String |
PROPERTY_HORIZONTAL_LINE_VISIBLE
The propertyName of the PropertyChangeEvent that is fired when the visibility of the horizontal
line changes |
static String |
PROPERTY_MODEL
The propertyName of the PropertyChangeEvent that is fired when the model property changes |
static String |
PROPERTY_OBSERVED_MODEL
The propertyName of the PropertyChangeEvent that is fired when the (read-only) observedModel property changes |
static String |
PROPERTY_POSITION
The property name of the PropertyChangeEvent that is fired when the position of the cross hair changes. |
static String |
PROPERTY_SNAP_TO_POINTS
The propertyName of the PropertyChangeEvent that is fired when the snapToPoints property changes. |
static String |
PROPERTY_STROKE
The property name of the PropertyChangeEvent that is fired when the Stroke property changes. |
static String |
PROPERTY_UPDATE_FROM_MODEL
The property name of the PropertyChangeEvent that is fired when the UpdateFromModel property changes. |
static String |
PROPERTY_VERTICAL_LINE_VISIBLE
The propertyName of the PropertyChangeEvent that is fired when the visibility of the vertical
line changes |
static String |
PROPERTY_VISIBLE
The propertyName of the PropertyChangeEvent that is fired when the (read-only) visible property changes |
Constructor Summary | |
---|---|
ChartCrossHair()
Default constructor provided mainly for compatibility with Java bean pattern. |
|
ChartCrossHair(Chart chart)
Create a new ChartCrossHair instance for use with the supplied chart. |
|
ChartCrossHair(Chart chart,
boolean autoRegister)
Creates a new ChartCrossHair instance for use with the supplied chart. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this object. |
void |
componentHidden(ComponentEvent e)
|
void |
componentMoved(ComponentEvent e)
|
void |
componentResized(ComponentEvent e)
|
void |
componentShown(ComponentEvent e)
|
void |
detach()
|
void |
draw(Graphics g)
Draw the object implementing this interface onto the supplied Graphics context |
Chart |
getChart()
Returns the chart object this class operates with |
int |
getCircleDiameter()
The diameter of the circle that is used for locating the position of the cross hair |
Color |
getColor()
The color used for the cross hair |
ChartModel |
getModel()
Returns the model of interest, if any. |
ChartModel |
getObservedModel()
This is a read-only property that allows you to find out which model the cross hair is currently pointing at. |
Chartable |
getPosition()
Returns the position of the cross hair in user coordinates |
Stroke |
getStroke()
Returns the stroke currently used for the horizontal and vertical line of the cross hair |
Point |
getXAxisPoint()
Returns the pixel point for (x, 0). |
Point |
getYAxisPoint()
Returns the pixel point for (y, 0). |
boolean |
isHorizontalLineVisible()
Returns the flag to indicate whether a horizontal line is drawn as part of the cross hair |
boolean |
isSnapToPoints()
Returns a value indicating whether the cross hair is allowed to assume a position between adjacent data points of a model (false) or 'snap' to genuine points (true). |
boolean |
isUpdateFromModel()
Returns the value of the updateFromModel property |
boolean |
isVerticalLineVisible()
Returns the flag to indicate whether a vertical line is drawn as part of the cross hair |
void |
mouseClicked(MouseEvent e)
Not used |
void |
mouseDragged(MouseEvent e)
Recognises a change in the mouse position under dragging |
void |
mouseEntered(MouseEvent e)
Makes the visible property true when the mouse enters the chart |
void |
mouseExited(MouseEvent e)
Makes the visible property false when the mouse exits the chart |
void |
mouseMoved(MouseEvent e)
Recognises a change in the mouse position |
void |
mousePressed(MouseEvent e)
Not used |
void |
mouseReleased(MouseEvent e)
Not used |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a previously-added listener |
void |
setChart(Chart chart)
Specify the chart object on which the cross hair operates |
void |
setCircleDiameter(int circleDiameter)
Sets the diameter of the circle to use for the centre of the cross hair |
void |
setColor(Color color)
Set the color to use for the cross hair |
void |
setHorizontalLineVisible(boolean horizontalLineVisible)
Specify whether a horizontal line should be drawn as part of the cross hair |
void |
setModel(ChartModel model)
If you set the model of the ChartValueReporter, then only points from that model will be reported. |
void |
setPosition(Chartable chartable)
Enables you to set the position of the ChartCrossHair programmatically |
void |
setSnapToPoints(boolean snapToPoints)
Specify whether the cross hair should 'snap' to known data points. |
void |
setStroke(Stroke stroke)
Specify the stroke to use for the horizontal and vertical lines of the cross hair |
void |
setUpdateFromModel(boolean updateFromModel)
Specify whether the position of the cross hair is dependent on one or more models in the chart. |
void |
setVerticalLineVisible(boolean verticalLineVisible)
Specify whether a vertical line should be drawn as part of the cross hair |
void |
update()
Update the cross hair using the latest known cursor position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROPERTY_COLOR
propertyName
of the PropertyChangeEvent
that is fired when the color property changes
public static final String PROPERTY_CHART
propertyName
of the PropertyChangeEvent that is fired when the chart property changes
public static final String PROPERTY_CIRCLE_DIAMETER
propertyName
of the PropertyChangeEvent that is fired when the circleDiameter property changes
public static final String PROPERTY_MODEL
propertyName
of the PropertyChangeEvent that is fired when the model property changes
public static final String PROPERTY_OBSERVED_MODEL
propertyName
of the PropertyChangeEvent that is fired when the (read-only) observedModel property changes
public static final String PROPERTY_POSITION
public static final String PROPERTY_SNAP_TO_POINTS
propertyName
of the PropertyChangeEvent that is fired when the snapToPoints property changes.
public static final String PROPERTY_STROKE
public static final String PROPERTY_UPDATE_FROM_MODEL
public static final String PROPERTY_VISIBLE
propertyName
of the PropertyChangeEvent that is fired when the (read-only) visible property changes
public static final String PROPERTY_HORIZONTAL_LINE_VISIBLE
propertyName
of the PropertyChangeEvent that is fired when the visibility of the horizontal
line changes
public static final String PROPERTY_VERTICAL_LINE_VISIBLE
propertyName
of the PropertyChangeEvent that is fired when the visibility of the vertical
line changes
Constructor Detail |
---|
public ChartCrossHair()
public ChartCrossHair(Chart chart)
chart
- the Chart instance for which we wish to create a cross hairpublic ChartCrossHair(Chart chart, boolean autoRegister)
chart
- the chart instance for which we wish to create a CrossHairautoRegister
- whether we wish to auto-register the CrossHair as a listener on the chart.Method Detail |
---|
public void detach()
public void addPropertyChangeListener(PropertyChangeListener listener)
ChartModel
that is under the cross hair changes.
listener
- the PropertyChangeListenerpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener
- the PropertyChangeListener to removepublic Chart getChart()
public void setChart(Chart chart)
chart
- the chart objectpublic boolean isVerticalLineVisible()
public void setVerticalLineVisible(boolean verticalLineVisible)
verticalLineVisible
- whether the line is visiblepublic boolean isHorizontalLineVisible()
public void setHorizontalLineVisible(boolean horizontalLineVisible)
horizontalLineVisible
- whether the line is visiblepublic boolean isSnapToPoints()
public void setSnapToPoints(boolean snapToPoints)
snapToPoints
- the new value of the snapToPoints propertypublic boolean isUpdateFromModel()
public void setUpdateFromModel(boolean updateFromModel)
updateFromModel
- the new value of the updateFromModel propertypublic Stroke getStroke()
public void setStroke(Stroke stroke)
stroke
- the stroke to use for the horizontal and vertical line of the cross hairpublic Point getXAxisPoint()
public Point getYAxisPoint()
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
public void componentResized(ComponentEvent e)
componentResized
in interface ComponentListener
public void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
public void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
public void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
public ChartModel getModel()
public void setModel(ChartModel model)
model
- the model from which points should be reportedpublic Color getColor()
public void setColor(Color color)
color
- the new color to usepublic ChartModel getObservedModel()
public void update()
public void setPosition(Chartable chartable)
chartable
- the position of the cross hair in user coordinatespublic Chartable getPosition()
public void draw(Graphics g)
draw
in interface Drawable
g
- the Graphics contextpublic int getCircleDiameter()
public void setCircleDiameter(int circleDiameter)
circleDiameter
- given in pixels
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |