JIDE 3.5.15

com.jidesoft.chart.model
Class SummingChartModel

java.lang.Object
  extended by com.jidesoft.chart.model.AbstractDelegatingChartModel
      extended by com.jidesoft.chart.model.SummingChartModel
All Implemented Interfaces:
AnnotatedChartModel, AnnotationModel, ChartModel, ChartModelListener, RangeProvider, Named, Iterable<Chartable>

public class SummingChartModel
extends AbstractDelegatingChartModel
implements RangeProvider

A chart model that gets its y values by summing the corresponding values of its delegate chart models. The delegate chart models should have the same number of points. Points with the same index will be summed.

The class assumes by default that you wish to sum the y values of the delegate models. If you wish to sum the x values instead for a horizontal bar chart, you must set the orientation of the SummingChartModel. (see the setOrientation() method).


Constructor Summary
SummingChartModel()
          Default Constructor
SummingChartModel(ChartModel... delegates)
          Creates a ChartModel that sums values in the supplied models
SummingChartModel(Collection<ChartModel> delegates)
           
SummingChartModel(String modelName, ChartModel... delegates)
          Creates a ChartModel that sums values in the supplied models
 
Method Summary
 void clear()
           
protected  Chartable createChartable(Positionable xPos, Positionable yPos)
           
 Annotation getAnnotation(int n)
          Currently unsupported, but may become supported in the future
 int getAnnotationCount()
          Currently unsupported so always returns 0
 Orientation getOrientation()
          Returns the orientation in which the summing occurs (by default, vertical)
 Chartable getPoint(int n)
          Returns the nth point in the model.
 int getPointCount()
          Returns the number of points in the model
 Range<?> getXRange()
          Returns the x range of the model (as a Numeric Range)
 AggregatedRange getXRange(Positionable pos)
           
 Range<?> getYRange()
          Returns the y range of the model (as a Numeric Range)
 AggregatedRange getYRange(Positionable pos)
           
 boolean isAnnotationsVisible()
          Use this method to discover whether annotations should be shown or hidden.
 boolean isConsiderDelegateRanges()
           
 void setAnnotationsVisible(boolean visible)
          Specify whether annotations should be shown
 void setConsiderDelegateRanges(boolean considerDelegateRanges)
          Suppose you have two delegate models for which an x coordinate in one of those models has a value of 10 and the same x coordinate in the other model has a value of -10.
 void setOrientation(Orientation orientation)
          Specify the direction in which the summing should occur.
protected  void update()
           
 
Methods inherited from class com.jidesoft.chart.model.AbstractDelegatingChartModel
addChartModelListener, chartModelChanged, equals, fireModelChanged, getDelegate, getDelegate, getDelegates, getName, hashCode, init, isCyclical, iterator, removeChartModelListener, setDelegate, setDelegates, setDelegates, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SummingChartModel

public SummingChartModel()
Default Constructor


SummingChartModel

public SummingChartModel(ChartModel... delegates)
Creates a ChartModel that sums values in the supplied models

Parameters:
delegates - the chart models that we wish to sum over

SummingChartModel

public SummingChartModel(Collection<ChartModel> delegates)

SummingChartModel

public SummingChartModel(String modelName,
                         ChartModel... delegates)
Creates a ChartModel that sums values in the supplied models

Parameters:
modelName - the name of the constructed model
delegates - the chart models that we wish to sum over
Method Detail

clear

public void clear()

isConsiderDelegateRanges

public boolean isConsiderDelegateRanges()

setConsiderDelegateRanges

public void setConsiderDelegateRanges(boolean considerDelegateRanges)
Suppose you have two delegate models for which an x coordinate in one of those models has a value of 10 and the same x coordinate in the other model has a value of -10. Then the sum is clearly zero, but what should be returned when asking for the y range of this model? When considerDelegateRanges is true, then the y range is from -10 to 10, whereas when it is false, the y range is from 0 to 0. By default it is true.


getAnnotation

public Annotation getAnnotation(int n)
Currently unsupported, but may become supported in the future

Specified by:
getAnnotation in interface AnnotationModel
Specified by:
getAnnotation in class AbstractDelegatingChartModel
Parameters:
n - the index.
Returns:
the nth annotation

getAnnotationCount

public int getAnnotationCount()
Currently unsupported so always returns 0

Specified by:
getAnnotationCount in interface AnnotationModel
Specified by:
getAnnotationCount in class AbstractDelegatingChartModel
Returns:
the number of annotations

isAnnotationsVisible

public boolean isAnnotationsVisible()
Description copied from interface: AnnotationModel
Use this method to discover whether annotations should be shown or hidden.

Specified by:
isAnnotationsVisible in interface AnnotationModel
Returns:
whether annotations should be shown

setAnnotationsVisible

public void setAnnotationsVisible(boolean visible)
Description copied from interface: AnnotationModel
Specify whether annotations should be shown

Specified by:
setAnnotationsVisible in interface AnnotationModel
Parameters:
visible - whether annotations should be shown

getOrientation

public Orientation getOrientation()
Returns the orientation in which the summing occurs (by default, vertical)

Returns:
the orientation in which the summing occurs (by default, vertical)

setOrientation

public void setOrientation(Orientation orientation)
Specify the direction in which the summing should occur. By default, summing occurs in the vertical orientation which corresponds to the y axis.

Parameters:
orientation - the orientation of the summing

getPoint

public Chartable getPoint(int n)
Returns the nth point in the model. The nth point in the model is computed by summing the nth points of all the delegate models

Specified by:
getPoint in interface ChartModel
Specified by:
getPoint in class AbstractDelegatingChartModel
Parameters:
n - the index in the model
Returns:
the nth point in the model

getPointCount

public int getPointCount()
Returns the number of points in the model

Specified by:
getPointCount in interface ChartModel
Specified by:
getPointCount in class AbstractDelegatingChartModel
Returns:
the number of points in the model

getXRange

public Range<?> getXRange()
Returns the x range of the model (as a Numeric Range)

Specified by:
getXRange in interface RangeProvider
Returns:
the x range of the model

getXRange

public AggregatedRange getXRange(Positionable pos)

getYRange

public Range<?> getYRange()
Returns the y range of the model (as a Numeric Range)

Specified by:
getYRange in interface RangeProvider
Returns:
the y range of the model

getYRange

public AggregatedRange getYRange(Positionable pos)

createChartable

protected Chartable createChartable(Positionable xPos,
                                    Positionable yPos)

update

protected void update()
Specified by:
update in class AbstractDelegatingChartModel

JIDE 3.5.15