/*
* Copyright 2005 Joe Walker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsx3.chart;
import org.directwebremoting.ScriptBuffer;
import org.directwebremoting.ScriptSessions;
import org.directwebremoting.io.Context;
/**
* Class encapsulating behavior shared by PointSeries and BubbleSeries
* @author Joe Walker [joe at getahead dot org]
* @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
*/
public class PlotSeries extends jsx3.chart.Series
{
/**
* All reverse ajax proxies need context to work from
* @param context The script that got us to where we are now
*/
public PlotSeries(Context context, String extension)
{
super(context, extension);
}
/**
* The instance initializer.
* @param name the GI name of the instance
* @param seriesName the name of the Series, will be displayed in the Legend for most chart types
*/
public PlotSeries(String name, String seriesName)
{
super((Context) null, (String) null);
ScriptBuffer script = new ScriptBuffer();
script.appendCall("new PlotSeries", name, seriesName);
setInitScript(script);
}
/**
* Returns the x-coordinate of a data point in this series for the given record.
* @param record the <record/> node
*/
public void getXValue(jsx3.xml.Node record, org.directwebremoting.ui.Callback<Integer> callback)
{
ScriptBuffer script = new ScriptBuffer();
String callbackPrefix = "";
if (callback != null)
{
callbackPrefix = "var reply = ";
}
script.appendCall(callbackPrefix + getContextPath() + "getXValue", record);
if (callback != null)
{
String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, Integer.class);
script.appendCall("__System.activateCallback", key, "reply");
}
ScriptSessions.addScript(script);
}
/**
* Returns the y-coordinate of a data point in this series for the given record.
* @param record the <record/> node
*/
public void getYValue(jsx3.xml.Node record, org.directwebremoting.ui.Callback<Integer> callback)
{
ScriptBuffer script = new ScriptBuffer();
String callbackPrefix = "";
if (callback != null)
{
callbackPrefix = "var reply = ";
}
script.appendCall(callbackPrefix + getContextPath() + "getYValue", record);
if (callback != null)
{
String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, Integer.class);
script.appendCall("__System.activateCallback", key, "reply");
}
ScriptSessions.addScript(script);
}
/**
* Returns the xField field.
* @param callback xField
*/
public void getXField(org.directwebremoting.ui.Callback<String> callback)
{
ScriptBuffer script = new ScriptBuffer();
String callbackPrefix = "";
if (callback != null)
{
callbackPrefix = "var reply = ";
}
script.appendCall(callbackPrefix + getContextPath() + "getXField");
if (callback != null)
{
String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, String.class);
script.appendCall("__System.activateCallback", key, "reply");
}
ScriptSessions.addScript(script);
}
/**
* Sets the xField field.
* @param xField the new value for xField
*/
public void setXField(String xField)
{
ScriptBuffer script = new ScriptBuffer();
script.appendCall(getContextPath() + "setXField", xField);
ScriptSessions.addScript(script);
}
/**
* Returns the yField field.
* @param callback yField
*/
public void getYField(org.directwebremoting.ui.Callback<String> callback)
{
ScriptBuffer script = new ScriptBuffer();
String callbackPrefix = "";
if (callback != null)
{
callbackPrefix = "var reply = ";
}
script.appendCall(callbackPrefix + getContextPath() + "getYField");
if (callback != null)
{
String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, String.class);
script.appendCall("__System.activateCallback", key, "reply");
}
ScriptSessions.addScript(script);
}
/**
* Sets the yField field.
* @param yField the new value for yField
*/
public void setYField(String yField)
{
ScriptBuffer script = new ScriptBuffer();
script.appendCall(getContextPath() + "setYField", yField);
ScriptSessions.addScript(script);
}
/**
* Returns the renderer field.
* @return renderer
*/
public jsx3.chart.PointRenderer getRenderer()
{
String extension = "getRenderer().";
try
{
java.lang.reflect.Constructor<jsx3.chart.PointRenderer> ctor = jsx3.chart.PointRenderer.class.getConstructor(Context.class, String.class);
return ctor.newInstance(this, extension);
}
catch (Exception ex)
{
throw new IllegalArgumentException("Unsupported type: " + jsx3.chart.PointRenderer.class.getName());
}
}
/**
* Sets the renderer field.
* @param renderer the new value for renderer
*/
public void setRenderer(String renderer)
{
ScriptBuffer script = new ScriptBuffer();
script.appendCall(getContextPath() + "setRenderer", renderer);
ScriptSessions.addScript(script);
}
/**
* Returns the renderer used for the legend.
* @return the same renderer as used to draw the points
*/
public jsx3.chart.PointRenderer getLegendRenderer()
{
String extension = "getLegendRenderer().";
try
{
java.lang.reflect.Constructor<jsx3.chart.PointRenderer> ctor = jsx3.chart.PointRenderer.class.getConstructor(Context.class, String.class);
return ctor.newInstance(this, extension);
}
catch (Exception ex)
{
throw new IllegalArgumentException("Unsupported type: " + jsx3.chart.PointRenderer.class.getName());
}
}
}