|
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.model.DefaultChartModel
public class DefaultChartModel
A default implementation of the ChartModel interface; now with improved API
such that the add
and remove
methods return the
ChartModel instance.
This allows chaining of method calls, as in:
ChartModel m = new DefaultChartModel(); m.addPoint(1, 2).addPoint(2, 3).addPoint(6, 7);
DefaultChartModel
now also implements Comparable
so
it is easy to sort multiple model alphabetically by their names
Note It is no longer possible to specify the order in which points are iterated by setting an orientation property. They are iterated in the order in which they were added. If they should be iterated over along the x or y axis, then wrap this model in a SortedChartModel.
Constructor Summary | |
---|---|
DefaultChartModel()
Zero argument constructor creates a DefaultChartModel with no points |
|
DefaultChartModel(DefaultChartModel model)
Creates a DefaultChartModel as a copy of an existing DefaultChartModel |
|
DefaultChartModel(Object key)
The key provided here is used in the equals() method and can be used to help uniquely identify the model. |
Method Summary | |
---|---|
void |
addAnnotation(Annotation annotation)
Add the supplied annotation |
void |
addChartModelListener(ChartModelListener listener)
Register the listener's interest in this chart model. |
DefaultChartModel |
addPoint(Chartable point)
Appends a point to the model and fires an update event |
DefaultChartModel |
addPoint(Chartable point,
boolean fireUpdate)
Adds a point to the chart model as a Chartable, and specifying whether a change event should be fired following the change. |
DefaultChartModel |
addPoint(double x,
double y)
Adds a point to the chart model, then fires an update event |
DefaultChartModel |
addPoint(double x,
double y,
boolean fireUpdate)
Adds a point to the chart model using doubles and specifying whether an event should be fired |
DefaultChartModel |
addPoint(double x,
int y)
Adds a point to the ChartModel using the supplied x and y values, then fires an update event |
DefaultChartModel |
addPoint(double x,
Positionable y)
Adds a point to the chart model using a double and a Positionable, then fires an update event |
DefaultChartModel |
addPoint(double x,
Positionable y,
boolean fireUpdate)
Adds a point to the chart model using a double and a Positionable and specifying whether an event should be fired |
DefaultChartModel |
addPoint(int index,
Chartable point)
Inserts a point in the chart model at the given index. |
DefaultChartModel |
addPoint(int index,
Chartable point,
boolean fireUpdate)
Inserts a point to the chart model at the given index, also specifying whether a change event should be fired following the change. |
DefaultChartModel |
addPoint(int x,
double y)
Adds a point to the ChartModel using the supplied x and y values, then fires an update event |
DefaultChartModel |
addPoint(int x,
int y)
Adds a point to the ChartModel using the supplied x and y values, then fires an update event. |
DefaultChartModel |
addPoint(Positionable x,
double y)
Adds a point to the chart model using a Positionable and a double, then fires an update event |
DefaultChartModel |
addPoint(Positionable x,
double y,
boolean fireUpdate)
Adds a point to the chart model using a Positionable and a double and specifying whether an event should be fired |
DefaultChartModel |
addPoint(Positionable x,
Positionable y)
Adds a point to the chart model using two Positionable instances, then fires an update event |
DefaultChartModel |
addPoint(Positionable x,
Positionable y,
boolean fireUpdate)
Adds a point to the chart model using Positionables and specifying whether an event should be fired |
void |
clearAnnotations()
Clear all the annotations in the model |
void |
clearPoints()
Remove all the points in the model and fire a model change event |
int |
compareTo(ChartModel other)
|
boolean |
equals(Object other)
|
protected void |
fireModelChanged()
Fire an 'all bets off' change event to the listeners |
protected void |
fireModelChanged(ChartModelChangeEvent changeEvent)
Fire the supplied change event to the listeners |
Annotation |
getAnnotation(int n)
Gets the nth annotation. |
int |
getAnnotationCount()
Returns the number of annotations on this model |
Object |
getKey()
A key is a more generalised association than a name. |
String |
getName()
The name of a ChartModel is important, as different chart models are assumed to have different names. |
Chartable |
getPoint(int index)
Gets the nth point. |
int |
getPointCount()
Gets the number of points in the data set |
double |
getXLeadingMarginProportion()
Deprecated. this method will be removed some time after release 3.3.3 |
Range<Double> |
getXRange()
Returns the X range of the points of the model |
Range<Double> |
getXRange(double leadingMarginProportion,
double trailingMarginProportion)
|
double |
getXTrailingMarginProportion()
Deprecated. this method will be removed some time after release 3.3.3 |
double |
getYLeadingMarginProportion()
Deprecated. this method will be removed some time after release 3.3.3 |
Range<Double> |
getYRange()
Returns the Y Range of the points of the model |
Range<Double> |
getYRange(double leadingMarginProportion,
double trailingMarginProportion)
Returns a range, but applies a margin to the start and end of the range. |
double |
getYTrailingMarginProportion()
Deprecated. this method will be removed some time after release 3.3.3 |
int |
hashCode()
|
boolean |
isAnnotationsVisible()
Use this method to discover whether annotations should be shown or hidden. |
boolean |
isCyclical()
Should a line be drawn from the last to the first point? |
boolean |
isFiringEventsOnEDT()
|
Iterator<Chartable> |
iterator()
|
void |
removeAnnotation(Annotation annotation)
Remove the supplied annotation |
void |
removeChartModelListener(ChartModelListener listener)
De-register the listener's interest in this chart model. |
DefaultChartModel |
removePoint(Chartable p)
Remove the supplied point from the model. |
DefaultChartModel |
removePoint(Chartable p,
boolean fireUpdate)
Remove the supplied point from the model, and indicate whether a change event should be fired from this model to its listeners. |
DefaultChartModel |
removePoint(int index)
Remove the point from the model at the supplied index |
DefaultChartModel |
removePoint(int index,
boolean fireUpdate)
Remove the point from the model at the supplied index, and indicate whether a change event should be fired from this model to its listeners. |
DefaultChartModel |
replacePoint(int index,
Chartable c)
Replace the point in the model at the specified index |
DefaultChartModel |
replacePoint(int index,
Chartable c,
boolean fireUpdate)
Replace the point in the model at the specified index, and specify whether an event should be fired to notify interested listeners. |
void |
setAnnotationsVisible(boolean visible)
Specify whether annotations should be displayed. |
void |
setCyclical(boolean cyclical)
Specify whether the model is cyclical. |
void |
setFiringEventsOnEDT(boolean firingEventsOnEDT)
|
void |
setName(String name)
Sets the name of the ChartModel. |
void |
setXLeadingMarginProportion(double marginProportion)
Deprecated. this method will be removed some time after release 3.3.3 |
void |
setXTrailingMarginProportion(double marginProportion)
Deprecated. this method will be removed some time after release 3.3.3 |
void |
setYLeadingMarginProportion(double marginProportion)
Deprecated. this method will be removed some time after release 3.3.3 |
void |
setYTrailingMarginProportion(double marginProportion)
Deprecated. this method will be removed some time after release 3.3.3 |
String |
toString()
|
void |
update()
You can call this if you make changes to the model that would not normally fire an update event. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DefaultChartModel()
public DefaultChartModel(DefaultChartModel model)
model
- the ChartModel to copypublic DefaultChartModel(Object key)
key
- the key object that uniquely identifies the objectMethod Detail |
---|
public String getName()
Chart
, make sure they have different names.
getName
in interface ChartModel
getName
in interface Named
public Object getKey()
public void setName(String name)
name
- the new name of the ChartModelpublic boolean isFiringEventsOnEDT()
public void setFiringEventsOnEDT(boolean firingEventsOnEDT)
public Chartable getPoint(int index)
getPoint
in interface ChartModel
index
- the index
ChartModel
.public void clearPoints()
public void clearAnnotations()
public int getPointCount()
getPointCount
in interface ChartModel
public DefaultChartModel addPoint(Chartable point)
point
- the point to add
public DefaultChartModel addPoint(int x, int y)
If you're working in pure Java, this method is subsumed by the addPoint(double, double) method, but if you're accessing the library through, say, Clojure, then it won't match on the signature if you provide whole numbers. So we provide this signature too.
x
- the x coordinate as an inty
- the y coordinate as an int
public DefaultChartModel addPoint(int x, double y)
x
- the x coordinate as an inty
- the y coordinate as a double
addPoint(int, int)
public DefaultChartModel addPoint(double x, int y)
x
- the x coordinate as a doubley
- the y coordinate as an int
addPoint(int, int)
public DefaultChartModel addPoint(double x, double y)
x
- the x coordinatey
- the y coordinate
public DefaultChartModel addPoint(Positionable x, Positionable y)
x
- the x coordinatey
- the y coordinate
public DefaultChartModel addPoint(double x, Positionable y)
x
- the x coordinatey
- the y coordinate
public DefaultChartModel addPoint(Positionable x, double y)
x
- the x coordinatey
- the y coordinate
public DefaultChartModel addPoint(double x, double y, boolean fireUpdate)
x
- the x coordinatey
- the y coordinatefireUpdate
- whether an event should be fired following the change
public DefaultChartModel addPoint(Positionable x, Positionable y, boolean fireUpdate)
x
- the x coordinatey
- the y coordinatefireUpdate
- whether an event should be fired following the change
public DefaultChartModel addPoint(double x, Positionable y, boolean fireUpdate)
x
- the x coordinatey
- the y coordinatefireUpdate
- whether an event should be fired following the change
public DefaultChartModel addPoint(Positionable x, double y, boolean fireUpdate)
x
- the x coordinatey
- the y coordinatefireUpdate
- whether an event should be fired following the change
public DefaultChartModel addPoint(Chartable point, boolean fireUpdate)
point
- the Chartable point to addfireUpdate
- whether to fire an update event to interested listeners
public DefaultChartModel addPoint(int index, Chartable point)
index
- the index at which the point will be addedpoint
- the point to add
public DefaultChartModel addPoint(int index, Chartable point, boolean fireUpdate)
index
- the index at which the point will be addedpoint
- the Chartable point to addfireUpdate
- whether to fire an update event to interested listeners
public DefaultChartModel replacePoint(int index, Chartable c)
index
- the index of the point to replace. The first index is 0.c
- the new Chartable point to place in the model at the specified index
public DefaultChartModel replacePoint(int index, Chartable c, boolean fireUpdate)
index
- the index of the point to replace. The first index is 0c
- the new Chartable point to place in the model at the specified indexfireUpdate
- whether an event should be fired to notify listeners
public DefaultChartModel removePoint(int index)
index
- the index of the point to remove. The first index is 0.
public DefaultChartModel removePoint(int index, boolean fireUpdate)
index
- the index of the point to remove. The first index is 0.fireUpdate
- whether a change event should be fired to listeners following the change.
public DefaultChartModel removePoint(Chartable p)
hashCode()
and equals()
methods of the supplied Chartable object should behave properly.
p
- the point to remove
public DefaultChartModel removePoint(Chartable p, boolean fireUpdate)
p
- the point to removefireUpdate
- whether a change event should be fired to listeners following the change.
public int getAnnotationCount()
getAnnotationCount
in interface AnnotationModel
public Annotation getAnnotation(int n)
AnnotationModel
getAnnotation
in interface AnnotationModel
n
- the index.
public void addAnnotation(Annotation annotation)
annotation
- the annotation to addpublic void removeAnnotation(Annotation annotation)
annotation
- the annotation object to remove from the modelpublic double getXLeadingMarginProportion()
public void setXLeadingMarginProportion(double marginProportion)
public double getYLeadingMarginProportion()
public void setYLeadingMarginProportion(double marginProportion)
public double getXTrailingMarginProportion()
public void setXTrailingMarginProportion(double marginProportion)
public double getYTrailingMarginProportion()
public void setYTrailingMarginProportion(double marginProportion)
public Range<Double> getXRange()
getXRange
in interface RangeProvider
public Range<Double> getXRange(double leadingMarginProportion, double trailingMarginProportion)
public Range<Double> getYRange()
getYRange
in interface RangeProvider
public Range<Double> getYRange(double leadingMarginProportion, double trailingMarginProportion)
leadingMarginProportion
- a number between 0 and 1, typical value 0.05 = 5%trailingMarginProportion
- a number between 0 and 1, typical value 0.05 = 5%
public boolean isAnnotationsVisible()
AnnotationModel
isAnnotationsVisible
in interface AnnotationModel
public void setAnnotationsVisible(boolean visible)
setAnnotationsVisible
in interface AnnotationModel
visible
- whether annotations should be shownpublic void addChartModelListener(ChartModelListener listener)
addChartModelListener
in interface ChartModel
listener
- the listener that will receive eventspublic void removeChartModelListener(ChartModelListener listener)
removeChartModelListener
in interface ChartModel
listener
- the listener that will no longer receive eventspublic Iterator<Chartable> iterator()
iterator
in interface Iterable<Chartable>
public boolean isCyclical()
isCyclical
in interface ChartModel
public void setCyclical(boolean cyclical)
cyclical
- whether the model is cyclicalpublic void update()
protected void fireModelChanged(ChartModelChangeEvent changeEvent)
changeEvent
- the object describing the change that occurredprotected void fireModelChanged()
public int hashCode()
hashCode
in class Object
public boolean equals(Object other)
equals
in class Object
public int compareTo(ChartModel other)
compareTo
in interface Comparable<ChartModel>
public String toString()
toString
in class Object
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |