1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
<?xml version="1.0" encoding="UTF-8"?>
<model:Screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:model="http://wireframesketcher.com/1.0/model.ecore">
<widgets xsi:type="model:Window" x="25" y="25" width="816" height="578" text="Java - org.eclipse.draw2d.geometry.Rectangle - Eclipse" measuredWidth="816" measuredHeight="578"/>
<widgets xsi:type="model:Menu" x="25" y="44" width="803" text="File,Edit,Source,Refactor,Navigate,Search,Project,Run,Window,Help" measuredWidth="803" measuredHeight="30">
<items x="5" y="0" width="30" height="30" text="File"/>
<items x="35" y="0" width="34" height="30" text="Edit"/>
<items x="69" y="0" width="55" height="30" text="Source"/>
<items x="124" y="0" width="62" height="30" text="Refactor"/>
<items x="186" y="0" width="67" height="30" text="Navigate"/>
<items x="253" y="0" width="55" height="30" text="Search"/>
<items x="308" y="0" width="54" height="30" text="Project"/>
<items x="362" y="0" width="33" height="30" text="Run"/>
<items x="395" y="0" width="57" height="30" text="Window"/>
<items x="452" y="0" width="39" height="30" text="Help"/>
</widgets>
<widgets xsi:type="model:VLine" x="29" y="74" height="26" measuredWidth="6" measuredHeight="26"/>
<widgets xsi:type="model:VLine" x="169" y="74" height="26" measuredWidth="6" measuredHeight="26"/>
<widgets xsi:type="model:VLine" x="239" y="74" height="26" measuredWidth="6" measuredHeight="26"/>
<widgets xsi:type="model:VLine" x="361" y="74" height="26" measuredWidth="6" measuredHeight="26"/>
<widgets xsi:type="model:VLine" x="473" y="74" height="26" measuredWidth="6" measuredHeight="26"/>
<widgets xsi:type="model:VLine" x="569" y="74" height="26" measuredWidth="6" measuredHeight="26"/>
<widgets xsi:type="model:Icon" x="255" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="271" y="80" measuredWidth="16" measuredHeight="16" icon="empty-arrow-down (small)"/>
<widgets xsi:type="model:Icon" x="289" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="315" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="341" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="585" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="601" y="80" measuredWidth="16" measuredHeight="16" icon="empty-arrow-down (small)"/>
<widgets xsi:type="model:Icon" x="619" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="635" y="80" measuredWidth="16" measuredHeight="16" icon="empty-arrow-down (small)"/>
<widgets xsi:type="model:Icon" x="45" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="71" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="97" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="123" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="149" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="377" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="393" y="80" measuredWidth="16" measuredHeight="16" icon="empty-arrow-down (small)"/>
<widgets xsi:type="model:Icon" x="411" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="427" y="80" measuredWidth="16" measuredHeight="16" icon="empty-arrow-down (small)"/>
<widgets xsi:type="model:Icon" x="445" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="461" y="80" measuredWidth="16" measuredHeight="16" icon="empty-arrow-down (small)"/>
<widgets xsi:type="model:Icon" x="489" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="515" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="541" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="557" y="80" measuredWidth="16" measuredHeight="16" icon="empty-arrow-down (small)"/>
<widgets xsi:type="model:Icon" x="185" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="211" y="80" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="227" y="80" measuredWidth="16" measuredHeight="16" icon="empty-arrow-down (small)"/>
<widgets xsi:type="model:HLine" x="313" y="573" width="2" measuredWidth="2" measuredHeight="6"/>
<widgets xsi:type="model:Label" x="318" y="573" text="Read-Only" measuredWidth="69" measuredHeight="25">
<font/>
</widgets>
<widgets xsi:type="model:HLine" x="432" y="573" width="2" measuredWidth="2" measuredHeight="6"/>
<widgets xsi:type="model:Label" x="437" y="573" text="Smart Insert" measuredWidth="85" measuredHeight="25">
<font/>
</widgets>
<widgets xsi:type="model:HLine" x="544" y="573" width="2" measuredWidth="2" measuredHeight="6"/>
<widgets xsi:type="model:Label" x="549" y="573" text="41 : 8" measuredWidth="41" measuredHeight="25">
<font/>
</widgets>
<widgets xsi:type="model:Icon" x="45" y="579" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="69" y="142" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="95" y="142" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:VLine" x="115" y="136" height="26" measuredWidth="6" measuredHeight="26"/>
<widgets xsi:type="model:Icon" x="127" y="142" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Tree" x="34" y="164" width="135" height="404" text="fakessh
fakessh2
ksm
ksmrcp
ksm-trunk
playground1
quercustest
rcpapp
zs
" measuredWidth="135" measuredHeight="404" verticalScrollbar="true">
<items x="0" y="5" width="118" height="23" text="fakessh"/>
<items x="0" y="28" width="118" height="23" text="fakessh2"/>
<items x="0" y="51" width="118" height="23" text="ksm"/>
<items x="0" y="74" width="118" height="23" text="ksmrcp"/>
<items x="0" y="97" width="118" height="23" text="ksm-trunk"/>
<items x="0" y="120" width="118" height="23" text="playground1"/>
<items x="0" y="143" width="118" height="23" text="quercustest"/>
<items x="0" y="166" width="118" height="23" text="rcpapp"/>
<items x="0" y="189" width="118" height="23" text="zs"/>
</widgets>
<widgets xsi:type="model:Icon" x="680" y="141" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="706" y="141" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="732" y="141" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="758" y="141" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Icon" x="784" y="141" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:Tree" x="675" y="161" width="153" height="263" text="Rectangle
-serialVersionUID : long
-SINGLETON : Rectangle
-height : int
-width : int
-x : int
-y : int
-Rectangle()
-Rectangle(int, int, int, int)
-Rectangle(Point, Dimension)
-Rectangle(Point, Point)
-Rectangle(Rectangle)
-Rectangle(Rectangle)
-bottom() : int
-contains(int, int) : boolean
-contains(Point) : boolean
-contains(Rectangle) : boolean
-crop(Insets) : Rectangle
-equals(Object) : boolean
-expand(int, int) : Rectangle
-expand(Insets) : Rectangle
-getBottom() : Point
-getBottomLeft() : Point
-getBottomRight() : Point
-getCenter() : Point
-getCopy() : Rectangle
-getCropped(Insets) : Rectangle
-getExpanded(int, int) : Rectangle
-getExpanded(Insets) : Rectangle
-getIntersection(Rectangle) : Rectangle
-getLeft() : Point
-getLocation() : Point
-getPosition(Point) : int
-getResized(int, int) : Rectangle
-getResized(Dimension) : Rectangle
-getRight() : Point
-getSize() : Dimension
-getTop() : Point
-getTopLeft() : Point
-getTopRight() : Point
-getTranslated(int, int) : Rectangle
-getTranslated(Point) : Rectangle
-getTransposed() : Rectangle
-getUnion(Rectangle) : Rectangle
-hashCode() : int
-intersect(Rectangle) : Rectangle
-intersects(Rectangle) : boolean
-isEmpty() : boolean
-performScale(double) : void
-performTranslate(int, int) : void
-preciseHeight() : double
-preciseWidth() : double
-preciseX() : double
-preciseY() : double
-resize(int, int) : Rectangle
-resize(Dimension) : Rectangle
-right() : int
-scale(double) : Rectangle
-scale(double, double) : Rectangle
-setBounds(Rectangle) : Rectangle
-setLocation(int, int) : Rectangle
-setLocation(Point) : Rectangle
-setSize(int, int) : Rectangle
-setSize(Dimension) : Rectangle
-shrink(int, int) : Rectangle
-toString() : String
-touches(Rectangle) : boolean
-translate(int, int) : Rectangle
-translate(Point) : Rectangle
-transpose() : Rectangle
-union(int, int) : Rectangle
-union(int, int, int, int) : Rectangle
-union(Dimension) : Rectangle
-union(Point) : void
-union(Rectangle) : Rectangle
" measuredWidth="153" measuredHeight="263" verticalScrollbar="true">
<items x="0" y="5" width="136" height="23" text="Rectangle"/>
<items x="0" y="28" width="136" height="23" text="-serialVersionUID : long"/>
<items x="0" y="51" width="136" height="23" text="-SINGLETON : Rectangle"/>
<items x="0" y="74" width="136" height="23" text="-height : int"/>
<items x="0" y="97" width="136" height="23" text="-width : int"/>
<items x="0" y="120" width="136" height="23" text="-x : int"/>
<items x="0" y="143" width="136" height="23" text="-y : int"/>
<items x="0" y="166" width="136" height="23" text="-Rectangle()"/>
<items x="0" y="189" width="136" height="23" text="-Rectangle(int, int, int, int)"/>
<items x="0" y="212" width="136" height="23" text="-Rectangle(Point, Dimension)"/>
<items x="0" y="235" width="136" height="23" text="-Rectangle(Point, Point)"/>
<items x="0" y="258" width="136" height="23" text="-Rectangle(Rectangle)"/>
<items x="0" y="281" width="136" height="23" text="-Rectangle(Rectangle)"/>
<items x="0" y="304" width="136" height="23" text="-bottom() : int"/>
<items x="0" y="327" width="136" height="23" text="-contains(int, int) : boolean"/>
<items x="0" y="350" width="136" height="23" text="-contains(Point) : boolean"/>
<items x="0" y="373" width="136" height="23" text="-contains(Rectangle) : boolean"/>
<items x="0" y="396" width="136" height="23" text="-crop(Insets) : Rectangle"/>
<items x="0" y="419" width="136" height="23" text="-equals(Object) : boolean"/>
<items x="0" y="442" width="136" height="23" text="-expand(int, int) : Rectangle"/>
<items x="0" y="465" width="136" height="23" text="-expand(Insets) : Rectangle"/>
<items x="0" y="488" width="136" height="23" text="-getBottom() : Point"/>
<items x="0" y="511" width="136" height="23" text="-getBottomLeft() : Point"/>
<items x="0" y="534" width="136" height="23" text="-getBottomRight() : Point"/>
<items x="0" y="557" width="136" height="23" text="-getCenter() : Point"/>
<items x="0" y="580" width="136" height="23" text="-getCopy() : Rectangle"/>
<items x="0" y="603" width="136" height="23" text="-getCropped(Insets) : Rectangle"/>
<items x="0" y="626" width="136" height="23" text="-getExpanded(int, int) : Rectangle"/>
<items x="0" y="649" width="136" height="23" text="-getExpanded(Insets) : Rectangle"/>
<items x="0" y="672" width="136" height="23" text="-getIntersection(Rectangle) : Rectangle"/>
<items x="0" y="695" width="136" height="23" text="-getLeft() : Point"/>
<items x="0" y="718" width="136" height="23" text="-getLocation() : Point"/>
<items x="0" y="741" width="136" height="23" text="-getPosition(Point) : int"/>
<items x="0" y="764" width="136" height="23" text="-getResized(int, int) : Rectangle"/>
<items x="0" y="787" width="136" height="23" text="-getResized(Dimension) : Rectangle"/>
<items x="0" y="810" width="136" height="23" text="-getRight() : Point"/>
<items x="0" y="833" width="136" height="23" text="-getSize() : Dimension"/>
<items x="0" y="856" width="136" height="23" text="-getTop() : Point"/>
<items x="0" y="879" width="136" height="23" text="-getTopLeft() : Point"/>
<items x="0" y="902" width="136" height="23" text="-getTopRight() : Point"/>
<items x="0" y="925" width="136" height="23" text="-getTranslated(int, int) : Rectangle"/>
<items x="0" y="948" width="136" height="23" text="-getTranslated(Point) : Rectangle"/>
<items x="0" y="971" width="136" height="23" text="-getTransposed() : Rectangle"/>
<items x="0" y="994" width="136" height="23" text="-getUnion(Rectangle) : Rectangle"/>
<items x="0" y="1017" width="136" height="23" text="-hashCode() : int"/>
<items x="0" y="1040" width="136" height="23" text="-intersect(Rectangle) : Rectangle"/>
<items x="0" y="1063" width="136" height="23" text="-intersects(Rectangle) : boolean"/>
<items x="0" y="1086" width="136" height="23" text="-isEmpty() : boolean"/>
<items x="0" y="1109" width="136" height="23" text="-performScale(double) : void"/>
<items x="0" y="1132" width="136" height="23" text="-performTranslate(int, int) : void"/>
<items x="0" y="1155" width="136" height="23" text="-preciseHeight() : double"/>
<items x="0" y="1178" width="136" height="23" text="-preciseWidth() : double"/>
<items x="0" y="1201" width="136" height="23" text="-preciseX() : double"/>
<items x="0" y="1224" width="136" height="23" text="-preciseY() : double"/>
<items x="0" y="1247" width="136" height="23" text="-resize(int, int) : Rectangle"/>
<items x="0" y="1270" width="136" height="23" text="-resize(Dimension) : Rectangle"/>
<items x="0" y="1293" width="136" height="23" text="-right() : int"/>
<items x="0" y="1316" width="136" height="23" text="-scale(double) : Rectangle"/>
<items x="0" y="1339" width="136" height="23" text="-scale(double, double) : Rectangle"/>
<items x="0" y="1362" width="136" height="23" text="-setBounds(Rectangle) : Rectangle"/>
<items x="0" y="1385" width="136" height="23" text="-setLocation(int, int) : Rectangle"/>
<items x="0" y="1408" width="136" height="23" text="-setLocation(Point) : Rectangle"/>
<items x="0" y="1431" width="136" height="23" text="-setSize(int, int) : Rectangle"/>
<items x="0" y="1454" width="136" height="23" text="-setSize(Dimension) : Rectangle"/>
<items x="0" y="1477" width="136" height="23" text="-shrink(int, int) : Rectangle"/>
<items x="0" y="1500" width="136" height="23" text="-toString() : String"/>
<items x="0" y="1523" width="136" height="23" text="-touches(Rectangle) : boolean"/>
<items x="0" y="1546" width="136" height="23" text="-translate(int, int) : Rectangle"/>
<items x="0" y="1569" width="136" height="23" text="-translate(Point) : Rectangle"/>
<items x="0" y="1592" width="136" height="23" text="-transpose() : Rectangle"/>
<items x="0" y="1615" width="136" height="23" text="-union(int, int) : Rectangle"/>
<items x="0" y="1638" width="136" height="23" text="-union(int, int, int, int) : Rectangle"/>
<items x="0" y="1661" width="136" height="23" text="-union(Dimension) : Rectangle"/>
<items x="0" y="1684" width="136" height="23" text="-union(Point) : void"/>
<items x="0" y="1707" width="136" height="23" text="-union(Rectangle) : Rectangle"/>
</widgets>
<widgets xsi:type="model:TextArea" x="185" y="136" width="476" height="288" text=" * Copyright (c) 2000, 2010 IBM Corporation and others.
package org.eclipse.draw2d.geometry;

import org.eclipse.draw2d.PositionConstants;

public class Rectangle
 implements 
Cloneable, java.io.Serializable,
 Translatable {
	/** the X value */
	public int x;
	/** the Y value */
	public int y;
	/** the width */
	public int width;
	/** the height */
	public int height;

	/**
	 * A singleton for use in short calculations. Use to avoid newing
	 * unnecessary objects.
	 */
	public static final Rectangle SINGLETON = new Rectangle();

	static final long serialVersionUID = 1;

	/**
	 * Constructs a Rectangle at the origin with zero width and height.
	 * 
	 * @since 2.0
	 */
	public Rectangle() {
	}

	/**
	 * Constructs a Rectangle given a location and size.
	 * 
	 * @param p
	 * the location
	 * @param size
	 * the size
	 * @since 2.0
	 */
	public Rectangle(Point p, Dimension size) {
		this(p.x, p.y, size.width, size.height);
	}

	/**
	 * Constructs a copy of the provided Rectangle.
	 * 
	 * @param rect
	 * Rectangle supplying the initial values
	 * @since 2.0
	 */
	public Rectangle(Rectangle rect) {
		this(rect.x, rect.y, rect.width, rect.height);
	}

	/**
	 * Constructs a copy of the provided SWT
	 * {@link org.eclipse.swt.graphics.Rectangle}.
	 * 
	 * @param rect
	 * The SWT Rectangle being copied
	 * @since 2.0
	 */
	public Rectangle(org.eclipse.swt.graphics.Rectangle rect) {
		this(rect.x, rect.y, rect.width, rect.height);
	}

	/**
	 * Constructs a Rectangle with the provided values.
	 * 
	 * @param x
	 * X location
	 * @param y
	 * Y location
	 * @param width
	 * Width of the rectangle
	 * @param height
	 * Height of the rectangle
	 * @since 2.0
	 */
	public Rectangle(int x, int y, int width, int height) {
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}

	/**
	 * Constructs the smallest Rectangle that contains the specified Points.
	 * 
	 * @param p1
	 * Upper left hand corner
	 * @param p2
	 * Lower right hand corner
	 * @since 2.0
	 */
	public Rectangle(Point p1, Point p2) {
		this.x = Math.min(p1.x, p2.x);
		this.y = Math.min(p1.y, p2.y);
		this.width = Math.abs(p2.x - p1.x) + 1;
		this.height = Math.abs(p2.y - p1.y) + 1;
	}

	/**
	 * Returns the y-coordinate of the bottom of this Rectangle.
	 * 
	 * @return The Y coordinate of the bottom
	 * @since 2.0
	 */
	public int bottom() {
		return y + height;
	}

	/**
	 * Returns whether the given point is within the boundaries of this
	 * Rectangle. The boundaries are inclusive of the top and left edges, but
	 * exclusive of the bottom and right edges.
	 * 
	 * @param pt
	 * Point being tested for containment
	 * @return true if the Point is within this Rectangle
	 * @since 2.0
	 */
	public boolean contains(Point pt) {
		return contains(pt.x, pt.y);
	}

	/**
	 * Returns <code>true</code> if the given rectangle is contained within the
	 * boundaries of this Rectangle.
	 * 
	 * @param rect
	 * the Rectangle to test
	 * @return true if the Rectangle is within this Rectangle
	 */
	public boolean contains(Rectangle rect) {
		return x <= rect.x && y <= rect.y && right() >= rect.right()
				&& bottom() >= rect.bottom();
	}

	/**
	 * Returns whether the given coordinates are within the boundaries of this
	 * Rectangle. The boundaries are inclusive of the top and left edges, but
	 * exclusive of the bottom and right edges.
	 * 
	 * @param x
	 * X value
	 * @param y
	 * Y value
	 * @return true if the coordinates are within this Rectangle
	 * @since 2.0
	 */
	public boolean contains(int x, int y) {
		return y >= this.y && y < this.y + this.height && x >= this.x
				&& x < this.x + this.width;
	}

	/**
	 * Crops this rectangle by the amount specified in <code>insets</code>.
	 * 
	 * @param insets
	 * Insets to be removed from the Rectangle
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle crop(Insets insets) {
		if (insets == null)
			return this;
		x += insets.left;
		y += insets.top;
		width -= (insets.getWidth());
		height -= (insets.getHeight());
		return this;
	}

	/**
	 * Returns whether the input object is equal to this Rectangle or not.
	 * Rectangles are equivalent if their x, y, height, and width values are the
	 * same.
	 * 
	 * @param o
	 * Object being tested for equality
	 * @return Returns the result of the equality test
	 * @since 2.0
	 */
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o instanceof Rectangle) {
			Rectangle r = (Rectangle) o;
			return (x == r.x) && (y == r.y) && (width == r.width)
					&& (height == r.height);
		}
		return false;
	}

	/**
	 * Expands the horizontal and vertical sides of this Rectangle with the
	 * values provided as input, and returns this for convenience. The location
	 * of its center is kept constant.
	 * 
	 * @param h
	 * Horizontal increment
	 * @param v
	 * Vertical increment
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle expand(int h, int v) {
		return shrink(-h, -v);
	}

	/**
	 * Expands the horizontal and vertical sides of this Rectangle by the width
	 * and height of the given Insets, and returns this for convenience.
	 * 
	 * @param insets
	 * contains the amounts to expand on each side
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle expand(Insets insets) {
		x -= insets.left;
		y -= insets.top;
		height += insets.getHeight();
		width += insets.getWidth();
		return this;
	}

	/**
	 * Returns a new Point representing the middle point of the bottom side of
	 * this Rectangle.
	 * 
	 * @return Point at the bottom of the Rectangle
	 * @since 2.0
	 */
	public Point getBottom() {
		return new Point(x + width / 2, bottom());
	}

	/**
	 * Returns a new Point representing the bottom left point of this Rectangle.
	 * 
	 * @return Point at the bottom left of the rectangle
	 * @since 2.0
	 */
	public Point getBottomLeft() {
		return new Point(x, y + height);
	}

	/**
	 * Returns a new Point representing the bottom right point of this
	 * Rectangle.
	 * 
	 * @return Point at the bottom right of the rectangle
	 * @since 2.0
	 */
	public Point getBottomRight() {
		return new Point(x + width, y + height);
	}

	/**
	 * Returns a new point representing the center of this Rectangle.
	 * 
	 * @return Point at the center of the rectangle
	 */
	public Point getCenter() {
		return new Point(x + width / 2, y + height / 2);
	}

	/**
	 * Returns a new Rectangle which has the exact same parameters as this
	 * Rectangle.
	 * 
	 * @return Copy of this Rectangle
	 * @since 2.0
	 */
	public Rectangle getCopy() {

		if (getClass() == Rectangle.class) {
			/* avoid clone() call cost see bug #260740 */
			return new Rectangle(this);
		} else {
			try {
				return (Rectangle) clone();
			} catch (CloneNotSupportedException exc) {
				return new Rectangle(this);
			}
		}
	}

	/**
	 * Returns a new Rectangle with the specified insets cropped.
	 * 
	 * @param insets
	 * Insets being cropped from the Rectangle
	 * @return Cropped new Rectangle
	 */
	public Rectangle getCropped(Insets insets) {
		Rectangle r = new Rectangle(this);
		r.crop(insets);
		return r;
	}

	/**
	 * Returns a new incremented Rectangle, where the sides are expanded by the
	 * horizonatal and vertical values provided. The center of the Rectangle is
	 * maintained constant.
	 * 
	 * @param h
	 * Horizontal increment
	 * @param v
	 * Vertical inrement
	 * @return A new expanded Rectangle
	 * @since 2.0
	 */
	public Rectangle getExpanded(int h, int v) {
		return new Rectangle(this).expand(h, v);
	}

	/**
	 * Creates and returns a new Rectangle with the bounds of <code>this</code>
	 * Rectangle, expanded by the given Insets.
	 * 
	 * @param insets
	 * The insets used to expand this rectangle
	 * @return A new expanded Rectangle
	 * @since 2.0
	 */
	public Rectangle getExpanded(Insets insets) {
		return new Rectangle(this).expand(insets);
	}

	/**
	 * Returns a new Rectangle which has the intersection of this Rectangle and
	 * the rectangle provided as input. Returns an empty Rectangle if there is
	 * no interection.
	 * 
	 * @param rect
	 * Rectangle provided to test for intersection
	 * @return A new Rectangle representing the intersection
	 * @since 2.0
	 */
	public Rectangle getIntersection(Rectangle rect) {
		int x1 = Math.max(x, rect.x);
		int x2 = Math.min(x + width, rect.x + rect.width);
		int y1 = Math.max(y, rect.y);
		int y2 = Math.min(y + height, rect.y + rect.height);
		if (((x2 - x1) < 0) || ((y2 - y1) < 0))
			return new Rectangle(0, 0, 0, 0); // No intersection
		else
			return new Rectangle(x1, y1, x2 - x1, y2 - y1);
	}

	/**
	 * Returns a new Point representing the middle point of the left hand side
	 * of this Rectangle.
	 * 
	 * @return Point at the left of the Rectangle
	 */
	public Point getLeft() {
		return new Point(x, y + height / 2);
	}

	/**
	 * Returns the upper left hand corner of the rectangle.
	 * 
	 * @return Location of the rectangle
	 * @see #setLocation(Point)
	 */
	public Point getLocation() {
		return new Point(x, y);
	}

	/**
	 * <P>
	 * Returns an integer which represents the position of the given point with
	 * respect to this rectangle. Possible return values are bitwise ORs of the
	 * constants WEST, EAST, NORTH, and SOUTH as found in
	 * {@link org.eclipse.draw2d.PositionConstants}.
	 * 
	 * <P>
	 * Returns PositionConstant.NONE if the given point is inside this
	 * Rectangle.
	 * 
	 * @param pt
	 * The Point whose position has to be determined
	 * @return An <code>int</code> which is a PositionConstant
	 * @see org.eclipse.draw2d.PositionConstants
	 * @since 2.0
	 */
	public int getPosition(Point pt) {
		int result = PositionConstants.NONE;

		if (contains(pt))
			return result;

		if (pt.x < x)
			result = PositionConstants.WEST;
		else if (pt.x >= (x + width))
			result = PositionConstants.EAST;

		if (pt.y < y)
			result = result | PositionConstants.NORTH;
		else if (pt.y >= (y + height))
			result = result | PositionConstants.SOUTH;

		return result;
	}

	/**
	 * Returns a new Rectangle which is equivalent to this Rectangle with its
	 * dimensions modified by the passed width <i>w</i> and height <i>h</i>.
	 * 
	 * @param w
	 * Amount by which width is to be resized
	 * @param h
	 * Amount by which height is to be resized
	 * @return a new rectangle with its width and height modified
	 */
	public Rectangle getResized(int w, int h) {
		return new Rectangle(this).resize(w, h);
	}

	/**
	 * Returns a new Rectangle which is equivalent to this Rectangle with its
	 * dimensions modified by the passed Dimension <i>d</i>.
	 * 
	 * @param d
	 * Dimensions by which the rectangle's size should be modified
	 * @return The new rectangle with the modified dimensions
	 * @since 2.0
	 */
	public Rectangle getResized(Dimension d) {
		return new Rectangle(this).resize(d);
	}

	/**
	 * Returns a new Point which represents the middle point of the right hand
	 * side of this Rectangle.
	 * 
	 * @return Point at the right of the Rectangle
	 * @since 2.0
	 */
	public Point getRight() {
		return new Point(right(), y + height / 2);
	}

	/**
	 * Retuns the dimensions of this Rectangle.
	 * 
	 * @return Size of this Rectangle as a Dimension
	 * @since 2.0
	 */
	public Dimension getSize() {
		return new Dimension(width, height);
	}

	/**
	 * Returns a new Point which represents the middle point of the top side of
	 * this Rectangle.
	 * 
	 * @return Point at the top of the Rectangle
	 * @since 2.0
	 */
	public Point getTop() {
		return new Point(x + width / 2, y);
	}

	/**
	 * Returns a new Point which represents the top left hand corner of this
	 * Rectangle.
	 * 
	 * @return Point at the top left of the rectangle
	 * @since 2.0
	 */
	public Point getTopLeft() {
		return new Point(x, y);
	}

	/**
	 * Returns a new Point which represents the top right hand corner of this
	 * Rectangle.
	 * 
	 * @return Point at the top right of the rectangle
	 * @since 2.0
	 */
	public Point getTopRight() {
		return new Point(x + width, y);
	}

	/**
	 * Returns a new Rectangle which is shifted along each axis by the passed
	 * values.
	 * 
	 * @param dx
	 * Displacement along X axis
	 * @param dy
	 * Displacement along Y axis
	 * @return The new translated rectangle
	 * @since 2.0
	 */
	public Rectangle getTranslated(int dx, int dy) {
		return new Rectangle(this).translate(dx, dy);
	}

	/**
	 * Returns a new Rectangle which is shifted by the position of the given
	 * Point.
	 * 
	 * @param pt
	 * Point providing the amount of shift along each axis
	 * @return The new translated Rectangle
	 * @since 2.0
	 */
	public Rectangle getTranslated(Point pt) {
		return new Rectangle(this).translate(pt);
	}

	/**
	 * Returns a new rectangle whose width and height have been interchanged, as
	 * well as its x and y values. This can be useful in orientation changes.
	 * 
	 * @return The transposed rectangle
	 * @since 2.0
	 */
	public Rectangle getTransposed() {
		Rectangle r = new Rectangle(this);
		r.transpose();
		return r;
	}

	/**
	 * Returns a new Rectangle which contains both this Rectangle and the
	 * Rectangle supplied as input.
	 * 
	 * @param rect
	 * Rectangle for calculating union
	 * @return A new unioned Rectangle
	 * @since 2.0
	 */
	public Rectangle getUnion(Rectangle rect) {
		if (rect == null || rect.isEmpty())
			return new Rectangle(this);
		Rectangle union = new Rectangle(Math.min(x, rect.x),
				Math.min(y, rect.y), 0, 0);
		union.width = Math.max(x + width, rect.x + rect.width) - union.x;
		union.height = Math.max(y + height, rect.y + rect.height) - union.y;
		return union;
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return (x + height + 1) * (y + width + 1) ^ x ^ y;
	}

	/**
	 * Sets the size of this Rectangle to the intersection region with the
	 * Rectangle supplied as input, and returns this for convenience. The
	 * location and dimensions are set to zero if there is no intersection with
	 * the input Rectangle.
	 * 
	 * @param rect
	 * Rectangle for the calculating intersection.
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle intersect(Rectangle rect) {
		int x1 = Math.max(x, rect.x);
		int x2 = Math.min(x + width, rect.x + rect.width);
		int y1 = Math.max(y, rect.y);
		int y2 = Math.min(y + height, rect.y + rect.height);
		if (((x2 - x1) < 0) || ((y2 - y1) < 0))
			x = y = width = height = 0; // No intersection
		else {
			x = x1;
			y = y1;
			width = x2 - x1;
			height = y2 - y1;
		}
		return this;
	}

	/**
	 * Returns <code>true</code> if the input Rectangle intersects this
	 * Rectangle.
	 * 
	 * @param rect
	 * Rectangle for the intersetion test
	 * @return <code>true</code> if the input Rectangle intersects this
	 * Rectangle
	 * @since 2.0
	 */
	public boolean intersects(Rectangle rect) {
		return rect.x < x + width && rect.y < y + height
				&& rect.x + rect.width > x && rect.y + rect.height > y;
	}

	/**
	 * Returns <code>true</code> if this Rectangle's width or height is less
	 * than or equal to 0.
	 * 
	 * @return <code>true</code> if this Rectangle is empty
	 * @since 2.0
	 */
	public boolean isEmpty() {
		return width <= 0 || height <= 0;
	}

	/**
	 * @see Translatable#performScale(double)
	 */
	public void performScale(double factor) {
		scale(factor);
	}

	/**
	 * @see Translatable#performTranslate(int, int)
	 */
	public void performTranslate(int dx, int dy) {
		translate(dx, dy);
	}

	/**
	 * Resizes this Rectangle by the Dimension provided as input and returns
	 * this for convenience. This Rectange's width will become this.width +
	 * sizeDelta.width. Likewise for height.
	 * 
	 * @param sizeDelta
	 * Resize data as a Dimension
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle resize(Dimension sizeDelta) {
		width += sizeDelta.width;
		height += sizeDelta.height;
		return this;
	}

	/**
	 * Resizes this Rectangle by the values supplied as input and returns this
	 * for convenience. This Rectangle's width will become this.width + dw. This
	 * Rectangle's height will become this.height + dh.
	 * 
	 * @param dw
	 * Amount by which width is to be resized
	 * @param dh
	 * Amount by which height is to be resized
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle resize(int dw, int dh) {
		width += dw;
		height += dh;
		return this;
	}

	/**
	 * Returns the x-coordinate of the right side of this Rectangle.
	 * 
	 * @return The X coordinate of the right side
	 * @since 2.0
	 */
	public int right() {
		return x + width;
	}

	/**
	 * Scales the location and size of this Rectangle by the given scale and
	 * returns this for convenience.
	 * 
	 * @param scaleFactor
	 * The factor by which this rectangle will be scaled
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public final Rectangle scale(double scaleFactor) {
		return scale(scaleFactor, scaleFactor);
	}

	/**
	 * Scales the location and size of this Rectangle by the given scales and
	 * returns this for convenience.
	 * 
	 * @param scaleX
	 * the factor by which the X dimension has to be scaled
	 * @param scaleY
	 * the factor by which the Y dimension has to be scaled
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle scale(double scaleX, double scaleY) {
		int oldX = x;
		int oldY = y;
		x = (int) (Math.floor(x * scaleX));
		y = (int) (Math.floor(y * scaleY));
		width = (int) (Math.ceil((oldX + width) * scaleX)) - x;
		height = (int) (Math.ceil((oldY + height) * scaleY)) - y;
		return this;
	}

	/**
	 * Sets the parameters of this Rectangle from the Rectangle passed in and
	 * returns this for convenience.
	 * 
	 * @return <code>this</code> for convenience
	 * @param rect
	 * Rectangle providing the bounding values
	 * @since 2.0
	 */
	public Rectangle setBounds(Rectangle rect) {
		x = rect.x;
		y = rect.y;
		width = rect.width;
		height = rect.height;
		return this;
	}

	/**
	 * Sets the location of this Rectangle to the point given as input and
	 * returns this for convenience.
	 * 
	 * @return <code>this</code> for convenience
	 * @param p
	 * New position of this Rectangle
	 * @since 2.0
	 */
	public Rectangle setLocation(Point p) {
		x = p.x;
		y = p.y;
		return this;
	}

	/**
	 * Sets the location of this Rectangle to the coordinates given as input and
	 * returns this for convenience.
	 * 
	 * @param x1
	 * The new X coordinate
	 * @param y1
	 * The new Y coordinate
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle setLocation(int x1, int y1) {
		x = x1;
		y = y1;
		return this;
	}

	/**
	 * Sets the width and height of this Rectangle to the width and height of
	 * the given Dimension and returns this for convenience.
	 * 
	 * @param d
	 * The new Dimension
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle setSize(Dimension d) {
		width = d.width;
		height = d.height;
		return this;
	}

	/**
	 * Sets the width of this Rectangle to <i>w</i> and the height of this
	 * Rectangle to <i>h</i> and returns this for convenience.
	 * 
	 * @return <code>this</code> for convenience
	 * @param w
	 * The new width
	 * @param h
	 * The new height
	 * @since 2.0
	 */
	public Rectangle setSize(int w, int h) {
		width = w;
		height = h;
		return this;
	}

	/**
	 * Shrinks the sides of this Rectangle by the horizontal and vertical values
	 * provided as input, and returns this Rectangle for convenience. The center
	 * of this Rectangle is kept constant.
	 * 
	 * @param h
	 * Horizontal reduction amount
	 * @param v
	 * Vertical reduction amount
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle shrink(int h, int v) {
		x += h;
		width -= (h + h);
		y += v;
		height -= (v + v);
		return this;
	}

	/**
	 * Returns the description of this Rectangle.
	 * 
	 * @return String containing the description
	 * @since 2.0
	 */
	public String toString() {
		return "Rectangle(" + x + ", " + y + ", " + //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
				width + ", " + height + ")";//$NON-NLS-2$//$NON-NLS-1$
	}

	/**
	 * Returns <code>true</code> if the input Rectangle touches this Rectangle.
	 * 
	 * @param rect
	 * Rectangle being checked for contact
	 * @return <code>true</code> if rect touches this Rectangle
	 * @since 2.0
	 */
	public boolean touches(Rectangle rect) {
		return rect.x <= x + width && rect.y <= y + height
				&& rect.x + rect.width >= x && rect.y + rect.height >= y;
	}

	/**
	 * Moves this Rectangle horizontally by the x value of the given Point and
	 * vertically by the y value of the given Point, then returns this Rectangle
	 * for convenience.
	 * 
	 * @param p
	 * Point which provides translation information
	 * @return <code>this</code> for convenience
	 */
	public Rectangle translate(Point p) {
		x += p.x;
		y += p.y;
		return this;
	}

	/**
	 * Moves this Rectangle horizontally by dx and vertically by dy, then
	 * returns this Rectangle for convenience.
	 * 
	 * @param dx
	 * Shift along X axis
	 * @param dy
	 * Shift along Y axis
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle translate(int dx, int dy) {
		x += dx;
		y += dy;
		return this;
	}

	/**
	 * Switches the x and y values, as well as the width and height of this
	 * Rectangle. Useful for orientation changes.
	 * 
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle transpose() {
		int temp = x;
		x = y;
		y = temp;
		temp = width;
		width = height;
		height = temp;
		return this;
	}

	/**
	 * Unions this Rectangle's width and height with the specified Dimension.
	 * 
	 * @param d
	 * Dimension being unioned
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle union(Dimension d) {
		width = Math.max(width, d.width);
		height = Math.max(height, d.height);
		return this;
	}

	/**
	 * Updates this Rectangle's bounds to the minimum size which can hold both
	 * this Rectangle and the coordinate (x,y).
	 * 
	 * @return <code>this</code> for convenience
	 * @param x1
	 * X coordinate
	 * @param y1
	 * Y coordinate
	 * @since 2.0
	 */
	public Rectangle union(int x1, int y1) {
		if (x1 < x) {
			width += (x - x1);
			x = x1;
		} else {
			int right = x + width;
			if (x1 >= right) {
				right = x1 + 1;
				width = right - x;
			}
		}
		if (y1 < y) {
			height += (y - y1);
			y = y1;
		} else {
			int bottom = y + height;
			if (y1 >= bottom) {
				bottom = y1 + 1;
				height = bottom - y;
			}
		}
		return this;
	}

	/**
	 * Updates this Rectangle's bounds to the minimum size which can hold both
	 * this Rectangle and the given Point.
	 * 
	 * @param p
	 * Point to be unioned with this Rectangle
	 * @since 2.0
	 */
	public void union(Point p) {
		union(p.x, p.y);
	}

	/**
	 * Updates this Rectangle's dimensions to the minimum size which can hold
	 * both this Rectangle and the given Rectangle.
	 * 
	 * @return <code>this</code> for convenience
	 * @param rect
	 * Rectangle to be unioned with this Rectangle
	 * @since 2.0
	 */
	public Rectangle union(Rectangle rect) {
		if (rect == null)
			return this;
		return union(rect.x, rect.y, rect.width, rect.height);
	}

	/**
	 * Updates this Rectangle's dimensions to the minimum size which can hold
	 * both this Rectangle and the rectangle (x, y, w, h).
	 * 
	 * @param x
	 * X coordiante of desired union.
	 * @param y
	 * Y coordiante of desired union.
	 * @param w
	 * Width of desired union.
	 * @param h
	 * Height of desired union.
	 * @return <code>this</code> for convenience
	 * @since 2.0
	 */
	public Rectangle union(int x, int y, int w, int h) {
		int right = Math.max(this.x + width, x + w);
		int bottom = Math.max(this.y + height, y + h);
		this.x = Math.min(this.x, x);
		this.y = Math.min(this.y, y);
		this.width = right - this.x;
		this.height = bottom - this.y;
		return this;
	}

	/**
	 * Returns <code>double</code> x coordinate
	 * 
	 * @return <code>double</code> x coordinate
	 * @since 3.4
	 */
	public double preciseX() {
		return x;
	}

	/**
	 * Returns <code>double</code> y coordinate
	 * 
	 * @return <code>double</code> y coordinate
	 * @since 3.4
	 */
	public double preciseY() {
		return y;
	}

	/**
	 * Returns <code>double</code> width
	 * 
	 * @return <code>double</code> width
	 * @since 3.4
	 */
	public double preciseWidth() {
		return width;
	}

	/**
	 * Returns <code>double</code> height
	 * 
	 * @return <code>double</code> height
	 * @since 3.4
	 */
	public double preciseHeight() {
		return height;
	}

}
" measuredWidth="476" measuredHeight="288" verticalScrollbar="true">
<font/>
</widgets>
<widgets xsi:type="model:Tabs" x="175" y="106" text="NodeFigure.java,Figure.class,Rectangle.class" measuredWidth="336" measuredHeight="30" selection="2">
<items x="1" y="0" width="122" height="30" text="NodeFigure.java"/>
<items x="123" y="0" width="94" height="30" text="Figure.class"/>
<items x="217" y="0" width="118" height="30" text="Rectangle.class"/>
</widgets>
<widgets xsi:type="model:Tabs" x="672" y="106" text="Outline" measuredWidth="67" measuredHeight="30" selection="0">
<items x="1" y="0" width="65" height="30" text="Outline"/>
</widgets>
<widgets xsi:type="model:Tabs" x="175" y="430" text="Problems,Javadoc,Declaration,Console" measuredWidth="315" measuredHeight="30" selection="4">
<items x="1" y="0" width="80" height="30" text="Problems"/>
<items x="81" y="0" width="69" height="30" text="Javadoc"/>
<items x="150" y="0" width="93" height="30" text="Declaration"/>
<items x="243" y="0" width="71" height="30" text="Console"/>
</widgets>
<widgets xsi:type="model:Label" x="178" y="460" text="No consoles to display at this time." measuredWidth="229" measuredHeight="25">
<font/>
</widgets>
<widgets xsi:type="model:Tabs" x="31" y="106" text="Project Explorer" measuredWidth="122" measuredHeight="30" selection="0">
<items x="1" y="0" width="120" height="30" text="Project Explorer"/>
</widgets>
<widgets xsi:type="model:Icon" x="154" y="142" measuredWidth="16" measuredHeight="16" icon="image (small)"/>
<widgets xsi:type="model:VLine" x="172" y="106" height="465" measuredWidth="6" measuredHeight="465"/>
<widgets xsi:type="model:HLine" x="175" y="427" width="666" measuredWidth="666" measuredHeight="6"/>
<widgets xsi:type="model:VLine" x="669" y="106" height="321" measuredWidth="6" measuredHeight="321"/>
<widgets xsi:type="model:VLine" x="29" y="573" height="30" measuredWidth="6" measuredHeight="30"/>
<widgets xsi:type="model:VLine" x="655" y="573" height="30" measuredWidth="6" measuredHeight="30"/>
<widgets xsi:type="model:Tooltip" x="650" y="38" text="CoolBar" measuredWidth="67" measuredHeight="42">
<font bold="true" italic="true"/>
</widgets>
<widgets xsi:type="model:Tooltip" x="489" y="13" text="Menu" measuredWidth="50" measuredHeight="42">
<font bold="true" italic="true"/>
</widgets>
<widgets xsi:type="model:Tooltip" x="616" y="555" text="StatusBar" measuredWidth="82" measuredHeight="42">
<font bold="true" italic="true"/>
</widgets>
<widgets xsi:type="model:Label" x="377" y="259" text="IEditorPart\nInstances" measuredWidth="230" measuredHeight="110" textAlignment="Center">
<font size="32"/>
</widgets>
<widgets xsi:type="model:Label" x="86" y="497" text="ViewPart's" measuredWidth="225" measuredHeight="59" textAlignment="Center">
<font size="32"/>
</widgets>
<widgets xsi:type="model:Label" x="606" y="408" text="ViewPart's" measuredWidth="225" measuredHeight="59" textAlignment="Center">
<font size="32"/>
</widgets>
<hRuler/>
<vRuler/>
<font/>
</model:Screen>
|