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.BarChart. Draws horizontal bars between the y axis and an x value determined
024: by the data provider, or between two x values determined by the data provider. A bar series has the
025: following fields:
026:
027: xField the attribute of a record to use as the horizontal extent of the bar, required
028: yField the attribute of a record to use as the vertical midpoint of the bar, required if the y axis
029: of the chart is a value axis
030: minField the attribute of a record to use as the minimum horizontal extent of the bar, optional
031: * @author Joe Walker [joe at getahead dot org]
032: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
033: */
034: public class BarSeries 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 BarSeries(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 BarSeries(String name, String seriesName) {
051: super ((Context) null, (String) null, (ScriptProxy) null);
052: ScriptBuffer script = new ScriptBuffer();
053: script.appendCall("new BarSeries", name, seriesName);
054: setInitScript(script);
055: }
056:
057: /**
058: *
059: */
060: public static final int DEFAULT_BARHEIGHT = 10;
061:
062: /**
063: * Returns the barHeight field.
064: * @param callback barHeight
065: */
066: @SuppressWarnings("unchecked")
067: public void getBarHeight(
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: + "getBarHeight");
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 barHeight field.
092: * @param barHeight the new value for barHeight
093: */
094: public void setBarHeight(int barHeight) {
095: ScriptBuffer script = new ScriptBuffer();
096: script.appendCall(getContextPath() + "setBarHeight", barHeight);
097: getScriptProxy().addScript(script);
098: }
099:
100: /**
101: * The default tooltip function for this type of series.
102: * @param series
103: * @param record
104: */
105: @SuppressWarnings("unchecked")
106: public void tooltip(jsx3.chart.Series series, jsx3.xml.Node record,
107: org.directwebremoting.proxy.Callback<String> callback) {
108: ScriptBuffer script = new ScriptBuffer();
109: String callbackPrefix = "";
110:
111: if (callback != null) {
112: callbackPrefix = "var reply = ";
113: }
114:
115: script.appendCall(
116: callbackPrefix + getContextPath() + "tooltip", series,
117: record);
118:
119: if (callback != null) {
120: String key = org.directwebremoting.extend.CallbackHelper
121: .saveCallback(callback, String.class);
122: script
123: .appendCall("__System.activateCallback", key,
124: "reply");
125: }
126:
127: getScriptProxy().addScript(script);
128: }
129:
130: }
|