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: * Paints a vector line defined by two end points.
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class Line extends jsx3.vector.Shape {
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 Line(Context context, String extension,
034: ScriptProxy scriptProxy) {
035: super (context, extension, scriptProxy);
036: }
037:
038: /**
039: * The instance initializer.
040: * @param left left position (in pixels) of the object relative to its parent container
041: * @param top top position (in pixels) of the object relative to its parent container
042: * @param x1 the x coordinate of the starting point
043: * @param y1 the y coordinate of the starting point
044: * @param x2 the x coordinate of the ending point
045: * @param y2 the y coordinate of the ending point
046: */
047: public Line(int left, int top, int x1, int y1, int x2, int y2) {
048: super ((Context) null, (String) null, (ScriptProxy) null);
049: ScriptBuffer script = new ScriptBuffer();
050: script.appendCall("new Line", left, top, x1, y1, x2, y2);
051: setInitScript(script);
052: }
053:
054: /**
055: * Sets all the coordinates at once.
056: * @param x1 the x coordinate of the starting point
057: * @param y1 the y coordinate of the starting point
058: * @param x2 the x coordinate of the ending point
059: * @param y2 the y coordinate of the ending point
060: */
061: public void setPoints(int x1, int y1, int x2, int y2) {
062: ScriptBuffer script = new ScriptBuffer();
063: script.appendCall(getContextPath() + "setPoints", x1, y1, x2,
064: y2);
065: getScriptProxy().addScript(script);
066: }
067:
068: /**
069: * Returns the x1 field.
070: * @param callback x1
071: */
072: @SuppressWarnings("unchecked")
073: public void getX1(
074: org.directwebremoting.proxy.Callback<Integer> callback) {
075: ScriptBuffer script = new ScriptBuffer();
076: String callbackPrefix = "";
077:
078: if (callback != null) {
079: callbackPrefix = "var reply = ";
080: }
081:
082: script.appendCall(callbackPrefix + getContextPath() + "getX1");
083:
084: if (callback != null) {
085: String key = org.directwebremoting.extend.CallbackHelper
086: .saveCallback(callback, Integer.class);
087: script
088: .appendCall("__System.activateCallback", key,
089: "reply");
090: }
091:
092: getScriptProxy().addScript(script);
093: }
094:
095: /**
096: * Sets the x1 field.
097: * @param x1 the new value for x1
098: */
099: public void setX1(int x1) {
100: ScriptBuffer script = new ScriptBuffer();
101: script.appendCall(getContextPath() + "setX1", x1);
102: getScriptProxy().addScript(script);
103: }
104:
105: /**
106: * Returns the y1 field.
107: * @param callback y1
108: */
109: @SuppressWarnings("unchecked")
110: public void getY1(
111: org.directwebremoting.proxy.Callback<Integer> callback) {
112: ScriptBuffer script = new ScriptBuffer();
113: String callbackPrefix = "";
114:
115: if (callback != null) {
116: callbackPrefix = "var reply = ";
117: }
118:
119: script.appendCall(callbackPrefix + getContextPath() + "getY1");
120:
121: if (callback != null) {
122: String key = org.directwebremoting.extend.CallbackHelper
123: .saveCallback(callback, Integer.class);
124: script
125: .appendCall("__System.activateCallback", key,
126: "reply");
127: }
128:
129: getScriptProxy().addScript(script);
130: }
131:
132: /**
133: * Sets the y1 field.
134: * @param y1 the new value for y1
135: */
136: public void setY1(int y1) {
137: ScriptBuffer script = new ScriptBuffer();
138: script.appendCall(getContextPath() + "setY1", y1);
139: getScriptProxy().addScript(script);
140: }
141:
142: /**
143: * Returns the x2 field.
144: * @param callback x2
145: */
146: @SuppressWarnings("unchecked")
147: public void getX2(
148: org.directwebremoting.proxy.Callback<Integer> callback) {
149: ScriptBuffer script = new ScriptBuffer();
150: String callbackPrefix = "";
151:
152: if (callback != null) {
153: callbackPrefix = "var reply = ";
154: }
155:
156: script.appendCall(callbackPrefix + getContextPath() + "getX2");
157:
158: if (callback != null) {
159: String key = org.directwebremoting.extend.CallbackHelper
160: .saveCallback(callback, Integer.class);
161: script
162: .appendCall("__System.activateCallback", key,
163: "reply");
164: }
165:
166: getScriptProxy().addScript(script);
167: }
168:
169: /**
170: * Sets the x2 field.
171: * @param x2 the new value for x2
172: */
173: public void setX2(int x2) {
174: ScriptBuffer script = new ScriptBuffer();
175: script.appendCall(getContextPath() + "setX2", x2);
176: getScriptProxy().addScript(script);
177: }
178:
179: /**
180: * Returns the y2 field.
181: * @param callback y2
182: */
183: @SuppressWarnings("unchecked")
184: public void getY2(
185: org.directwebremoting.proxy.Callback<Integer> callback) {
186: ScriptBuffer script = new ScriptBuffer();
187: String callbackPrefix = "";
188:
189: if (callback != null) {
190: callbackPrefix = "var reply = ";
191: }
192:
193: script.appendCall(callbackPrefix + getContextPath() + "getY2");
194:
195: if (callback != null) {
196: String key = org.directwebremoting.extend.CallbackHelper
197: .saveCallback(callback, Integer.class);
198: script
199: .appendCall("__System.activateCallback", key,
200: "reply");
201: }
202:
203: getScriptProxy().addScript(script);
204: }
205:
206: /**
207: * Sets the y2 field.
208: * @param y2 the new value for y2
209: */
210: public void setY2(int y2) {
211: ScriptBuffer script = new ScriptBuffer();
212: script.appendCall(getContextPath() + "setY2", y2);
213: getScriptProxy().addScript(script);
214: }
215:
216: }
|