Revision 39415 branches/v2_0_0_prep/libraries/libCorePlugin/src/org/gvsig/coreplugin/mdiManager/NewSkin.java

View differences:

NewSkin.java
347 347
                singletonPreviouslyAdded = true;
348 348
            }
349 349
        }
350
        
351
        if( !singletonPreviouslyAdded ) {
352
            Point new_loc = this.getLocationForAlignment(p, align);
353
            p.getWindowInfo().setX(new_loc.x);
354
            p.getWindowInfo().setY(new_loc.y);
355
        }
356
        
350 357
        IWindow window = addWindow(p);
351
        if( !window.getWindowInfo().isModal() ) {
352
        	// if the window is modal at this oint is already closed
353
	        if( !singletonPreviouslyAdded ) {
354
	            alignFrame(window,align);
355
	        }
356
        }
357 358
        return window;
358 359
    }
359 360

  
......
1372 1373
        ToolsSwingLocator.getWindowManager().showWindow(panel, title, mode);
1373 1374
    }
1374 1375
    
1376
    
1377
    private Point getLocationForAlignment(IWindow panel, int mode) {
1378
        
1379
        // The top-left square of frame reference
1380
        Point newReferencePoint = new Point();
1381

  
1382
        // A reference to the panel where the JInternalFrame will be displayed
1383
        Container contentPane = ((JFrame)PluginServices.getMainFrame()).getContentPane();
1384

  
1385
        // Get the NewStatusBar component
1386
        NewStatusBar newStatusBar = ((NewStatusBar)contentPane.getComponent(1));
1387

  
1388
        JDesktopPane dpane = this.getDesktopPane();
1389
        // The last substraction is for case when there is any menu,... at left
1390
        int visibleWidth = contentPane.getWidth() - contentPane.getX();
1391
        // The last substraction is for case when there is any menu,... at top
1392
        int visibleHeight = contentPane.getHeight() - newStatusBar.getHeight() - contentPane.getY() - Math.abs(dpane.getY() - contentPane.getY());
1393

  
1394
//        ---------------------------------------------------------------
1395
//        |FIRST_LINE_START(23)   PAGE_START(19)     FIRST_LINE_END(24) |
1396
//        |                                                             |
1397
//        |                                                             |
1398
//        |LINE_START(21)           CENTER(10)              LINE_END(22)|
1399
//        |                                                             |
1400
//        |                                                             |
1401
//        |LAST_LINE_START(25)     PAGE_END(20)       LAST_LINE_END(26) |
1402
//        ---------------------------------------------------------------
1403
        
1404
        int win_h = panel.getWindowInfo().getHeight();
1405
        int win_w = panel.getWindowInfo().getWidth();
1406
        
1407
        switch (mode) {
1408
        case ALIGN_FIRST_LINE_START:
1409
            newReferencePoint.x = DefaultXMargin;
1410
            newReferencePoint.y = DefaultYMargin;
1411
            break;
1412
        
1413
        case ALIGN_PAGE_START:
1414
            newReferencePoint.x = visibleWidth / 2;
1415
            newReferencePoint.y = DefaultYMargin;
1416
            break;
1417
        
1418
        case ALIGN_FIRST_LINE_END:
1419
            newReferencePoint.x = visibleWidth - win_w - DefaultXMargin;
1420
            newReferencePoint.y = DefaultYMargin;
1421
            break;
1422
        
1423
        case ALIGN_FIRST_LINE_END_CASCADE:
1424
            newReferencePoint.x = visibleWidth - win_w - (int)(DefaultXMargin + (DefaultXMargin*1.5*this.alignCounter));
1425
            newReferencePoint.y = DefaultYMargin + (int)(DefaultYMargin*1.5*this.alignCounter);
1426
            if( ++this.alignCounter >5 ) {
1427
                this.alignCounter = 0;
1428
            }
1429
            break;
1430
        
1431
        case ALIGN_LINE_START:
1432
            newReferencePoint.x = DefaultXMargin;
1433
            newReferencePoint.y = visibleHeight / 2;
1434
            break;
1435
        
1436
        case ALIGN_LINE_END:
1437
            newReferencePoint.x = visibleWidth - win_w - DefaultXMargin;
1438
            newReferencePoint.y = visibleHeight / 2;
1439
            break;
1440
        
1441
        case ALIGN_LAST_LINE_START:
1442
            newReferencePoint.x = DefaultXMargin;
1443
            newReferencePoint.y = visibleHeight - win_h - DefaultYMargin;
1444
            break;
1445
        
1446
        case ALIGN_PAGE_END:
1447
            newReferencePoint.x = visibleWidth / 2;
1448
            newReferencePoint.y = visibleHeight - win_h - DefaultYMargin;
1449
            break;
1450
        
1451
        case ALIGN_LAST_LINE_END:
1452
            newReferencePoint.x = visibleWidth - win_w - DefaultXMargin;
1453
            newReferencePoint.y = visibleHeight - win_h - DefaultYMargin;
1454
            break;
1455
        
1456
        default:
1457
        case ALIGN_CENTER:
1458
            newReferencePoint.x = visibleWidth / 2;
1459
            newReferencePoint.y = visibleHeight / 2;
1460
            break;
1461
        }
1462
        
1463
        if( newReferencePoint.x < 0 ) {
1464
            newReferencePoint.x = DefaultXMargin;
1465
        }
1466
        if( newReferencePoint.y < 0 ) {
1467
            newReferencePoint.y = DefaultYMargin;
1468
        }
1469
        
1470
        return newReferencePoint;
1471
    }
1472
    
1375 1473
}

Also available in: Unified diff