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.vector;
017:
018: import org.directwebremoting.ScriptBuffer;
019: import org.directwebremoting.proxy.ScriptProxy;
020: import org.directwebremoting.proxy.io.Context;
021:
022: /**
023: * Represents a vector line style.
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class Stroke extends jsx3.html.Tag {
028: /**
029: * All reverse ajax proxies need context to work from
030: * @param scriptProxy The place we are writing scripts to
031: * @param context The script that got us to where we are now
032: */
033: public Stroke(Context context, String extension,
034: ScriptProxy scriptProxy) {
035: super (context, extension, scriptProxy);
036: }
037:
038: /**
039: * The instance initializer.
040: * @param color the color value, as a hex String or 24-bit integer value, defaults to 0x000000
041: * @param width the width of the stroke, in pixels, defaults to 1
042: * @param alpha the opacity value, valid values are between 0 and 1, defaults to 1
043: */
044: public Stroke(String color, int width, float alpha) {
045: super ((Context) null, (String) null, (ScriptProxy) null);
046: ScriptBuffer script = new ScriptBuffer();
047: script.appendCall("new Stroke", color, width, alpha);
048: setInitScript(script);
049: }
050:
051: /**
052: * The instance initializer.
053: * @param color the color value, as a hex String or 24-bit integer value, defaults to 0x000000
054: * @param width the width of the stroke, in pixels, defaults to 1
055: * @param alpha the opacity value, valid values are between 0 and 1, defaults to 1
056: */
057: public Stroke(int color, int width, float alpha) {
058: super ((Context) null, (String) null, (ScriptProxy) null);
059: ScriptBuffer script = new ScriptBuffer();
060: script.appendCall("new Stroke", color, width, alpha);
061: setInitScript(script);
062: }
063:
064: /**
065: * Returns the color field.
066: * @param callback color
067: */
068: @SuppressWarnings("unchecked")
069: public void getColor(
070: org.directwebremoting.proxy.Callback<Integer> 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: + "getColor");
080:
081: if (callback != null) {
082: String key = org.directwebremoting.extend.CallbackHelper
083: .saveCallback(callback, Integer.class);
084: script
085: .appendCall("__System.activateCallback", key,
086: "reply");
087: }
088:
089: getScriptProxy().addScript(script);
090: }
091:
092: /**
093: * Returns the color field, as a CSS hex string.
094: */
095: @SuppressWarnings("unchecked")
096: public void getColorHtml(
097: org.directwebremoting.proxy.Callback<String> callback) {
098: ScriptBuffer script = new ScriptBuffer();
099: String callbackPrefix = "";
100:
101: if (callback != null) {
102: callbackPrefix = "var reply = ";
103: }
104:
105: script.appendCall(callbackPrefix + getContextPath()
106: + "getColorHtml");
107:
108: if (callback != null) {
109: String key = org.directwebremoting.extend.CallbackHelper
110: .saveCallback(callback, String.class);
111: script
112: .appendCall("__System.activateCallback", key,
113: "reply");
114: }
115:
116: getScriptProxy().addScript(script);
117: }
118:
119: /**
120: * Sets the color field.
121: * @param color the new value for color
122: */
123: public void setColor(String color) {
124: ScriptBuffer script = new ScriptBuffer();
125: script.appendCall(getContextPath() + "setColor", color);
126: getScriptProxy().addScript(script);
127: }
128:
129: /**
130: * Sets the color field.
131: * @param color the new value for color
132: */
133: public void setColor(int color) {
134: ScriptBuffer script = new ScriptBuffer();
135: script.appendCall(getContextPath() + "setColor", color);
136: getScriptProxy().addScript(script);
137: }
138:
139: /**
140: * Returns the width field.
141: * @param callback width
142: */
143: @SuppressWarnings("unchecked")
144: public void getWidth(
145: org.directwebremoting.proxy.Callback<Integer> callback) {
146: ScriptBuffer script = new ScriptBuffer();
147: String callbackPrefix = "";
148:
149: if (callback != null) {
150: callbackPrefix = "var reply = ";
151: }
152:
153: script.appendCall(callbackPrefix + getContextPath()
154: + "getWidth");
155:
156: if (callback != null) {
157: String key = org.directwebremoting.extend.CallbackHelper
158: .saveCallback(callback, Integer.class);
159: script
160: .appendCall("__System.activateCallback", key,
161: "reply");
162: }
163:
164: getScriptProxy().addScript(script);
165: }
166:
167: /**
168: * Sets the width field.
169: * @param width the new value for width
170: */
171: public void setWidth(int width) {
172: ScriptBuffer script = new ScriptBuffer();
173: script.appendCall(getContextPath() + "setWidth", width);
174: getScriptProxy().addScript(script);
175: }
176:
177: /**
178: * Returns the alpha field.
179: * @param callback alpha
180: */
181: @SuppressWarnings("unchecked")
182: public void getAlpha(
183: org.directwebremoting.proxy.Callback<Float> callback) {
184: ScriptBuffer script = new ScriptBuffer();
185: String callbackPrefix = "";
186:
187: if (callback != null) {
188: callbackPrefix = "var reply = ";
189: }
190:
191: script.appendCall(callbackPrefix + getContextPath()
192: + "getAlpha");
193:
194: if (callback != null) {
195: String key = org.directwebremoting.extend.CallbackHelper
196: .saveCallback(callback, Float.class);
197: script
198: .appendCall("__System.activateCallback", key,
199: "reply");
200: }
201:
202: getScriptProxy().addScript(script);
203: }
204:
205: /**
206: * Sets the alpha field.
207: * @param alpha the new value for alpha
208: */
209: public void setAlpha(float alpha) {
210: ScriptBuffer script = new ScriptBuffer();
211: script.appendCall(getContextPath() + "setAlpha", alpha);
212: getScriptProxy().addScript(script);
213: }
214:
215: /**
216: * parses a VectorStroke from a string representation, that format is "color width alpha"
217: * @param v the string representation
218: * @param callback null if v is empty, v if v is already a VectorStroke, or otherwise a new VectorStroke created by parsing the string according to the format specified above
219: */
220: @SuppressWarnings("unchecked")
221: public void valueOf(String v,
222: org.directwebremoting.proxy.Callback<String> callback) {
223: ScriptBuffer script = new ScriptBuffer();
224: String callbackPrefix = "";
225:
226: if (callback != null) {
227: callbackPrefix = "var reply = ";
228: }
229:
230: script.appendCall(
231: callbackPrefix + getContextPath() + "valueOf", v);
232:
233: if (callback != null) {
234: String key = org.directwebremoting.extend.CallbackHelper
235: .saveCallback(callback, String.class);
236: script
237: .appendCall("__System.activateCallback", key,
238: "reply");
239: }
240:
241: getScriptProxy().addScript(script);
242: }
243:
244: }
|