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: * A more efficient way of painting many vector rectangles of the same fill and stroke.
24: * @author Joe Walker [joe at getahead dot org]
25: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
26: */
27: public class RectangleGroup 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 RectangleGroup(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 width width (in pixels) of the object
43: * @param height height (in pixels) of the object
44: */
45: public RectangleGroup(int left, int top, int width, int height) {
46: super ((Context) null, (String) null, (ScriptProxy) null);
47: ScriptBuffer script = new ScriptBuffer();
48: script.appendCall("new RectangleGroup", left, top, width,
49: height);
50: setInitScript(script);
51: }
52:
53: /**
54: * add a rectangle to this group
55: * @param x1 the x-coordinate of the left edge of the rectangle
56: * @param y1 the y-coordinate of the top edge of the rectangle
57: * @param x2 the x-coordinate of the right edge of the rectangle
58: * @param y2 the y-coordinate of the bottom edge of the rectangle
59: */
60: public void addRectangle(int x1, int y1, int x2, int y2) {
61: ScriptBuffer script = new ScriptBuffer();
62: script.appendCall(getContextPath() + "addRectangle", x1, y1,
63: x2, y2);
64: getScriptProxy().addScript(script);
65: }
66:
67: /**
68: * add a rectangle to this group
69: * @param x1 the x-coordinate of the left edge of the rectangle
70: * @param y1 the y-coordinate of the top edge of the rectangle
71: * @param w the width of the rectangle
72: * @param h the height of the rectangle
73: */
74: public void addRelativeRectangle(int x1, int y1, int w, int h) {
75: ScriptBuffer script = new ScriptBuffer();
76: script.appendCall(getContextPath() + "addRelativeRectangle",
77: x1, y1, w, h);
78: getScriptProxy().addScript(script);
79: }
80:
81: /**
82: * clear all rectangles out of the group
83: */
84: public void clearRectangles() {
85: ScriptBuffer script = new ScriptBuffer();
86: script.appendCall(getContextPath() + "clearRectangles");
87: getScriptProxy().addScript(script);
88: }
89:
90: }
|