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: * Chart component that renders a simple legend. A legend may contain a list of series or a list of
024: categories, depending on the type of chart.
025: * @author Joe Walker [joe at getahead dot org]
026: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
027: */
028: public class Legend extends jsx3.chart.ChartComponent {
029: /**
030: * All reverse ajax proxies need context to work from
031: * @param scriptProxy The place we are writing scripts to
032: * @param context The script that got us to where we are now
033: */
034: public Legend(Context context, String extension,
035: ScriptProxy scriptProxy) {
036: super (context, extension, scriptProxy);
037: }
038:
039: /**
040: * The instance initializer.
041: * @param name the GI name of the instance
042: */
043: public Legend(String name) {
044: super ((Context) null, (String) null, (ScriptProxy) null);
045: ScriptBuffer script = new ScriptBuffer();
046: script.appendCall("new Legend", name);
047: setInitScript(script);
048: }
049:
050: /**
051: * the default width
052: */
053: public static final int DEFAULT_WIDTH = 100;
054:
055: /**
056: * the default height
057: */
058: public static final int DEFAULT_HEIGHT = 100;
059:
060: /**
061: * Returns the boxHeight field, the diameter of the box that shows the fill of each series or category.
062: * @param callback boxHeight
063: */
064: @SuppressWarnings("unchecked")
065: public void getBoxHeight(
066: org.directwebremoting.proxy.Callback<Integer> callback) {
067: ScriptBuffer script = new ScriptBuffer();
068: String callbackPrefix = "";
069:
070: if (callback != null) {
071: callbackPrefix = "var reply = ";
072: }
073:
074: script.appendCall(callbackPrefix + getContextPath()
075: + "getBoxHeight");
076:
077: if (callback != null) {
078: String key = org.directwebremoting.extend.CallbackHelper
079: .saveCallback(callback, Integer.class);
080: script
081: .appendCall("__System.activateCallback", key,
082: "reply");
083: }
084:
085: getScriptProxy().addScript(script);
086: }
087:
088: /**
089: * Sets the boxHeight field.
090: * @param boxHeight the new value for boxHeight
091: */
092: public void setBoxHeight(int boxHeight) {
093: ScriptBuffer script = new ScriptBuffer();
094: script.appendCall(getContextPath() + "setBoxHeight", boxHeight);
095: getScriptProxy().addScript(script);
096: }
097:
098: /**
099: * Returns the lineHeight field, the vertical space taken for each legend entry.
100: * @param callback lineHeight
101: */
102: @SuppressWarnings("unchecked")
103: public void getLineHeight(
104: org.directwebremoting.proxy.Callback<Integer> callback) {
105: ScriptBuffer script = new ScriptBuffer();
106: String callbackPrefix = "";
107:
108: if (callback != null) {
109: callbackPrefix = "var reply = ";
110: }
111:
112: script.appendCall(callbackPrefix + getContextPath()
113: + "getLineHeight");
114:
115: if (callback != null) {
116: String key = org.directwebremoting.extend.CallbackHelper
117: .saveCallback(callback, Integer.class);
118: script
119: .appendCall("__System.activateCallback", key,
120: "reply");
121: }
122:
123: getScriptProxy().addScript(script);
124: }
125:
126: /**
127: * Sets the lineHeight field.
128: * @param lineHeight the new value for lineHeight
129: */
130: public void setLineHeight(int lineHeight) {
131: ScriptBuffer script = new ScriptBuffer();
132: script.appendCall(getContextPath() + "setLineHeight",
133: lineHeight);
134: getScriptProxy().addScript(script);
135: }
136:
137: /**
138: * Returns the labelClass field, the CSS class name applied to the name of each series or category.
139: * @param callback labelClass
140: */
141: @SuppressWarnings("unchecked")
142: public void getLabelClass(
143: org.directwebremoting.proxy.Callback<String> callback) {
144: ScriptBuffer script = new ScriptBuffer();
145: String callbackPrefix = "";
146:
147: if (callback != null) {
148: callbackPrefix = "var reply = ";
149: }
150:
151: script.appendCall(callbackPrefix + getContextPath()
152: + "getLabelClass");
153:
154: if (callback != null) {
155: String key = org.directwebremoting.extend.CallbackHelper
156: .saveCallback(callback, String.class);
157: script
158: .appendCall("__System.activateCallback", key,
159: "reply");
160: }
161:
162: getScriptProxy().addScript(script);
163: }
164:
165: /**
166: * Sets the labelClass field.
167: * @param labelClass the new value for labelClass
168: */
169: public void setLabelClass(String labelClass) {
170: ScriptBuffer script = new ScriptBuffer();
171: script.appendCall(getContextPath() + "setLabelClass",
172: labelClass);
173: getScriptProxy().addScript(script);
174: }
175:
176: /**
177: * Returns the labelStyle field, a CSS style attribute applied to the name of each series or category, ie "font-family: Arial; font-size: 10px;".
178: * @param callback labelStyle
179: */
180: @SuppressWarnings("unchecked")
181: public void getLabelStyle(
182: org.directwebremoting.proxy.Callback<String> callback) {
183: ScriptBuffer script = new ScriptBuffer();
184: String callbackPrefix = "";
185:
186: if (callback != null) {
187: callbackPrefix = "var reply = ";
188: }
189:
190: script.appendCall(callbackPrefix + getContextPath()
191: + "getLabelStyle");
192:
193: if (callback != null) {
194: String key = org.directwebremoting.extend.CallbackHelper
195: .saveCallback(callback, String.class);
196: script
197: .appendCall("__System.activateCallback", key,
198: "reply");
199: }
200:
201: getScriptProxy().addScript(script);
202: }
203:
204: /**
205: * Sets the labelStyle field.
206: * @param labelStyle the new value for labelStyle
207: */
208: public void setLabelStyle(String labelStyle) {
209: ScriptBuffer script = new ScriptBuffer();
210: script.appendCall(getContextPath() + "setLabelStyle",
211: labelStyle);
212: getScriptProxy().addScript(script);
213: }
214:
215: /**
216: * Returns the backgroundFill field, a string representation of the vector fill used to color in the background of the legend.
217: * @param callback backgroundFill
218: */
219: @SuppressWarnings("unchecked")
220: public void getBackgroundFill(
221: org.directwebremoting.proxy.Callback<String> callback) {
222: ScriptBuffer script = new ScriptBuffer();
223: String callbackPrefix = "";
224:
225: if (callback != null) {
226: callbackPrefix = "var reply = ";
227: }
228:
229: script.appendCall(callbackPrefix + getContextPath()
230: + "getBackgroundFill");
231:
232: if (callback != null) {
233: String key = org.directwebremoting.extend.CallbackHelper
234: .saveCallback(callback, String.class);
235: script
236: .appendCall("__System.activateCallback", key,
237: "reply");
238: }
239:
240: getScriptProxy().addScript(script);
241: }
242:
243: /**
244: * Sets the backgroundFill field.
245: * @param backgroundFill the new value for backgroundFill
246: */
247: public void setBackgroundFill(String backgroundFill) {
248: ScriptBuffer script = new ScriptBuffer();
249: script.appendCall(getContextPath() + "setBackgroundFill",
250: backgroundFill);
251: getScriptProxy().addScript(script);
252: }
253:
254: /**
255: * Returns the backgroundStroke field, a string representation of the VectorStroke used to outline the legend.
256: * @param callback backgroundStroke
257: */
258: @SuppressWarnings("unchecked")
259: public void getBackgroundStroke(
260: org.directwebremoting.proxy.Callback<String> callback) {
261: ScriptBuffer script = new ScriptBuffer();
262: String callbackPrefix = "";
263:
264: if (callback != null) {
265: callbackPrefix = "var reply = ";
266: }
267:
268: script.appendCall(callbackPrefix + getContextPath()
269: + "getBackgroundStroke");
270:
271: if (callback != null) {
272: String key = org.directwebremoting.extend.CallbackHelper
273: .saveCallback(callback, String.class);
274: script
275: .appendCall("__System.activateCallback", key,
276: "reply");
277: }
278:
279: getScriptProxy().addScript(script);
280: }
281:
282: /**
283: * Sets the backgroundStroke field.
284: * @param backgroundStroke the new value for backgroundStroke
285: */
286: public void setBackgroundStroke(String backgroundStroke) {
287: ScriptBuffer script = new ScriptBuffer();
288: script.appendCall(getContextPath() + "setBackgroundStroke",
289: backgroundStroke);
290: getScriptProxy().addScript(script);
291: }
292:
293: /**
294: * Returns the preferredWidth field, the width that this component would like to have, though its true size is dictated by the container component.
295: * @param callback preferredWidth
296: */
297: @SuppressWarnings("unchecked")
298: public void getPreferredWidth(
299: org.directwebremoting.proxy.Callback<Integer> callback) {
300: ScriptBuffer script = new ScriptBuffer();
301: String callbackPrefix = "";
302:
303: if (callback != null) {
304: callbackPrefix = "var reply = ";
305: }
306:
307: script.appendCall(callbackPrefix + getContextPath()
308: + "getPreferredWidth");
309:
310: if (callback != null) {
311: String key = org.directwebremoting.extend.CallbackHelper
312: .saveCallback(callback, Integer.class);
313: script
314: .appendCall("__System.activateCallback", key,
315: "reply");
316: }
317:
318: getScriptProxy().addScript(script);
319: }
320:
321: /**
322: * Sets the preferredWidth field.
323: * @param preferredWidth the new value for preferredWidth
324: */
325: public void setPreferredWidth(int preferredWidth) {
326: ScriptBuffer script = new ScriptBuffer();
327: script.appendCall(getContextPath() + "setPreferredWidth",
328: preferredWidth);
329: getScriptProxy().addScript(script);
330: }
331:
332: /**
333: * Returns the preferredHeight field, the height that this component would like to have, though its true size is dictated by the container component.
334: * @param callback preferredHeight
335: */
336: @SuppressWarnings("unchecked")
337: public void getPreferredHeight(
338: org.directwebremoting.proxy.Callback<Integer> callback) {
339: ScriptBuffer script = new ScriptBuffer();
340: String callbackPrefix = "";
341:
342: if (callback != null) {
343: callbackPrefix = "var reply = ";
344: }
345:
346: script.appendCall(callbackPrefix + getContextPath()
347: + "getPreferredHeight");
348:
349: if (callback != null) {
350: String key = org.directwebremoting.extend.CallbackHelper
351: .saveCallback(callback, Integer.class);
352: script
353: .appendCall("__System.activateCallback", key,
354: "reply");
355: }
356:
357: getScriptProxy().addScript(script);
358: }
359:
360: /**
361: * Sets the preferredHeight field.
362: * @param preferredHeight the new value for preferredHeight
363: */
364: public void setPreferredHeight(int preferredHeight) {
365: ScriptBuffer script = new ScriptBuffer();
366: script.appendCall(getContextPath() + "setPreferredHeight",
367: preferredHeight);
368: getScriptProxy().addScript(script);
369: }
370:
371: /**
372: * Find the first jsx3.chart.ChartLabel child
373: */
374: @SuppressWarnings("unchecked")
375: public jsx3.chart.ChartLabel getLegendTitle() {
376: String extension = "getLegendTitle().";
377: try {
378: java.lang.reflect.Constructor<jsx3.chart.ChartLabel> ctor = jsx3.chart.ChartLabel.class
379: .getConstructor(Context.class, String.class,
380: ScriptProxy.class);
381: return ctor.newInstance(this , extension, getScriptProxy());
382: } catch (Exception ex) {
383: throw new IllegalArgumentException("Unsupported type: "
384: + jsx3.chart.ChartLabel.class.getName());
385: }
386: }
387:
388: }
|