org.cafesip.gwtcomp.client.ui.charting
Class LiveDataPanel

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Panel
              extended by com.google.gwt.user.client.ui.ComplexPanel
                  extended by com.google.gwt.user.client.ui.FlowPanel
                      extended by org.cafesip.gwtcomp.client.ui.charting.LiveDataPanel
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.IndexedPanel, java.lang.Iterable<com.google.gwt.user.client.ui.Widget>

public class LiveDataPanel
extends com.google.gwt.user.client.ui.FlowPanel

Enables GWT application to display live data in the form of charts and tables. The chart display dynamic data that is updated from the server side at a pre-defined intervals. Such panels are useful for displaying changing information such as stock values, temperature, etc. In order to display live charts, GWT applications have to instantiate an object of this type and add it to a panel of the GWT application you are developing. In addition, you need to provide a server-side class that contains the logic to provides the chart configuration and the data needed to populate the chart periodically. The GWTCOMP server-side framework will instantiate this class and invoke methods on this class periodically to fetch the data. The fetched data is then transferred to the client-side which displays the data on the panel. Note that the communication between the client and the server components is transparent and your application will not have to deal with it. The data source class must implement the LiveDataSource interface or extend a convenience class like SimpleLiveDataSource (more such classes will be added in future releases). A GWT application may contain multiple live data panels. Each data panel is identified by there parameters:

  1. identifier - may be used to identify the type of chart, For example - "STOCKS". You application may have multiple identifiers like "STOCKS", "BONDS", "FUTURES", etc.
  2. instance - may be used to identify a specific instance. For example - "STOCKS-US".
  3. param - an additional parameter to specify additional parameters. For example - "GOOG, MSFT"
When the data source is invoked by the GWTCOMP framework, these parameters are passed to the method being invoked. You application can use these parameters to locate the data from a database or other data sources.

In order for this to work, you will need to add the following elements to the web.xml file for your application:

  <servlet>
  <servlet-name>LiveDataService</servlet-name>
  <servlet-class>
  org.cafesip.gwtcomp.server.LiveDataServiceImpl
  </servlet-class>
  <init-param>
  <param-name>data-source-class</param-name>
  <param-value>org.cafesip.gwtcomp.examples.server.LiveDataSourceSample</param-value>
  </init-param>
  </servlet>
 
  <servlet-mapping>
  <servlet-name>LiveDataService</servlet-name>
  <url-pattern>/gwtcomp/liveDataService</url-pattern>
  </servlet-mapping>
 
 
Replace the value of the init-param, data-source-class with the fully qualified class name of your data source class. This class must be present in the server package.

The following jars must be present in your classpath in order to compile the client-side of the GWT application. These jars must be in the classpath regardless of whether you are using LiveDataPanel or not because of the way the GWT compiler works.

Examples:

CSS Style Rules:

Screen-Shots:


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 double GOLDEN_RATIO
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
LiveDataPanel(java.lang.String identifier, java.lang.String instance, java.lang.String param)
          A constructor for this class.
LiveDataPanel(java.lang.String identifier, java.lang.String instance, java.lang.String param, int width)
          A constructor for this class.
LiveDataPanel(java.lang.String identifier, java.lang.String instance, java.lang.String param, int width, int height)
          A constructor for this class.
 
Method Summary
 TimeSeriesChartPanel getChartPanel()
           
 java.lang.String getIdentifier()
           
 java.lang.String getParam()
           
protected  void onAttach()
           
protected  void onDetach()
           
 void setChartPanel(TimeSeriesChartPanel chartPanel)
           
 void setIdentifier(java.lang.String identifier)
           
 void setParam(java.lang.String param)
           
 void startRefresh()
          Start (restart) screen refresh.
 void stopRefresh()
          Stop refreshing the screen with new data.
 
Methods inherited from class com.google.gwt.user.client.ui.FlowPanel
add, insert
 
Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel
add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, insert, insert, iterator, remove, remove
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
adopt, adopt, clear, disown, doAttachChildren, doDetachChildren, onLoad, onUnload, orphan
 
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, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GOLDEN_RATIO

public static final double GOLDEN_RATIO
See Also:
Constant Field Values
Constructor Detail

LiveDataPanel

public LiveDataPanel(java.lang.String identifier,
                     java.lang.String instance,
                     java.lang.String param)
A constructor for this class.

Parameters:
identifier - see above
instance - see above
param - see above

LiveDataPanel

public LiveDataPanel(java.lang.String identifier,
                     java.lang.String instance,
                     java.lang.String param,
                     int width,
                     int height)
A constructor for this class.

Parameters:
identifier - see above
instance - see above
param - see above
width - width of the panel
height - height of the panel

LiveDataPanel

public LiveDataPanel(java.lang.String identifier,
                     java.lang.String instance,
                     java.lang.String param,
                     int width)
A constructor for this class.

Parameters:
identifier - see above
instance - see above
param - see above
width - the width of the panel. The height is calculated using the GOLDEN_RATIO.
Method Detail

getIdentifier

public java.lang.String getIdentifier()
Returns:
Returns the identifier.

setIdentifier

public void setIdentifier(java.lang.String identifier)
Parameters:
identifier - The identifier to set.

getParam

public java.lang.String getParam()
Returns:
Returns the param.

setParam

public void setParam(java.lang.String param)
Parameters:
param - The param to set.

stopRefresh

public void stopRefresh()
Stop refreshing the screen with new data.


startRefresh

public void startRefresh()
Start (restart) screen refresh.


onDetach

protected void onDetach()
Overrides:
onDetach in class com.google.gwt.user.client.ui.Widget

onAttach

protected void onAttach()
Overrides:
onAttach in class com.google.gwt.user.client.ui.Widget

getChartPanel

public TimeSeriesChartPanel getChartPanel()
Returns:
Returns the chartPanel.

setChartPanel

public void setChartPanel(TimeSeriesChartPanel chartPanel)
Parameters:
chartPanel - The chartPanel to set.


http://www.cafesip.org