org.swtchart.internal.series
Class Series

java.lang.Object
  extended by org.swtchart.internal.series.Series
All Implemented Interfaces:
ISeries
Direct Known Subclasses:
BarSeries, LineSeries

public abstract class Series
extends java.lang.Object
implements ISeries

Series.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.swtchart.ISeries
ISeries.SeriesType
 
Field Summary
protected  Chart chart
          the chart
protected  ICompress compressor
          the compressor
protected static ISeries.SeriesType DEFAULT_SERIES_TYPE
          the default series type
protected  java.lang.String id
          the series id
protected  boolean isXMonotoneIncreasing
          the state indicating whether x series are monotone increasing
protected  double maxX
          the maximum value of x series
protected  double maxY
          the maximum value of y series
protected  double minX
          the minimum value of x series
protected  double minY
          the minimum value of y series
protected  SeriesLabel seriesLabel
          the series label
protected  boolean stackEnabled
          the state indicating if the series is a stacked type
protected  double[] stackSeries
          the stack series
protected  ISeries.SeriesType type
          the series type
protected  boolean visible
          the visibility of series
protected  int xAxisId
          the x axis id
protected  ErrorBar xErrorBar
          the x error bar
protected  double[] xSeries
          the x series
protected  int yAxisId
          the y axis id
protected  ErrorBar yErrorBar
          the y error bar
protected  double[] ySeries
          the y series
 
Constructor Summary
protected Series(Chart chart, java.lang.String id)
          Constructor.
 
Method Summary
 void addDisposeListener(IDisposeListener listener)
          Adds the dispose listener.
protected  void dispose()
          Disposes SWT resources.
 void draw(GC gc, int width, int height)
          Draws series.
protected abstract  void draw(GC gc, int width, int height, Axis xAxis, Axis yAxis)
          Draws series.
 void enableStack(boolean enabled)
          Enables the stack series.
abstract  Range getAdjustedRange(Axis axis, int length)
          Gets the adjusted range to show all series in screen.
protected  ICompress getCompressor()
          Gets the compressor.
 java.lang.String getId()
          Gets the series id.
 ISeriesLabel getLabel()
          Gets the series label.
 Point getPixelCoordinates(int index)
          Gets the pixel coordinates corresponding to the given series index.
protected  Range getRangeWithMargin(int lowerPlotMargin, int upperPlotMargin, int length, Axis axis, Range range)
          Gets the range with given margin.
 ISeries.SeriesType getType()
          Gets the series type.
 int getXAxisId()
          Gets the X axis id.
 java.util.Date[] getXDateSeries()
          Gets the X date series.
 IErrorBar getXErrorBar()
          Gets the X error bar.
 Range getXRange()
          Gets the X range of series.
 double[] getXSeries()
          Gets the X series.
 int getYAxisId()
          Gets the Y axis id.
 IErrorBar getYErrorBar()
          Gets the Y error bar.
 Range getYRange()
          Gets the Y range of series.
 double[] getYSeries()
          Gets the Y series.
 boolean isDateSeries()
          Gets the state indicating if date series is set.
 boolean isStackEnabled()
          Gets the state indicating if stack is enabled.
 boolean isValidStackSeries()
          Gets the state indicating if the series is valid stack series.
 boolean isVisible()
          Gets the visibility state.
 boolean isVisibleInLegend()
          Gets the visibility state in legend.
protected abstract  void setCompressor()
          Sets the compressor.
protected  void setStackSeries(double[] stackSeries)
          Sets the stack series
 void setVisible(boolean visible)
          Sets the visibility state.
 void setVisibleInLegend(boolean visible)
          Sets the visibility state in legend.
 void setXAxisId(int id)
          Sets the X axis id.
 void setXDateSeries(java.util.Date[] series)
          Sets the X date series.
 void setXSeries(double[] series)
          Sets the X series.
 void setYAxisId(int id)
          Sets the Y axis id.
 void setYSeries(double[] series)
          Sets the Y series.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERIES_TYPE

protected static final ISeries.SeriesType DEFAULT_SERIES_TYPE
the default series type


xSeries

protected double[] xSeries
the x series


ySeries

protected double[] ySeries
the y series


minX

protected double minX
the minimum value of x series


maxX

protected double maxX
the maximum value of x series


minY

protected double minY
the minimum value of y series


maxY

protected double maxY
the maximum value of y series


id

protected java.lang.String id
the series id


compressor

protected ICompress compressor
the compressor


xAxisId

protected int xAxisId
the x axis id


yAxisId

protected int yAxisId
the y axis id


visible

protected boolean visible
the visibility of series


isXMonotoneIncreasing

protected boolean isXMonotoneIncreasing
the state indicating whether x series are monotone increasing


type

protected ISeries.SeriesType type
the series type


seriesLabel

protected SeriesLabel seriesLabel
the series label


xErrorBar

protected ErrorBar xErrorBar
the x error bar


yErrorBar

protected ErrorBar yErrorBar
the y error bar


chart

protected Chart chart
the chart


stackEnabled

protected boolean stackEnabled
the state indicating if the series is a stacked type


stackSeries

protected double[] stackSeries
the stack series

Constructor Detail

Series

protected Series(Chart chart,
                 java.lang.String id)
Constructor.

Parameters:
chart - the chart
id - the series id
Method Detail

getId

public java.lang.String getId()
Description copied from interface: ISeries
Gets the series id.

Specified by:
getId in interface ISeries
Returns:
the series id

setVisible

public void setVisible(boolean visible)
Description copied from interface: ISeries
Sets the visibility state.

Specified by:
setVisible in interface ISeries
Parameters:
visible - the visibility state

isVisible

public boolean isVisible()
Description copied from interface: ISeries
Gets the visibility state.

Specified by:
isVisible in interface ISeries
Returns:
true if series is visible

getType

public ISeries.SeriesType getType()
Description copied from interface: ISeries
Gets the series type.

Specified by:
getType in interface ISeries
Returns:
the series type

isStackEnabled

public boolean isStackEnabled()
Description copied from interface: ISeries
Gets the state indicating if stack is enabled.

Specified by:
isStackEnabled in interface ISeries
Returns:
the state indicating if stack is enabled

enableStack

public void enableStack(boolean enabled)
Description copied from interface: ISeries
Enables the stack series. The series has to contain only positive values.

Specified by:
enableStack in interface ISeries
Parameters:
enabled - true if enabling stack series

setXSeries

public void setXSeries(double[] series)
Description copied from interface: ISeries
Sets the X series.

Specified by:
setXSeries in interface ISeries
Parameters:
series - the X series

getXSeries

public double[] getXSeries()
Description copied from interface: ISeries
Gets the X series. If the X series is not set, null will be returned.

Specified by:
getXSeries in interface ISeries
Returns:
the X series

setYSeries

public void setYSeries(double[] series)
Description copied from interface: ISeries
Sets the Y series.

Specified by:
setYSeries in interface ISeries
Parameters:
series - the Y series

getYSeries

public double[] getYSeries()
Description copied from interface: ISeries
Gets the Y series. If the Y series haven't been set yet, null will be returned.

Specified by:
getYSeries in interface ISeries
Returns:
the Y series

setXDateSeries

public void setXDateSeries(java.util.Date[] series)
Description copied from interface: ISeries
Sets the X date series.

X series and X date series are exclusive. X date series will be cleared by setting X series, and vice versa.

Specified by:
setXDateSeries in interface ISeries
Parameters:
series - the X date series

getXDateSeries

public java.util.Date[] getXDateSeries()
Description copied from interface: ISeries
Gets the X date series.

Specified by:
getXDateSeries in interface ISeries
Returns:
the X date series, or null if X date series is not set.

isDateSeries

public boolean isDateSeries()
Gets the state indicating if date series is set.

Returns:
true if date series is set

isValidStackSeries

public boolean isValidStackSeries()
Gets the state indicating if the series is valid stack series.

Returns:
true if the series is valid stack series

getXRange

public Range getXRange()
Gets the X range of series.

Returns:
the X range of series

getAdjustedRange

public abstract Range getAdjustedRange(Axis axis,
                                       int length)
Gets the adjusted range to show all series in screen. This range includes the size of plot like symbol or bar.

Parameters:
axis - the axis
length - the axis length in pixels
Returns:
the adjusted range

getYRange

public Range getYRange()
Gets the Y range of series.

Returns:
the Y range of series

getCompressor

protected ICompress getCompressor()
Gets the compressor.

Returns:
the compressor

setCompressor

protected abstract void setCompressor()
Sets the compressor.


getXAxisId

public int getXAxisId()
Description copied from interface: ISeries
Gets the X axis id.

Specified by:
getXAxisId in interface ISeries
Returns:
the X axis id

setXAxisId

public void setXAxisId(int id)
Description copied from interface: ISeries
Sets the X axis id.

Specified by:
setXAxisId in interface ISeries
Parameters:
id - the X axis id.

getYAxisId

public int getYAxisId()
Description copied from interface: ISeries
Gets the Y axis id.

Specified by:
getYAxisId in interface ISeries
Returns:
the Y axis id

setYAxisId

public void setYAxisId(int id)
Description copied from interface: ISeries
Sets the Y axis id.

Specified by:
setYAxisId in interface ISeries
Parameters:
id - the Y axis id.

getLabel

public ISeriesLabel getLabel()
Description copied from interface: ISeries
Gets the series label.

Specified by:
getLabel in interface ISeries
Returns:
the series label

getXErrorBar

public IErrorBar getXErrorBar()
Description copied from interface: ISeries
Gets the X error bar. This is typically used for scatter chart.

Specified by:
getXErrorBar in interface ISeries
Returns:
the X error bar

getYErrorBar

public IErrorBar getYErrorBar()
Description copied from interface: ISeries
Gets the Y error bar.

Specified by:
getYErrorBar in interface ISeries
Returns:
the Y error bar

setStackSeries

protected void setStackSeries(double[] stackSeries)
Sets the stack series

Parameters:
stackSeries - The stack series

getPixelCoordinates

public Point getPixelCoordinates(int index)
Description copied from interface: ISeries
Gets the pixel coordinates corresponding to the given series index.

Specified by:
getPixelCoordinates in interface ISeries
Parameters:
index - the series index
Returns:
the pixel coordinates

getRangeWithMargin

protected Range getRangeWithMargin(int lowerPlotMargin,
                                   int upperPlotMargin,
                                   int length,
                                   Axis axis,
                                   Range range)
Gets the range with given margin.

Parameters:
lowerPlotMargin - the lower margin in pixels
upperPlotMargin - the upper margin in pixels
length - the axis length in pixels
axis - the axis
range - the range
Returns:
the range with margin

setVisibleInLegend

public void setVisibleInLegend(boolean visible)
Description copied from interface: ISeries
Sets the visibility state in legend.

Specified by:
setVisibleInLegend in interface ISeries
Parameters:
visible - the visibility state in legend

isVisibleInLegend

public boolean isVisibleInLegend()
Description copied from interface: ISeries
Gets the visibility state in legend.

Specified by:
isVisibleInLegend in interface ISeries
Returns:
true if series is visible in legend

dispose

protected void dispose()
Disposes SWT resources.


addDisposeListener

public void addDisposeListener(IDisposeListener listener)
Description copied from interface: ISeries
Adds the dispose listener. The newly created color or font for series can be disposed with the dispose listener when they are no longer needed.

Specified by:
addDisposeListener in interface ISeries
Parameters:
listener - the dispose listener

draw

public void draw(GC gc,
                 int width,
                 int height)
Draws series.

Parameters:
gc - the graphics context
width - the width to draw series
height - the height to draw series

draw

protected abstract void draw(GC gc,
                             int width,
                             int height,
                             Axis xAxis,
                             Axis yAxis)
Draws series.

Parameters:
gc - the graphics context
width - the width to draw series
height - the height to draw series
xAxis - the x axis
yAxis - the y axis