001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package jsx3.chart;
017:
018: import org.directwebremoting.ScriptBuffer;
019: import org.directwebremoting.proxy.ScriptProxy;
020: import org.directwebremoting.proxy.io.Context;
021:
022: /**
023: * A data series used for a jsx3.chart.PointChart. A point series has the following fields:
024: xField - the attribute of a record to use as the x-coordinate of points in the series, required
025: yField - the attribute of a record to use as the y-coordinate of points in the series, required
026: magnitude - the magnitude of all the points in the series
027: pointRenderer - string that evals to an object that implements the renderer interface, optional
028: * @author Joe Walker [joe at getahead dot org]
029: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
030: */
031: public class PointSeries extends jsx3.chart.PlotSeries {
032: /**
033: * All reverse ajax proxies need context to work from
034: * @param scriptProxy The place we are writing scripts to
035: * @param context The script that got us to where we are now
036: */
037: public PointSeries(Context context, String extension,
038: ScriptProxy scriptProxy) {
039: super (context, extension, scriptProxy);
040: }
041:
042: /**
043: * The instance initializer.
044: * @param name the GI name of the instance
045: * @param seriesName the name of the Series, will be displayed in the Legend for most chart types
046: */
047: public PointSeries(String name, String seriesName) {
048: super ((Context) null, (String) null, (ScriptProxy) null);
049: ScriptBuffer script = new ScriptBuffer();
050: script.appendCall("new PointSeries", name, seriesName);
051: setInitScript(script);
052: }
053:
054: /**
055: *
056: */
057: public static final int DEFAULT_MAGNITUDE = 4;
058:
059: /**
060: * Returns the magnitude field, the magnitude value to use for each data point in this series.
061: * @param callback magnitude
062: */
063: @SuppressWarnings("unchecked")
064: public void getMagnitude(
065: org.directwebremoting.proxy.Callback<Integer> callback) {
066: ScriptBuffer script = new ScriptBuffer();
067: String callbackPrefix = "";
068:
069: if (callback != null) {
070: callbackPrefix = "var reply = ";
071: }
072:
073: script.appendCall(callbackPrefix + getContextPath()
074: + "getMagnitude");
075:
076: if (callback != null) {
077: String key = org.directwebremoting.extend.CallbackHelper
078: .saveCallback(callback, Integer.class);
079: script
080: .appendCall("__System.activateCallback", key,
081: "reply");
082: }
083:
084: getScriptProxy().addScript(script);
085: }
086:
087: /**
088: * Sets the magnitude field.
089: * @param magnitude the new value for magnitude
090: */
091: public void setMagnitude(int magnitude) {
092: ScriptBuffer script = new ScriptBuffer();
093: script.appendCall(getContextPath() + "setMagnitude", magnitude);
094: getScriptProxy().addScript(script);
095: }
096:
097: /**
098: * The default tooltip function for this type of series.
099: * @param series
100: * @param record
101: */
102: @SuppressWarnings("unchecked")
103: public void tooltip(jsx3.chart.Series series, jsx3.xml.Node record,
104: org.directwebremoting.proxy.Callback<String> callback) {
105: ScriptBuffer script = new ScriptBuffer();
106: String callbackPrefix = "";
107:
108: if (callback != null) {
109: callbackPrefix = "var reply = ";
110: }
111:
112: script.appendCall(
113: callbackPrefix + getContextPath() + "tooltip", series,
114: record);
115:
116: if (callback != null) {
117: String key = org.directwebremoting.extend.CallbackHelper
118: .saveCallback(callback, String.class);
119: script
120: .appendCall("__System.activateCallback", key,
121: "reply");
122: }
123:
124: getScriptProxy().addScript(script);
125: }
126:
127: }
|