org.cafesip.gwtcomp.client.ui.charting
Class LiveDataPanel
java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Panel
com.google.gwt.user.client.ui.ComplexPanel
com.google.gwt.user.client.ui.FlowPanel
org.cafesip.gwtcomp.client.ui.charting.LiveDataPanel
- All Implemented Interfaces:
- HasHandlers, EventListener, HasWidgets, IndexedPanel, InsertPanel, Iterable<Widget>
public class LiveDataPanel
- extends 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(es) that contain the logic to provide the
chart configurations and the data needed to populate the charts periodically.
Each class handles a single chart that is identified by a context (see
below). The GWTCOMP server-side framework will instantiate these classes and
invoke methods on them periodically to fetch the data. The fetched data is
then transferred to the client-side which displays the data on the panels.
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 classes 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:
- context - may be used to identify the type of chart, For example -
"STOCKS". You application may have multiple contexts like "STOCKS", "BONDS",
"FUTURES", etc. As explained above, you can provide a data source for every
context.
- instance - may be used to identify a specific instance. For example -
"STOCKS-US".
- 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-contextName</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>
Note the use of the parameter data-source-class-contextName. Replace the
contextName with the name of the context. This is the context that you will
specify in the constructor parameters. In addition, 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 classpath. You
can have multiple data-source-class-contextName init parameters, one for each
context. In addition, you can add an init parameter data-source-class (no
context) to specify the default data source class. When the GWTCOMP server
side receives a request with an context that is not specified in the web.xml,
it lets the default data source class handle the request.
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.
CSS Style Rules:
- .gwtcomp-LiveDataPanel { } - style for the LiveDataPanel
Screen-Shots:
- Author:
- Amit Chatterjee
| 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.Widget |
addDomHandler, addHandler, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, removeFromParent, setLayoutData, sinkEvents |
| 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, toString, unsinkEvents |
GOLDEN_RATIO
public static final double GOLDEN_RATIO
- See Also:
- Constant Field Values
LiveDataPanel
public LiveDataPanel(String context,
String instance,
String param)
- A constructor for this class.
- Parameters:
context - see aboveinstance - see aboveparam - see above
LiveDataPanel
public LiveDataPanel(String context,
String instance,
String param,
int width,
int height)
- A constructor for this class.
- Parameters:
context - see aboveinstance - see aboveparam - see abovewidth - width of the panelheight - height of the panel
LiveDataPanel
public LiveDataPanel(String context,
String instance,
String param,
int width)
- A constructor for this class.
- Parameters:
context - see aboveinstance - see aboveparam - see abovewidth - the width of the panel. The height is calculated using the
GOLDEN_RATIO.
getContext
public String getContext()
- Returns:
- Returns the context.
setContext
public void setContext(String context)
- Parameters:
context - The context to set.
getParam
public String getParam()
- Returns:
- Returns the param.
setParam
public void setParam(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 Widget
onAttach
protected void onAttach()
- Overrides:
onAttach in class Widget
getChartPanel
public TimeSeriesChartPanel getChartPanel()
- Returns:
- Returns the chartPanel.
setChartPanel
public void setChartPanel(TimeSeriesChartPanel chartPanel)
- Parameters:
chartPanel - The chartPanel to set.
Copyright © 2010 Cafesip.org. All Rights Reserved.