org.gicentre.utils.stat
Class BarChart

java.lang.Object
  extended by org.gicentre.utils.stat.AbstractChart
      extended by org.gicentre.utils.stat.BarChart

public class BarChart
extends AbstractChart

Represents a bar chart. Appearance can be customised such as display of axes, bar colours, orientations etc.

Version:
3.0, 10th August, 2010.
Author:
Jo Wood, giCentre, City University London.

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gicentre.utils.stat.AbstractChart
AbstractChart.Side
 
Field Summary
 
Fields inherited from class org.gicentre.utils.stat.AbstractChart
axisFormatter, data, logTics, parent, tics, transposeAxes
 
Constructor Summary
BarChart(processing.core.PApplet parent)
          Initialises a bar chart.
 
Method Summary
 void draw(float xOrigin, float yOrigin, float width, float height)
          Draws the bar chart within the given bounds.
 void setBarColour(float[] colourData, ColourTable cTable)
          Provides the data and colour table from which to colour bars.
 void setBarColour(int colour)
          Determines the colours of the bars to be displayed on the chart.
 void setBarGap(float gap)
          Sets the gap between adjacent bars.
 void setBarLabels(java.lang.String[] labels)
          Sets the bar names to be displayed as axis labels.
 void setCategoryFormat(java.lang.String format)
          Sets the numerical format for numbers shown on the category axis.
 void setData(float[] values)
          Sets the data values to be displayed in the chart.
 void setLogValues(boolean isLog)
          Determines whether or not the values represented by the length of each bar should be log10-scaled.
 void setMaxValue(float maxVal)
          Sets the maximum value for the bar chart.
 void setMinValue(float minVal)
          Sets the minimum value for the bar chart.
 void setReverseCategories(boolean reverse)
          Determines if the order of the category values should be reversed or not.
 void setValueFormat(java.lang.String format)
          Sets the numerical format for numbers shown on the value axis.
 void showCategoryAxis(boolean showAxis)
          Determines whether or not the category axis is drawn.
 void showValueAxis(boolean showAxis)
          Determines whether or not the value axis is drawn.
 void transposeAxes(boolean transpose)
          Determines if the axes should be transposed (so that categories appear on the vertical axis and values on the horizontal axis).
 
Methods inherited from class org.gicentre.utils.stat.AbstractChart
convertToLog, getBorder, getIsLogScale, getMax, getMaxLog, getMin, getMinBorder, getMinLog, getShowAxis, setBorder, setData, setFormat, setIsLogScale, setMax, setMin, setMinBorder, setMinBorder, setRange, showAxis
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BarChart

public BarChart(processing.core.PApplet parent)
Initialises a bar chart.

Parameters:
parent - Parent sketch in which this chart is to be drawn.
Method Detail

setData

public void setData(float[] values)
Sets the data values to be displayed in the chart. Each item in the given array is assumed to be in a linear sequence of equal width.

Parameters:
values - Sequence of values to chart.

draw

public void draw(float xOrigin,
                 float yOrigin,
                 float width,
                 float height)
Draws the bar chart within the given bounds.

Specified by:
draw in class AbstractChart
Parameters:
xOrigin - left-hand pixel coordinate of the area in which to draw the chart.
yOrigin - top pixel coordinate of the area in which to draw the chart.
width - Width in pixels of the area in which to draw the chart.
height - Height in pixels of the area in which to draw the chart.

setLogValues

public void setLogValues(boolean isLog)
Determines whether or not the values represented by the length of each bar should be log10-scaled.

Parameters:
isLog - True if values are to be log10-scaled or false if linear.

setMinValue

public void setMinValue(float minVal)
Sets the minimum value for the bar chart. Can be used to ensure multiple charts can share the same origin.

Parameters:
minVal - Minimum value to use for scaling bar lengths.

setMaxValue

public void setMaxValue(float maxVal)
Sets the maximum value for the bar chart. Can be used to ensure multiple charts are scaled to the same maximum.

Parameters:
maxVal - Maximum value to use for scaling bar lengths.

setBarLabels

public void setBarLabels(java.lang.String[] labels)
Sets the bar names to be displayed as axis labels. If set to null, the category number is displayed in the axis.

Parameters:
labels - Array of labels corresponding to each of the bars in the chart.

showValueAxis

public void showValueAxis(boolean showAxis)
Determines whether or not the value axis is drawn.

Parameters:
showAxis - Value axis is drawn if true.

showCategoryAxis

public void showCategoryAxis(boolean showAxis)
Determines whether or not the category axis is drawn.

Parameters:
showAxis - Category axis is drawn if true.

transposeAxes

public void transposeAxes(boolean transpose)
Determines if the axes should be transposed (so that categories appear on the vertical axis and values on the horizontal axis).

Parameters:
transpose - Axes are transposed if true.

setBarGap

public void setBarGap(float gap)
Sets the gap between adjacent bars.

Parameters:
gap - Gap between adjacent bars in pixels

setReverseCategories

public void setReverseCategories(boolean reverse)
Determines if the order of the category values should be reversed or not.

Parameters:
reverse - Category order reversed if true.

setValueFormat

public void setValueFormat(java.lang.String format)
Sets the numerical format for numbers shown on the value axis.

Parameters:
format - Format for numbers on the value axis.

setCategoryFormat

public void setCategoryFormat(java.lang.String format)
Sets the numerical format for numbers shown on the category axis.

Parameters:
format - Format for numbers on the category axis.

setBarColour

public void setBarColour(int colour)
Determines the colours of the bars to be displayed on the chart. This method will give a uniform colour to all bars.

Parameters:
colour - Colour of bars.

setBarColour

public void setBarColour(float[] colourData,
                         ColourTable cTable)
Provides the data and colour table from which to colour bars. Each data item should by in the same order as the data provided to setData().

Parameters:
colourData - Data used to colour bars
cTable - Colour table that translates data values into colours.


gicentreUtils V.3.0, API documentation generated 13th August, 2010