com.rednels.ofcgwt.client
Class ChartWidget

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.rednels.ofcgwt.client.ChartWidget
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, IChartData

public class ChartWidget
extends com.google.gwt.user.client.ui.Widget
implements IChartData

A gwt chart widget based on Open Flash Chart.

Create the ChartWidget and add anywhere a GWT widget can be used. Use ChartData.toString() to produce a JSON string that this chart widget uses via its setJsonData(String) method.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
static java.lang.String ALTERNATE_SWF_SRC
           
static java.lang.String BLANK_CHART_JSON_DATA
           
static java.lang.String MIN_PLAYER_VERSION
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
ChartWidget()
          Creates a new ChartWidget.
 
Method Summary
 void addChartListeners(IChartListener listener)
          Adds an IChartListener that implements the handleChartReadyEvent method
 java.lang.String addOnClickListener(IOnClickListener listener)
          Adds an IOnClickListener that implements the handleOnClickEvent method.
 java.lang.String getFlashUrl()
          Gets the current OFC flash URL.
 java.lang.String getHeight()
          Gets the objects height.
 java.lang.String getInnerDivTextForFlashPlayerNotFound()
          Gets the InnerDiv Text for when flash player is not found or can't be injected.
 java.lang.String getJsonData()
          Gets the current JSON data for this chart.
 java.lang.String getSwfId()
          Get the currently set swf ID of this chart widget
 java.lang.String getUrlPrefix()
           
 java.lang.String getWidth()
          Gets the objects width.
 boolean isCacheFixEnabled()
          Is the CacheFix Enabled?
 void notifyImageSaved()
          Notifies registered chart listeners that the image was saved
 void notifyOnClick(java.lang.String evt)
          Notifies registered chart listeners that the chart is ready
 void notifyReady()
          Notifies registered chart listeners that the chart is ready
 void removeChartListeners(IChartListener listener)
          Removes an IChartListener
 void saveJpgImagetoURL(java.lang.String url, boolean debug)
          Saves a JPG image of this chart and send the JPG to the url provided.
 void setCacheFixEnabled(boolean enable)
          Enables an fix/workaround that stops caching of the swf which on IE may solve some bugs.
 void setFlashUrl(java.lang.String url)
          Sets the OFC flash URL.
 void setHeight(java.lang.String height)
           
 void setInnerDivTextForFlashPlayerNotFound(java.lang.String divtext)
          Sets the InnerDiv Text for when flash player is not found or can't be injected.
 void setJsonData(java.lang.String json)
          Sets the JSON data for this chart & updates the chart if ready.
 void setUrlPrefix(java.lang.String urlPrefix)
          Sets the url prefix of the OFC flash swf file.
 void setWidth(java.lang.String width)
           
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onBrowserEvent, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setPixelSize, setSize, setStyleName, setStylePrimaryName, setTitle, setVisible, setVisible, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BLANK_CHART_JSON_DATA

public static final java.lang.String BLANK_CHART_JSON_DATA
See Also:
Constant Field Values

MIN_PLAYER_VERSION

public static final java.lang.String MIN_PLAYER_VERSION
See Also:
Constant Field Values

ALTERNATE_SWF_SRC

public static final java.lang.String ALTERNATE_SWF_SRC
See Also:
Constant Field Values
Constructor Detail

ChartWidget

public ChartWidget()
Creates a new ChartWidget. *

Method Detail

addChartListeners

public void addChartListeners(IChartListener listener)
Adds an IChartListener that implements the handleChartReadyEvent method

Parameters:
listener - an IChartListener

addOnClickListener

public java.lang.String addOnClickListener(IOnClickListener listener)
Adds an IOnClickListener that implements the handleOnClickEvent method.

Note: not really intended to be used directly - you must add the returned function signature to the JSON onClick event.

Easier Option: Use addOnClickListener within the models (such as Element/Pie.Slice etc) and this method will get function signature, register the event handler and add to JSON string.

Specified by:
addOnClickListener in interface IChartData
Parameters:
listener - an IChartListener
Returns:
function signature String

getFlashUrl

public java.lang.String getFlashUrl()
Gets the current OFC flash URL. Defaults to just "open-flash-chart.swf"

Returns:
the flashurl

getHeight

public java.lang.String getHeight()
Gets the objects height.

Returns:
height

getInnerDivTextForFlashPlayerNotFound

public java.lang.String getInnerDivTextForFlashPlayerNotFound()
Gets the InnerDiv Text for when flash player is not found or can't be injected.

Returns:
string

getJsonData

public java.lang.String getJsonData()
Gets the current JSON data for this chart.

Specified by:
getJsonData in interface IChartData
Returns:
a JSON string

getSwfId

public java.lang.String getSwfId()
Description copied from interface: IChartData
Get the currently set swf ID of this chart widget

Specified by:
getSwfId in interface IChartData
Returns:
the swfId

getUrlPrefix

public java.lang.String getUrlPrefix()
Returns:
the urlPrefix

getWidth

public java.lang.String getWidth()
Gets the objects width.

Returns:
width

isCacheFixEnabled

public boolean isCacheFixEnabled()
Is the CacheFix Enabled?

Returns:
true if cache fix is enabled, false if not

notifyImageSaved

public void notifyImageSaved()
Notifies registered chart listeners that the image was saved


notifyOnClick

public void notifyOnClick(java.lang.String evt)
Notifies registered chart listeners that the chart is ready

Specified by:
notifyOnClick in interface IChartData
Parameters:
evt - the event id String

notifyReady

public void notifyReady()
Notifies registered chart listeners that the chart is ready

Specified by:
notifyReady in interface IChartData

removeChartListeners

public void removeChartListeners(IChartListener listener)
Removes an IChartListener

Parameters:
listener - an IChartListener

saveJpgImagetoURL

public void saveJpgImagetoURL(java.lang.String url,
                              boolean debug)
Saves a JPG image of this chart and send the JPG to the url provided. Call does nothing if the required flash player is not loaded.

Parameters:
url - the url to call
debug - enable debug

setCacheFixEnabled

public void setCacheFixEnabled(boolean enable)
Enables an fix/workaround that stops caching of the swf which on IE may solve some bugs. The workaround adds a unique parameter url to each SWF making each chart widget non-cachable. On IE this feature is enabled by default, other agents it is disabled.

Enable this if you find problems in with multiple charts.

Parameters:
enable - - true to enable, false to disable

setFlashUrl

public void setFlashUrl(java.lang.String url)
Sets the OFC flash URL. ie "\path\open-flash-chart.swf"

Parameters:
url - string

setHeight

public void setHeight(java.lang.String height)
Overrides:
setHeight in class com.google.gwt.user.client.ui.UIObject

setInnerDivTextForFlashPlayerNotFound

public void setInnerDivTextForFlashPlayerNotFound(java.lang.String divtext)
Sets the InnerDiv Text for when flash player is not found or can't be injected.
Defaults to "FlashPlayer ${flashPlayer.version} is required."

Parameters:
divtext - a string

setJsonData

public void setJsonData(java.lang.String json)
Sets the JSON data for this chart & updates the chart if ready. Does nothing if the required flash player is not loaded.

Parameters:
json - a JSON string

setUrlPrefix

public void setUrlPrefix(java.lang.String urlPrefix)
Sets the url prefix of the OFC flash swf file. Defaults to the value of GWT.getModuleBaseURL()

Parameters:
urlPrefix - a URL string

setWidth

public void setWidth(java.lang.String width)
Overrides:
setWidth in class com.google.gwt.user.client.ui.UIObject