Revision 11989 branches/v10/frameworks/_fwAndami/src/com/iver/andami/ui/mdiManager/WindowInfo.java

View differences:

WindowInfo.java
1 1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2 2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
3
 * Copyright (C) 2004-2007 IVER T.I. and Generalitat Valenciana.
4 4
 *
5 5
 * This program is free software; you can redistribute it and/or
6 6
 * modify it under the terms of the GNU General Public License
......
44 44
import java.beans.PropertyChangeListener;
45 45
import java.beans.PropertyChangeSupport;
46 46

  
47
import org.exolab.castor.xml.XMLException;
48

  
47 49
import com.iver.andami.PluginServices;
48 50
import com.iver.utiles.XMLEntity;
49 51

  
50 52

  
51 53
/**
52
 * DOCUMENT ME!
53
 *
54
 * This class represents the state of the associated window.
55
 * The <code>set</code> methods (<code>setX</code>, <code>setY</code>,
56
 * <code>setHeight</code>, etc) are immediately reflected on the
57
 * window.
58
 * 
54 59
 * @author Fernando Gonz?lez Cort?s
55 60
 */
56 61
public class WindowInfo {
57
    /** DOCUMENT ME! */
62
	/** Specifies that the window is resizable  */
58 63
    public static final int RESIZABLE = 1;
59 64

  
60
    /** DOCUMENT ME! */
65
    /** Specifies that the window is maximizable */
61 66
    public static final int MAXIMIZABLE = 2;
62 67

  
63
    /** DOCUMENT ME! */
68
    /** Specifies that the window is iconifiable */
64 69
    public static final int ICONIFIABLE = 4;
65 70

  
66
    /** DOCUMENT ME! */
71
    /** Specifies that the window is modal */
67 72
    public static final int MODALDIALOG = 8;
73
    /** Specifies that the window is modeless (it's on the top but doesn't block any other window) */
68 74
    public static final int MODELESSDIALOG = 16;
75
    /** Specifies that the window may be docked inside another window */
69 76
    public static final int PALETTE = 32;
70 77
    private PropertyChangeSupport support = new PropertyChangeSupport(this);
71 78

  
......
81 88
    /** DOCUMENT ME! */
82 89
    private boolean modal = false;
83 90
    private boolean modeless = false;
84
    
91

  
85 92
    /**
86 93
     * Do we want to persist the geometry of this window in the project file?
87 94
     */
......
97 104
    /** These properties store the dimension and position of the frame */
98 105
    private int width = -1;
99 106
    private int height = -1;
100
    private int x = -1;
101
    private int y = -1;
107
    private int x = 0;
108
    private int y = 0;
102 109
    /**
103 110
     * These properties store the position and dimension of the frame when it is not maximized
104 111
     * (so that it can be restored to its original size). They are equal to the not-normal properties
......
128 135
    private String selectedTool;
129 136

  
130 137
    /**
131
     * DOCUMENT ME!
138
     * Returns the current x coordinate of the window's origin
139
     * (left-upper corner of the window).
132 140
     *
133
     * @return Returns the x.
141
     * @return Returns the value (in pixels) of the x coordinate
142
     * of the window's origin.
134 143
     */
135 144
    public int getX() {
136 145
        return x;
137 146
    }
138 147

  
139 148
    /**
140
     * DOCUMENT ME!
149
     * Sets the x coordinate of the window's origin
150
     * (left-upper corner of the window).
141 151
     *
142
     * @param x The x to set.
152
     * @param x	The value (in pixels) of the x coordinate to set.
143 153
     */
144 154
    public void setX(int x) {
145 155
    	support.firePropertyChange("x", this.x, x);
......
149 159
    }
150 160

  
151 161
    /**
152
     * DOCUMENT ME!
153
     *
154
     * @return Returns the y.
162
     * Gets the value of the y coordinate for the origin
163
     * (left-upper corner of the window) of the associated
164
     * window.
165
     * 
166
     * @return Returns the y coordinate (in pixels).
155 167
     */
156 168
    public int getY() {
157 169
        return y;
158 170
    }
159 171

  
160 172
    /**
161
     * DOCUMENT ME!
162
     *
163
     * @param y The y to set.
173
     * Sets the value of the y coordinate for the origin
174
     * (left-upper corner of the window) of the associated
175
     * window.
176
     * 
177
     * @param y The value (in pixels) of the y coordinate
164 178
     */
165 179
    public void setY(int y) {
166 180
    	support.firePropertyChange("y", this.y, y);
......
217 231
    }
218 232

  
219 233
    /**
220
     * Si es iconificable
234
     * Determines whether the associated window is iconifiable or not
221 235
     *
222 236
     * @return
223 237
     */
......
226 240
    }
227 241

  
228 242
    /**
229
     * Si es maximizable
243
     * Determines whether the associated window is maximizable or not
230 244
     *
231 245
     * @return
232 246
     */
......
235 249
    }
236 250

  
237 251
    /**
238
     * Si es resizable
252
     * Determines whether the associated window is resizable or not
239 253
     *
240 254
     * @return
241 255
     */
......
244 258
    }
245 259

  
246 260
    /**
247
     * Devuelve si el di?logo es modal
261
     * Determines whether the associated window is modal or not
248 262
     *
249 263
     * @return
250 264
     */
......
253 267
    }
254 268

  
255 269
    /**
256
     * Obtiene la altura de la vista
270
     * Gets the window height.
257 271
     *
258
     * @return
272
     * @return The window height (in pixels).
259 273
     */
260 274
    public int getHeight() {
261 275
        return height;
262 276
    }
263 277

  
264 278
    /**
265
     * Obtiene la anchura de la vista
279
     * Gets the window width.
266 280
     *
267
     * @return
281
     * @return The window width (in pixels).
268 282
     */
269 283
    public int getWidth() {
270 284
        return width;
271 285
    }
272 286

  
273 287
    /**
274
     * establece la propiedad altura
288
     * Sets the window height.
275 289
     *
276
     * @param h
290
     * @param The window height (in pixels)
277 291
     */
278 292
    public void setHeight(int h) {
279 293
    	if (h!=-1)
......
284 298
    }
285 299

  
286 300
    /**
287
     * establece la propiedad anchura
301
     * Sets the width property for the associated Window.
288 302
     *
289
     * @param i
303
     * @param w The new width.
290 304
     */
291 305
    public void setWidth(int w) {
292 306
    	if (w!=-1)
......
297 311
    }
298 312

  
299 313
    /**
300
     * obtiene la propiedad titulo
314
     * Gets the title property
301 315
     *
302 316
     * @return
303 317
     */
......
306 320
    }
307 321

  
308 322
    /**
309
     * establece la propiedad titulo
323
     * Sets the title property.
310 324
     *
311
     * @param string
325
     * @param title The new title.
312 326
     */
313 327
    public void setTitle(String string) {
314 328
    	support.firePropertyChange("title", this.title, string);
......
316 330
    }
317 331

  
318 332
    /**
319
     * DOCUMENT ME!
333
     * Determines whether the associated window is modeless
334
     * (it is on the top but does not block any other window)
320 335
     *
321 336
     * @return
322
     */
323
    public boolean isModeless() {
337
     */boolean isModeless() {
324 338
        return modeless;
325 339
    }
326 340

  
327
    /**
328
     * DOCUMENT ME!
329
     *
330
     * @return
331
     */
341
     /**
342
      * Determines whether the associated window is visible
343
      *
344
      * @return true if the associated window is visible, false
345
      * if it is hidden
346
      */
332 347
    public boolean isVisible() {
333 348
        return visible;
334 349
    }
335 350

  
351
    /**
352
     * Determines whether the associated dockable window is
353
     * currently in palette status or docked.
354
     *
355
     * @return true if the window is currently in palette status,
356
     * false if it is docked in another window
357
     */
336 358
    public boolean isPalette()
337 359
    {
338 360
        return palette;
339 361
    }
340 362

  
363
    /**
364
     * Sets the window's ID.
365
     * 
366
     * @param id An integer to identify the window. Different
367
     * windows must have different IDs.
368
     */
341 369
    public void setId(int id){
342 370
    	this.id = id;
343 371
    }
344 372

  
373
    /**
374
     * Gets the window ID.
375
     * 
376
     * @return id An integer to identify the window. Different
377
     * windows must have different IDs.
378
     */
345 379
    public int getId(){
346 380
    	return id;
347 381
    }
348 382

  
383
    /**
384
     * Updates all the properties in this object so that
385
     * they match the properties of the provided
386
     * <code>wi</code> object. The changes are not reflected on the
387
     * window, just the WindowInfo object is updated.
388
     * 
389
     * @param vi A WindowInfo object containing the new
390
     * properties of the window.
391
     */
349 392
    public void setWindowInfo(WindowInfo vi){
350 393
    	this.resizable = vi.resizable;
351 394
    	this.maximizable = vi.maximizable;
......
371 414
    	this.isClosed = vi.isClosed;
372 415
    	this.persistWindow = vi.persistWindow;
373 416
    }
417
    
418
    /**
419
     * Sets whether the window is in palette mode or is in docked mode. 
420
     * This method <b>does not</b> update the window status, it just
421
     * updates the WindowInfo object. Use the IWindowTransform interface
422
     * to actually change the window status.
423
     * 
424
     * @param b
425
     */
374 426
    public void toPalette(boolean b){
375 427
    	this.palette=b;
376 428
    }
377 429

  
430
    /**
431
     * Gets the actionCommand of the currently selected tool for this
432
     * window.
433
     * @return
434
     */
378 435
    public String getSelectedTool() {
379 436
        return selectedTool;
380 437
    }
381 438

  
439
    /**
440
     * Sets the actionCommand of the currently selected tool for this
441
     * window.
442

  
443
     * @param selectedTool The actionCommand of the tool which is
444
     * going to be selected for this window.
445
     */
382 446
    public void setSelectedTool(String selectedTool) {
383 447
        if (selectedTool != null)
384 448
            this.selectedTool = selectedTool;
385 449
    }
386 450

  
387
    /* Finds out whether a view is open (showing) or closed */
451
    /**
452
     *  Finds out whether a window is open (showing) or closed
453
     */
388 454
    public boolean isClosed() {
389 455
    	return isClosed;
390 456
    }
391 457

  
392
    /* Specifies whether a view is open (showing) or closed */
458
    /**
459
     *  Specifies whether a window is open (showing) or closed
460
     */
393 461
    public void setClosed(boolean closed) {
394 462
    	support.firePropertyChange("closed", this.isClosed, closed);
395 463
    	this.isClosed = closed;
396 464
    }
397 465

  
466

  
467
    /**
468
     * Sets the x coordinate of the window's origin
469
     * when the window is not maximized. When the window is maximized,
470
     * it does not change the current window's position, but the
471
     * window will have this x coordinate when it gets restored.
472
     *
473
     * @param normalX	The value (in pixels) of the x coordinate to set.
474
     */
398 475
    public void setNormalX(int normalX) {
399 476
    	support.firePropertyChange("normalX", this.normalX, normalX);
400 477
    	this.normalX = normalX;
401 478
    }
402 479

  
480
    /**
481
     * Sets the y coordinate of the window's origin
482
     * when the window is not maximized. When the window is maximized,
483
     * it does not change the current window's position, but the
484
     * window will have this y coordinate when it gets restored.
485
     *
486
     * @param normalY	The value (in pixels) of the y coordinate to set.
487
     */
403 488
    public void setNormalY(int normalY) {
404 489
    	support.firePropertyChange("normalY", this.normalY, normalY);
405 490
    	this.normalY = normalY;
406 491
    }
407 492

  
493
    /**
494
     * Sets the height of the window
495
     * when the window is not maximized. When the window is maximized,
496
     * it does not change the current window's height, but the
497
     * window will have this height when it gets restored.
498
     *
499
     * @param normalHeight	The height (in pixels) to set.
500
     */
408 501
    public void setNormalHeight(int normalHeight) {
409 502
    	support.firePropertyChange("normalHeight", this.normalHeight, normalHeight);
410 503
    	this.normalHeight = normalHeight;
411 504
    }
412 505

  
506
    /**
507
     * Sets the width of the window
508
     * when the window is not maximized. When the window is maximized,
509
     * it does not change the current window's width, but the
510
     * window will have this width when it gets restored.
511
     *
512
     * @param normalWidth	The width (in pixels) to set.
513
     */
413 514
    public void setNormalWidth(int normalWidth) {
414 515
    	support.firePropertyChange("normalWidth", this.normalWidth, normalWidth);
415 516
    	this.normalWidth = normalWidth;
416 517
    }
417 518

  
418

  
519
    /**
520
     * Specifies whether the window is maximized or not.
521
     */ 
419 522
    public void setMaximized(boolean maximized) {
420 523
    	support.firePropertyChange("maximized", this.isMaximized, maximized);
421 524
    	this.isMaximized = maximized;
422 525
    }
423
    
526

  
527
    /**
528
     * Specifies whether the window is maximizable or not.
529
     */ 
424 530
    public void setMaximizable(boolean maximizable) {
425 531
    	this.maximizable = maximizable;
426 532
    }
......
435 541
    	support.firePropertyChange("height", this.height, height);
436 542
    	this.height = height;
437 543
    }
438

  
544
    
545
    /**
546
     * Sets the bounds of the window
547
     * when the window is not maximized. When the window is maximized,
548
     * it does not change the current window's bounds, but the
549
     * window will have this bounds when it gets restored.
550
     *
551
     * @param x	The normal x (in pixels) to set.
552
     * @param y	The normal y (in pixels) to set.
553
     * @param width	The normal width (in pixels) to set.
554
     * @param height	The normal height (in pixels) to set.
555
     */
439 556
    public void setNormalBounds(int x, int y, int width, int height) {
440 557
    	support.firePropertyChange("normalX", this.normalX, x);
441 558
    	this.normalX = x;
......
446 563
    	support.firePropertyChange("normalWeight", this.normalHeight, height);
447 564
    	this.normalHeight = height;
448 565
    }
449

  
566
    
567
    /**
568
     * Gets the bounds of the window
569
     * when the window is not maximized. When the window is maximized,
570
     * it gets the bounds that the window will have when it gets restored.
571
     * 
572
     * @return the bounds of the window when the window is not maximized,
573
     * or if it is maximized, the bounds that the window will have when
574
     * it gets restored
575
     */
450 576
    public Rectangle getNormalBounds() {
451 577
    	return new Rectangle(getNormalX(), getNormalY(), getNormalWidth(), getNormalHeight());
452 578
    }
453 579

  
580
    /**
581
     * Sets the bounds of the window
582
     * when the window is not maximized. When the window is maximized,
583
     * it does not change the current window's bounds, but the
584
     * window will have this bounds when it gets restored.
585
     *
586
     * @param normalBounds The normal bounds to set
587
     */
454 588
    public void setNormalBounds(Rectangle normalBounds) {
455
    	Rectangle oldBounds = new Rectangle(this.normalX, this.normalY, 
589
    	Rectangle oldBounds = new Rectangle(this.normalX, this.normalY,
456 590
    			this.normalWidth, this.normalHeight);
457 591
    	support.firePropertyChange("normalBounds", oldBounds, normalBounds);
458 592
    	support.firePropertyChange("normalX", this.normalX, normalBounds.x);
......
465 599
    	normalWidth = normalBounds.width;
466 600
    }
467 601

  
602
    /**
603
     * Set the bounds of the window.
604
     * 
605
     * @param bounds The bounds to set.
606
     */
468 607
    public void setBounds(Rectangle bounds) {
469 608
    	support.firePropertyChange("x", this.x, bounds.x);
470 609
    	x = bounds.x;
......
476 615
    	width = bounds.width;
477 616
    }
478 617

  
618
    /**
619
     * Gets the bounds of the window.
620
     * 
621
     * @return the bounds of the window.
622
     */
479 623
    public Rectangle getBounds() {
480 624
    	return new Rectangle(x, y, width, height);
481 625
    }
482 626

  
627
    /**
628
     * Gets the x coordinate of the window's origin when the window is not
629
     * maximized. When the window is maximized, gets the x coordinate that
630
     * it will have when it gets restored
631
     * 
632
     * @return the normal x coordinate of the window's origin
633
     */
483 634
    public int getNormalX() {
484 635
    	if (normalX!=0)
485 636
    		return this.normalX;
......
487 638
    		return x;
488 639
    }
489 640

  
641
    /**
642
     * Gets the x coordinate of the window's origin when the window is not
643
     * maximized. When the window is maximized, gets the y coordinate that
644
     * it will have when it gets restored
645
     * 
646
     * @return the normal y coordinate of the window's origin
647
     */
490 648
    public int getNormalY() {
491 649
    	if (normalY!=0)
492 650
    		return this.normalY;
......
494 652
    		return y;
495 653
    }
496 654

  
655
    /**
656
     * Gets the height of the window's origin when the window is not
657
     * maximized. When the window is maximized, gets the height that
658
     * it will have when it gets restored
659
     * 
660
     * @return the normal height of the window
661
     */
497 662
    public int getNormalHeight() {
498 663
    	if (normalHeight!=0)
499 664
    		return this.normalHeight;
......
501 666
    		return height;
502 667
    }
503 668

  
669
    /**
670
     * Gets the width of the window's origin when the window is not
671
     * maximized. When the window is maximized, gets the width that
672
     * it will have when it gets restored
673
     * 
674
     * @return the normal width of the window
675
     */
504 676
    public int getNormalWidth() {
505 677
    	if (normalWidth!=0)
506 678
    		return this.normalWidth;
......
508 680
    		return width;
509 681
    }
510 682

  
683
    /**
684
     * Determines whether the window is maximized or not
685
     * 
686
     * @return true if the window is maximized, false otherwise
687
     */
511 688
    public boolean isMaximized() {
512 689
    	return this.isMaximized;
513 690
    }
514
    
691

  
515 692
    /**
516 693
     * Checks if the geometry of this window should be persisted in the
517 694
     * project file. This is set by the persistWindow(boolean) method,
518 695
     * and the default value is true.
519
     * 
696
     *
520 697
     * @return True if the geometry of this window should be persisted
521 698
     * in the project files, false otherwise.
522 699
     */
523 700
    public boolean checkPersistence() {
524 701
    	return this.persistWindow;
525 702
    }
526
    
703

  
527 704
    /**
528 705
     * Set whether the geometry of this window should be persisted in the
529 706
     * project files.
530
     * 
707
     *
531 708
     * @param persist
532 709
     */
533 710
    public void setPersistence(boolean persist) {
534 711
    	this.persistWindow = persist;
535 712
    }
536
    
713

  
537 714
    /**
538 715
	 * Gets the window properties in an XMLEntity object, suitable
539 716
	 * for persistence.
......
542 719
	 * not persistent
543 720
     * @throws SaveException
544 721
	 * @throws XMLException
545
	 * @throws SaveException
546 722
	 */
547 723
	public XMLEntity getXMLEntity() {
548 724
		XMLEntity xml = new XMLEntity();
......
566 742
		}
567 743
		return xml;
568 744
	}
569
	
570
	
745

  
746
	/**
747
	 * Creates a WindowInfo object from an XMLEntity containing the
748
	 * window properties.
749
	 *  
750
	 * @param xml An XMLEntity object containing the window properties
751
	 * 
752
	 * @return A new WindowInfo object, containing the properties
753
	 * specified in the XMLEntity parameters 
754
	 */
571 755
	public static WindowInfo createFromXMLEntity(XMLEntity xml)
572 756
	{
573 757
		WindowInfo result = new WindowInfo();
......
594 778

  
595 779
		return result;
596 780
	}
597
	
781

  
782
	/**
783
	 * Updates this WindowInfo object according to the properties
784
	 * provided by the XMLEntity parameter.
785
	 *  
786
	 * @param xml An XMLEntity object containing the window properties
787
	 */
598 788
	public void getPropertiesFromXMLEntity(XMLEntity xml)
599 789
	{
600 790
		this.x = xml.getIntProperty("X");

Also available in: Unified diff