1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package cs.pancava.caltha.worlds;
21
22 import cs.pancava.caltha.Editor;
23 import java.awt.Color;
24 import java.awt.Font;
25 import java.awt.Graphics2D;
26 import java.awt.font.TextLayout;
27 import java.awt.geom.Ellipse2D;
28
29
30
31
32
33
34
35
36 public class Room extends GameEntity
37 {
38
39
40
41 private Ellipse2D graphicsObject;
42
43
44
45
46 private int diameter;
47
48
49
50
51 private final Color ROOM_COLOR = Color.BLUE;
52
53
54
55
56 private final Color ROOM_SELECTED_COLOR = Color.CYAN;
57
58
59
60
61 private final Color TEXT_COLOR = Color.WHITE;
62
63
64
65
66
67
68
69 public Room(final int x, final int y, final int r)
70 {
71 super(x, y, World.WORLD_ROOM, Editor.getEditorDesktop().getWorld().getWorldRoomsAL().size());
72
73 this.diameter = r;
74
75 this.graphicsObject = new Ellipse2D.Double(x, y, this.diameter, this.diameter);
76 }
77
78
79
80
81
82 @Override
83 public final int getCenterX()
84 {
85 return this.getLocationX() + this.diameter / 2;
86 }
87
88
89
90
91
92 @Override
93 public final int getCenterY()
94 {
95 return this.getLocationY() + this.diameter / 2;
96 }
97
98
99
100
101
102 @Override
103 public final Object getGraphicsObject()
104 {
105 return this.graphicsObject;
106 }
107
108
109
110
111
112 @Override
113 public final void showGraphicsObject(final Graphics2D g2)
114 {
115 final TextLayout textID = new TextLayout(String.valueOf(this.getId()),
116 new Font("Helvetica", 0, this.diameter / 2),
117 g2.getFontRenderContext());
118
119
120 this.graphicsObject.setFrame(this.getLocationX(), this.getLocationY(), this.diameter, this.diameter);
121
122 if (this.isSeleted())
123 {
124 g2.setColor(this.ROOM_SELECTED_COLOR);
125 }
126 else
127 {
128 g2.setColor(this.ROOM_COLOR);
129 }
130
131 g2.fill(this.graphicsObject);
132
133 g2.setColor(this.TEXT_COLOR);
134 textID.draw(g2,
135 this.getLocationX() + (int) ((this.diameter - textID.getBounds().getWidth()) / 2),
136 this.getLocationY() + (int) (this.diameter - textID.getBounds().getHeight()));
137 }
138
139
140
141
142
143 @Override
144 public final GameEntity getFirstRoom()
145 {
146 return null;
147 }
148
149
150
151
152
153 @Override
154 public final GameEntity getSecondRoom()
155 {
156 throw new UnsupportedOperationException("Not supported yet.");
157 }
158 }