Ignore:
Timestamp:
2012-03-16T18:23:04+01:00 (12 years ago)
Author:
akks
Message:

Warning against misaligned imagery for new users - see #7450.
Added addTopPanel function in MapFrame for other possible enhancements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r5035 r5091  
    55
    66import java.awt.BorderLayout;
     7import java.awt.Component;
    78import java.awt.Container;
    89import java.awt.Dimension;
    910import java.awt.Font;
     11import java.awt.GridBagLayout;
    1012import java.awt.Rectangle;
    1113import java.awt.event.ActionEvent;
     
    6567import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    6668import org.openstreetmap.josm.tools.Destroyable;
     69import org.openstreetmap.josm.tools.GBC;
    6770
    6871/**
     
    113116     */
    114117    private List<ToggleDialog> allDialogs = new ArrayList<ToggleDialog>();
     118    private final JPanel leftPanel;
    115119    private final DialogsPanel dialogsPanel;
    116120
     
    140144        setLayout(new BorderLayout());
    141145
     146       
    142147        mapView = new MapView(contentPane);
    143148
    144149        new FileDrop(mapView);
    145 
     150       
     151        leftPanel = new JPanel();
     152        leftPanel.setLayout(new GridBagLayout());
     153       
     154        leftPanel.add(mapView, GBC.std().fill());
     155       
    146156        // toolbar
    147157        toolBarActions.setFloatable(false);
     
    158168        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    159169        dialogsPanel = new DialogsPanel(splitPane);
    160         splitPane.setLeftComponent(mapView);
     170        splitPane.setLeftComponent(leftPanel);
    161171        splitPane.setRightComponent(dialogsPanel);
    162172
     
    499509        Main.pref.putInteger("toggleDialogs.width", dialogsPanel.getWidth());
    500510    }
     511   
     512     /*
     513     * Remove panel from top of MapView by class
     514     */
     515     public void removeTopPanel(Class<?> type) {
     516        int n = leftPanel.getComponentCount();
     517        for (int i=0; i<n; i++) {
     518            Component c = leftPanel.getComponent(i);
     519            if (type.isInstance(c)) {
     520                leftPanel.remove(i);
     521                leftPanel.doLayout();
     522//                repaint();
     523                return;
     524            }
     525        }
     526    }
     527   
     528    /*
     529    * Find panel on top of MapView by class
     530    */
     531    public <T> T getTopPanel(Class<T> type) {
     532        int n = leftPanel.getComponentCount();
     533        for (int i=0; i<n; i++) {
     534            Component c = leftPanel.getComponent(i);
     535            if (type.isInstance(c)) {
     536                return type.cast(c);
     537            }
     538        }
     539        return null;
     540    }
     541
     542    /**
     543     * Add component @param c on top of MapView
     544     */
     545    public void addTopPanel(Component c) {
     546        leftPanel.add(c, GBC.eol().fill(GBC.HORIZONTAL), leftPanel.getComponentCount()-1);
     547        leftPanel.doLayout();
     548        c.doLayout();
     549    }
    501550
    502551    /**
Note: See TracChangeset for help on using the changeset viewer.