svn-gvsig-desktop / tags / gvSIGv0_6_1RELEASE / frameworks / _fwAndami / src / com / iver / andami / ui / mdiManager / ViewInfo.java @ 5222
History | View | Annotate | Download (9.83 KB)
1 | 1104 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 598 | fernando | package com.iver.andami.ui.mdiManager; |
42 | |||
43 | import java.beans.PropertyChangeListener; |
||
44 | import java.beans.PropertyChangeSupport; |
||
45 | 5039 | cesar | import java.awt.Rectangle; |
46 | 598 | fernando | |
47 | |||
48 | /**
|
||
49 | * DOCUMENT ME!
|
||
50 | *
|
||
51 | * @author Fernando Gonz?lez Cort?s
|
||
52 | */
|
||
53 | public class ViewInfo { |
||
54 | /** DOCUMENT ME! */
|
||
55 | public static final int RESIZABLE = 1; |
||
56 | |||
57 | /** DOCUMENT ME! */
|
||
58 | public static final int MAXIMIZABLE = 2; |
||
59 | |||
60 | /** DOCUMENT ME! */
|
||
61 | public static final int ICONIFIABLE = 4; |
||
62 | |||
63 | /** DOCUMENT ME! */
|
||
64 | public static final int MODALDIALOG = 8; |
||
65 | public static final int MODELESSDIALOG = 16; |
||
66 | 3001 | fjp | public static final int PALETTE = 32; |
67 | 598 | fernando | private PropertyChangeSupport support = new PropertyChangeSupport(this); |
68 | |||
69 | /** DOCUMENT ME! */
|
||
70 | private boolean resizable = false; |
||
71 | |||
72 | /** DOCUMENT ME! */
|
||
73 | private boolean maximizable = false; |
||
74 | |||
75 | /** DOCUMENT ME! */
|
||
76 | private boolean iconifiable = false; |
||
77 | |||
78 | /** DOCUMENT ME! */
|
||
79 | private boolean modal = false; |
||
80 | private boolean modeless = false; |
||
81 | 3001 | fjp | |
82 | /**
|
||
83 | * Se usa para poner una ventana de tipo paleta, por
|
||
84 | * encima de las dem?s. Equivale a poner usar
|
||
85 | * JDesktopPane.PALETTE_LAYER
|
||
86 | */
|
||
87 | private boolean palette = false; |
||
88 | 598 | fernando | |
89 | 5039 | cesar | /** These properties store the dimension and position of the frame */
|
90 | 598 | fernando | private int width = -1; |
91 | private int height = -1; |
||
92 | private int x = 0; |
||
93 | private int y = 0; |
||
94 | 5039 | cesar | /**
|
95 | * These properties store the position and dimension of the frame when it is not maximized
|
||
96 | * (so that it can be restored to its original size). They are equal to the not-normal properties
|
||
97 | * when the frame is not maximized, and different when the frame is maximized.
|
||
98 | */
|
||
99 | private int normalX = 0; |
||
100 | private int normalY = 0; |
||
101 | private int normalHeight = 0; |
||
102 | private int normalWidth = 0; |
||
103 | /* Whether the window is maximized */
|
||
104 | private boolean isMaximized = false; |
||
105 | 598 | fernando | private boolean visible = true; |
106 | 5039 | cesar | /* Whether the window is closed */
|
107 | private boolean isClosed = false; |
||
108 | 598 | fernando | |
109 | /** DOCUMENT ME! */
|
||
110 | private String title; |
||
111 | |||
112 | private int id; |
||
113 | 2684 | fjp | |
114 | /**
|
||
115 | * ActionCommand del tool seleccionado. Lo usamos
|
||
116 | * para activar el tool que estaba seleccionado en
|
||
117 | * la vista, cuando volvemos a ella.
|
||
118 | */
|
||
119 | private String selectedTool; |
||
120 | 598 | fernando | |
121 | /**
|
||
122 | * DOCUMENT ME!
|
||
123 | *
|
||
124 | * @return Returns the x.
|
||
125 | */
|
||
126 | public int getX() { |
||
127 | return x;
|
||
128 | } |
||
129 | |||
130 | /**
|
||
131 | * DOCUMENT ME!
|
||
132 | *
|
||
133 | * @param x The x to set.
|
||
134 | */
|
||
135 | public void setX(int x) { |
||
136 | support.firePropertyChange("x", this.x, x); |
||
137 | this.x = x;
|
||
138 | } |
||
139 | |||
140 | /**
|
||
141 | * DOCUMENT ME!
|
||
142 | *
|
||
143 | * @return Returns the y.
|
||
144 | */
|
||
145 | public int getY() { |
||
146 | return y;
|
||
147 | } |
||
148 | |||
149 | /**
|
||
150 | * DOCUMENT ME!
|
||
151 | *
|
||
152 | * @param y The y to set.
|
||
153 | */
|
||
154 | public void setY(int y) { |
||
155 | support.firePropertyChange("y", this.y, y); |
||
156 | this.y = y;
|
||
157 | } |
||
158 | |||
159 | /**
|
||
160 | * DOCUMENT ME!
|
||
161 | *
|
||
162 | * @param listener
|
||
163 | */
|
||
164 | public void addPropertyChangeListener(PropertyChangeListener listener) { |
||
165 | support.addPropertyChangeListener(listener); |
||
166 | } |
||
167 | |||
168 | /**
|
||
169 | * DOCUMENT ME!
|
||
170 | *
|
||
171 | * @param listener
|
||
172 | */
|
||
173 | public void removePropertyChangeListener(PropertyChangeListener listener) { |
||
174 | support.removePropertyChangeListener(listener); |
||
175 | } |
||
176 | |||
177 | /**
|
||
178 | * Establece las propiedades de la vista
|
||
179 | *
|
||
180 | * @param code Bit-or de las propiedades de la vista
|
||
181 | *
|
||
182 | * @throws IllegalStateException DOCUMENT ME!
|
||
183 | */
|
||
184 | public ViewInfo(int code) { |
||
185 | resizable = (code % 2) > 0; |
||
186 | code = code / 2;
|
||
187 | maximizable = (code % 2) > 0; |
||
188 | code = code / 2;
|
||
189 | iconifiable = (code % 2) > 0; |
||
190 | code = code / 2;
|
||
191 | modal = (code % 2) > 0; |
||
192 | code = code / 2;
|
||
193 | modeless = (code % 2) > 0; |
||
194 | 3001 | fjp | code = code / 2;
|
195 | palette = (code % 2) > 0; |
||
196 | 598 | fernando | |
197 | if (modal && modeless) {
|
||
198 | throw new IllegalStateException("modal && modeless"); |
||
199 | } |
||
200 | } |
||
201 | |||
202 | public ViewInfo(){
|
||
203 | |||
204 | } |
||
205 | |||
206 | /**
|
||
207 | * Si es iconificable
|
||
208 | *
|
||
209 | * @return
|
||
210 | */
|
||
211 | public boolean isIconifiable() { |
||
212 | return iconifiable;
|
||
213 | } |
||
214 | |||
215 | /**
|
||
216 | * Si es maximizable
|
||
217 | *
|
||
218 | * @return
|
||
219 | */
|
||
220 | public boolean isMaximizable() { |
||
221 | return maximizable;
|
||
222 | } |
||
223 | |||
224 | /**
|
||
225 | * Si es resizable
|
||
226 | *
|
||
227 | * @return
|
||
228 | */
|
||
229 | public boolean isResizable() { |
||
230 | return resizable;
|
||
231 | } |
||
232 | |||
233 | /**
|
||
234 | * Devuelve si el di?logo es modal
|
||
235 | *
|
||
236 | * @return
|
||
237 | */
|
||
238 | public boolean isModal() { |
||
239 | return modal;
|
||
240 | } |
||
241 | |||
242 | /**
|
||
243 | * Obtiene la altura de la vista
|
||
244 | *
|
||
245 | * @return
|
||
246 | */
|
||
247 | public int getHeight() { |
||
248 | return height;
|
||
249 | } |
||
250 | |||
251 | /**
|
||
252 | * Obtiene la anchura de la vista
|
||
253 | *
|
||
254 | * @return
|
||
255 | */
|
||
256 | public int getWidth() { |
||
257 | return width;
|
||
258 | } |
||
259 | |||
260 | /**
|
||
261 | * establece la propiedad altura
|
||
262 | *
|
||
263 | * @param i
|
||
264 | */
|
||
265 | public void setHeight(int i) { |
||
266 | support.firePropertyChange("height", this.height, i); |
||
267 | height = i; |
||
268 | } |
||
269 | |||
270 | /**
|
||
271 | * establece la propiedad anchura
|
||
272 | *
|
||
273 | * @param i
|
||
274 | */
|
||
275 | public void setWidth(int i) { |
||
276 | support.firePropertyChange("width", this.width, i); |
||
277 | width = i; |
||
278 | } |
||
279 | |||
280 | /**
|
||
281 | * obtiene la propiedad titulo
|
||
282 | *
|
||
283 | * @return
|
||
284 | */
|
||
285 | public String getTitle() { |
||
286 | return title;
|
||
287 | } |
||
288 | |||
289 | /**
|
||
290 | * establece la propiedad titulo
|
||
291 | *
|
||
292 | * @param string
|
||
293 | */
|
||
294 | public void setTitle(String string) { |
||
295 | support.firePropertyChange("title", this.title, string); |
||
296 | title = string; |
||
297 | } |
||
298 | |||
299 | /**
|
||
300 | * DOCUMENT ME!
|
||
301 | *
|
||
302 | * @return
|
||
303 | */
|
||
304 | public boolean isModeless() { |
||
305 | return modeless;
|
||
306 | } |
||
307 | |||
308 | /**
|
||
309 | * DOCUMENT ME!
|
||
310 | *
|
||
311 | * @return
|
||
312 | */
|
||
313 | public boolean isVisible() { |
||
314 | return visible;
|
||
315 | } |
||
316 | |||
317 | 3001 | fjp | public boolean isPalette() |
318 | { |
||
319 | return palette;
|
||
320 | } |
||
321 | |||
322 | 598 | fernando | public void setId(int id){ |
323 | this.id = id;
|
||
324 | } |
||
325 | |||
326 | public int getId(){ |
||
327 | return id;
|
||
328 | } |
||
329 | 975 | fernando | |
330 | public void setViewInfo(ViewInfo vi){ |
||
331 | this.resizable = vi.resizable;
|
||
332 | this.maximizable = vi.maximizable;
|
||
333 | this.iconifiable = vi.iconifiable;
|
||
334 | this.modal = vi.modal;
|
||
335 | this.modeless = vi.modeless;
|
||
336 | this.width = vi.width;
|
||
337 | this.height = vi.height;
|
||
338 | this.x = vi.x;
|
||
339 | this.y = vi.y;
|
||
340 | this.visible = vi.visible;
|
||
341 | this.title = vi.title;
|
||
342 | this.id = vi.id;
|
||
343 | } |
||
344 | 2684 | fjp | |
345 | public String getSelectedTool() { |
||
346 | return selectedTool;
|
||
347 | } |
||
348 | |||
349 | public void setSelectedTool(String selectedTool) { |
||
350 | if (selectedTool != null) |
||
351 | this.selectedTool = selectedTool;
|
||
352 | } |
||
353 | 5039 | cesar | |
354 | /* Finds out whether a view is open (showing) or closed */
|
||
355 | public boolean isClosed() { |
||
356 | return isClosed;
|
||
357 | } |
||
358 | |||
359 | /* Specifies whether a view is open (showing) or closed */
|
||
360 | public void setClosed(boolean closed) { |
||
361 | this.isClosed = closed;
|
||
362 | } |
||
363 | |||
364 | public void setNormalX(int normalX) { |
||
365 | this.normalX = normalX;
|
||
366 | } |
||
367 | |||
368 | public void setNormalY(int normalY) { |
||
369 | this.normalY = normalY;
|
||
370 | } |
||
371 | |||
372 | public void setNormalHeight(int normalHeight) { |
||
373 | this.normalHeight = normalHeight;
|
||
374 | } |
||
375 | |||
376 | public void setNormalWidth(int normalWidth) { |
||
377 | this.normalWidth = normalWidth;
|
||
378 | } |
||
379 | |||
380 | |||
381 | public void setMaximized(boolean maximized) { |
||
382 | this.isMaximized = maximized;
|
||
383 | } |
||
384 | |||
385 | private void setBounds(int x, int y, int width, int height) { |
||
386 | this.x = x;
|
||
387 | this.y = y;
|
||
388 | this.width = width;
|
||
389 | this.height = height;
|
||
390 | } |
||
391 | |||
392 | public void setNormalBounds(int x, int y, int width, int height) { |
||
393 | this.normalX = x;
|
||
394 | this.normalY = y;
|
||
395 | this.normalWidth = width;
|
||
396 | this.normalHeight = height;
|
||
397 | } |
||
398 | |||
399 | public Rectangle getNormalBounds() { |
||
400 | return new Rectangle(getNormalX(), getNormalY(), getNormalWidth(), getNormalHeight()); |
||
401 | } |
||
402 | |||
403 | public void setNormalBounds(Rectangle normalBounds) { |
||
404 | normalX = normalBounds.x; |
||
405 | normalY = normalBounds.y; |
||
406 | normalHeight = normalBounds.height; |
||
407 | normalWidth = normalBounds.width; |
||
408 | } |
||
409 | |||
410 | public void setBounds(Rectangle bounds) { |
||
411 | x = bounds.x; |
||
412 | y = bounds.y; |
||
413 | height = bounds.height; |
||
414 | width = bounds.width; |
||
415 | } |
||
416 | |||
417 | public Rectangle getBounds() { |
||
418 | return new Rectangle(x, y, width, height); |
||
419 | } |
||
420 | |||
421 | public int getNormalX() { |
||
422 | if (normalX!=0) |
||
423 | return this.normalX; |
||
424 | else
|
||
425 | return x;
|
||
426 | } |
||
427 | |||
428 | public int getNormalY() { |
||
429 | if (normalY!=0) |
||
430 | return this.normalY; |
||
431 | else
|
||
432 | return y;
|
||
433 | } |
||
434 | |||
435 | public int getNormalHeight() { |
||
436 | if (normalHeight!=0) |
||
437 | return this.normalHeight; |
||
438 | else
|
||
439 | return height;
|
||
440 | } |
||
441 | |||
442 | public int getNormalWidth() { |
||
443 | if (normalWidth!=0) |
||
444 | return this.normalWidth; |
||
445 | else
|
||
446 | return width;
|
||
447 | } |
||
448 | |||
449 | public boolean isMaximized() { |
||
450 | return this.isMaximized; |
||
451 | } |
||
452 | |||
453 | 598 | fernando | } |