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: * The data series type for a jsx3.chart.ColumnChart. Draws vertical columns between the x axis and a y value determined
024: by the data provider, or between two y values determined by the data provider. A column series has the
025: following fields:
026:
027: yField the attribute of a record to use as the vertical extent of the column, required
028: xField the attribute of a record to use as the horizontal midpoint of the column, required if the x axis
029: of the chart is a value axis
030: minField the attribute of a record to use as the minimum vertical extent of the column, optional
031: * @author Joe Walker [joe at getahead dot org]
032: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
033: */
034: public class ColumnSeries extends jsx3.chart.BCSeries {
035: /**
036: * All reverse ajax proxies need context to work from
037: * @param scriptProxy The place we are writing scripts to
038: * @param context The script that got us to where we are now
039: */
040: public ColumnSeries(Context context, String extension,
041: ScriptProxy scriptProxy) {
042: super (context, extension, scriptProxy);
043: }
044:
045: /**
046: * The instance initializer.
047: * @param name the GI name of the instance
048: * @param seriesName the name of the Series, will be displayed in the Legend for most chart types
049: */
050: public ColumnSeries(String name, String seriesName) {
051: super ((Context) null, (String) null, (ScriptProxy) null);
052: ScriptBuffer script = new ScriptBuffer();
053: script.appendCall("new ColumnSeries", name, seriesName);
054: setInitScript(script);
055: }
056:
057: /**
058: *
059: */
060: public static final int DEFAULT_COLUMNWIDTH = 10;
061:
062: /**
063: * Returns the columnWidth field.
064: * @param callback columnWidth
065: */
066: @SuppressWarnings("unchecked")
067: public void getColumnWidth(
068: org.directwebremoting.proxy.Callback<Integer> callback) {
069: ScriptBuffer script = new ScriptBuffer();
070: String callbackPrefix = "";
071:
072: if (callback != null) {
073: callbackPrefix = "var reply = ";
074: }
075:
076: script.appendCall(callbackPrefix + getContextPath()
077: + "getColumnWidth");
078:
079: if (callback != null) {
080: String key = org.directwebremoting.extend.CallbackHelper
081: .saveCallback(callback, Integer.class);
082: script
083: .appendCall("__System.activateCallback", key,
084: "reply");
085: }
086:
087: getScriptProxy().addScript(script);
088: }
089:
090: /**
091: * Sets the columnWidth field.
092: * @param columnWidth the new value for columnWidth
093: */
094: public void setColumnWidth(int columnWidth) {
095: ScriptBuffer script = new ScriptBuffer();
096: script.appendCall(getContextPath() + "setColumnWidth",
097: columnWidth);
098: getScriptProxy().addScript(script);
099: }
100:
101: /**
102: * The default tooltip function for this type of series.
103: * @param series
104: * @param record
105: */
106: @SuppressWarnings("unchecked")
107: public void tooltip(jsx3.chart.Series series, jsx3.xml.Node record,
108: org.directwebremoting.proxy.Callback<String> callback) {
109: ScriptBuffer script = new ScriptBuffer();
110: String callbackPrefix = "";
111:
112: if (callback != null) {
113: callbackPrefix = "var reply = ";
114: }
115:
116: script.appendCall(
117: callbackPrefix + getContextPath() + "tooltip", series,
118: record);
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: }
|