org.hackystat.projectbrowser.googlechart
Class GoogleChart

java.lang.Object
  extended by org.hackystat.projectbrowser.googlechart.GoogleChart
All Implemented Interfaces:
java.io.Serializable

public class GoogleChart
extends java.lang.Object
implements java.io.Serializable

Chart class that represent a chart image that generated from Google Chart API.

Author:
Shaoxuan Zhang
See Also:
Serialized Form

Field Summary
static java.lang.String DATAITEM_SEPARATOR
          character that separate data items in a data set.
static java.lang.String DATASET_SEPARATOR
          character that separate data sets.
static java.lang.String GOOGLECHART_API_URL
          host of google chart service.
static int MAX_SIZE
          The maximum size of a google chart.
static java.lang.String PARAMETER_SEPARATOR
          character that separate parameter.
 
Constructor Summary
GoogleChart(ChartType chartType, int width, int height)
          initialize the chart with indispensable parameter.
 
Method Summary
 void addAxisLabel(java.lang.String type)
          add a label with default label values.
 void addAxisLabel(java.lang.String type, java.util.List<java.lang.String> labels, java.lang.String color)
          add a label with given label values.
 void addAxisRange(java.lang.String type, java.util.List<java.lang.Double> range, java.lang.String color)
          add a label with given label range.
 void addColor(java.awt.Color color)
          add the color to color list.
 void addColor(java.lang.String color)
          add the color to color list.
 void addLineStyle(double thickness, double lineLength, double blankLength)
          add a line style with the given parameters.
static java.lang.String colorToString(java.awt.Color color)
          convert a Color object to a String, with format of RRGGBB.
 java.lang.String getBackgroundColor()
           
 java.util.List<java.util.List<java.lang.Double>> getChartData()
           
 java.util.List<java.util.List<java.lang.Double>> getChartDataScale()
           
 java.util.List<java.lang.String> getChartLegend()
           
 java.util.List<java.lang.String> getChartMarker()
           
 ChartType getChartType()
           
 java.util.List<java.lang.String> getColors()
           
 int getHeight()
           
 java.util.List<java.lang.String> getMarkerColors()
           
static java.lang.String getNextJetColor()
           
static java.lang.String getNextMarker()
          Return the next available marker.
static java.lang.String getRandomColor()
           
static java.lang.String getRandomMarker()
           
 java.lang.String getTitle()
           
 java.lang.String getUrl()
          Return the URL that represent this chart from Google Chart API.
 int getWidth()
           
 boolean isYAxisEmpty()
           
 void setBackgroundColor(java.lang.String backgroundColor)
           
 void setBarChartSize(int barHeight, int groupSpace, int barSpace)
          Set the size of the bar chart.
 void setChartData(java.util.List<java.util.List<java.lang.Double>> chartData)
           
 void setChartDataScale(java.util.List<java.util.List<java.lang.Double>> chartDataScale)
           
 void setChartType(ChartType chartType)
           
 void setHeight(int height)
           
 void setMarkerColors(java.util.List<java.lang.String> markerColors)
           
 void setTitle(java.lang.String title)
           
 void setWidth(int width)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GOOGLECHART_API_URL

public static final java.lang.String GOOGLECHART_API_URL
host of google chart service.

See Also:
Constant Field Values

PARAMETER_SEPARATOR

public static final java.lang.String PARAMETER_SEPARATOR
character that separate parameter.

See Also:
Constant Field Values

DATASET_SEPARATOR

public static final java.lang.String DATASET_SEPARATOR
character that separate data sets.

See Also:
Constant Field Values

DATAITEM_SEPARATOR

public static final java.lang.String DATAITEM_SEPARATOR
character that separate data items in a data set.

See Also:
Constant Field Values

MAX_SIZE

public static final int MAX_SIZE
The maximum size of a google chart.

See Also:
Constant Field Values
Constructor Detail

GoogleChart

public GoogleChart(ChartType chartType,
                   int width,
                   int height)
initialize the chart with indispensable parameter.

Parameters:
chartType - type of this chart.
width - width.
height - height.
Method Detail

getNextMarker

public static java.lang.String getNextMarker()
Return the next available marker.

Returns:
a String that represents the marker

getUrl

public java.lang.String getUrl()
Return the URL that represent this chart from Google Chart API.

Returns:
the URL of this chart.

colorToString

public static java.lang.String colorToString(java.awt.Color color)
convert a Color object to a String, with format of RRGGBB.

Parameters:
color - the Color to be convert.
Returns:
a string that represent the color.

setWidth

public void setWidth(int width)
Parameters:
width - the width to set

getWidth

public int getWidth()
Returns:
the width

setHeight

public void setHeight(int height)
Parameters:
height - the height to set

getHeight

public int getHeight()
Returns:
the height

setChartType

public void setChartType(ChartType chartType)
Parameters:
chartType - the chartType to set

getChartType

public ChartType getChartType()
Returns:
the chartType

setChartData

public void setChartData(java.util.List<java.util.List<java.lang.Double>> chartData)
Parameters:
chartData - the chartData to set

getChartData

public java.util.List<java.util.List<java.lang.Double>> getChartData()
Returns:
the chartData

setChartDataScale

public void setChartDataScale(java.util.List<java.util.List<java.lang.Double>> chartDataScale)
Parameters:
chartDataScale - the chartDataScale to set

getChartDataScale

public java.util.List<java.util.List<java.lang.Double>> getChartDataScale()
Returns:
the chartDataScale

getColors

public java.util.List<java.lang.String> getColors()
Returns:
the color list.

addColor

public void addColor(java.lang.String color)
add the color to color list.

Parameters:
color - String that represent the color in format RRGGBB.

addColor

public void addColor(java.awt.Color color)
add the color to color list.

Parameters:
color - the Color to add.

setTitle

public void setTitle(java.lang.String title)
Parameters:
title - the title to set

getTitle

public java.lang.String getTitle()
Returns:
the title

addAxisLabel

public void addAxisLabel(java.lang.String type)
add a label with default label values.

Parameters:
type - axis label type, either x, t, y, or r.

addAxisLabel

public void addAxisLabel(java.lang.String type,
                         java.util.List<java.lang.String> labels,
                         java.lang.String color)
add a label with given label values.

Parameters:
type - axis label type, either x, t, y, or r.
labels - the given label values.
color - the axis color.

addAxisRange

public void addAxisRange(java.lang.String type,
                         java.util.List<java.lang.Double> range,
                         java.lang.String color)
add a label with given label range.

Parameters:
type - axis label type, either x, t, y, or r.
range - the given range.
color - the axis color.

addLineStyle

public void addLineStyle(double thickness,
                         double lineLength,
                         double blankLength)
add a line style with the given parameters.

Parameters:
thickness - thickness of the line.
lineLength - length of the line segment.
blankLength - length of the blank segment.

isYAxisEmpty

public boolean isYAxisEmpty()
Returns:
true if no Y axis in this chart yet.

getChartMarker

public java.util.List<java.lang.String> getChartMarker()
Returns:
the chartMarker

getChartLegend

public java.util.List<java.lang.String> getChartLegend()
Returns:
the chartLegend

getRandomColor

public static java.lang.String getRandomColor()
Returns:
a random color in format of RRGGBB.

getRandomMarker

public static java.lang.String getRandomMarker()
Returns:
a random marker.

setMarkerColors

public void setMarkerColors(java.util.List<java.lang.String> markerColors)
Parameters:
markerColors - the markerColors to set

getMarkerColors

public java.util.List<java.lang.String> getMarkerColors()
Returns:
the markerColors

setBarChartSize

public void setBarChartSize(int barHeight,
                            int groupSpace,
                            int barSpace)
Set the size of the bar chart.

Parameters:
barHeight - the height or width of the bar.
groupSpace - the space between groups.
barSpace - the space between bars in a group.

setBackgroundColor

public void setBackgroundColor(java.lang.String backgroundColor)
Parameters:
backgroundColor - the backgroundColor to set

getBackgroundColor

public java.lang.String getBackgroundColor()
Returns:
the backgroundColor

getNextJetColor

public static java.lang.String getNextJetColor()
Returns:
a random color in format of RRGGBB.