org.faceless.graph2
Class Series

java.lang.Object
  extended by 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
 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 a Marker to this Series.
 String getName()
          Return the name of this series
 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 an Output, 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 the outputToSeries method.
 void setStyle(Style style)
          Set the style (color) to plot this series with.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

toString

public String toString()
Overrides:
toString in class Object

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 by Graph.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 a Marker to this Series.

Parameters:
marker - the Marker to add
x - the X co-ordinate to place the marker at
y - 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 in ImageOutput.getAreas()), or null if a name is not required.
x1 - the starting X co-ordinate of the line. If NaN, will be set to -Infinity
y1 - the starting Y co-ordinate of the line. If NaN, will be set to -Infinity
x2 - the ending X co-ordinate of the line. If NaN, will be set to +Infinity
y2 - the ending Y co-ordinate of the line. If NaN, will be set to +Infinity
style - 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 in ImageOutput.getAreas()), or null if a name is not required.
x1 - the starting X co-ordinate of the line. If NaN, will be set to -Infinity
y1 - the starting Y co-ordinate of the line. If NaN, will be set to -Infinity
x2 - the ending X co-ordinate of the line. If NaN, will be set to +Infinity
y2 - the ending Y co-ordinate of the line. If NaN, will be set to +Infinity
style - 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 an Output, 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 the Output the Series was plotted to
y - the Y co-ordinate of the point, relative to the bottom of the Output the Series was plotted to
out - an array of two doubles which the output values will be written to, or null 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, return out

outputToSeriesFunction

public String outputToSeriesFunction()
This method returns two lines of JavaScript which perform the same function as the outputToSeries 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)


Copyright © 2001-2011 Big Faceless Organization