Package org.swtchart.internal.series
Class Series
java.lang.Object
org.swtchart.internal.series.Series
- All Implemented Interfaces:
ISeries
- Direct Known Subclasses:
BarSeries
,LineSeries
Series.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.swtchart.ISeries
ISeries.SeriesType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Chart
the chartprotected ICompress
the compressorprotected static final ISeries.SeriesType
the default series typeprotected String
the series idprotected boolean
the state indicating whether x series are monotone increasingprotected double
the maximum value of x seriesprotected double
the maximum value of y seriesprotected double
the minimum value of x seriesprotected double
the minimum value of y seriesprotected SeriesLabel
the series labelprotected boolean
the state indicating if the series is a stacked typeprotected double[]
the stack seriesprotected ISeries.SeriesType
the series typeprotected boolean
the visibility of seriesprotected int
the x axis idprotected ErrorBar
the x error barprotected double[]
the x seriesprotected int
the y axis idprotected ErrorBar
the y error barprotected double[]
the y series -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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
Gets the compressor.Gets the series descriptiongetId()
Gets the series id.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.getType()
Gets the series type.int
Gets the X axis id.Date[]
Gets the X date series.Gets the X error bar.Gets the X range of series.double[]
Gets the X series.int
Gets the Y axis id.Gets the Y error bar.Gets the Y range of series.double[]
Gets the Y series.boolean
Gets the state indicating if date series is set.boolean
Gets the state indicating if stack is enabled.boolean
Gets the state indicating if the series is valid stack series.boolean
Gets the visibility state.boolean
Gets the visibility state in legend.protected abstract void
Sets the compressor.void
setDescription
(String description) Sets the series description.protected void
setStackSeries
(double[] stackSeries) Sets the stack seriesvoid
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
(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.
-
Field Details
-
DEFAULT_SERIES_TYPE
the default series type -
xSeries
protected double[] xSeriesthe x series -
ySeries
protected double[] ySeriesthe y series -
minX
protected double minXthe minimum value of x series -
maxX
protected double maxXthe maximum value of x series -
minY
protected double minYthe minimum value of y series -
maxY
protected double maxYthe maximum value of y series -
id
the series id -
compressor
the compressor -
xAxisId
protected int xAxisIdthe x axis id -
yAxisId
protected int yAxisIdthe y axis id -
visible
protected boolean visiblethe visibility of series -
isXMonotoneIncreasing
protected boolean isXMonotoneIncreasingthe state indicating whether x series are monotone increasing -
type
the series type -
seriesLabel
the series label -
xErrorBar
the x error bar -
yErrorBar
the y error bar -
chart
the chart -
stackEnabled
protected boolean stackEnabledthe state indicating if the series is a stacked type -
stackSeries
protected double[] stackSeriesthe stack series
-
-
Constructor Details
-
Series
Constructor.- Parameters:
chart
- the chartid
- the series id
-
-
Method Details
-
getId
Description copied from interface:ISeries
Gets the series id. -
setVisible
public void setVisible(boolean visible) Description copied from interface:ISeries
Sets the visibility state.- Specified by:
setVisible
in interfaceISeries
- Parameters:
visible
- the visibility state
-
isVisible
public boolean isVisible()Description copied from interface:ISeries
Gets the visibility state. -
getType
Description copied from interface:ISeries
Gets the series type. -
isStackEnabled
public boolean isStackEnabled()Description copied from interface:ISeries
Gets the state indicating if stack is enabled.- Specified by:
isStackEnabled
in interfaceISeries
- 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 interfaceISeries
- 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 interfaceISeries
- 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, empty array will be returned.- Specified by:
getXSeries
in interfaceISeries
- Returns:
- the X series
-
setYSeries
public void setYSeries(double[] series) Description copied from interface:ISeries
Sets the Y series.- Specified by:
setYSeries
in interfaceISeries
- 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, empty array will be returned.- Specified by:
getYSeries
in interfaceISeries
- Returns:
- the Y series
-
setXDateSeries
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 interfaceISeries
- Parameters:
series
- the X date series
-
getXDateSeries
Description copied from interface:ISeries
Gets the X date series.- Specified by:
getXDateSeries
in interfaceISeries
- Returns:
- the X date series, or empty array 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
Gets the X range of series.- Returns:
- the X range of series
-
getAdjustedRange
Gets the adjusted range to show all series in screen. This range includes the size of plot like symbol or bar.- Parameters:
axis
- the axislength
- the axis length in pixels- Returns:
- the adjusted range
-
getYRange
Gets the Y range of series.- Returns:
- the Y range of series
-
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 interfaceISeries
- 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 interfaceISeries
- Parameters:
id
- the X axis id.
-
getYAxisId
public int getYAxisId()Description copied from interface:ISeries
Gets the Y axis id.- Specified by:
getYAxisId
in interfaceISeries
- 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 interfaceISeries
- Parameters:
id
- the Y axis id.
-
getLabel
Description copied from interface:ISeries
Gets the series label. -
getXErrorBar
Description copied from interface:ISeries
Gets the X error bar. This is typically used for scatter chart.- Specified by:
getXErrorBar
in interfaceISeries
- Returns:
- the X error bar
-
getYErrorBar
Description copied from interface:ISeries
Gets the Y error bar.- Specified by:
getYErrorBar
in interfaceISeries
- 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 interfaceISeries
- 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 pixelsupperPlotMargin
- the upper margin in pixelslength
- the axis length in pixelsaxis
- the axisrange
- 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 interfaceISeries
- 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 interfaceISeries
- Returns:
- true if series is visible in legend
-
setDescription
Description copied from interface:ISeries
Sets the series description.For example, you may store the description explaining what this series is, and display it on tool tip with mouse hover on the series.
By default, legend displays the description, when it is set.
- Specified by:
setDescription
in interfaceISeries
- Parameters:
description
- the series description, or null to clear it
-
getDescription
Description copied from interface:ISeries
Gets the series description- Specified by:
getDescription
in interfaceISeries
- Returns:
- the series description, or null if not set
-
dispose
protected void dispose()Disposes SWT resources. -
addDisposeListener
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 interfaceISeries
- Parameters:
listener
- the dispose listener
-
draw
public void draw(GC gc, int width, int height) Draws series.- Parameters:
gc
- the graphics contextwidth
- the width to draw seriesheight
- the height to draw series
-
draw
Draws series.- Parameters:
gc
- the graphics contextwidth
- the width to draw seriesheight
- the height to draw seriesxAxis
- the x axisyAxis
- the y axis
-