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 plot (scatter/point/bubble) chart.
024:
025: Series: PointSeries, BubbleSeries
026: Axes: both X and Y axis must be value axes
027: * @author Joe Walker [joe at getahead dot org]
028: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
029: */
030: public class PlotChart extends jsx3.chart.CartesianChart {
031: /**
032: * All reverse ajax proxies need context to work from
033: * @param scriptProxy The place we are writing scripts to
034: * @param context The script that got us to where we are now
035: */
036: public PlotChart(Context context, String extension,
037: ScriptProxy scriptProxy) {
038: super (context, extension, scriptProxy);
039: }
040:
041: /**
042: * The instance initializer.
043: * @param name the GI name of the instance
044: * @param left left position (in pixels) of the chart relative to its parent container
045: * @param top top position (in pixels) of the chart relative to its parent container
046: * @param width width (in pixels) of the chart
047: * @param height height (in pixels) of the chart
048: */
049: public PlotChart(String name, int left, int top, int width,
050: int height) {
051: super ((Context) null, (String) null, (ScriptProxy) null);
052: ScriptBuffer script = new ScriptBuffer();
053: script.appendCall("new PlotChart", name, left, top, width,
054: height);
055: setInitScript(script);
056: }
057:
058: /**
059: *
060: */
061: public static final String MAG_RADIUS = "radius";
062:
063: /**
064: *
065: */
066: public static final String MAG_DIAMETER = "diameter";
067:
068: /**
069: *
070: */
071: public static final String MAG_AREA = "area";
072:
073: /**
074: *
075: */
076: public static final int DEFAULT_MAX_POINT_RADIUS = 30;
077:
078: /**
079: * Returns the maxPointRadius field, limit the radius of points on this chart to this value.
080: * @param callback maxPointRadius
081: */
082: @SuppressWarnings("unchecked")
083: public void getMaxPointRadius(
084: org.directwebremoting.proxy.Callback<Integer> callback) {
085: ScriptBuffer script = new ScriptBuffer();
086: String callbackPrefix = "";
087:
088: if (callback != null) {
089: callbackPrefix = "var reply = ";
090: }
091:
092: script.appendCall(callbackPrefix + getContextPath()
093: + "getMaxPointRadius");
094:
095: if (callback != null) {
096: String key = org.directwebremoting.extend.CallbackHelper
097: .saveCallback(callback, Integer.class);
098: script
099: .appendCall("__System.activateCallback", key,
100: "reply");
101: }
102:
103: getScriptProxy().addScript(script);
104: }
105:
106: /**
107: * Sets the maxPointRadius field.
108: * @param maxPointRadius the new value for maxPointRadius
109: */
110: public void setMaxPointRadius(int maxPointRadius) {
111: ScriptBuffer script = new ScriptBuffer();
112: script.appendCall(getContextPath() + "setMaxPointRadius",
113: maxPointRadius);
114: getScriptProxy().addScript(script);
115: }
116:
117: /**
118: * Returns the magnitudeMethod field; the magnitude method defines how the magnitude value of a record in a bubble series is converted to a radius for the rendered point; a value of "radius" means that the magnitude will equal the radius of the point, "diameter" means that the magnitude will equal the diameter (2 * radius), and "area" means that the area of the point will be proportional to the magnitude.
119: * @param callback magnitudeMethod, one of {"radius","diameter","area"}
120: */
121: @SuppressWarnings("unchecked")
122: public void getMagnitudeMethod(
123: org.directwebremoting.proxy.Callback<String> callback) {
124: ScriptBuffer script = new ScriptBuffer();
125: String callbackPrefix = "";
126:
127: if (callback != null) {
128: callbackPrefix = "var reply = ";
129: }
130:
131: script.appendCall(callbackPrefix + getContextPath()
132: + "getMagnitudeMethod");
133:
134: if (callback != null) {
135: String key = org.directwebremoting.extend.CallbackHelper
136: .saveCallback(callback, String.class);
137: script
138: .appendCall("__System.activateCallback", key,
139: "reply");
140: }
141:
142: getScriptProxy().addScript(script);
143: }
144:
145: /**
146: * Sets the magnitudeMethod field, one of {"radius","diameter","area"}.
147: * @param magnitudeMethod the new value for magnitudeMethod
148: */
149: public void setMagnitudeMethod(String magnitudeMethod) {
150: ScriptBuffer script = new ScriptBuffer();
151: script.appendCall(getContextPath() + "setMagnitudeMethod",
152: magnitudeMethod);
153: getScriptProxy().addScript(script);
154: }
155:
156: }
|