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: * Axis type that displays a set of discrete values (categories). Usually a category corresponds to a
024: record in the chart's data provider.
025: * @author Joe Walker [joe at getahead dot org]
026: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
027: */
028: public class CategoryAxis extends jsx3.chart.Axis {
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 CategoryAxis(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: * @param horizontal whether this axis is horizontal (x), otherwise it's vertical (y)
043: * @param primary whether this axis is primary, otherwise it's secondary
044: */
045: public CategoryAxis(String name, boolean horizontal, boolean primary) {
046: super ((Context) null, (String) null, (ScriptProxy) null);
047: ScriptBuffer script = new ScriptBuffer();
048: script
049: .appendCall("new CategoryAxis", name, horizontal,
050: primary);
051: setInitScript(script);
052: }
053:
054: /**
055: *
056: */
057: public static final String TICKS_ALIGNED = "aligned";
058:
059: /**
060: *
061: */
062: public static final String TICKS_BETWEEN = "between";
063:
064: /**
065: * Returns the tickAlignment field, if 'between' then the midpoint of the category is between two major ticks, otherwise if 'aligned' then the midpoint of the category is aligned with a major tick.
066: * @param callback tickAlignment, one of {'aligned','between'}
067: */
068: @SuppressWarnings("unchecked")
069: public void getTickAlignment(
070: org.directwebremoting.proxy.Callback<String> callback) {
071: ScriptBuffer script = new ScriptBuffer();
072: String callbackPrefix = "";
073:
074: if (callback != null) {
075: callbackPrefix = "var reply = ";
076: }
077:
078: script.appendCall(callbackPrefix + getContextPath()
079: + "getTickAlignment");
080:
081: if (callback != null) {
082: String key = org.directwebremoting.extend.CallbackHelper
083: .saveCallback(callback, String.class);
084: script
085: .appendCall("__System.activateCallback", key,
086: "reply");
087: }
088:
089: getScriptProxy().addScript(script);
090: }
091:
092: /**
093: * Sets the tickAlignment field.
094: * @param tickAlignment the new value for tickAlignment, one of {'aligned','between'}
095: */
096: public void setTickAlignment(String tickAlignment) {
097: ScriptBuffer script = new ScriptBuffer();
098: script.appendCall(getContextPath() + "setTickAlignment",
099: tickAlignment);
100: getScriptProxy().addScript(script);
101: }
102:
103: /**
104: * Returns the categoryField field, the attribute of records from the data provider that contains the category name (this value can still be transformed by Axis's 'labelFunction' field).
105: * @param callback categoryField
106: */
107: @SuppressWarnings("unchecked")
108: public void getCategoryField(
109: org.directwebremoting.proxy.Callback<String> callback) {
110: ScriptBuffer script = new ScriptBuffer();
111: String callbackPrefix = "";
112:
113: if (callback != null) {
114: callbackPrefix = "var reply = ";
115: }
116:
117: script.appendCall(callbackPrefix + getContextPath()
118: + "getCategoryField");
119:
120: if (callback != null) {
121: String key = org.directwebremoting.extend.CallbackHelper
122: .saveCallback(callback, String.class);
123: script
124: .appendCall("__System.activateCallback", key,
125: "reply");
126: }
127:
128: getScriptProxy().addScript(script);
129: }
130:
131: /**
132: * Sets the categoryField field.
133: * @param categoryField the new value for categoryField
134: */
135: public void setCategoryField(String categoryField) {
136: ScriptBuffer script = new ScriptBuffer();
137: script.appendCall(getContextPath() + "setCategoryField",
138: categoryField);
139: getScriptProxy().addScript(script);
140: }
141:
142: /**
143: * Returns the paddingLow field, the number of category widths to pad the beginning of the axis with.
144: * @param callback paddingLow
145: */
146: @SuppressWarnings("unchecked")
147: public void getPaddingLow(
148: org.directwebremoting.proxy.Callback<Float> callback) {
149: ScriptBuffer script = new ScriptBuffer();
150: String callbackPrefix = "";
151:
152: if (callback != null) {
153: callbackPrefix = "var reply = ";
154: }
155:
156: script.appendCall(callbackPrefix + getContextPath()
157: + "getPaddingLow");
158:
159: if (callback != null) {
160: String key = org.directwebremoting.extend.CallbackHelper
161: .saveCallback(callback, Float.class);
162: script
163: .appendCall("__System.activateCallback", key,
164: "reply");
165: }
166:
167: getScriptProxy().addScript(script);
168: }
169:
170: /**
171: * Sets the paddingLow field.
172: * @param paddingLow the new value for paddingLow
173: */
174: public void setPaddingLow(float paddingLow) {
175: ScriptBuffer script = new ScriptBuffer();
176: script.appendCall(getContextPath() + "setPaddingLow",
177: paddingLow);
178: getScriptProxy().addScript(script);
179: }
180:
181: /**
182: * Returns the paddingHigh field, the number of category widths to pad the end of the axis with.
183: * @param callback paddingHigh
184: */
185: @SuppressWarnings("unchecked")
186: public void getPaddingHigh(
187: org.directwebremoting.proxy.Callback<Float> callback) {
188: ScriptBuffer script = new ScriptBuffer();
189: String callbackPrefix = "";
190:
191: if (callback != null) {
192: callbackPrefix = "var reply = ";
193: }
194:
195: script.appendCall(callbackPrefix + getContextPath()
196: + "getPaddingHigh");
197:
198: if (callback != null) {
199: String key = org.directwebremoting.extend.CallbackHelper
200: .saveCallback(callback, Float.class);
201: script
202: .appendCall("__System.activateCallback", key,
203: "reply");
204: }
205:
206: getScriptProxy().addScript(script);
207: }
208:
209: /**
210: * Sets the paddingHigh field.
211: * @param paddingHigh the new value for paddingHigh
212: */
213: public void setPaddingHigh(float paddingHigh) {
214: ScriptBuffer script = new ScriptBuffer();
215: script.appendCall(getContextPath() + "setPaddingHigh",
216: paddingHigh);
217: getScriptProxy().addScript(script);
218: }
219:
220: }
|