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