01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package jsx3.vector;
17:
18: import org.directwebremoting.ScriptBuffer;
19: import org.directwebremoting.proxy.ScriptProxy;
20: import org.directwebremoting.proxy.io.Context;
21:
22: /**
23: * Paints a vector polygon defined by a set of points.
24: * @author Joe Walker [joe at getahead dot org]
25: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
26: */
27: public class Polygon extends jsx3.vector.Shape {
28: /**
29: * All reverse ajax proxies need context to work from
30: * @param scriptProxy The place we are writing scripts to
31: * @param context The script that got us to where we are now
32: */
33: public Polygon(Context context, String extension,
34: ScriptProxy scriptProxy) {
35: super (context, extension, scriptProxy);
36: }
37:
38: /**
39: * The instance initializer.
40: * @param left left position (in pixels) of the object relative to its parent container
41: * @param top top position (in pixels) of the object relative to its parent container
42: * @param points the list of points comprising the polygon
43: */
44: public Polygon(int left, int top, String points) {
45: super ((Context) null, (String) null, (ScriptProxy) null);
46: ScriptBuffer script = new ScriptBuffer();
47: script.appendCall("new Polygon", left, top, points);
48: setInitScript(script);
49: }
50:
51: /**
52: * The instance initializer.
53: * @param left left position (in pixels) of the object relative to its parent container
54: * @param top top position (in pixels) of the object relative to its parent container
55: * @param points the list of points comprising the polygon
56: */
57: public Polygon(int left, int top, Object[] points) {
58: super ((Context) null, (String) null, (ScriptProxy) null);
59: ScriptBuffer script = new ScriptBuffer();
60: script.appendCall("new Polygon", left, top, points);
61: setInitScript(script);
62: }
63:
64: /**
65: * Sets the polygon points as an array of point objects or strings.
66: * @param points an array of strings or objects to stringify as "x y"
67: */
68: public void setPoints(Object[] points) {
69: ScriptBuffer script = new ScriptBuffer();
70: script.appendCall(getContextPath() + "setPoints", points);
71: getScriptProxy().addScript(script);
72: }
73:
74: /**
75: * Sets the polygon points as an array of coordinates.
76: * @param points an array of alternating x and y coordinates
77: */
78: public void setPointsAsNumberArray(Object[] points) {
79: ScriptBuffer script = new ScriptBuffer();
80: script.appendCall(getContextPath() + "setPointsAsNumberArray",
81: points);
82: getScriptProxy().addScript(script);
83: }
84:
85: /**
86: * Sets the points as a string.
87: * @param points a string in the form "x1 y1 x2 y2 ..."
88: */
89: public void setPointsAsString(String points) {
90: ScriptBuffer script = new ScriptBuffer();
91: script.appendCall(getContextPath() + "setPointsAsString",
92: points);
93: getScriptProxy().addScript(script);
94: }
95:
96: }
|