Venice 0.751beta

nz.org.venice.chart.graph
Class AbstractGraph

java.lang.Object
  extended bynz.org.venice.chart.graph.AbstractGraph
All Implemented Interfaces:
Graph
Direct Known Subclasses:
BarChartGraph, BarGraph, BollingerBandsGraph, CandleStickGraph, CountbackLineGraph, CustomGraph, ExpMovingAverageGraph, FiboGraph, HighLowBarGraph, KDGraph, LineGraph, MACDGraph, MomentumGraph, MovingAverageGraph, MultipleMovingAverageGraph, OBVGraph, PointAndFigureGraph, RSIGraph, SecondDerivative, StandardDeviationGraph, SupportAndResistenceGraph

public abstract class AbstractGraph
extends java.lang.Object
implements Graph

Set the default values for a graph based on a single GraphSource. All graphs that are based on a single GraphSource object will almost certainly want to use these default values. Graphs that use multiple GraphSource objects will still probably want to extend this class and override any differences.

Author:
Andrew Leppard
See Also:
Graph, GraphUI, GraphSource

Field Summary
 
Fields inherited from interface nz.org.venice.chart.graph.Graph
TOOL_TIP_BUFFER
 
Constructor Summary
AbstractGraph(GraphSource source)
          Set the default values to the ones provided by this GraphSource.
 
Method Summary
 boolean dataAvailable(java.util.Vector date)
          Return true if there is data available for date X
 double[] getAcceptableMajorDeltas()
          Return an array of acceptable major deltas for the vertical axis.
 double[] getAcceptableMinorDeltas()
          Return an array of acceptable minor deltas for the vertical axis.
 java.lang.Comparable getEndX()
          Get the last X value that this graph will draw.
 double getHighestY(java.util.List xRange)
          Return the highest Y value in the given X range.
 double getLowestY(java.util.List xRange)
          Return the loweset Y value in the given X range.
 java.util.HashMap getSettings()
          Return the graph's current settings.
protected  GraphSource getSource()
          Get underlying GraphSource we are using for default values.
 java.lang.String getSourceName()
          Return the name of the source data that we are graphing, e.g.
 int getSourceType()
          Return the type of the source data that we are graphing, e.g.
 java.lang.Comparable getStartX()
          Get the first X value that this graph will draw.
 java.lang.String getToolTipText(java.lang.Comparable x, int y, int yoffset, double verticalScale, double bottomLineValue)
          Get the tool tip text for the given X value and y coordinate.
 GraphUI getUI(java.util.HashMap settings)
          Returns the graph's user interface.
 java.util.Set getXRange()
          Get all X values that this graph will draw.
 java.lang.Double getY(java.lang.Comparable x)
          Return the Y value for the given X value.
 java.lang.String getYLabel(double value)
          Convert the Y value to a label to be displayed in the vertical axis.
 void setSettings(java.util.HashMap settings)
          Set the graph's user definable settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nz.org.venice.chart.graph.Graph
getName, isPrimary, render
 

Constructor Detail

AbstractGraph

public AbstractGraph(GraphSource source)
Set the default values to the ones provided by this GraphSource.

Parameters:
source - default GraphSource to use
Method Detail

getSource

protected GraphSource getSource()
Get underlying GraphSource we are using for default values.

Returns:
the default GraphSource

getToolTipText

public java.lang.String getToolTipText(java.lang.Comparable x,
                                       int y,
                                       int yoffset,
                                       double verticalScale,
                                       double bottomLineValue)
Get the tool tip text for the given X value and y coordinate.

Specified by:
getToolTipText in interface Graph
Parameters:
x - the X value
y - the y coordinate
yoffset - y offset from top of graph
verticalScale - vertical scale factor
bottomLineValue - the Y value of the lowest line in the graph
Returns:
the tool tip text for the default GraphSource

getStartX

public java.lang.Comparable getStartX()
Get the first X value that this graph will draw.

Specified by:
getStartX in interface Graph
Returns:
X value of the first x coordinate in the default GraphSource's Graphable

getEndX

public java.lang.Comparable getEndX()
Get the last X value that this graph will draw.

Specified by:
getEndX in interface Graph
Returns:
X value of the last x coordinate in the default GraphSource's Graphable

getXRange

public java.util.Set getXRange()
Get all X values that this graph will draw.

Specified by:
getXRange in interface Graph
Returns:
X values in the default GraphSource's Graphable

getYLabel

public java.lang.String getYLabel(double value)
Convert the Y value to a label to be displayed in the vertical axis.

Specified by:
getYLabel in interface Graph
Parameters:
value - y value
Returns:
the Y label text that the default GraphSource would display

getSourceName

public java.lang.String getSourceName()
Return the name of the source data that we are graphing, e.g. CBA.

Specified by:
getSourceName in interface Graph
Returns:
the name of the source

getSourceType

public int getSourceType()
Return the type of the source data that we are graphing, e.g. Portfolio.

Specified by:
getSourceType in interface Graph
Returns:
the name of the source

getY

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

Specified by:
getY in interface Graph
Parameters:
x - value
Returns:
Y value of the default GraphSource

getHighestY

public double getHighestY(java.util.List xRange)
Return the highest Y value in the given X range.

Specified by:
getHighestY in interface Graph
Parameters:
xRange - range of X values
Returns:
the highest Y value of the default GraphSource

getLowestY

public double getLowestY(java.util.List xRange)
Return the loweset Y value in the given X range.

Specified by:
getLowestY in interface Graph
Parameters:
xRange - range of X values
Returns:
the lowest Y value of the default GraphSource

getAcceptableMajorDeltas

public double[] getAcceptableMajorDeltas()
Return an array of acceptable major deltas for the vertical axis.

Specified by:
getAcceptableMajorDeltas in interface Graph
Returns:
an array of doubles representing the minor deltas of the default GraphSource

getAcceptableMinorDeltas

public double[] getAcceptableMinorDeltas()
Return an array of acceptable minor deltas for the vertical axis.

Specified by:
getAcceptableMinorDeltas in interface Graph
Returns:
an array of doubles representing the minor deltas of the default GraphSource
See Also:
Graph.getAcceptableMajorDeltas()

getSettings

public java.util.HashMap getSettings()
Return the graph's current settings. Each graph must contain its user definable settings in a hashmap. If a graph does not have any user definable settings, then it can just return an empty hashmap here.

Specified by:
getSettings in interface Graph
Returns:
settings

setSettings

public void setSettings(java.util.HashMap settings)
Set the graph's user definable settings.

Specified by:
setSettings in interface Graph
Parameters:
settings - the new settings

getUI

public GraphUI getUI(java.util.HashMap settings)
Returns the graph's user interface. The default action is to return null which indicates that the graph does not have a user interface. If the graph does have a user interface then it should override this method.

Specified by:
getUI in interface Graph
Parameters:
settings - initial settings (ignored)
Returns:
null

dataAvailable

public boolean dataAvailable(java.util.Vector date)
Return true if there is data available for date X

Specified by:
dataAvailable in interface Graph
Parameters:
date - - Comparable date
Returns:
true Trivially true for all graphs except for P&F

Venice 0.751beta