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.BubbleChart. A bubble 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: magnitudeField - the attribute of a record to use as the magnitude of points in the series, required
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 BubbleSeries 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 BubbleSeries(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 BubbleSeries(String name, String seriesName) {
048: super ((Context) null, (String) null, (ScriptProxy) null);
049: ScriptBuffer script = new ScriptBuffer();
050: script.appendCall("new BubbleSeries", name, seriesName);
051: setInitScript(script);
052: }
053:
054: /**
055: * The default tooltip function for this type of series.
056: * @param series
057: * @param record
058: */
059: @SuppressWarnings("unchecked")
060: public void tooltip(jsx3.chart.Series series, jsx3.xml.Node record,
061: org.directwebremoting.proxy.Callback<String> callback) {
062: ScriptBuffer script = new ScriptBuffer();
063: String callbackPrefix = "";
064:
065: if (callback != null) {
066: callbackPrefix = "var reply = ";
067: }
068:
069: script.appendCall(
070: callbackPrefix + getContextPath() + "tooltip", series,
071: record);
072:
073: if (callback != null) {
074: String key = org.directwebremoting.extend.CallbackHelper
075: .saveCallback(callback, String.class);
076: script
077: .appendCall("__System.activateCallback", key,
078: "reply");
079: }
080:
081: getScriptProxy().addScript(script);
082: }
083:
084: /**
085: * Returns the magnitudeField field.
086: * @param callback magnitudeField
087: */
088: @SuppressWarnings("unchecked")
089: public void getMagnitudeField(
090: org.directwebremoting.proxy.Callback<String> callback) {
091: ScriptBuffer script = new ScriptBuffer();
092: String callbackPrefix = "";
093:
094: if (callback != null) {
095: callbackPrefix = "var reply = ";
096: }
097:
098: script.appendCall(callbackPrefix + getContextPath()
099: + "getMagnitudeField");
100:
101: if (callback != null) {
102: String key = org.directwebremoting.extend.CallbackHelper
103: .saveCallback(callback, String.class);
104: script
105: .appendCall("__System.activateCallback", key,
106: "reply");
107: }
108:
109: getScriptProxy().addScript(script);
110: }
111:
112: /**
113: * Sets the magnitudeField field.
114: * @param magnitudeField the new value for magnitudeField
115: */
116: public void setMagnitudeField(String magnitudeField) {
117: ScriptBuffer script = new ScriptBuffer();
118: script.appendCall(getContextPath() + "setMagnitudeField",
119: magnitudeField);
120: getScriptProxy().addScript(script);
121: }
122:
123: /**
124: * Returns the magnitude of a data point in this series for the given record.
125: * @param record the <record/> node
126: */
127: @SuppressWarnings("unchecked")
128: public void getMagnitudeValue(jsx3.xml.Node record,
129: org.directwebremoting.proxy.Callback<Integer> callback) {
130: ScriptBuffer script = new ScriptBuffer();
131: String callbackPrefix = "";
132:
133: if (callback != null) {
134: callbackPrefix = "var reply = ";
135: }
136:
137: script.appendCall(callbackPrefix + getContextPath()
138: + "getMagnitudeValue", record);
139:
140: if (callback != null) {
141: String key = org.directwebremoting.extend.CallbackHelper
142: .saveCallback(callback, Integer.class);
143: script
144: .appendCall("__System.activateCallback", key,
145: "reply");
146: }
147:
148: getScriptProxy().addScript(script);
149: }
150:
151: }
|