net.sf.click.extras.graph
Class JSChart

java.lang.Object
  extended bynet.sf.click.control.AbstractControl
      extended bynet.sf.click.extras.graph.JSChart
All Implemented Interfaces:
Control, Serializable
Direct Known Subclasses:
JSBarChart, JSLineChart, JSPieChart

public abstract class JSChart
extends AbstractControl

Provides a abstract JavaScript Chart control.

Author:
Ahmed Mohombe, Malcolm Edgar
See Also:
Serialized Form

Field Summary
protected  int chartHeight
          Height of the DIV element that encloses this chart, default height 350 px.
protected  int chartWidth
          Width of the DIV element that encloses this chart, default width 380 px.
protected  String label
          The chart display label.
protected  List xLabels
          The list of X-Axis labels.
protected  List yValues
          The list of Y-Axis values.
 
Fields inherited from class net.sf.click.control.AbstractControl
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles
 
Fields inherited from interface net.sf.click.Control
CONTROL_MESSAGES
 
Constructor Summary
JSChart()
           
 
Method Summary
 void addPoint(int index, String pointLabel, Integer pointValue)
          Adds a "point" to the grapic/chart at a specified position in the list.
 void addPoint(String pointLabel, Integer pointValue)
          Adds a "point" to the grapic/chart at the end of the list.
 int getChartHeight()
          Return the height of the chart (the enclosing DIV element).
protected abstract  String[] getChartResources()
          Return the list of static chart resources to deploy.
 int getChartWidth()
          Return the width of the chart (the enclosing DIV element).
protected abstract  String getHtmlImportPattern()
          Return the HTML imports pattern string.
 String getHtmlImports()
          Return the HTML head import statements for the javascript files used by this control.
protected abstract  String getJSChartType()
          Return the JavaScript Chart type.
 String getLabel()
          Return the label of the chart.
 void onDeploy(ServletContext servletContext)
          Deploys the javascript files of this control to the [click/graph/jsgraph] directory.
 boolean onProcess()
          Returns true, as javascript charts perform no server side logic.
 void render(HtmlStringBuffer buffer)
          Render the HTML representation of the chart.
 void setChartHeight(int chartHeight)
          Set the height of the chart (of the enclosing DIV element), as a pixel value.
 void setChartWidth(int chartWidth)
          Set the width of the chart (of the enclosing DIV element), as a pixel value.
 void setLabel(String label)
          Set the chart display caption.
 void setListener(Object listener, String method)
          This method does nothing.
 String toString()
          Return the HTML rendered chart.
 
Methods inherited from class net.sf.click.control.AbstractControl
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getControlSizeEst, getId, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasStyles, onDestroy, onInit, onRender, registerActionEvent, removeStyleClass, renderTagBegin, renderTagEnd, setActionListener, setAttribute, setId, setName, setParent, setStyle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

chartHeight

protected int chartHeight
Height of the DIV element that encloses this chart, default height 350 px.


chartWidth

protected int chartWidth
Width of the DIV element that encloses this chart, default width 380 px.


label

protected String label
The chart display label.


xLabels

protected List xLabels
The list of X-Axis labels.


yValues

protected List yValues
The list of Y-Axis values.

Constructor Detail

JSChart

public JSChart()
Method Detail

addPoint

public void addPoint(String pointLabel,
                     Integer pointValue)
Adds a "point" to the grapic/chart at the end of the list.

Parameters:
pointLabel - the displayed label of the "point"
pointValue - the value of the "point".

addPoint

public void addPoint(int index,
                     String pointLabel,
                     Integer pointValue)
Adds a "point" to the grapic/chart at a specified position in the list.

Parameters:
index - index at which the specified point is to be inserted
pointLabel - the displayed label of the "point"
pointValue - the value of the "point".

getChartWidth

public int getChartWidth()
Return the width of the chart (the enclosing DIV element).

Returns:
the width of the chart

setChartWidth

public void setChartWidth(int chartWidth)
Set the width of the chart (of the enclosing DIV element), as a pixel value.

Parameters:
chartWidth - the chart width in pixels.

getChartHeight

public int getChartHeight()
Return the height of the chart (the enclosing DIV element).

Returns:
the height of the chart

setChartHeight

public void setChartHeight(int chartHeight)
Set the height of the chart (of the enclosing DIV element), as a pixel value.

Parameters:
chartHeight - the chart height in pixels.

getLabel

public String getLabel()
Return the label of the chart.

Returns:
the label of the chart

setLabel

public void setLabel(String label)
Set the chart display caption.

Parameters:
label - the display label of the chart

getHtmlImports

public String getHtmlImports()
Return the HTML head import statements for the javascript files used by this control.

Returns:
the HTML head import statements for the javascript files used by this control.
See Also:
Control.getHtmlImports()

setListener

public void setListener(Object listener,
                        String method)
This method does nothing.

Parameters:
listener - the listener object with the named method to invoke
method - the name of the method to invoke
See Also:
Control.setListener(Object, String)

render

public void render(HtmlStringBuffer buffer)
Render the HTML representation of the chart.

Parameters:
buffer - the specified buffer to render the control's output to
See Also:
toString()

toString

public String toString()
Return the HTML rendered chart.

Returns:
the HTML rendered chart string

onDeploy

public void onDeploy(ServletContext servletContext)
Deploys the javascript files of this control to the [click/graph/jsgraph] directory.

Parameters:
servletContext - the webapplication's servlet context
See Also:
Control.onDeploy(ServletContext)

onProcess

public boolean onProcess()
Returns true, as javascript charts perform no server side logic.

Returns:
true

getChartResources

protected abstract String[] getChartResources()
Return the list of static chart resources to deploy.

Returns:
the list of static chart resources to deploy

getHtmlImportPattern

protected abstract String getHtmlImportPattern()
Return the HTML imports pattern string.

Returns:
the HTML imports pattern string

getJSChartType

protected abstract String getJSChartType()
Return the JavaScript Chart type.

Returns:
the JavaScript Chart type