01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.core;
09:
10: import com.google.gwt.core.client.JavaScriptObject;
11: import com.gwtext.client.util.JavaScriptObjectHelper;
12:
13: /**
14: * This class represents an Element's Box.
15: *
16: * @see com.gwtext.client.core.BaseElement#setBox(Box)
17: * @see com.gwtext.client.core.BaseElement#setBox(Box, boolean, boolean)
18: * @see com.gwtext.client.core.BaseElement#setBox(Box, boolean, AnimationConfig)
19: */
20: public class Box extends JsObject {
21:
22: private int x;
23: private int y;
24: private int width;
25: private int height;
26:
27: /**
28: * Constructor
29: *
30: * @param x x-position
31: * @param y y-position
32: * @param width the box width
33: * @param height the box height
34: */
35: public Box(int x, int y, int width, int height) {
36: this .x = x;
37: this .y = y;
38: this .width = width;
39: this .height = height;
40: jsObj = JavaScriptObjectHelper.createObject();
41: JavaScriptObjectHelper.setAttribute(jsObj, "x", x);
42: JavaScriptObjectHelper.setAttribute(jsObj, "y", y);
43: JavaScriptObjectHelper.setAttribute(jsObj, "width", width);
44: JavaScriptObjectHelper.setAttribute(jsObj, "height", height);
45: }
46:
47: private static Box instance(JavaScriptObject jsObj) {
48: return new Box(JavaScriptObjectHelper.getAttributeAsInt(jsObj,
49: "x"), JavaScriptObjectHelper.getAttributeAsInt(jsObj,
50: "y"), JavaScriptObjectHelper.getAttributeAsInt(jsObj,
51: "width"), JavaScriptObjectHelper.getAttributeAsInt(
52: jsObj, "height"));
53: }
54:
55: /**
56: * Get the x position value.
57: *
58: * @return the x value
59: */
60: public int getX() {
61: return x;
62: }
63:
64: /**
65: * Get the y position value.
66: *
67: * @return the y position
68: */
69: public int getY() {
70: return y;
71: }
72:
73: /**
74: * Get the box width.
75: *
76: * @return the box width
77: */
78: public int getWidth() {
79: return width;
80: }
81:
82: /**
83: * Get the box height.
84: *
85: * @return the box height
86: */
87: public int getHeight() {
88: return height;
89: }
90: }
|