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 for a line chart. An line series draws a set of points connected by a line.
024: A line series has the following properties:
025:
026: xField the attribute of a record to use as the x-coordinate of points in the series, required if
027: the x-axis is a value axis
028: yField the attribute of a record to use as the y-coordinate of points in the series, required
029: form defines how the area is drawn, one of {'segment','step','reverseStep','horizontal','vertical'},
030: defaults to 'segment'
031: interpolateValues if true the the line will be continuous even over missing data points, if false the
032: the line will break over missing data points
033: pointRadius the radius of the points to render at each data point on the line, optional
034: pointRenderer string that evals to an object that implements the renderer interface, optional
035: pointFill string representation of a vector fill for the points
036: pointStroke string representation of a VectorStroke for the points
037: pointGradient string representation of a vector fill gradient for the points
038: * @author Joe Walker [joe at getahead dot org]
039: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
040: */
041: public class LineSeries extends jsx3.chart.Series {
042: /**
043: * All reverse ajax proxies need context to work from
044: * @param scriptProxy The place we are writing scripts to
045: * @param context The script that got us to where we are now
046: */
047: public LineSeries(Context context, String extension,
048: ScriptProxy scriptProxy) {
049: super (context, extension, scriptProxy);
050: }
051:
052: /**
053: * The instance initializer.
054: * @param name the GI name of the instance
055: * @param seriesName the name of the Series, will be displayed in the Legend for most chart types
056: */
057: public LineSeries(String name, String seriesName) {
058: super ((Context) null, (String) null, (ScriptProxy) null);
059: ScriptBuffer script = new ScriptBuffer();
060: script.appendCall("new LineSeries", name, seriesName);
061: setInitScript(script);
062: }
063:
064: /**
065: *
066: */
067: public static final String FORM_SEGMENT = "segment";
068:
069: /**
070: *
071: */
072: public static final String FORM_STEP = "step";
073:
074: /**
075: *
076: */
077: public static final String FORM_REVSTEP = "reverseStep";
078:
079: /**
080: *
081: */
082: public static final String FORM_HORIZONTAL = "horizontal";
083:
084: /**
085: *
086: */
087: public static final String FORM_VERTICAL = "vertical";
088:
089: /**
090: * Returns the xField field.
091: * @param callback xField
092: */
093: @SuppressWarnings("unchecked")
094: public void getXField(
095: org.directwebremoting.proxy.Callback<String> callback) {
096: ScriptBuffer script = new ScriptBuffer();
097: String callbackPrefix = "";
098:
099: if (callback != null) {
100: callbackPrefix = "var reply = ";
101: }
102:
103: script.appendCall(callbackPrefix + getContextPath()
104: + "getXField");
105:
106: if (callback != null) {
107: String key = org.directwebremoting.extend.CallbackHelper
108: .saveCallback(callback, String.class);
109: script
110: .appendCall("__System.activateCallback", key,
111: "reply");
112: }
113:
114: getScriptProxy().addScript(script);
115: }
116:
117: /**
118: * Sets the xField field.
119: * @param xField the new value for xField
120: */
121: public void setXField(String xField) {
122: ScriptBuffer script = new ScriptBuffer();
123: script.appendCall(getContextPath() + "setXField", xField);
124: getScriptProxy().addScript(script);
125: }
126:
127: /**
128: * Returns the yField field.
129: * @param callback yField
130: */
131: @SuppressWarnings("unchecked")
132: public void getYField(
133: org.directwebremoting.proxy.Callback<String> callback) {
134: ScriptBuffer script = new ScriptBuffer();
135: String callbackPrefix = "";
136:
137: if (callback != null) {
138: callbackPrefix = "var reply = ";
139: }
140:
141: script.appendCall(callbackPrefix + getContextPath()
142: + "getYField");
143:
144: if (callback != null) {
145: String key = org.directwebremoting.extend.CallbackHelper
146: .saveCallback(callback, String.class);
147: script
148: .appendCall("__System.activateCallback", key,
149: "reply");
150: }
151:
152: getScriptProxy().addScript(script);
153: }
154:
155: /**
156: * Sets the yField field.
157: * @param yField the new value for yField
158: */
159: public void setYField(String yField) {
160: ScriptBuffer script = new ScriptBuffer();
161: script.appendCall(getContextPath() + "setYField", yField);
162: getScriptProxy().addScript(script);
163: }
164:
165: /**
166: * Returns the form field.
167: * @param callback form
168: */
169: @SuppressWarnings("unchecked")
170: public void getForm(
171: org.directwebremoting.proxy.Callback<String> callback) {
172: ScriptBuffer script = new ScriptBuffer();
173: String callbackPrefix = "";
174:
175: if (callback != null) {
176: callbackPrefix = "var reply = ";
177: }
178:
179: script
180: .appendCall(callbackPrefix + getContextPath()
181: + "getForm");
182:
183: if (callback != null) {
184: String key = org.directwebremoting.extend.CallbackHelper
185: .saveCallback(callback, String.class);
186: script
187: .appendCall("__System.activateCallback", key,
188: "reply");
189: }
190:
191: getScriptProxy().addScript(script);
192: }
193:
194: /**
195: * Sets the form field, checks for valid value.
196: * @param form the new value for form, one of {'segment','step','reverseStep','horizontal','vertical'}
197: */
198: public void setForm(String form) {
199: ScriptBuffer script = new ScriptBuffer();
200: script.appendCall(getContextPath() + "setForm", form);
201: getScriptProxy().addScript(script);
202: }
203:
204: /**
205: * Returns the interpolateValues field.
206: * @param callback interpolateValues
207: */
208: @SuppressWarnings("unchecked")
209: public void getInterpolateValues(
210: org.directwebremoting.proxy.Callback<Boolean> callback) {
211: ScriptBuffer script = new ScriptBuffer();
212: String callbackPrefix = "";
213:
214: if (callback != null) {
215: callbackPrefix = "var reply = ";
216: }
217:
218: script.appendCall(callbackPrefix + getContextPath()
219: + "getInterpolateValues");
220:
221: if (callback != null) {
222: String key = org.directwebremoting.extend.CallbackHelper
223: .saveCallback(callback, Boolean.class);
224: script
225: .appendCall("__System.activateCallback", key,
226: "reply");
227: }
228:
229: getScriptProxy().addScript(script);
230: }
231:
232: /**
233: * Sets the interpolateValues field.
234: * @param interpolateValues the new value for interpolateValues
235: */
236: public void setInterpolateValues(boolean interpolateValues) {
237: ScriptBuffer script = new ScriptBuffer();
238: script.appendCall(getContextPath() + "setInterpolateValues",
239: interpolateValues);
240: getScriptProxy().addScript(script);
241: }
242:
243: /**
244: * Returns the pointRadius field.
245: * @param callback pointRadius
246: */
247: @SuppressWarnings("unchecked")
248: public void getPointRadius(
249: org.directwebremoting.proxy.Callback<Integer> callback) {
250: ScriptBuffer script = new ScriptBuffer();
251: String callbackPrefix = "";
252:
253: if (callback != null) {
254: callbackPrefix = "var reply = ";
255: }
256:
257: script.appendCall(callbackPrefix + getContextPath()
258: + "getPointRadius");
259:
260: if (callback != null) {
261: String key = org.directwebremoting.extend.CallbackHelper
262: .saveCallback(callback, Integer.class);
263: script
264: .appendCall("__System.activateCallback", key,
265: "reply");
266: }
267:
268: getScriptProxy().addScript(script);
269: }
270:
271: /**
272: * Sets the pointRadius field.
273: * @param pointRadius the new value for pointRadius
274: */
275: public void setPointRadius(int pointRadius) {
276: ScriptBuffer script = new ScriptBuffer();
277: script.appendCall(getContextPath() + "setPointRadius",
278: pointRadius);
279: getScriptProxy().addScript(script);
280: }
281:
282: /**
283: * Returns the pointRenderer field.
284: * @return pointRenderer
285: */
286: @SuppressWarnings("unchecked")
287: public jsx3.chart.PointRenderer getPointRenderer() {
288: String extension = "getPointRenderer().";
289: try {
290: java.lang.reflect.Constructor<jsx3.chart.PointRenderer> ctor = jsx3.chart.PointRenderer.class
291: .getConstructor(Context.class, String.class,
292: ScriptProxy.class);
293: return ctor.newInstance(this , extension, getScriptProxy());
294: } catch (Exception ex) {
295: throw new IllegalArgumentException("Unsupported type: "
296: + jsx3.chart.PointRenderer.class.getName());
297: }
298: }
299:
300: /**
301: * Sets the pointRenderer field, should eval to an object that implements the renderer interface.
302: * @param pointRenderer the new value for pointRenderer, as a string
303: */
304: public void setPointRenderer(String pointRenderer) {
305: ScriptBuffer script = new ScriptBuffer();
306: script.appendCall(getContextPath() + "setPointRenderer",
307: pointRenderer);
308: getScriptProxy().addScript(script);
309: }
310:
311: /**
312: * Returns the pointFill field.
313: * @param callback pointFill
314: */
315: @SuppressWarnings("unchecked")
316: public void getPointFill(
317: org.directwebremoting.proxy.Callback<String> callback) {
318: ScriptBuffer script = new ScriptBuffer();
319: String callbackPrefix = "";
320:
321: if (callback != null) {
322: callbackPrefix = "var reply = ";
323: }
324:
325: script.appendCall(callbackPrefix + getContextPath()
326: + "getPointFill");
327:
328: if (callback != null) {
329: String key = org.directwebremoting.extend.CallbackHelper
330: .saveCallback(callback, String.class);
331: script
332: .appendCall("__System.activateCallback", key,
333: "reply");
334: }
335:
336: getScriptProxy().addScript(script);
337: }
338:
339: /**
340: * Sets the pointFill field.
341: * @param pointFill the new value for pointFill
342: */
343: public void setPointFill(String pointFill) {
344: ScriptBuffer script = new ScriptBuffer();
345: script.appendCall(getContextPath() + "setPointFill", pointFill);
346: getScriptProxy().addScript(script);
347: }
348:
349: /**
350: * Returns the pointStroke field.
351: * @param callback pointStroke
352: */
353: @SuppressWarnings("unchecked")
354: public void getPointStroke(
355: org.directwebremoting.proxy.Callback<String> callback) {
356: ScriptBuffer script = new ScriptBuffer();
357: String callbackPrefix = "";
358:
359: if (callback != null) {
360: callbackPrefix = "var reply = ";
361: }
362:
363: script.appendCall(callbackPrefix + getContextPath()
364: + "getPointStroke");
365:
366: if (callback != null) {
367: String key = org.directwebremoting.extend.CallbackHelper
368: .saveCallback(callback, String.class);
369: script
370: .appendCall("__System.activateCallback", key,
371: "reply");
372: }
373:
374: getScriptProxy().addScript(script);
375: }
376:
377: /**
378: * Sets the pointStroke field.
379: * @param pointStroke the new value for pointStroke
380: */
381: public void setPointStroke(String pointStroke) {
382: ScriptBuffer script = new ScriptBuffer();
383: script.appendCall(getContextPath() + "setPointStroke",
384: pointStroke);
385: getScriptProxy().addScript(script);
386: }
387:
388: /**
389: * Returns the pointGradient field.
390: * @param callback pointGradient
391: */
392: @SuppressWarnings("unchecked")
393: public void getPointGradient(
394: org.directwebremoting.proxy.Callback<String> callback) {
395: ScriptBuffer script = new ScriptBuffer();
396: String callbackPrefix = "";
397:
398: if (callback != null) {
399: callbackPrefix = "var reply = ";
400: }
401:
402: script.appendCall(callbackPrefix + getContextPath()
403: + "getPointGradient");
404:
405: if (callback != null) {
406: String key = org.directwebremoting.extend.CallbackHelper
407: .saveCallback(callback, String.class);
408: script
409: .appendCall("__System.activateCallback", key,
410: "reply");
411: }
412:
413: getScriptProxy().addScript(script);
414: }
415:
416: /**
417: * Sets the pointGradient field.
418: * @param pointGradient the new value for pointGradient
419: */
420: public void setPointGradient(String pointGradient) {
421: ScriptBuffer script = new ScriptBuffer();
422: script.appendCall(getContextPath() + "setPointGradient",
423: pointGradient);
424: getScriptProxy().addScript(script);
425: }
426:
427: /**
428: * The default tooltip function for this type of series.
429: * @param series
430: * @param record
431: */
432: @SuppressWarnings("unchecked")
433: public void tooltip(jsx3.chart.Series series, jsx3.xml.Node record,
434: org.directwebremoting.proxy.Callback<String> callback) {
435: ScriptBuffer script = new ScriptBuffer();
436: String callbackPrefix = "";
437:
438: if (callback != null) {
439: callbackPrefix = "var reply = ";
440: }
441:
442: script.appendCall(
443: callbackPrefix + getContextPath() + "tooltip", series,
444: record);
445:
446: if (callback != null) {
447: String key = org.directwebremoting.extend.CallbackHelper
448: .saveCallback(callback, String.class);
449: script
450: .appendCall("__System.activateCallback", key,
451: "reply");
452: }
453:
454: getScriptProxy().addScript(script);
455: }
456:
457: }
|