From 3e429f382382962134143c36f68003fcae03e527 Mon Sep 17 00:00:00 2001
From: Michael Zangl <michael.zangl@student.kit.edu>
Date: Wed, 1 Jul 2015 16:41:13 +0200
Subject: [PATCH 09/11] Move creation of the MapView children to new method.
---
src/org/openstreetmap/josm/gui/MapView.java | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/src/org/openstreetmap/josm/gui/MapView.java b/src/org/openstreetmap/josm/gui/MapView.java
index b2129bc..77613b4 100644
|
a
|
b
|
import java.awt.image.BufferedImage;
|
| 22 | 22 | import java.beans.PropertyChangeEvent; |
| 23 | 23 | import java.beans.PropertyChangeListener; |
| 24 | 24 | import java.util.ArrayList; |
| | 25 | import java.util.Arrays; |
| 25 | 26 | import java.util.Collection; |
| 26 | 27 | import java.util.Collections; |
| 27 | 28 | import java.util.LinkedHashSet; |
| … |
… |
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
| 34 | 35 | import javax.swing.AbstractButton; |
| 35 | 36 | import javax.swing.ActionMap; |
| 36 | 37 | import javax.swing.InputMap; |
| | 38 | import javax.swing.JComponent; |
| 37 | 39 | import javax.swing.JFrame; |
| 38 | 40 | import javax.swing.JPanel; |
| 39 | 41 | |
| … |
… |
implements PropertyChangeListener, PreferenceChangedListener, OsmDataLayer.Layer
|
| 298 | 300 | @Override public void componentResized(ComponentEvent e) { |
| 299 | 301 | removeComponentListener(this); |
| 300 | 302 | |
| 301 | | MapSlider zoomSlider = new MapSlider(MapView.this); |
| 302 | | add(zoomSlider); |
| 303 | | zoomSlider.setBounds(3, 0, 114, 30); |
| 304 | | zoomSlider.setFocusTraversalKeysEnabled(!unregisterTab); |
| 305 | | |
| 306 | | MapScaler scaler = new MapScaler(MapView.this); |
| 307 | | add(scaler); |
| 308 | | scaler.setLocation(10, 30); |
| | 303 | for (JComponent c : getMapNavigationComponents(MapView.this)) { |
| | 304 | MapView.this.add(c); |
| | 305 | } |
| 309 | 306 | |
| 310 | 307 | mapMover = new MapMover(MapView.this, contentPane); |
| 311 | 308 | } |
| … |
… |
implements PropertyChangeListener, PreferenceChangedListener, OsmDataLayer.Layer
|
| 339 | 336 | } |
| 340 | 337 | } |
| 341 | 338 | |
| | 339 | /** |
| | 340 | * Adds the map navigation components to a |
| | 341 | * @param forMapView The map view to get the components for. |
| | 342 | * @return A list containing the correctly positioned map navigation components. |
| | 343 | */ |
| | 344 | public static List<? extends JComponent> getMapNavigationComponents(MapView forMapView) { |
| | 345 | MapSlider zoomSlider = new MapSlider(forMapView); |
| | 346 | zoomSlider.setBounds(3, 0, 114, 30); |
| | 347 | zoomSlider.setFocusTraversalKeysEnabled(Shortcut.findShortcut(KeyEvent.VK_TAB, 0) == null); |
| | 348 | |
| | 349 | MapScaler scaler = new MapScaler(forMapView); |
| | 350 | scaler.setLocation(10,30); |
| | 351 | |
| | 352 | return Arrays.asList(zoomSlider, scaler); |
| | 353 | } |
| | 354 | |
| 342 | 355 | // remebered geometry of the component |
| 343 | 356 | private Dimension oldSize = null; |
| 344 | 357 | private Point oldLoc = null; |