/* * Copyright 2005 Joe Walker * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jsx3.chart; import org.directwebremoting.ScriptBuffer; import org.directwebremoting.ScriptSessions; import org.directwebremoting.io.Context; /** * Chart component that renders a simple legend. A legend may contain a list of series or a list of categories, depending on the type of chart. * @author Joe Walker [joe at getahead dot org] * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator */ public class Legend extends jsx3.chart.ChartComponent { /** * All reverse ajax proxies need context to work from * @param context The script that got us to where we are now */ public Legend(Context context, String extension) { super(context, extension); } /** * The instance initializer. * @param name the GI name of the instance */ public Legend(String name) { super((Context) null, (String) null); ScriptBuffer script = new ScriptBuffer(); script.appendCall("new Legend", name); setInitScript(script); } /** * the default width */ public static final int DEFAULT_WIDTH = 100; /** * the default height */ public static final int DEFAULT_HEIGHT = 100; /** * Returns the boxHeight field, the diameter of the box that shows the fill of each series or category. * @param callback boxHeight */ public void getBoxHeight(org.directwebremoting.ui.Callback<Integer> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getBoxHeight"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, Integer.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the boxHeight field. * @param boxHeight the new value for boxHeight */ public void setBoxHeight(int boxHeight) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setBoxHeight", boxHeight); ScriptSessions.addScript(script); } /** * Returns the lineHeight field, the vertical space taken for each legend entry. * @param callback lineHeight */ public void getLineHeight(org.directwebremoting.ui.Callback<Integer> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getLineHeight"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, Integer.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the lineHeight field. * @param lineHeight the new value for lineHeight */ public void setLineHeight(int lineHeight) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setLineHeight", lineHeight); ScriptSessions.addScript(script); } /** * Returns the labelClass field, the CSS class name applied to the name of each series or category. * @param callback labelClass */ public void getLabelClass(org.directwebremoting.ui.Callback<String> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getLabelClass"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, String.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the labelClass field. * @param labelClass the new value for labelClass */ public void setLabelClass(String labelClass) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setLabelClass", labelClass); ScriptSessions.addScript(script); } /** * Returns the labelStyle field, a CSS style attribute applied to the name of each series or category, ie "font-family: Arial; font-size: 10px;". * @param callback labelStyle */ public void getLabelStyle(org.directwebremoting.ui.Callback<String> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getLabelStyle"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, String.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the labelStyle field. * @param labelStyle the new value for labelStyle */ public void setLabelStyle(String labelStyle) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setLabelStyle", labelStyle); ScriptSessions.addScript(script); } /** * Returns the backgroundFill field, a string representation of the vector fill used to color in the background of the legend. * @param callback backgroundFill */ public void getBackgroundFill(org.directwebremoting.ui.Callback<String> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getBackgroundFill"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, String.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the backgroundFill field. * @param backgroundFill the new value for backgroundFill */ public void setBackgroundFill(String backgroundFill) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setBackgroundFill", backgroundFill); ScriptSessions.addScript(script); } /** * Returns the backgroundStroke field, a string representation of the VectorStroke used to outline the legend. * @param callback backgroundStroke */ public void getBackgroundStroke(org.directwebremoting.ui.Callback<String> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getBackgroundStroke"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, String.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the backgroundStroke field. * @param backgroundStroke the new value for backgroundStroke */ public void setBackgroundStroke(String backgroundStroke) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setBackgroundStroke", backgroundStroke); ScriptSessions.addScript(script); } /** * Returns the preferredWidth field, the width that this component would like to have, though its true size is dictated by the container component. * @param callback preferredWidth */ public void getPreferredWidth(org.directwebremoting.ui.Callback<Integer> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getPreferredWidth"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, Integer.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the preferredWidth field. * @param preferredWidth the new value for preferredWidth */ public void setPreferredWidth(int preferredWidth) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setPreferredWidth", preferredWidth); ScriptSessions.addScript(script); } /** * Returns the preferredHeight field, the height that this component would like to have, though its true size is dictated by the container component. * @param callback preferredHeight */ public void getPreferredHeight(org.directwebremoting.ui.Callback<Integer> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + getContextPath() + "getPreferredHeight"); if (callback != null) { String key = org.directwebremoting.extend.CallbackHelperFactory.get().saveCallback(callback, Integer.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); } /** * Sets the preferredHeight field. * @param preferredHeight the new value for preferredHeight */ public void setPreferredHeight(int preferredHeight) { ScriptBuffer script = new ScriptBuffer(); script.appendCall(getContextPath() + "setPreferredHeight", preferredHeight); ScriptSessions.addScript(script); } /** * Find the first jsx3.chart.ChartLabel child */ public jsx3.chart.ChartLabel getLegendTitle() { String extension = "getLegendTitle()."; try { java.lang.reflect.Constructor<jsx3.chart.ChartLabel> ctor = jsx3.chart.ChartLabel.class.getConstructor(Context.class, String.class); return ctor.newInstance(this, extension); } catch (Exception ex) { throw new IllegalArgumentException("Unsupported type: " + jsx3.chart.ChartLabel.class.getName()); } } }