Changeset 8555 in josm


Ignore:
Timestamp:
2015-07-01T21:38:18+02:00 (9 years ago)
Author:
bastiK
Message:

applied #11635 - Move creation of the MapView children to new method. (patch by michael2402)

File:
1 edited

Legend:

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

    r8553 r8555  
    2323import java.beans.PropertyChangeListener;
    2424import java.util.ArrayList;
     25import java.util.Arrays;
    2526import java.util.Collection;
    2627import java.util.Collections;
     
    302303                removeComponentListener(this);
    303304
    304                 MapSlider zoomSlider = new MapSlider(MapView.this);
    305                 add(zoomSlider);
    306                 zoomSlider.setBounds(3, 0, 114, 30);
    307                 zoomSlider.setFocusTraversalKeysEnabled(!unregisterTab);
    308 
    309                 MapScaler scaler = new MapScaler(MapView.this);
    310                 add(scaler);
    311                 scaler.setLocation(10, 30);
     305                for (JComponent c : getMapNavigationComponents(MapView.this)) {
     306                    MapView.this.add(c);
     307                }
    312308
    313309                mapMover = new MapMover(MapView.this, contentPane);
     
    341337            setFocusTraversalKeysEnabled(false);
    342338        }
     339    }
     340
     341    /**
     342     * Adds the map navigation components to a
     343     * @param forMapView The map view to get the components for.
     344     * @return A list containing the correctly positioned map navigation components.
     345     */
     346    public static List<? extends JComponent> getMapNavigationComponents(MapView forMapView) {
     347        MapSlider zoomSlider = new MapSlider(forMapView);
     348        zoomSlider.setBounds(3, 0, 114, 30);
     349        zoomSlider.setFocusTraversalKeysEnabled(Shortcut.findShortcut(KeyEvent.VK_TAB, 0) == null);
     350
     351        MapScaler scaler = new MapScaler(forMapView);
     352        scaler.setLocation(10,30);
     353
     354        return Arrays.asList(zoomSlider, scaler);
    343355    }
    344356
Note: See TracChangeset for help on using the changeset viewer.