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 chart component to render a text box. Used to render the titles of charts, legends, axes, and series.
024: Encapsulates all the font settings of the label so that the parent container does not experience
025: property bloat.
026: * @author Joe Walker [joe at getahead dot org]
027: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
028: */
029: public class ChartLabel extends jsx3.chart.ChartComponent {
030: /**
031: * All reverse ajax proxies need context to work from
032: * @param scriptProxy The place we are writing scripts to
033: * @param context The script that got us to where we are now
034: */
035: public ChartLabel(Context context, String extension,
036: ScriptProxy scriptProxy) {
037: super (context, extension, scriptProxy);
038: }
039:
040: /**
041: * The instance initializer.
042: * @param name the GI name of the instance
043: * @param text text to display in the label
044: */
045: public ChartLabel(String name, String text) {
046: super ((Context) null, (String) null, (ScriptProxy) null);
047: ScriptBuffer script = new ScriptBuffer();
048: script.appendCall("new ChartLabel", name, text);
049: setInitScript(script);
050: }
051:
052: /**
053: * the default preferred width
054: */
055: public static final int DEFAULT_WIDTH = 100;
056:
057: /**
058: * non-rotated angle
059: */
060: public static final int ROTATION_NORMAL = 0;
061:
062: /**
063: * angle for one-quarter clockwise rotation
064: */
065: public static final int ROTATION_CW = 90;
066:
067: /**
068: * angle for one-quarter counter-clockwise rotation
069: */
070: public static final int ROTATION_CCW = 270;
071:
072: /**
073: * Returns the preferredWidth field.
074: * @param callback preferredWidth
075: */
076: @SuppressWarnings("unchecked")
077: public void getPreferredWidth(
078: org.directwebremoting.proxy.Callback<Integer> callback) {
079: ScriptBuffer script = new ScriptBuffer();
080: String callbackPrefix = "";
081:
082: if (callback != null) {
083: callbackPrefix = "var reply = ";
084: }
085:
086: script.appendCall(callbackPrefix + getContextPath()
087: + "getPreferredWidth");
088:
089: if (callback != null) {
090: String key = org.directwebremoting.extend.CallbackHelper
091: .saveCallback(callback, Integer.class);
092: script
093: .appendCall("__System.activateCallback", key,
094: "reply");
095: }
096:
097: getScriptProxy().addScript(script);
098: }
099:
100: /**
101: * Sets the preferredWidth field.
102: * @param preferredWidth the new value for preferredWidth
103: */
104: public void setPreferredWidth(int preferredWidth) {
105: ScriptBuffer script = new ScriptBuffer();
106: script.appendCall(getContextPath() + "setPreferredWidth",
107: preferredWidth);
108: getScriptProxy().addScript(script);
109: }
110:
111: /**
112: * Returns the preferredHeight field.
113: * @param callback preferredHeight
114: */
115: @SuppressWarnings("unchecked")
116: public void getPreferredHeight(
117: org.directwebremoting.proxy.Callback<Integer> callback) {
118: ScriptBuffer script = new ScriptBuffer();
119: String callbackPrefix = "";
120:
121: if (callback != null) {
122: callbackPrefix = "var reply = ";
123: }
124:
125: script.appendCall(callbackPrefix + getContextPath()
126: + "getPreferredHeight");
127:
128: if (callback != null) {
129: String key = org.directwebremoting.extend.CallbackHelper
130: .saveCallback(callback, Integer.class);
131: script
132: .appendCall("__System.activateCallback", key,
133: "reply");
134: }
135:
136: getScriptProxy().addScript(script);
137: }
138:
139: /**
140: * Sets the preferredHeight field.
141: * @param preferredHeight the new value for preferredHeight
142: */
143: public void setPreferredHeight(int preferredHeight) {
144: ScriptBuffer script = new ScriptBuffer();
145: script.appendCall(getContextPath() + "setPreferredHeight",
146: preferredHeight);
147: getScriptProxy().addScript(script);
148: }
149:
150: /**
151: * Returns the alpha field, the opacity of the background fill.
152: * @param callback alpha
153: */
154: @SuppressWarnings("unchecked")
155: public void getAlpha(
156: org.directwebremoting.proxy.Callback<Float> callback) {
157: ScriptBuffer script = new ScriptBuffer();
158: String callbackPrefix = "";
159:
160: if (callback != null) {
161: callbackPrefix = "var reply = ";
162: }
163:
164: script.appendCall(callbackPrefix + getContextPath()
165: + "getAlpha");
166:
167: if (callback != null) {
168: String key = org.directwebremoting.extend.CallbackHelper
169: .saveCallback(callback, Float.class);
170: script
171: .appendCall("__System.activateCallback", key,
172: "reply");
173: }
174:
175: getScriptProxy().addScript(script);
176: }
177:
178: /**
179: * Sets the alpha field.
180: * @param alpha the new value for alpha
181: */
182: public void setAlpha(float alpha) {
183: ScriptBuffer script = new ScriptBuffer();
184: script.appendCall(getContextPath() + "setAlpha", alpha);
185: getScriptProxy().addScript(script);
186: }
187:
188: /**
189: * Returns the borderStroke field, string representation of the VectorStroke used to outline the background.
190: * @param callback borderStroke
191: */
192: @SuppressWarnings("unchecked")
193: public void getBorderStroke(
194: org.directwebremoting.proxy.Callback<String> callback) {
195: ScriptBuffer script = new ScriptBuffer();
196: String callbackPrefix = "";
197:
198: if (callback != null) {
199: callbackPrefix = "var reply = ";
200: }
201:
202: script.appendCall(callbackPrefix + getContextPath()
203: + "getBorderStroke");
204:
205: if (callback != null) {
206: String key = org.directwebremoting.extend.CallbackHelper
207: .saveCallback(callback, String.class);
208: script
209: .appendCall("__System.activateCallback", key,
210: "reply");
211: }
212:
213: getScriptProxy().addScript(script);
214: }
215:
216: /**
217: * Sets the borderStroke field.
218: * @param borderStroke the new value for borderStroke
219: */
220: public void setBorderStroke(String borderStroke) {
221: ScriptBuffer script = new ScriptBuffer();
222: script.appendCall(getContextPath() + "setBorderStroke",
223: borderStroke);
224: getScriptProxy().addScript(script);
225: }
226:
227: /**
228: * Returns the labelRotation field.
229: * @param callback labelRotation
230: */
231: @SuppressWarnings("unchecked")
232: public void getLabelRotation(
233: org.directwebremoting.proxy.Callback<Integer> callback) {
234: ScriptBuffer script = new ScriptBuffer();
235: String callbackPrefix = "";
236:
237: if (callback != null) {
238: callbackPrefix = "var reply = ";
239: }
240:
241: script.appendCall(callbackPrefix + getContextPath()
242: + "getLabelRotation");
243:
244: if (callback != null) {
245: String key = org.directwebremoting.extend.CallbackHelper
246: .saveCallback(callback, Integer.class);
247: script
248: .appendCall("__System.activateCallback", key,
249: "reply");
250: }
251:
252: getScriptProxy().addScript(script);
253: }
254:
255: /**
256: * Sets the labelRotation field.
257: * @param labelRotation the new value for labelRotation, one of {0, 90, 270}
258: */
259: public void setLabelRotation(int labelRotation) {
260: ScriptBuffer script = new ScriptBuffer();
261: script.appendCall(getContextPath() + "setLabelRotation",
262: labelRotation);
263: getScriptProxy().addScript(script);
264: }
265:
266: /**
267: * whether this label is display at 90 or -90 degrees
268: */
269: @SuppressWarnings("unchecked")
270: public void isRotated(
271: org.directwebremoting.proxy.Callback<Boolean> callback) {
272: ScriptBuffer script = new ScriptBuffer();
273: String callbackPrefix = "";
274:
275: if (callback != null) {
276: callbackPrefix = "var reply = ";
277: }
278:
279: script.appendCall(callbackPrefix + getContextPath()
280: + "isRotated");
281:
282: if (callback != null) {
283: String key = org.directwebremoting.extend.CallbackHelper
284: .saveCallback(callback, Boolean.class);
285: script
286: .appendCall("__System.activateCallback", key,
287: "reply");
288: }
289:
290: getScriptProxy().addScript(script);
291: }
292:
293: }
|