|
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.TableToChartAdapter
public class TableToChartAdapter
This class converts a table model to a chart model. You can specify the columns to use for the
x and y axes respectively, with setXColumn()
and setYColumn()
.
As a table model doesn't contain highlight information, this class also provides a facility to store highlights for points. (These points are usually part of the ChartPoints rather than the ChartModel).
Field Summary | |
---|---|
static String |
PROPERTY_X_COLUMN
|
static String |
PROPERTY_Y_COLUMN
|
Constructor Summary | |
---|---|
TableToChartAdapter(String name,
TableModel delegate)
Construct a Chart Model from a TableModel using columns of the table model |
Method Summary | |
---|---|
void |
addAnnotation(Annotation dec)
|
void |
addChartModelListener(ChartModelListener listener)
Register the listener's interest in this chart model. |
void |
addHighlight(int n,
Highlight h)
Add a highlight for the point with index n |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a listener to listen for changes in bound properties |
void |
clearAnnotations()
|
protected void |
fireModelChanged()
|
Annotation |
getAnnotation(int n)
Gets the nth annotation. |
int |
getAnnotationCount()
Returns the number of annotations |
TableModel |
getDelegate()
|
Integer |
getMaxRow()
|
Integer |
getMinRow()
|
String |
getName()
The name of a ChartModel is important, as different chart models are assumed to have different names. |
Chartable |
getPoint(int n)
Returns the nth point of the ChartModel by delegating down to the underlying TableModel. |
int |
getPointCount()
Gets the number of points in the data set |
int |
getXColumn()
|
Range<?> |
getXRange()
|
int |
getYColumn()
|
Range<?> |
getYRange()
|
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? |
Iterator<Chartable> |
iterator()
|
void |
removeAnnotation(Annotation dec)
|
void |
removeChartModelListener(ChartModelListener listener)
De-register the listener's interest in this chart model. |
void |
removeHighlight(int n)
Remove the highlight for the point with index n |
void |
setAnnotationsVisible(boolean visible)
Specify whether annotations should be shown |
void |
setCyclical(boolean cyclical)
|
void |
setDelegate(TableModel tableModel)
Set the delegate table model for this chart model. |
void |
setMaxRow(Integer maxRow)
Sets the maximum row index for the points of interest in the table model |
void |
setMinRow(Integer minRow)
Sets the minimum row index for the points of interest in the table model |
void |
setRowInterval(Integer from,
Integer to)
The preferred method to set the row interval in the underlying table model. |
void |
setXColumn(int xColumn)
Set the column to use for the x axis |
void |
setYColumn(int yColumn)
Set the column to use for the y axis |
void |
tableChanged(TableModelEvent e)
This method fires a chart model event to its listeners. |
void |
update()
Clear the cache of any points derived from the table model and notify listeners that the model has changed. |
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_X_COLUMN
public static final String PROPERTY_Y_COLUMN
Constructor Detail |
---|
public TableToChartAdapter(String name, TableModel delegate)
name
- the name of the chart model (used to differentiate from other chart models)delegate
- the underlying table modelMethod Detail |
---|
public void setDelegate(TableModel tableModel)
tableModel
- the new delegate table modelpublic TableModel getDelegate()
public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- a property change listenerpublic void addHighlight(int n, Highlight h)
n
- the index of the point for which we are adding a highlighth
- the highlight of the pointpublic void removeHighlight(int n)
n
- the index of the point for which we are removing a highlightpublic void setRowInterval(Integer from, Integer to)
setMinRow()
and setMaxRow()
because it fires one event for two changes.
from
- the (included) start row for the intervalto
- the (included) end row for the intervalpublic Integer getMinRow()
public void setMinRow(Integer minRow)
minRow
- the minimum row index in the table modelpublic Integer getMaxRow()
public void setMaxRow(Integer maxRow)
maxRow
- the maximum row index in the table modelpublic String getName()
Chart
, make sure they have different names.
getName
in interface ChartModel
getName
in interface Named
public int getXColumn()
public void setXColumn(int xColumn)
xColumn
- the column index in the delegate table modelpublic int getYColumn()
public void setYColumn(int yColumn)
yColumn
- the column index in the delegate table modelpublic Range<?> getXRange()
public Range<?> getYRange()
public Chartable getPoint(int n)
The delegate can supply any instance of Number, which includes Double and Integer, but also Float, BigDecimal, BigInteger and others. Regardless of the return type, non-null values are converted to a double so there may be the risk of loss of precision for some types. Make sure the values supplied by the delegate can be represented by a double.
getPoint
in interface ChartModel
n
- the index
ChartModel
.public int getPointCount()
The rules for the point count are as follows:
getPointCount
in interface ChartModel
public boolean isCyclical()
ChartModel
isCyclical
in interface ChartModel
public void setCyclical(boolean cyclical)
public int getAnnotationCount()
AnnotationModel
getAnnotationCount
in interface AnnotationModel
public void clearAnnotations()
public Annotation getAnnotation(int n)
AnnotationModel
getAnnotation
in interface AnnotationModel
n
- the index.
public void addAnnotation(Annotation dec)
public void removeAnnotation(Annotation dec)
public boolean isAnnotationsVisible()
AnnotationModel
isAnnotationsVisible
in interface AnnotationModel
public void setAnnotationsVisible(boolean visible)
AnnotationModel
setAnnotationsVisible
in interface AnnotationModel
visible
- whether annotations should be shownpublic void addChartModelListener(ChartModelListener listener)
ChartModel
addChartModelListener
in interface ChartModel
listener
- the listener that will receive eventspublic void removeChartModelListener(ChartModelListener listener)
ChartModel
removeChartModelListener
in interface ChartModel
listener
- the listener that will no longer receive eventspublic Iterator<Chartable> iterator()
iterator
in interface Iterable<Chartable>
public void update()
protected void fireModelChanged()
public void tableChanged(TableModelEvent e)
tableChanged
in interface TableModelListener
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |