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, org.openstreetmap.josm.tools.Destroyable

public class MapFrame
extends javax.swing.JPanel
implements org.openstreetmap.josm.tools.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.

Author:
imi
See Also:
Serialized Form

Nested Class Summary
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
 org.openstreetmap.josm.gui.dialogs.ConflictDialog conflictDialog
           
static int DEF_TOGGLE_DLG_WIDTH
          Default width of the toggle dialog area.
 org.openstreetmap.josm.gui.dialogs.FilterDialog filterDialog
           
 org.openstreetmap.josm.actions.mapmode.MapMode mapMode
          The current mode, this frame operates.
 org.openstreetmap.josm.actions.mapmode.SelectAction mapModeSelect
           
 MapView mapView
          The view control displayed.
 org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog propertiesDialog
           
 org.openstreetmap.josm.gui.dialogs.RelationListDialog relationListDialog
           
 org.openstreetmap.josm.gui.dialogs.SelectionListDialog selectionListDialog
           
 MapStatus statusLine
          The status line below the map
 javax.swing.ButtonGroup toolGroup
           
 org.openstreetmap.josm.gui.dialogs.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(org.openstreetmap.josm.gui.layer.Layer oldLayer, org.openstreetmap.josm.gui.layer.Layer newLayer)
           
 void addMapMode(IconToggleButton b)
           
static void addMapModeChangeListener(MapFrame.MapModeChangeListener listener)
          Adds a mapMode change listener
 IconToggleButton addToggleDialog(org.openstreetmap.josm.gui.dialogs.ToggleDialog dlg)
           
 IconToggleButton addToggleDialog(org.openstreetmap.josm.gui.dialogs.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(org.openstreetmap.josm.actions.mapmode.MapMode oldMapMode, org.openstreetmap.josm.actions.mapmode.MapMode newMapMode)
           
 javax.swing.Action getDefaultButtonAction()
           
<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(org.openstreetmap.josm.gui.layer.Layer newLayer)
           
 void layerRemoved(org.openstreetmap.josm.gui.layer.Layer oldLayer)
           
 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)
           
 void selectDrawTool(boolean onlyIfModeless)
           
 boolean selectMapMode(org.openstreetmap.josm.actions.mapmode.MapMode newMapMode)
          Change the operating map mode for the view.
 boolean selectMapMode(org.openstreetmap.josm.actions.mapmode.MapMode newMapMode, org.openstreetmap.josm.gui.layer.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 org.openstreetmap.josm.actions.mapmode.MapMode mapMode
The current mode, this frame operates.


mapView

public MapView mapView
The view control displayed.


statusLine

public MapStatus statusLine
The status line below the map


conflictDialog

public org.openstreetmap.josm.gui.dialogs.ConflictDialog conflictDialog

filterDialog

public org.openstreetmap.josm.gui.dialogs.FilterDialog filterDialog

relationListDialog

public org.openstreetmap.josm.gui.dialogs.RelationListDialog relationListDialog

validatorDialog

public org.openstreetmap.josm.gui.dialogs.ValidatorDialog validatorDialog

selectionListDialog

public org.openstreetmap.josm.gui.dialogs.SelectionListDialog selectionListDialog

propertiesDialog

public org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog propertiesDialog

mapModeSelect

public final org.openstreetmap.josm.actions.mapmode.SelectAction mapModeSelect

toolGroup

public final javax.swing.ButtonGroup toolGroup

DEF_TOGGLE_DLG_WIDTH

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

See Also:
Constant Field Values
Constructor Detail

MapFrame

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

selectSelectTool

public boolean selectSelectTool(boolean onlyIfModeless)

selectDrawTool

public void 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 org.openstreetmap.josm.tools.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(org.openstreetmap.josm.gui.dialogs.ToggleDialog dlg)

addToggleDialog

public IconToggleButton addToggleDialog(org.openstreetmap.josm.gui.dialogs.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(org.openstreetmap.josm.actions.mapmode.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(org.openstreetmap.josm.actions.mapmode.MapMode newMapMode,
                             org.openstreetmap.josm.gui.layer.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.

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(org.openstreetmap.josm.actions.mapmode.MapMode oldMapMode,
                                         org.openstreetmap.josm.actions.mapmode.MapMode newMapMode)

activeLayerChange

public void activeLayerChange(org.openstreetmap.josm.gui.layer.Layer oldLayer,
                              org.openstreetmap.josm.gui.layer.Layer newLayer)
Specified by:
activeLayerChange in interface MapView.LayerChangeListener

layerAdded

public void layerAdded(org.openstreetmap.josm.gui.layer.Layer newLayer)
Specified by:
layerAdded in interface MapView.LayerChangeListener

layerRemoved

public void layerRemoved(org.openstreetmap.josm.gui.layer.Layer oldLayer)
Specified by:
layerRemoved in interface MapView.LayerChangeListener