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: * Type of axis that displays a linear range of values.
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class LinearAxis extends jsx3.chart.Axis {
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 LinearAxis(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 horizontal whether this axis is horizontal (x), otherwise it's vertical (y)
042: * @param primary whether this axis is primary, otherwise it's secondary
043: */
044: public LinearAxis(String name, boolean horizontal, boolean primary) {
045: super ((Context) null, (String) null, (ScriptProxy) null);
046: ScriptBuffer script = new ScriptBuffer();
047: script.appendCall("new LinearAxis", name, horizontal, primary);
048: setInitScript(script);
049: }
050:
051: /**
052: * The minimum number of intervals to show when calculating by auto adjust.
053: */
054: public static final int MIN_INTERVALS = 5;
055:
056: /**
057: * The maximum number of intervals to show when calculating by auto adjust.
058: */
059: public static final int MAX_INTERVALS = 11;
060:
061: /**
062: * Returns the autoAdjust field, whether to adjust the max/min/interval to the range of the data.
063: * @param callback autoAdjust
064: */
065: @SuppressWarnings("unchecked")
066: public void getAutoAdjust(
067: org.directwebremoting.proxy.Callback<Boolean> callback) {
068: ScriptBuffer script = new ScriptBuffer();
069: String callbackPrefix = "";
070:
071: if (callback != null) {
072: callbackPrefix = "var reply = ";
073: }
074:
075: script.appendCall(callbackPrefix + getContextPath()
076: + "getAutoAdjust");
077:
078: if (callback != null) {
079: String key = org.directwebremoting.extend.CallbackHelper
080: .saveCallback(callback, Boolean.class);
081: script
082: .appendCall("__System.activateCallback", key,
083: "reply");
084: }
085:
086: getScriptProxy().addScript(script);
087: }
088:
089: /**
090: * Sets the autoAdjust field.
091: * @param autoAdjust the new value for autoAdjust
092: */
093: public void setAutoAdjust(boolean autoAdjust) {
094: ScriptBuffer script = new ScriptBuffer();
095: script.appendCall(getContextPath() + "setAutoAdjust",
096: autoAdjust);
097: getScriptProxy().addScript(script);
098: }
099:
100: /**
101: * Returns the baseAtZero field, whether to set either the min or max value of this axis to 0 if applicable and if autoAdjust is true.
102: * @param callback baseAtZero
103: */
104: @SuppressWarnings("unchecked")
105: public void getBaseAtZero(
106: org.directwebremoting.proxy.Callback<Boolean> callback) {
107: ScriptBuffer script = new ScriptBuffer();
108: String callbackPrefix = "";
109:
110: if (callback != null) {
111: callbackPrefix = "var reply = ";
112: }
113:
114: script.appendCall(callbackPrefix + getContextPath()
115: + "getBaseAtZero");
116:
117: if (callback != null) {
118: String key = org.directwebremoting.extend.CallbackHelper
119: .saveCallback(callback, Boolean.class);
120: script
121: .appendCall("__System.activateCallback", key,
122: "reply");
123: }
124:
125: getScriptProxy().addScript(script);
126: }
127:
128: /**
129: * Sets the baseAtZero field.
130: * @param baseAtZero the new value for baseAtZero
131: */
132: public void setBaseAtZero(boolean baseAtZero) {
133: ScriptBuffer script = new ScriptBuffer();
134: script.appendCall(getContextPath() + "setBaseAtZero",
135: baseAtZero);
136: getScriptProxy().addScript(script);
137: }
138:
139: /**
140: * Returns the min field, the minimum value displayed by this axis, overrides autoAdjust.
141: * @param callback min
142: */
143: @SuppressWarnings("unchecked")
144: public void getMin(
145: org.directwebremoting.proxy.Callback<Integer> callback) {
146: ScriptBuffer script = new ScriptBuffer();
147: String callbackPrefix = "";
148:
149: if (callback != null) {
150: callbackPrefix = "var reply = ";
151: }
152:
153: script.appendCall(callbackPrefix + getContextPath() + "getMin");
154:
155: if (callback != null) {
156: String key = org.directwebremoting.extend.CallbackHelper
157: .saveCallback(callback, Integer.class);
158: script
159: .appendCall("__System.activateCallback", key,
160: "reply");
161: }
162:
163: getScriptProxy().addScript(script);
164: }
165:
166: /**
167: * Sets the min field.
168: * @param min the new value for min
169: */
170: public void setMin(int min) {
171: ScriptBuffer script = new ScriptBuffer();
172: script.appendCall(getContextPath() + "setMin", min);
173: getScriptProxy().addScript(script);
174: }
175:
176: /**
177: * Returns the max field, the maximum value displayed by this axis, overrides autoAdjust.
178: * @param callback max
179: */
180: @SuppressWarnings("unchecked")
181: public void getMax(
182: org.directwebremoting.proxy.Callback<Integer> 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() + "getMax");
191:
192: if (callback != null) {
193: String key = org.directwebremoting.extend.CallbackHelper
194: .saveCallback(callback, Integer.class);
195: script
196: .appendCall("__System.activateCallback", key,
197: "reply");
198: }
199:
200: getScriptProxy().addScript(script);
201: }
202:
203: /**
204: * Sets the max field.
205: * @param max the new value for max
206: */
207: public void setMax(int max) {
208: ScriptBuffer script = new ScriptBuffer();
209: script.appendCall(getContextPath() + "setMax", max);
210: getScriptProxy().addScript(script);
211: }
212:
213: /**
214: * Returns the interval field, the interval between major ticks, overrides autoAdjust.
215: * @param callback interval
216: */
217: @SuppressWarnings("unchecked")
218: public void getInterval(
219: org.directwebremoting.proxy.Callback<Integer> callback) {
220: ScriptBuffer script = new ScriptBuffer();
221: String callbackPrefix = "";
222:
223: if (callback != null) {
224: callbackPrefix = "var reply = ";
225: }
226:
227: script.appendCall(callbackPrefix + getContextPath()
228: + "getInterval");
229:
230: if (callback != null) {
231: String key = org.directwebremoting.extend.CallbackHelper
232: .saveCallback(callback, Integer.class);
233: script
234: .appendCall("__System.activateCallback", key,
235: "reply");
236: }
237:
238: getScriptProxy().addScript(script);
239: }
240:
241: /**
242: * Sets the interval field.
243: * @param interval the new value for interval
244: */
245: public void setInterval(int interval) {
246: ScriptBuffer script = new ScriptBuffer();
247: script.appendCall(getContextPath() + "setInterval", interval);
248: getScriptProxy().addScript(script);
249: }
250:
251: /**
252: * convert a number value to a coordinate between 0 and this.length, if the value is outside of the range of the axis, return the closest value in the range
253: * @param value a value displayed along the axis
254: * @param callback coordinate along the axis
255: */
256: @SuppressWarnings("unchecked")
257: public void getCoordinateFor(Integer value,
258: org.directwebremoting.proxy.Callback<Integer> callback) {
259: ScriptBuffer script = new ScriptBuffer();
260: String callbackPrefix = "";
261:
262: if (callback != null) {
263: callbackPrefix = "var reply = ";
264: }
265:
266: script.appendCall(callbackPrefix + getContextPath()
267: + "getCoordinateFor", value);
268:
269: if (callback != null) {
270: String key = org.directwebremoting.extend.CallbackHelper
271: .saveCallback(callback, Integer.class);
272: script
273: .appendCall("__System.activateCallback", key,
274: "reply");
275: }
276:
277: getScriptProxy().addScript(script);
278: }
279:
280: /**
281: * same as getCoordinateFor(), but does not clip to bounds of the axis
282: * @param value
283: */
284: public void getCoordinateForNoClip(java.lang.Object value) {
285: ScriptBuffer script = new ScriptBuffer();
286: script.appendCall(getContextPath() + "getCoordinateForNoClip",
287: value);
288: getScriptProxy().addScript(script);
289: }
290:
291: }
|