JIDE 3.5.15

com.jidesoft.chart
Class DifferenceMarker

java.lang.Object
  extended by com.jidesoft.chart.DifferenceMarker
All Implemented Interfaces:
Drawable, Frontable, Shadowable

public class DifferenceMarker
extends Object
implements Drawable, Frontable, Shadowable

A Drawable that fills in the gap between two models to generate a chart.

Here is an example of a chart that uses a DifferenceMarker:

Difference Marker Screenshot

Note that this class assumes the points of the model are already ordered by their x values.


Field Summary
static String PROPERTY_AT_FRONT
           
static String PROPERTY_CHART
           
static String PROPERTY_MODEL1
           
static String PROPERTY_MODEL1_DOMINANT_FILL
           
static String PROPERTY_MODEL2
           
static String PROPERTY_MODEL2_DOMINANT_FILL
           
 
Constructor Summary
DifferenceMarker()
          If you use this constructor, don't forget that you will still have to call setChart() before it will work.
DifferenceMarker(Chart chart)
          Constructs a DifferenceMarker for the supplied Chart instance
DifferenceMarker(Chart chart, ChartModel model1, ChartModel model2)
          Constructs a DifferenceMarker for the supplied Chart instance and using the two supplied ChartModels
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a listener to property changes on this object
 void draw(Graphics g)
          The Drawable callback method
 Chart getChart()
          Returns the Chart to which this marker is applied
 Shape getDifferenceShape()
          Returns the Shape constructed by the DifferenceMarker
 ChartModel getModel1()
          Returns the first ChartModel used by the marker
 Paint getModel1DominantFill()
          Returns the paint filling used when model1 > model2
 ChartModel getModel2()
          Returns the second ChartModel used by the marker
 Paint getModel2DominantFill()
          Returns the paint filling used when model1 < model2
 double getSmoothness()
           
 boolean isAtFront()
          A method of the Frontable interface.
 boolean isShadowVisible()
          Discover whether this object is being drawn with a shadow
 boolean isSmooth()
           
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a previously-added PropertyChangeListener from this object
 void setAtFront(boolean atFront)
          Specify whether the DifferenceMarker should be drawn in front or behind of the ChartModels
 void setChart(Chart chart)
          Specify the chart to which this marker is applied
 void setFill(Paint fill)
          Convenience method for setting the model1Dominant and model2Dominant fills to be the same
 void setModel1(ChartModel model1)
          Specify the first ChartModel
 void setModel1DominantFill(Paint fill)
          Specify the paint to use when model1 > model2.
 void setModel2(ChartModel model2)
          Specify the second ChartModel
 void setModel2DominantFill(Paint fill)
          Specify the paint to use when model1 < model2.
 void setShadowVisible(boolean shadowVisible)
          Specify whether this object should be drawn with a shadow
 void setSmooth(boolean smooth)
           
 void setSmoothness(double smoothness)
           
protected  void update()
          Recomputes the positions of the fill and clipping regions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_AT_FRONT

public static final String PROPERTY_AT_FRONT
See Also:
Constant Field Values

PROPERTY_MODEL1

public static final String PROPERTY_MODEL1
See Also:
Constant Field Values

PROPERTY_MODEL2

public static final String PROPERTY_MODEL2
See Also:
Constant Field Values

PROPERTY_CHART

public static final String PROPERTY_CHART
See Also:
Constant Field Values

PROPERTY_MODEL1_DOMINANT_FILL

public static final String PROPERTY_MODEL1_DOMINANT_FILL
See Also:
Constant Field Values

PROPERTY_MODEL2_DOMINANT_FILL

public static final String PROPERTY_MODEL2_DOMINANT_FILL
See Also:
Constant Field Values
Constructor Detail

DifferenceMarker

public DifferenceMarker()
If you use this constructor, don't forget that you will still have to call setChart() before it will work.


DifferenceMarker

public DifferenceMarker(Chart chart)
Constructs a DifferenceMarker for the supplied Chart instance

Parameters:
chart - the Chart instance to which the DifferenceMarker will be applied

DifferenceMarker

public DifferenceMarker(Chart chart,
                        ChartModel model1,
                        ChartModel model2)
Constructs a DifferenceMarker for the supplied Chart instance and using the two supplied ChartModels

Parameters:
chart - the Chart instance to which the DifferenceMarker will be applied
model1 - a model used for constructing the DifferenceMarker
model2 - a model used for constructing the DifferenceMarker
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a listener to property changes on this object

Parameters:
listener - the PropertyChangeListener

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a previously-added PropertyChangeListener from this object

Parameters:
listener - the PropertyChangeListener

getChart

public Chart getChart()
Returns the Chart to which this marker is applied

Returns:
the Chart object

setChart

public void setChart(Chart chart)
Specify the chart to which this marker is applied

Parameters:
chart - the Chart object

getModel1

public ChartModel getModel1()
Returns the first ChartModel used by the marker

Returns:
the ChartModel object

setModel1

public void setModel1(ChartModel model1)
Specify the first ChartModel

Parameters:
model1 - the first ChartModel

getModel2

public ChartModel getModel2()
Returns the second ChartModel used by the marker

Returns:
the ChartModel object

setModel2

public void setModel2(ChartModel model2)
Specify the second ChartModel

Parameters:
model2 - the second ChartModel

isSmooth

public boolean isSmooth()

setSmooth

public void setSmooth(boolean smooth)

getSmoothness

public double getSmoothness()

setSmoothness

public void setSmoothness(double smoothness)

getDifferenceShape

public Shape getDifferenceShape()
Returns the Shape constructed by the DifferenceMarker

Returns:
the Shape of the DifferenceMarker

getModel1DominantFill

public Paint getModel1DominantFill()
Returns the paint filling used when model1 > model2

Returns:
the Paint filling

setModel1DominantFill

public void setModel1DominantFill(Paint fill)
Specify the paint to use when model1 > model2. If set to null the area will not be filled.

Parameters:
fill - the Paint (or Color) filling

getModel2DominantFill

public Paint getModel2DominantFill()
Returns the paint filling used when model1 < model2

Returns:
the Paint filling

setModel2DominantFill

public void setModel2DominantFill(Paint fill)
Specify the paint to use when model1 < model2. If set to null the area will not be filled.

Parameters:
fill - the Paint (or Color) filling

setFill

public void setFill(Paint fill)
Convenience method for setting the model1Dominant and model2Dominant fills to be the same

Parameters:
fill - the new Paint to use for regions between model1 and model2

update

protected void update()
Recomputes the positions of the fill and clipping regions


draw

public void draw(Graphics g)
The Drawable callback method

Specified by:
draw in interface Drawable
Parameters:
g - the Graphics context

isAtFront

public boolean isAtFront()
A method of the Frontable interface. By default returns false so the filling is drawn behind any lines.

Specified by:
isAtFront in interface Frontable
Returns:
whether the marker should be drawn in front of the Chart Models

setAtFront

public void setAtFront(boolean atFront)
Specify whether the DifferenceMarker should be drawn in front or behind of the ChartModels

Specified by:
setAtFront in interface Frontable
Parameters:
atFront - whether the object is to be shown in front of ChartModels.

isShadowVisible

public boolean isShadowVisible()
Discover whether this object is being drawn with a shadow

Specified by:
isShadowVisible in interface Shadowable
Returns:
a boolean to indicate whether this object is being drawn with a shadow

setShadowVisible

public void setShadowVisible(boolean shadowVisible)
Specify whether this object should be drawn with a shadow

Specified by:
setShadowVisible in interface Shadowable
Parameters:
shadowVisible - whether the object should have a shadow

JIDE 3.5.15