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: * Shared functionality between BarSeries and ColumnSeries.
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class BCSeries extends jsx3.chart.Series {
028: /**
029: * All reverse ajax proxies need context to work from
030: * @param scriptProxy The place we are writing scripts to
031: * @param context The script that got us to where we are now
032: */
033: public BCSeries(Context context, String extension,
034: ScriptProxy scriptProxy) {
035: super (context, extension, scriptProxy);
036: }
037:
038: /**
039: * The instance initializer.
040: * @param name the GI name of the instance
041: * @param seriesName the name of the Series, will be displayed in the Legend for most chart types
042: */
043: public BCSeries(String name, String seriesName) {
044: super ((Context) null, (String) null, (ScriptProxy) null);
045: ScriptBuffer script = new ScriptBuffer();
046: script.appendCall("new BCSeries", name, seriesName);
047: setInitScript(script);
048: }
049:
050: /**
051: * Returns the x-coordinate of a data point in this series for the given record.
052: * @param record the <record/> node
053: */
054: @SuppressWarnings("unchecked")
055: public void getXValue(jsx3.xml.Node record,
056: org.directwebremoting.proxy.Callback<Integer> callback) {
057: ScriptBuffer script = new ScriptBuffer();
058: String callbackPrefix = "";
059:
060: if (callback != null) {
061: callbackPrefix = "var reply = ";
062: }
063:
064: script.appendCall(callbackPrefix + getContextPath()
065: + "getXValue", record);
066:
067: if (callback != null) {
068: String key = org.directwebremoting.extend.CallbackHelper
069: .saveCallback(callback, Integer.class);
070: script
071: .appendCall("__System.activateCallback", key,
072: "reply");
073: }
074:
075: getScriptProxy().addScript(script);
076: }
077:
078: /**
079: * Returns the y-coordinate of a data point in this series for the given record.
080: * @param record the <record/> node
081: */
082: @SuppressWarnings("unchecked")
083: public void getYValue(jsx3.xml.Node record,
084: org.directwebremoting.proxy.Callback<Integer> callback) {
085: ScriptBuffer script = new ScriptBuffer();
086: String callbackPrefix = "";
087:
088: if (callback != null) {
089: callbackPrefix = "var reply = ";
090: }
091:
092: script.appendCall(callbackPrefix + getContextPath()
093: + "getYValue", record);
094:
095: if (callback != null) {
096: String key = org.directwebremoting.extend.CallbackHelper
097: .saveCallback(callback, Integer.class);
098: script
099: .appendCall("__System.activateCallback", key,
100: "reply");
101: }
102:
103: getScriptProxy().addScript(script);
104: }
105:
106: /**
107: * Returns the minimum value (x or y) of a data point in this series for the given record.
108: * @param record the <record/> node
109: */
110: @SuppressWarnings("unchecked")
111: public void getMinValue(jsx3.xml.Node record,
112: org.directwebremoting.proxy.Callback<Integer> callback) {
113: ScriptBuffer script = new ScriptBuffer();
114: String callbackPrefix = "";
115:
116: if (callback != null) {
117: callbackPrefix = "var reply = ";
118: }
119:
120: script.appendCall(callbackPrefix + getContextPath()
121: + "getMinValue", record);
122:
123: if (callback != null) {
124: String key = org.directwebremoting.extend.CallbackHelper
125: .saveCallback(callback, Integer.class);
126: script
127: .appendCall("__System.activateCallback", key,
128: "reply");
129: }
130:
131: getScriptProxy().addScript(script);
132: }
133:
134: /**
135: * Returns the xField field.
136: * @param callback xField
137: */
138: @SuppressWarnings("unchecked")
139: public void getXField(
140: org.directwebremoting.proxy.Callback<String> callback) {
141: ScriptBuffer script = new ScriptBuffer();
142: String callbackPrefix = "";
143:
144: if (callback != null) {
145: callbackPrefix = "var reply = ";
146: }
147:
148: script.appendCall(callbackPrefix + getContextPath()
149: + "getXField");
150:
151: if (callback != null) {
152: String key = org.directwebremoting.extend.CallbackHelper
153: .saveCallback(callback, String.class);
154: script
155: .appendCall("__System.activateCallback", key,
156: "reply");
157: }
158:
159: getScriptProxy().addScript(script);
160: }
161:
162: /**
163: * Sets the xField field.
164: * @param xField the new value for xField
165: */
166: public void setXField(String xField) {
167: ScriptBuffer script = new ScriptBuffer();
168: script.appendCall(getContextPath() + "setXField", xField);
169: getScriptProxy().addScript(script);
170: }
171:
172: /**
173: * Returns the yField field.
174: * @param callback yField
175: */
176: @SuppressWarnings("unchecked")
177: public void getYField(
178: org.directwebremoting.proxy.Callback<String> callback) {
179: ScriptBuffer script = new ScriptBuffer();
180: String callbackPrefix = "";
181:
182: if (callback != null) {
183: callbackPrefix = "var reply = ";
184: }
185:
186: script.appendCall(callbackPrefix + getContextPath()
187: + "getYField");
188:
189: if (callback != null) {
190: String key = org.directwebremoting.extend.CallbackHelper
191: .saveCallback(callback, String.class);
192: script
193: .appendCall("__System.activateCallback", key,
194: "reply");
195: }
196:
197: getScriptProxy().addScript(script);
198: }
199:
200: /**
201: * Sets the yField field.
202: * @param yField the new value for yField
203: */
204: public void setYField(String yField) {
205: ScriptBuffer script = new ScriptBuffer();
206: script.appendCall(getContextPath() + "setYField", yField);
207: getScriptProxy().addScript(script);
208: }
209:
210: /**
211: * Returns the minField field.
212: * @param callback minField
213: */
214: @SuppressWarnings("unchecked")
215: public void getMinField(
216: org.directwebremoting.proxy.Callback<String> callback) {
217: ScriptBuffer script = new ScriptBuffer();
218: String callbackPrefix = "";
219:
220: if (callback != null) {
221: callbackPrefix = "var reply = ";
222: }
223:
224: script.appendCall(callbackPrefix + getContextPath()
225: + "getMinField");
226:
227: if (callback != null) {
228: String key = org.directwebremoting.extend.CallbackHelper
229: .saveCallback(callback, String.class);
230: script
231: .appendCall("__System.activateCallback", key,
232: "reply");
233: }
234:
235: getScriptProxy().addScript(script);
236: }
237:
238: /**
239: * Sets the minField field.
240: * @param minField the new value for minField
241: */
242: public void setMinField(String minField) {
243: ScriptBuffer script = new ScriptBuffer();
244: script.appendCall(getContextPath() + "setMinField", minField);
245: getScriptProxy().addScript(script);
246: }
247:
248: }
|