org.openstreetmap.josm.gui
Class MapFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.openstreetmap.josm.gui.MapFrame
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, MapView.LayerChangeListener, Destroyable

public class MapFrame
extends javax.swing.JPanel
implements Destroyable, MapView.LayerChangeListener

One Map frame with one dataset behind. This is the container gui class whose display can be set to the different views.

See Also:
Serialized Form

Nested Class Summary
(package private)  class MapFrame.ListAllButtonsAction
           
static interface MapFrame.MapModeChangeListener
          Interface to notify listeners of the change of the mapMode.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.util.List<IconToggleButton> allDialogButtons
           
private  java.util.List<ToggleDialog> allDialogs
          The panel list of all toggle dialog icons.
private  java.util.List<IconToggleButton> allMapModeButtons
           
 ConflictDialog conflictDialog
           
static int DEF_TOGGLE_DLG_WIDTH
          Default width of the toggle dialog area.
private  DialogsPanel dialogsPanel
           
 FilterDialog filterDialog
           
private  java.util.Map<Layer,MapMode> lastMapMode
           
private  javax.swing.JPanel leftPanel
           
private  MapFrame.ListAllButtonsAction listAllDialogsAction
           
private  MapFrame.ListAllButtonsAction listAllMapModesAction
           
private  javax.swing.JButton listAllMapModesButton
           
private  javax.swing.JButton listAllToggleDialogsButton
           
 MapMode mapMode
          The current mode, this frame operates.
private static java.util.concurrent.CopyOnWriteArrayList<MapFrame.MapModeChangeListener> mapModeChangeListeners
          the mapMode listeners
private  MapMode mapModeDraw
           
private  java.util.List<MapMode> mapModes
           
 SelectAction mapModeSelect
           
private  MapMode mapModeZoom
           
 MapView mapView
          The view control displayed.
 PropertiesDialog propertiesDialog
           
 RelationListDialog relationListDialog
           
 SelectionListDialog selectionListDialog
           
private  Preferences.PreferenceChangedListener sidetoolbarPreferencesChangedListener
           
 MapStatus statusLine
          The status line below the map
private  javax.swing.JToolBar toolBarActions
          The toolbar with the action icons.
private  javax.swing.JToolBar toolBarToggle
           
 javax.swing.ButtonGroup toolGroup
           
 ValidatorDialog validatorDialog
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MapFrame(javax.swing.JPanel contentPane)
           
 
Method Summary
 void activeLayerChange(Layer oldLayer, Layer newLayer)
          Notifies this listener that the active layer has changed.
private  void addHideContextMenu(IconToggleButton b)
           
 void addMapMode(IconToggleButton b)
           
static void addMapModeChangeListener(MapFrame.MapModeChangeListener listener)
          Adds a mapMode change listener
 IconToggleButton addToggleDialog(ToggleDialog dlg)
           
 IconToggleButton addToggleDialog(ToggleDialog dlg, boolean isExpert)
          Call this to add new toggle dialogs to the left button-list
 void addTopPanel(java.awt.Component c)
          Add component @param c on top of MapView
 void destroy()
          Called as some kind of destructor when the last layer has been removed.
 void fillPanel(java.awt.Container panel)
          Fill the given panel by adding all necessary components to the different locations.
protected static void fireMapModeChanged(MapMode oldMapMode, MapMode newMapMode)
           
 javax.swing.Action getDefaultButtonAction()
           
private  MapMode getLastMapMode(Layer newLayer)
           
<T> T
getToggleDialog(java.lang.Class<T> type)
          Replies the instance of a toggle dialog of type type managed by this map frame
<T> T
getTopPanel(java.lang.Class<T> type)
           
 void initializeDialogsPane()
          Open all ToggleDialogs that have their preferences property set.
 void layerAdded(Layer newLayer)
          Notifies this listener that a layer has been added.
 void layerRemoved(Layer oldLayer)
          Notifies this listener that a layer has been removed.
 void rememberToggleDialogWidth()
          Remember the current width of the (possibly resized) toggle dialog area
static void removeMapModeChangeListener(MapFrame.MapModeChangeListener listener)
          Removes a mapMode change listener
 void removeTopPanel(java.lang.Class<?> type)
           
 boolean selectDrawTool(boolean onlyIfModeless)
           
 boolean selectMapMode(MapMode newMapMode)
          Change the operating map mode for the view.
 boolean selectMapMode(MapMode newMapMode, Layer newLayer)
          Another version of the selectMapMode for changing layer action.
 boolean selectSelectTool(boolean onlyIfModeless)
           
 boolean selectZoomTool(boolean onlyIfModeless)
           
 void setVisible(boolean aFlag)
          Fires an property changed event "visible".
 void validateToolBarsVisibility()
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mapMode

public MapMode mapMode
The current mode, this frame operates.


mapModes

private final java.util.List<MapMode> mapModes

mapView

public MapView mapView
The view control displayed.


toolBarActions

private javax.swing.JToolBar toolBarActions
The toolbar with the action icons. To add new toggle dialog actions, use addToggleDialog instead of adding directly to this list. To add a new mode use addMapMode.


toolBarToggle

private javax.swing.JToolBar toolBarToggle

statusLine

public MapStatus statusLine
The status line below the map


conflictDialog

public ConflictDialog conflictDialog

filterDialog

public FilterDialog filterDialog

relationListDialog

public RelationListDialog relationListDialog

validatorDialog

public ValidatorDialog validatorDialog

selectionListDialog

public SelectionListDialog selectionListDialog

propertiesDialog

public PropertiesDialog propertiesDialog

mapModeSelect

public final SelectAction mapModeSelect

mapModeDraw

private final MapMode mapModeDraw

mapModeZoom

private final MapMode mapModeZoom

allDialogs

private java.util.List<ToggleDialog> allDialogs
The panel list of all toggle dialog icons. To add new toggle dialog actions, use addToggleDialog instead of adding directly to this list.


leftPanel

private final javax.swing.JPanel leftPanel

dialogsPanel

private final DialogsPanel dialogsPanel

toolGroup

public final javax.swing.ButtonGroup toolGroup

allDialogButtons

private java.util.List<IconToggleButton> allDialogButtons

allMapModeButtons

private java.util.List<IconToggleButton> allMapModeButtons

listAllDialogsAction

private final MapFrame.ListAllButtonsAction listAllDialogsAction

listAllMapModesAction

private final MapFrame.ListAllButtonsAction listAllMapModesAction

listAllToggleDialogsButton

private final javax.swing.JButton listAllToggleDialogsButton

listAllMapModesButton

private final javax.swing.JButton listAllMapModesButton

DEF_TOGGLE_DLG_WIDTH

public static final int DEF_TOGGLE_DLG_WIDTH
Default width of the toggle dialog area.

See Also:
Constant Field Values

lastMapMode

private final java.util.Map<Layer,MapMode> lastMapMode

mapModeChangeListeners

private static final java.util.concurrent.CopyOnWriteArrayList<MapFrame.MapModeChangeListener> mapModeChangeListeners
the mapMode listeners


sidetoolbarPreferencesChangedListener

private Preferences.PreferenceChangedListener sidetoolbarPreferencesChangedListener
Constructor Detail

MapFrame

public MapFrame(javax.swing.JPanel contentPane)
Method Detail

selectSelectTool

public boolean selectSelectTool(boolean onlyIfModeless)

selectDrawTool

public boolean selectDrawTool(boolean onlyIfModeless)

selectZoomTool

public boolean selectZoomTool(boolean onlyIfModeless)

destroy

public void destroy()
Called as some kind of destructor when the last layer has been removed. Delegates the call to all Destroyables within this component (e.g. MapModes)

Specified by:
destroy in interface Destroyable

getDefaultButtonAction

public javax.swing.Action getDefaultButtonAction()

initializeDialogsPane

public void initializeDialogsPane()
Open all ToggleDialogs that have their preferences property set. Close all others.


addToggleDialog

public IconToggleButton addToggleDialog(ToggleDialog dlg)

addToggleDialog

public IconToggleButton addToggleDialog(ToggleDialog dlg,
                                        boolean isExpert)
Call this to add new toggle dialogs to the left button-list

Parameters:
dlg - The toggle dialog. It must not be in the list already.

addMapMode

public void addMapMode(IconToggleButton b)

setVisible

public void setVisible(boolean aFlag)
Fires an property changed event "visible".

Overrides:
setVisible in class javax.swing.JComponent

selectMapMode

public boolean selectMapMode(MapMode newMapMode)
Change the operating map mode for the view. Will call unregister on the old MapMode and register on the new one. Now this function also verifies if new map mode is correct mode for current layer and does not change mode in such cases.

Parameters:
mapMode - The new mode to set.
Returns:

selectMapMode

public boolean selectMapMode(MapMode newMapMode,
                             Layer newLayer)
Another version of the selectMapMode for changing layer action. Pass newly selected layer to this method.

Parameters:
newMapMode -
newLayer -
Returns:
True if mode is really selected

fillPanel

public void fillPanel(java.awt.Container panel)
Fill the given panel by adding all necessary components to the different locations.

Parameters:
panel - The container to fill. Must have an BorderLayout.

addHideContextMenu

private void addHideContextMenu(IconToggleButton b)

validateToolBarsVisibility

public void validateToolBarsVisibility()

getToggleDialog

public <T> T getToggleDialog(java.lang.Class<T> type)
Replies the instance of a toggle dialog of type type managed by this map frame

Type Parameters:
T -
Parameters:
type - the class of the toggle dialog, i.e. UserListDialog.class
Returns:
the instance of a toggle dialog of type type managed by this map frame; null, if no such dialog exists

rememberToggleDialogWidth

public void rememberToggleDialogWidth()
Remember the current width of the (possibly resized) toggle dialog area


removeTopPanel

public void removeTopPanel(java.lang.Class<?> type)

getTopPanel

public <T> T getTopPanel(java.lang.Class<T> type)

addTopPanel

public void addTopPanel(java.awt.Component c)
Add component @param c on top of MapView


addMapModeChangeListener

public static void addMapModeChangeListener(MapFrame.MapModeChangeListener listener)
Adds a mapMode change listener

Parameters:
listener - the listener. Ignored if null or already registered.

removeMapModeChangeListener

public static void removeMapModeChangeListener(MapFrame.MapModeChangeListener listener)
Removes a mapMode change listener

Parameters:
listener - the listener. Ignored if null or already registered.

fireMapModeChanged

protected static void fireMapModeChanged(MapMode oldMapMode,
                                         MapMode newMapMode)

activeLayerChange

public void activeLayerChange(Layer oldLayer,
                              Layer newLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that the active layer has changed.

Specified by:
activeLayerChange in interface MapView.LayerChangeListener
Parameters:
oldLayer - The previous active layer
newLayer - The new activer layer

getLastMapMode

private MapMode getLastMapMode(Layer newLayer)

layerAdded

public void layerAdded(Layer newLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that a layer has been added.

Specified by:
layerAdded in interface MapView.LayerChangeListener
Parameters:
newLayer - The new added layer

layerRemoved

public void layerRemoved(Layer oldLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that a layer has been removed.

Specified by:
layerRemoved in interface MapView.LayerChangeListener
Parameters:
oldLayer - The old removed layer


JOSM