forked from john-bai/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdapter.java
More file actions
52 lines (42 loc) · 855 Bytes
/
Copy pathAdapter.java
File metadata and controls
52 lines (42 loc) · 855 Bytes
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
package designpatterns;
import java.awt.Rectangle;
import java.awt.Point;
import java.awt.Dimension;
interface GUIComponent {
public Rectangle boundingBox();
}
class TextShapeAdapter implements GUIComponent
{
private TextBox text;
public TextShapeAdapter() {
text = new TextBox();
}
public Rectangle boundingBox() {
return new Rectangle(text.getOrigin(), text.getExtent());
}
}
class Shape implements GUIComponent
{
private Rectangle boundingBox;
public Shape() {
boundingBox = new Rectangle(0,0,100,100);
}
public Rectangle boundingBox() {
return boundingBox;
}
}
class TextBox
{
private Point origin;
private Dimension dimension;
public TextBox() {
origin = new Point(0,0);
dimension = new Dimension(10,10);
}
public Point getOrigin() {
return origin;
}
public Dimension getExtent() {
return dimension;
}
}