Venice 0.7beta

org.mov.chart.graph
Interface Graph

All Known Implementing Classes:
AbstractGraph, AdvanceDeclineGraph, BarChartGraph, BarGraph, BollingerBandsGraph, CandleStickGraph, CountbackLineGraph, CustomGraph, ExpMovingAverageGraph, HighLowBarGraph, LineGraph, MACDGraph, MomentumGraph, MovingAverageGraph, MultipleMovingAverageGraph, OBVGraph, PointAndFigureGraph, RSIGraph, StandardDeviationGraph, SupportAndResistenceGraph

public interface Graph

Provides a common interface to allow the charting module to support a variety of graphs. Classes that implement this interface will be able to render the graph onto the chart and provide axes information. Each graph can have its own user interface to allow the user to set user-definable parameters.

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

Field Summary
static int TOOL_TIP_BUFFER
          Maximum distance between the mouse pointer and the graph which will still make the tooltip come up
 
Method Summary
 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.lang.String getName()
          Return the name of the graph we are graphing, e.g.
 java.util.HashMap getSettings()
          Return the graph's current settings.
 java.lang.String getSourceName()
          Return the name 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)
          Return the graph's user interface to allow the user to modify its settings.
 java.util.Set getXRange()
          Get all X values that this graph will draw.
 java.lang.Double getY(java.lang.Comparable xRange)
          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.
 boolean isPrimary()
          Return whether the graph is a primary graph.
 void render(java.awt.Graphics g, java.awt.Color colour, int xoffset, int yoffset, double horizontalScale, double verticalScale, double bottomLineValue, java.util.List xRange)
          Draw the graph.
 void setSettings(java.util.HashMap settings)
          Set the graph's user definable settings.
 

Field Detail

TOOL_TIP_BUFFER

static final int TOOL_TIP_BUFFER
Maximum distance between the mouse pointer and the graph which will still make the tooltip come up

See Also:
Constant Field Values
Method Detail

render

void render(java.awt.Graphics g,
            java.awt.Color colour,
            int xoffset,
            int yoffset,
            double horizontalScale,
            double verticalScale,
            double bottomLineValue,
            java.util.List xRange)
Draw the graph.

Parameters:
g - the Graphics object to render to
colour - the colour the graph should be rendered in; override this if the graph should be drawn in a certain colour - such as a Moving Average graph
xoffset - the x offset in the graphics object where the graph starts
yoffset - the y offset in the graphics object where the graph starts
horizontalScale - horizontal scale factor; use this to convert between X value in the xRange to a cartesian coordinate x
verticalScale - vertical scale factor; use this to convert between Y value to a cartesian coordinate y
bottomLineValue - the Y value of the lowest line in the graph
xRange - a List of Comparable that contain the X values to plot

getToolTipText

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.

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 tooltip text

getStartX

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

Returns:
X value of the first x coordinate in graph

getEndX

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

Returns:
X value of the last x coordinate in graph

getXRange

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

Returns:
List of Comparable X values

getYLabel

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

Parameters:
value - y value
Returns:
the label text

getName

java.lang.String getName()
Return the name of the graph we are graphing, e.g. Simple Moving Average.

Returns:
the name of the graph

getSourceName

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

Returns:
the name of the source

getY

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

Parameters:
xRange - value
Returns:
Y value

getHighestY

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

Parameters:
xRange - range of X values
Returns:
the highest Y value

getLowestY

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

Parameters:
xRange - range of X values
Returns:
the lowest Y value

getAcceptableMajorDeltas

double[] getAcceptableMajorDeltas()
Return an array of acceptable major deltas for the vertical axis. The vertical axis is created in such a way that each horizontal line is placed in the graph at a sensible value, e.g. a graph may have four horizontal lines, each separated by $1.20:
 --------------- $4.80

 -----+==+------ $3.60
     /    \
 ---+------+---- $2.40
   /        \---
 -+------------- $1.20
 
Here the values of the horizontal lines are $1.20, $2.40, $3.60 & $4.80. These are sensible values, values such as $1.36, $2.72, $4.08 & $5.44 are not as sensible. All the allowable values are calculated by the cross product of Major Deltas x Minor Deltas.

Returns:
an array of doubles representing the major deltas

getAcceptableMinorDeltas

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

Returns:
an array of doubles representing the minor deltas
See Also:
getAcceptableMajorDeltas()

getSettings

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.

Returns:
settings

setSettings

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

Parameters:
settings - the new settings

getUI

GraphUI getUI(java.util.HashMap settings)
Return the graph's user interface to allow the user to modify its settings. Pass the initial settings or an empty hashmap to use the graph's default settings. If the graph does not have any user-definable settings, then it should not have a user interface and should return null here.

Parameters:
settings - initial settings
Returns:
user interface or null

isPrimary

boolean isPrimary()
Return whether the graph is a primary graph. Primary graphs will appear together in the top chart. Secondary graphs appear in their own charts which are added below. The day close graph is primary; while the day close graph is secondary.

Returns:
true if the graph is a primary graph

Venice 0.7beta