Venice 0.751beta

nz.org.venice.chart
Class Graphable

java.lang.Object
  extended bynz.org.venice.chart.Graphable
Direct Known Subclasses:
PFGraphable

public class Graphable
extends java.lang.Object

Represents a graphable set of X points and their associated Y points.

Example, loading up the class with an exponential graph:

 Graphable graphable = new Graphable();
 graphable.putY(new Double(1), new Double(1));
 graphable.putY(new Double(2), new Double(4));
 graphable.putY(new Double(3), new Double(9));
 graphable.putY(new Double(4), new Double(16));
 
Find the square of 3:
 Double squareOfThree = graphable.getY(new Double(3));
 

Author:
Andrew Leppard

Constructor Summary
Graphable()
          Create an empty graphable.
 
Method Summary
 java.lang.Comparable getEndX()
          Get the last X value where we have an associated Y value.
 double getHighestY(java.util.List xRange)
          Given an X range, inspect all the associated Y values and return the highest.
 double getLowestY(java.util.List xRange)
          Given an X range, inspect all the associated Y values and return the lowest.
 java.util.LinkedHashMap getMap()
           
 java.lang.Comparable getStartX()
          Get the first X value where we have an associated Y value.
 java.util.Set getXRange()
          Get all the X values for where we have an associated Y value.
 java.lang.Double getY(java.lang.Comparable x)
          Get the Y value for the given X value.
 java.util.Iterator iterator()
          Return an interator which iterates over the X values.
 void putY(java.lang.Comparable x, java.lang.Double y)
          Associate the given X value with the given Y value.
 double[] toArray()
          Return all the Y values as an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graphable

public Graphable()
Create an empty graphable.

Method Detail

getEndX

public java.lang.Comparable getEndX()
Get the last X value where we have an associated Y value.

Returns:
the last x value which we contain data

getStartX

public java.lang.Comparable getStartX()
Get the first X value where we have an associated Y value.

Returns:
the first x value which we contain data

getY

public java.lang.Double getY(java.lang.Comparable x)
Get the Y value for the given X value.

Parameters:
x - the x value
Returns:
y the associated y value

putY

public void putY(java.lang.Comparable x,
                 java.lang.Double y)
Associate the given X value with the given Y value. This function is used to "load" up the graphable with data.

Parameters:
x - the x value
y - the associated y value

getHighestY

public double getHighestY(java.util.List xRange)
Given an X range, inspect all the associated Y values and return the highest.

Parameters:
xRange - a List of Comparable objects
Returns:
the highest Y value

getLowestY

public double getLowestY(java.util.List xRange)
Given an X range, inspect all the associated Y values and return the lowest.

Parameters:
xRange - a List of Comparable objects
Returns:
the lowest Y value

getXRange

public java.util.Set getXRange()
Get all the X values for where we have an associated Y value.

Returns:
the set of all X values which have associated Y values

toArray

public double[] toArray()
Return all the Y values as an array. The array will be ordered by the X values.

Returns:
array of Y values

iterator

public java.util.Iterator iterator()
Return an interator which iterates over the X values.

Returns:
iterator

getMap

public java.util.LinkedHashMap getMap()

Venice 0.751beta