1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package cs.pancava.caltha.desktop;
21
22 import cs.pancava.caltha.EditorComponentListener;
23 import cs.pancava.caltha.graphics.EditorGraphicsWorld2D;
24 import cs.pancava.caltha.menu.World2DPopupMenuListener;
25 import java.awt.BorderLayout;
26 import java.awt.Dimension;
27 import java.awt.Toolkit;
28 import java.awt.event.MouseListener;
29 import javax.swing.JPanel;
30 import javax.swing.JScrollPane;
31 import javax.swing.JSplitPane;
32 import javax.swing.ScrollPaneConstants;
33
34
35
36
37
38
39
40
41 public class EditorDesktopTextBasedGames extends EditorDesktop
42 {
43
44
45
46 private static final long serialVersionUID = 20080731165138L;
47
48
49
50
51 private static final int MINIMUM_SIZE_SCROLL_PANE_WIDTH_I = 100;
52
53
54
55
56 private static final int MINIMUM_SIZE_SCROLL_PANE_HEIGHT_I = 50;
57
58
59
60
61
62 private static final double HEIGHT_WA_SPLIT_PANE_D = 0.80;
63
64
65
66
67
68
69 private JSplitPane dektop;
70
71
72
73
74 private JScrollPane propertiesScrollPane;
75
76
77
78
79
80 private WorldAttributeSplitPane waSplitPane;
81
82
83
84
85 public EditorDesktopTextBasedGames()
86 {
87 super(EditorDesktop.EDITOR_TEXT_BASED_GAMES);
88 }
89
90
91
92
93 @Override
94 public final void createDesktop()
95 {
96
97 this.setMainDesktop(new JPanel(new BorderLayout()));
98 this.getMainDesktop().setOpaque(true);
99
100
101 this.waSplitPane = new WorldAttributeSplitPane();
102 final JSplitPane top = this.waSplitPane.getSplitPane();
103
104
105
106
107
108 top.setBorder(null);
109
110 this.propertiesScrollPane = new JScrollPane();
111
112 this.dektop = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
113 top,
114 this.propertiesScrollPane);
115 this.dektop.setOneTouchExpandable(true);
116
117
118 top.setMinimumSize(new Dimension(EditorDesktopTextBasedGames.MINIMUM_SIZE_SCROLL_PANE_WIDTH_I,
119 EditorDesktopTextBasedGames.MINIMUM_SIZE_SCROLL_PANE_HEIGHT_I));
120 this.propertiesScrollPane.setMinimumSize(new Dimension(EditorDesktopTextBasedGames.MINIMUM_SIZE_SCROLL_PANE_WIDTH_I,
121 EditorDesktopTextBasedGames.MINIMUM_SIZE_SCROLL_PANE_HEIGHT_I));
122
123 this.getMainDesktop().add(this.dektop, BorderLayout.CENTER);
124
125
126 this.getMainDesktop().addComponentListener(new EditorComponentListener(this));
127
128 this.validate();
129 }
130
131
132
133
134
135 @Override
136 public final void resizeWin()
137 {
138 this.dektop.setDividerLocation((int) (this.getMainDesktop().getSize().height * EditorDesktopTextBasedGames.HEIGHT_WA_SPLIT_PANE_D));
139
140 this.waSplitPane.resizeWin(this.getMainDesktop().getSize().width);
141
142 this.validate();
143 }
144 }
145
146
147
148
149
150
151
152
153
154 class WorldAttributeSplitPane extends JPanel
155 {
156
157
158
159 private static final long serialVersionUID = 20080430223333L;
160
161
162
163
164 private static final int MINIMUM_SIZE_SCROLL_PANE_WIDTH_I = 100;
165
166
167
168
169 private static final int MINIMUM_SIZE_SCROLL_PANE_HEIGHT_I = 50;
170
171
172
173
174
175 private static final int WA_SPLIT_PANE_WIDTH = 800;
176
177
178
179
180
181 private static final int WA_SPLIT_PANE_HEIGHT = 600;
182
183
184
185
186
187 private static final double WIDTH_WORLD_SCROLL_PANE_D = 0.80;
188
189
190
191
192 private EditorGraphicsWorld2D graphicsWorld2D;
193
194
195
196
197 private JScrollPane attributeScrollPane;
198
199
200
201
202 private JSplitPane waSplitPane;
203
204
205
206
207
208 public WorldAttributeSplitPane()
209 {
210 this.graphicsWorld2D = new EditorGraphicsWorld2D();
211 this.attributeScrollPane = new JScrollPane();
212
213
214
215 JScrollPane scroller = new JScrollPane(this.graphicsWorld2D, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
216
217 this.waSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
218 scroller,
219 this.attributeScrollPane);
220
221 this.waSplitPane.setOneTouchExpandable(true);
222
223
224 final Dimension minimumSize = new Dimension(WorldAttributeSplitPane.MINIMUM_SIZE_SCROLL_PANE_WIDTH_I,
225 WorldAttributeSplitPane.MINIMUM_SIZE_SCROLL_PANE_HEIGHT_I);
226
227
228
229 this.graphicsWorld2D.setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize());
230
231 this.attributeScrollPane.setMinimumSize(minimumSize);
232
233
234 this.waSplitPane.setPreferredSize(new Dimension(WorldAttributeSplitPane.WA_SPLIT_PANE_WIDTH,
235 WorldAttributeSplitPane.WA_SPLIT_PANE_HEIGHT));
236
237 this.createWorldPopupMenu();
238 }
239
240
241
242
243
244
245
246 protected JSplitPane getSplitPane()
247 {
248 return this.waSplitPane;
249 }
250
251
252
253
254
255
256
257 public void resizeWin(final int widthI)
258 {
259 this.waSplitPane.setDividerLocation((int) (widthI * WorldAttributeSplitPane.WIDTH_WORLD_SCROLL_PANE_D));
260 }
261
262
263
264
265 private void createWorldPopupMenu()
266 {
267 final MouseListener popupListener = new World2DPopupMenuListener(this.graphicsWorld2D);
268 this.graphicsWorld2D.addMouseListener(popupListener);
269 }
270 }