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: * An axis that displays a range of values logarithmically (base^n and base^(n+1) occupy same visual space).
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class LogarithmicAxis 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 LogarithmicAxis(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 LogarithmicAxis(String name, boolean horizontal,
045: boolean primary) {
046: super ((Context) null, (String) null, (ScriptProxy) null);
047: ScriptBuffer script = new ScriptBuffer();
048: script.appendCall("new LogarithmicAxis", name, horizontal,
049: primary);
050: setInitScript(script);
051: }
052:
053: /**
054: * Returns the autoAdjust field.
055: * @param callback autoAdjust
056: */
057: @SuppressWarnings("unchecked")
058: public void getAutoAdjust(
059: org.directwebremoting.proxy.Callback<Boolean> callback) {
060: ScriptBuffer script = new ScriptBuffer();
061: String callbackPrefix = "";
062:
063: if (callback != null) {
064: callbackPrefix = "var reply = ";
065: }
066:
067: script.appendCall(callbackPrefix + getContextPath()
068: + "getAutoAdjust");
069:
070: if (callback != null) {
071: String key = org.directwebremoting.extend.CallbackHelper
072: .saveCallback(callback, Boolean.class);
073: script
074: .appendCall("__System.activateCallback", key,
075: "reply");
076: }
077:
078: getScriptProxy().addScript(script);
079: }
080:
081: /**
082: * Sets the autoAdjust field.
083: * @param autoAdjust the new value for autoAdjust
084: */
085: public void setAutoAdjust(boolean autoAdjust) {
086: ScriptBuffer script = new ScriptBuffer();
087: script.appendCall(getContextPath() + "setAutoAdjust",
088: autoAdjust);
089: getScriptProxy().addScript(script);
090: }
091:
092: /**
093: * Returns the baseAtZero field, whether or not to set the minimum value to base^0, otherwise will choose an appropriate value for the data range.
094: * @param callback baseAtZero
095: */
096: @SuppressWarnings("unchecked")
097: public void getBaseAtZero(
098: org.directwebremoting.proxy.Callback<Boolean> callback) {
099: ScriptBuffer script = new ScriptBuffer();
100: String callbackPrefix = "";
101:
102: if (callback != null) {
103: callbackPrefix = "var reply = ";
104: }
105:
106: script.appendCall(callbackPrefix + getContextPath()
107: + "getBaseAtZero");
108:
109: if (callback != null) {
110: String key = org.directwebremoting.extend.CallbackHelper
111: .saveCallback(callback, Boolean.class);
112: script
113: .appendCall("__System.activateCallback", key,
114: "reply");
115: }
116:
117: getScriptProxy().addScript(script);
118: }
119:
120: /**
121: * Sets the baseAtZero field.
122: * @param baseAtZero the new value for baseAtZero
123: */
124: public void setBaseAtZero(boolean baseAtZero) {
125: ScriptBuffer script = new ScriptBuffer();
126: script.appendCall(getContextPath() + "setBaseAtZero",
127: baseAtZero);
128: getScriptProxy().addScript(script);
129: }
130:
131: /**
132: * Returns the showNegativeValues field.
133: * @param callback showNegativeValues
134: */
135: @SuppressWarnings("unchecked")
136: public void getShowNegativeValues(
137: org.directwebremoting.proxy.Callback<Boolean> callback) {
138: ScriptBuffer script = new ScriptBuffer();
139: String callbackPrefix = "";
140:
141: if (callback != null) {
142: callbackPrefix = "var reply = ";
143: }
144:
145: script.appendCall(callbackPrefix + getContextPath()
146: + "getShowNegativeValues");
147:
148: if (callback != null) {
149: String key = org.directwebremoting.extend.CallbackHelper
150: .saveCallback(callback, Boolean.class);
151: script
152: .appendCall("__System.activateCallback", key,
153: "reply");
154: }
155:
156: getScriptProxy().addScript(script);
157: }
158:
159: /**
160: * Sets the showNegativeValues field.
161: * @param showNegativeValues the new value for showNegativeValues
162: */
163: public void setShowNegativeValues(boolean showNegativeValues) {
164: ScriptBuffer script = new ScriptBuffer();
165: script.appendCall(getContextPath() + "setShowNegativeValues",
166: showNegativeValues);
167: getScriptProxy().addScript(script);
168: }
169:
170: /**
171: * Returns the minExponent field, the range of values displayed will begin at base^minExpronent.
172: * @param callback minExponent
173: */
174: @SuppressWarnings("unchecked")
175: public void getMinExponent(
176: org.directwebremoting.proxy.Callback<Integer> callback) {
177: ScriptBuffer script = new ScriptBuffer();
178: String callbackPrefix = "";
179:
180: if (callback != null) {
181: callbackPrefix = "var reply = ";
182: }
183:
184: script.appendCall(callbackPrefix + getContextPath()
185: + "getMinExponent");
186:
187: if (callback != null) {
188: String key = org.directwebremoting.extend.CallbackHelper
189: .saveCallback(callback, Integer.class);
190: script
191: .appendCall("__System.activateCallback", key,
192: "reply");
193: }
194:
195: getScriptProxy().addScript(script);
196: }
197:
198: /**
199: * Sets the minExponent field.
200: * @param minExponent the new value for minExponent
201: */
202: public void setMinExponent(int minExponent) {
203: ScriptBuffer script = new ScriptBuffer();
204: script.appendCall(getContextPath() + "setMinExponent",
205: minExponent);
206: getScriptProxy().addScript(script);
207: }
208:
209: /**
210: * Returns the maxExponent field, the range of values displayed will end at base^maxExponent.
211: * @param callback maxExponent
212: */
213: @SuppressWarnings("unchecked")
214: public void getMaxExponent(
215: org.directwebremoting.proxy.Callback<Integer> callback) {
216: ScriptBuffer script = new ScriptBuffer();
217: String callbackPrefix = "";
218:
219: if (callback != null) {
220: callbackPrefix = "var reply = ";
221: }
222:
223: script.appendCall(callbackPrefix + getContextPath()
224: + "getMaxExponent");
225:
226: if (callback != null) {
227: String key = org.directwebremoting.extend.CallbackHelper
228: .saveCallback(callback, Integer.class);
229: script
230: .appendCall("__System.activateCallback", key,
231: "reply");
232: }
233:
234: getScriptProxy().addScript(script);
235: }
236:
237: /**
238: * Sets the maxExponent field.
239: * @param maxExponent the new value for maxExponent
240: */
241: public void setMaxExponent(int maxExponent) {
242: ScriptBuffer script = new ScriptBuffer();
243: script.appendCall(getContextPath() + "setMaxExponent",
244: maxExponent);
245: getScriptProxy().addScript(script);
246: }
247:
248: /**
249: * Returns the base field.
250: * @param callback base
251: */
252: @SuppressWarnings("unchecked")
253: public void getBase(
254: org.directwebremoting.proxy.Callback<Integer> callback) {
255: ScriptBuffer script = new ScriptBuffer();
256: String callbackPrefix = "";
257:
258: if (callback != null) {
259: callbackPrefix = "var reply = ";
260: }
261:
262: script
263: .appendCall(callbackPrefix + getContextPath()
264: + "getBase");
265:
266: if (callback != null) {
267: String key = org.directwebremoting.extend.CallbackHelper
268: .saveCallback(callback, Integer.class);
269: script
270: .appendCall("__System.activateCallback", key,
271: "reply");
272: }
273:
274: getScriptProxy().addScript(script);
275: }
276:
277: /**
278: * Sets the base field.
279: * @param base the new value for base
280: */
281: public void setBase(int base) {
282: ScriptBuffer script = new ScriptBuffer();
283: script.appendCall(getContextPath() + "setBase", base);
284: getScriptProxy().addScript(script);
285: }
286:
287: /**
288: * Returns the majorDivisions field, the number of major tick line divisions to place between the values base^n and base^(n+1). A good value can be base-1, though the default value is 1..
289: * @param callback majorDivisions
290: */
291: @SuppressWarnings("unchecked")
292: public void getMajorDivisions(
293: org.directwebremoting.proxy.Callback<Integer> callback) {
294: ScriptBuffer script = new ScriptBuffer();
295: String callbackPrefix = "";
296:
297: if (callback != null) {
298: callbackPrefix = "var reply = ";
299: }
300:
301: script.appendCall(callbackPrefix + getContextPath()
302: + "getMajorDivisions");
303:
304: if (callback != null) {
305: String key = org.directwebremoting.extend.CallbackHelper
306: .saveCallback(callback, Integer.class);
307: script
308: .appendCall("__System.activateCallback", key,
309: "reply");
310: }
311:
312: getScriptProxy().addScript(script);
313: }
314:
315: /**
316: * Sets the majorDivisions field.
317: * @param majorDivisions the new value for majorDivisions
318: */
319: public void setMajorDivisions(int majorDivisions) {
320: ScriptBuffer script = new ScriptBuffer();
321: script.appendCall(getContextPath() + "setMajorDivisions",
322: majorDivisions);
323: getScriptProxy().addScript(script);
324: }
325:
326: /**
327: * 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
328: * @param value a value displayed along the axis
329: * @param callback coordinate along the axis
330: */
331: @SuppressWarnings("unchecked")
332: public void getCoordinateFor(Integer value,
333: org.directwebremoting.proxy.Callback<Integer> callback) {
334: ScriptBuffer script = new ScriptBuffer();
335: String callbackPrefix = "";
336:
337: if (callback != null) {
338: callbackPrefix = "var reply = ";
339: }
340:
341: script.appendCall(callbackPrefix + getContextPath()
342: + "getCoordinateFor", value);
343:
344: if (callback != null) {
345: String key = org.directwebremoting.extend.CallbackHelper
346: .saveCallback(callback, Integer.class);
347: script
348: .appendCall("__System.activateCallback", key,
349: "reply");
350: }
351:
352: getScriptProxy().addScript(script);
353: }
354:
355: /**
356: * same as getCoordinateFor(), but does not clip to bounds of the axis
357: * @param value
358: */
359: public void getCoordinateForNoClip(java.lang.Object value) {
360: ScriptBuffer script = new ScriptBuffer();
361: script.appendCall(getContextPath() + "getCoordinateForNoClip",
362: value);
363: getScriptProxy().addScript(script);
364: }
365:
366: }
|