Changeset 3182 in josm for trunk/src


Ignore:
Timestamp:
2010-04-14T17:17:36+02:00 (10 years ago)
Author:
bastiK
Message:

fix position of relation editor

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r3102 r3182  
    548548        }
    549549        super.setVisible(visible);
    550         if (!visible) {
     550        if (visible) {
     551            RelationDialogManager.getRelationDialogManager().positionOnScreen(this);
     552        } else {
    551553            // make sure all registered listeners are unregistered
    552554            //
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java

    r3083 r3182  
    226226
    227227    /**
    228      * Positions an {@see RelationEditor} centered on the screen
    229      *
    230      * @param editor the editor
    231      */
    232     protected void centerOnScreen(RelationEditor editor) {
    233         Point p = new Point(0,0);
    234         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    235         p.x = (d.width - editor.getSize().width)/2;
    236         p.y = (d.height - editor.getSize().height)/2;
    237         p.x = Math.max(p.x,0);
    238         p.y = Math.max(p.y,0);
    239         editor.setLocation(p);
    240     }
    241 
    242     /**
    243228     * Replies true, if there is another open {@see RelationEditor} whose
    244229     * upper left corner is close to <code>p</code>.
     
    259244
    260245    /**
    261      * Positions a {@see RelationEditor} close to the center of the screen, in such
    262      * a way, that it doesn't entirely cover another {@see RelationEditor}
    263      *
    264      * @param editor
    265      */
    266     protected void positionCloseToScreenCenter(RelationEditor editor) {
    267         Point p = new Point(0,0);
    268         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    269         p.x = (d.width - editor.getSize().width)/2;
    270         p.y = (d.height - editor.getSize().height)/2;
    271         p.x = Math.max(p.x,0);
    272         p.y = Math.max(p.y,0);
    273         while(hasEditorWithCloseUpperLeftCorner(p)) {
    274             p.x += 20;
    275             p.y += 20;
    276         }
    277         editor.setLocation(p);
    278     }
    279 
    280     /**
    281246     * Positions a {@see RelationEditor} on the screen. Tries to center it on the
    282247     * screen. If it hide another instance of an editor at the same position this
     
    288253    public void positionOnScreen(RelationEditor editor) {
    289254        if (editor == null) return;
    290         if (openDialogs.isEmpty()) {
    291             centerOnScreen(editor);
    292         } else {
    293             positionCloseToScreenCenter(editor);
     255        if (!openDialogs.isEmpty()) {
     256            Point corner = editor.getLocation();
     257            while(hasEditorWithCloseUpperLeftCorner(corner)) {
     258                // shift a little, so that the dialogs are not exactly on top of each other
     259                corner.x += 20;
     260                corner.y += 20;
     261            }
     262            editor.setLocation(corner);
    294263        }
    295264    }
Note: See TracChangeset for help on using the changeset viewer.