khartzToolz
Class KhartzElectionBar

java.lang.Object
  |
  +--khartzToolz.KhartzBaseChart
        |
        +--khartzToolz.KhartzElectionBar
All Implemented Interfaces:
KhartzChart

public class KhartzElectionBar
extends KhartzBaseChart
implements KhartzChart

Since:
23/02/2003
Version:
1.1
Author:
Austin Warren

Field Summary
 BarSegment[] barSegments
           
 
Constructor Summary
KhartzElectionBar(double[] values, java.lang.String[] labels, java.util.Date[] dates, java.awt.Rectangle size, java.lang.String title, java.awt.Color[] colorArray)
          Standard constructor of an Election Bar Chart
 
Method Summary
 int calcBarHeight(double converter, double value)
          Calculates the height of a bar segment in pixels.
 void calcBarLayout()
          Calculates barSpacing between bar segments, the barWidth of each bar and the barHeightConverter based on the array of values that have been passed.
 void calcIncrement()
          Calculates the value of xTickIncrement - the spacing of tick marks on the y axis of the chart
 boolean contains(java.awt.Point p)
          Scans the available segments within the chart in sequence, to see if the Point p is contained within the area of one of those segments.
 void createSegments()
          Creates the array of individual bar segments.
 double getAxisMinValue()
          Calculates the minimum value that should be displayed at the bottom of the x axis scale on the left hand side of the chart.
 double getBarHeightConverter()
          Access method for the barHeightConverter property.
 int getBarSpacing()
          Access method for the barSpacing property.
 int getBarWidth()
          Access method for the barWidth property.
 java.awt.Font getFont()
          Returns the current chart font
 java.lang.String getLabel(int i)
          Fetches a text label from the the array of labels held by the chart
 double getRelativeTextSize()
          Gets the current text size setting for the chart.
 java.awt.Dimension getSize()
           
 double getValue(int i)
          Fetches a value from the array of values contained within the chart.
 int getXTickIncrement()
          Access method for the xTickIncrement property.
 int getXTickIncrementNumber()
          Access method for the xTickIncrementNumber property.
 int getXTickPixelIncrement()
          Access method for the xTickPixelIncrement property.
 void mouseMoved(java.awt.event.MouseEvent e)
          Used to send a mouse event to the chart for action when a mouse is moved
 void mouseReleased(java.awt.event.MouseEvent e)
          An action that is performed by the chart when the mouse button is released within the applet window.
 void paint(java.awt.Graphics g)
          Does the work of painting the chart area and calls the individual bar segments to paint themselves using their own paint() commands.
 void setBarHeightConverter(double aBarHeightConverter)
          Sets the value of the barHeightConverter property.
 void setBarSpacing(int aBarSpacing)
          Sets the value of the barSpacing property.
 void setBarWidth(int aBarWidth)
          Sets the value of the barWidth property.
 void setColorArray(java.awt.Color[] colorArray)
          Sets the current range of values associated with the segments in the Chart
 void setFont(java.awt.Font f)
          Sets the font for the current chart
 void setRelativeTextSize(double size)
          Sets the relative size of the text to be displayed on the chart.
 void setXTickIncrement(int aXTickIncrement)
          Sets the value of the xTickIncrement property.
 void setXTickIncrementNumber(int aXTickIncrementNumber)
          Sets the value of the xTickIncrementNumber property.
 void setXTickPixelIncrement(int aXTickPixelIncrement)
          Sets the value of the xTickPixelIncrement property.
 java.lang.String toString()
          Returns a string representation of the chart containing key information.
 
Methods inherited from class khartzToolz.KhartzBaseChart
getBottomMargin, getChartMargin, getChartSize, getChartTitle, getColorArray, getLabels, getLeftMargin, getMaxValue, getMinValue, getRightMargin, getTextFont, getTopMargin, getValues, getVersionMessage, setBottomMargin, setChartMargin, setChartSize, setChartTitle, setLabels, setLeftMargin, setRightMargin, setTextFont, setTopMargin, setValues, setVersionMessage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface khartzToolz.KhartzChart
getChartSize
 

Field Detail

barSegments

public BarSegment[] barSegments
Constructor Detail

KhartzElectionBar

public KhartzElectionBar(double[] values,
                         java.lang.String[] labels,
                         java.util.Date[] dates,
                         java.awt.Rectangle size,
                         java.lang.String title,
                         java.awt.Color[] colorArray)
Standard constructor of an Election Bar Chart
Parameters:
values[] - The range of values to be charted
values[] - The labels to be displayed for each chart
chart - The containing chart instance
labels[] - An array containing the text labels
dates[] - An array containing dates associated with the data
title - The title to be displayed
size - The size of the chart area
colorArray[] - An array of colors that define the segment colors
Since:
30/12/2002
Method Detail

getXTickIncrement

public int getXTickIncrement()
Access method for the xTickIncrement property.
Returns:
the current value of the xTickIncrement property

setXTickIncrement

public void setXTickIncrement(int aXTickIncrement)
Sets the value of the xTickIncrement property.
Parameters:
aXTickIncrement - the new value of the xTickIncrement property

getBarSpacing

public int getBarSpacing()
Access method for the barSpacing property.
Returns:
the current value of the barSpacing property

setBarSpacing

public void setBarSpacing(int aBarSpacing)
Sets the value of the barSpacing property.
Parameters:
aBarSpacing - the new value of the barSpacing property

getBarWidth

public int getBarWidth()
Access method for the barWidth property.
Returns:
the current value of the barWidth property

setBarWidth

public void setBarWidth(int aBarWidth)
Sets the value of the barWidth property.
Parameters:
aBarWidth - the new value of the barWidth property

getBarHeightConverter

public double getBarHeightConverter()
Access method for the barHeightConverter property.
Returns:
the current value of the barHeightConverter property

setBarHeightConverter

public void setBarHeightConverter(double aBarHeightConverter)
Sets the value of the barHeightConverter property.
Parameters:
aBarHeightConverter - the new value of the barHeightConverter property

getXTickPixelIncrement

public int getXTickPixelIncrement()
Access method for the xTickPixelIncrement property.
Returns:
the current value of the xTickPixelIncrement property

setXTickPixelIncrement

public void setXTickPixelIncrement(int aXTickPixelIncrement)
Sets the value of the xTickPixelIncrement property.
Parameters:
aXTickPixelIncrement - the new value of the xTickPixelIncrement property

getXTickIncrementNumber

public int getXTickIncrementNumber()
Access method for the xTickIncrementNumber property.
Returns:
the current value of the xTickIncrementNumber property

setXTickIncrementNumber

public void setXTickIncrementNumber(int aXTickIncrementNumber)
Sets the value of the xTickIncrementNumber property.
Parameters:
aXTickIncrementNumber - the new value of the xTickIncrementNumber property

paint

public void paint(java.awt.Graphics g)
Does the work of painting the chart area and calls the individual bar segments to paint themselves using their own paint() commands.
Specified by:
paint in interface KhartzChart
Parameters:
g -  
Since:
30/12/2002

contains

public boolean contains(java.awt.Point p)
Description copied from interface: KhartzChart
Scans the available segments within the chart in sequence, to see if the Point p is contained within the area of one of those segments.
Specified by:
contains in interface KhartzChart
Parameters:
p -  
Returns:
boolean
Since:
30/12/2002

getSize

public java.awt.Dimension getSize()
Specified by:
getSize in interface KhartzChart
Returns:
java.awt.Dimension
Since:
30/12/2002

toString

public java.lang.String toString()
Description copied from interface: KhartzChart
Returns a string representation of the chart containing key information.
Specified by:
toString in interface KhartzChart
Overrides:
toString in class java.lang.Object
Returns:
String
Since:
30/12/2002

getValue

public double getValue(int i)
Description copied from interface: KhartzChart
Fetches a value from the array of values contained within the chart.
Specified by:
getValue in interface KhartzChart
Overrides:
getValue in class KhartzBaseChart
Parameters:
i -  
Returns:
double
Since:
30/12/2002

getLabel

public java.lang.String getLabel(int i)
Description copied from interface: KhartzChart
Fetches a text label from the the array of labels held by the chart
Specified by:
getLabel in interface KhartzChart
Overrides:
getLabel in class KhartzBaseChart
Parameters:
i -  
Returns:
String
Since:
30/12/2002

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Description copied from interface: KhartzChart
Used to send a mouse event to the chart for action when a mouse is moved
Specified by:
mouseMoved in interface KhartzChart
Parameters:
e -  
Since:
30/12/2002

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Description copied from interface: KhartzChart
An action that is performed by the chart when the mouse button is released within the applet window.
Specified by:
mouseReleased in interface KhartzChart
Parameters:
e -  
Since:
30/12/2002

setRelativeTextSize

public void setRelativeTextSize(double size)
Description copied from interface: KhartzChart
Sets the relative size of the text to be displayed on the chart. Font sizes are set by the chart relative to it's width and height in pixels. This gives the additional control required where very large or small charts are being used.
Specified by:
setRelativeTextSize in interface KhartzChart
Parameters:
size -  
Since:
30/12/2002

getRelativeTextSize

public double getRelativeTextSize()
Description copied from interface: KhartzChart
Gets the current text size setting for the chart. 1 is the default.
Specified by:
getRelativeTextSize in interface KhartzChart
Returns:
double
Since:
30/12/2002

calcIncrement

public void calcIncrement()
Calculates the value of xTickIncrement - the spacing of tick marks on the y axis of the chart
Since:
24/02/2003

getFont

public java.awt.Font getFont()
Description copied from interface: KhartzChart
Returns the current chart font
Specified by:
getFont in interface KhartzChart
Returns:
java.awt.Font
Since:
30/12/2002

setFont

public void setFont(java.awt.Font f)
Description copied from interface: KhartzChart
Sets the font for the current chart
Specified by:
setFont in interface KhartzChart
Parameters:
f -  
Since:
30/12/2002

setColorArray

public void setColorArray(java.awt.Color[] colorArray)
Description copied from interface: KhartzChart
Sets the current range of values associated with the segments in the Chart
Specified by:
setColorArray in interface KhartzChart
Overrides:
setColorArray in class KhartzBaseChart
Parameters:
colorArray[] -  
Since:
30/12/2002

calcBarLayout

public void calcBarLayout()
Calculates barSpacing between bar segments, the barWidth of each bar and the barHeightConverter based on the array of values that have been passed.
Since:
30/12/2002

getAxisMinValue

public double getAxisMinValue()
Calculates the minimum value that should be displayed at the bottom of the x axis scale on the left hand side of the chart.
Returns:
double
Since:
30/12/2002

createSegments

public void createSegments()
Creates the array of individual bar segments.
Since:
30/12/2002

calcBarHeight

public int calcBarHeight(double converter,
                         double value)
Calculates the height of a bar segment in pixels.
Parameters:
converter - Is the barHeightConverter value
value - The value that the bar segment represents in the chart
Returns:
int
Since:
30/12/2002