Package org.faceless.graph2
Class Series
- java.lang.Object
-
- org.faceless.graph2.Series
-
- Direct Known Subclasses:
AbstractLineSeries
,AreaSeries
,BubbleSeries
,CandleSeries
,GeneralBarSeries
,ScatterSeries
public abstract class Series extends Object
The Series class is the abstract superclass for all types of data to be plotted on an
AxesGraph
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBox(String name, double x1, double y1, double x2, double y2, Style style)
Add a box to this Series.void
addLine(String name, double x1, double y1, double x2, double y2, Style style)
Add a line to this Series.void
addMarker(AbstractMarker marker, double x, double y)
Add aMarker
to this Series.String
getName()
Return the name of this seriesdouble[]
outputToSeries(double x, double y, double[] out)
Given the (X,Y) co-ordinates of a point that was plotted on this Series and displayed on anOutput
, return the original co-ordinates as specified in Series space.String
outputToSeriesFunction()
This method returns two lines of JavaScript which perform the same function as theoutputToSeries
method.void
setStyle(Style style)
Set the style (color) to plot this series with.String
toString()
-
-
-
Method Detail
-
setStyle
public final void setStyle(Style style)
Set the style (color) to plot this series with. If a style isn't set explicitly, the next default style (as set byGraph.setDefaultColors(java.awt.Paint[])
) is used.
-
getName
public final String getName()
Return the name of this series- Since:
- 2.4.2
-
addMarker
public void addMarker(AbstractMarker marker, double x, double y)
Add aMarker
to this Series.- Parameters:
marker
- the Marker to addx
- the X co-ordinate to place the marker aty
- the Y co-ordinate to place the marker at
-
addLine
public void addLine(String name, double x1, double y1, double x2, double y2, Style style)
Add a line to this Series. This can be used to draw arbitrary lines on the graph. Infinite or NaN values can be used to draw lines that cover the whole width or height of the graph - for instance, to add a horizontal line across the whole graph where y=10, try:addLine(-Double.POSITIVE_INFINITY, 10, Double.POSITIVE_INFINITY, 10, style);
- Parameters:
name
- the name of the line (so it can be found inOutput.getAreas()
), ornull
if a name is not required.x1
- the starting X co-ordinate of the line. If NaN, will be set to -Infinityy1
- the starting Y co-ordinate of the line. If NaN, will be set to -Infinityx2
- the ending X co-ordinate of the line. If NaN, will be set to +Infinityy2
- the ending Y co-ordinate of the line. If NaN, will be set to +Infinitystyle
- the style to apply to the line
-
addBox
public void addBox(String name, double x1, double y1, double x2, double y2, Style style)
Add a box to this Series. This can be used to draw arbitrary boxes on the graph. Infinite or NaN values can be used to draw boxes that cover the whole width or height of the graph - for instance, to add a horizontal box across the whole graph where y=10, try:addBox(-Double.POSITIVE_INFINITY, 10, Double.POSITIVE_INFINITY, 10, style);
- Parameters:
name
- the name of the line (so it can be found inOutput.getAreas()
), ornull
if a name is not required.x1
- the starting X co-ordinate of the line. If NaN, will be set to -Infinityy1
- the starting Y co-ordinate of the line. If NaN, will be set to -Infinityx2
- the ending X co-ordinate of the line. If NaN, will be set to +Infinityy2
- the ending Y co-ordinate of the line. If NaN, will be set to +Infinitystyle
- the style to apply to the line- Since:
- 2.3
-
outputToSeries
public double[] outputToSeries(double x, double y, double[] out)
Given the (X,Y) co-ordinates of a point that was plotted on this Series and displayed on anOutput
, return the original co-ordinates as specified in Series space. In other words, convert a point in Output-space back to the original Series-space. This method would typically be used to determine exactly what point in a Series the mouse is hovering over.- Parameters:
x
- the X co-ordinate of the point, relative to the left side of theOutput
the Series was plotted toy
- the Y co-ordinate of the point, relative to the bottom of theOutput
the Series was plotted toout
- an array of two doubles which the output values will be written to, ornull
to allocate a new one- Returns:
- an array of two doubles containing the (x,y) co-ordinates of the point in Series-space. If
out
was not null, returnout
-
outputToSeriesFunction
public String outputToSeriesFunction()
This method returns two lines of JavaScript which perform the same function as theoutputToSeries
method. Assuming two variables "x" and "y", the first line is the new value of the "x" variable and the second is the new value of "y". Again, the output of this method would typically be used with interactive graphs to determine which point the mouse is hovering over- Returns:
- a String containing two lines of JavaScript. Both lines will
look something like
1.2*x + 3.2*y + ((-1*x+0*y+4)/12)
-
-