Package org.openstreetmap.josm.gui
Class MapFrame
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.openstreetmap.josm.gui.MapFrame
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,LayerManager.LayerChangeListener
,MainLayerManager.ActiveLayerChangeListener
,Destroyable
public class MapFrame extends javax.swing.JPanel implements Destroyable, MainLayerManager.ActiveLayerChangeListener, LayerManager.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
Nested Classes Modifier and Type Class Description (package private) class
MapFrame.ListAllButtonsAction
static interface
MapFrame.MapModeChangeListener
Interface to notify listeners of the change of the mapMode.private class
MapFrame.SideToolbarPopupMenu
-
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
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<IconToggleButton>
allDialogButtons
private java.util.List<ToggleDialog>
allDialogs
java.util.List<IconToggleButton>
allMapModeButtons
All map mode buttons.ConflictDialog
conflictDialog
Conflict dialogstatic int
DEF_TOGGLE_DLG_WIDTH
Default width of the toggle dialog area.private DialogsPanel
dialogsPanel
FilterDialog
filterDialog
Filter dialogAdvancedKeyPressDetector
keyDetector
This object allows to detect key press and release eventsprivate java.util.Map<Layer,MapMode>
lastMapMode
private javax.swing.JPanel
leftPanel
private MapFrame.ListAllButtonsAction
listAllDialogsAction
private MapFrame.ListAllButtonsAction
listAllMapModesAction
MapMode
mapMode
The current mode, this frame operates.private static java.util.concurrent.CopyOnWriteArrayList<MapFrame.MapModeChangeListener>
mapModeChangeListeners
the mapMode listenersDeleteAction
mapModeDelete
Delete modeDrawAction
mapModeDraw
Draw modeSelectAction
mapModeSelect
Select modeSelectLassoAction
mapModeSelectLasso
Select Lasso modeZoomAction
mapModeZoom
Zoom modeMapPaintDialog
mapPaintDialog
Map paint dialogMapView
mapView
The view control displayed.static BooleanProperty
MODELESS
Do not require to switch modes (potlatch style workflow) for drawing/selecting map modes.NotesDialog
noteDialog
Notes dialogPropertiesDialog
propertiesDialog
Properties dialogRelationListDialog
relationListDialog
Relation list dialogSelectionListDialog
selectionListDialog
Selection list dialogstatic BooleanProperty
SIDE_TOOLBAR_VISIBLE
Whether the side toolbar is visibleprivate javax.swing.JComponent
sideToolBar
The toolbar with the action icons.private AbstractProperty.ValueChangeListener<java.lang.Boolean>
sidetoolbarPreferencesChangedListener
private javax.swing.JSplitPane
splitPane
The split pane with the mapview (leftPanel) and toggle dialogs (dialogsPanel).MapStatus
statusLine
The status line below the mapprivate static IntegerProperty
TOGGLE_DIALOGS_WIDTH
static BooleanProperty
TOOLBAR_VISIBLE
Whether the toolbar is visibleprivate javax.swing.JToolBar
toolBarActions
private javax.swing.ButtonGroup
toolBarActionsGroup
private javax.swing.JToolBar
toolBarToggle
ValidatorDialog
validatorDialog
Validator dialog-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description MapFrame(ViewportData viewportData)
Constructs a newMapFrame
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Called whenever the active or edit layer changed.void
addMapMode(IconToggleButton b)
Adds a new map mode buttonstatic void
addMapModeChangeListener(MapFrame.MapModeChangeListener listener)
Adds a mapMode change listenerIconToggleButton
addToggleDialog(ToggleDialog dlg)
Adds a new toggle dialog to the left button list.IconToggleButton
addToggleDialog(ToggleDialog dlg, boolean isExpert)
Call this to add new toggle dialogs to the left button-listvoid
addTopPanel(java.awt.Component c)
Add componentc
on top of MapViewvoid
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()
Gets the action of the default (first) map modeprivate MapMode
getLastMapMode(Layer newLayer)
<T extends ToggleDialog>
TgetToggleDialog(java.lang.Class<T> type)
Replies the instance of a toggle dialog of typetype
managed by this map frame<T> T
getTopPanel(java.lang.Class<T> type)
Find panel on top of MapView by classvoid
initializeDialogsPane()
Open all ToggleDialogs that have their preferences property set.void
layerAdded(LayerManager.LayerAddEvent e)
Notifies this listener that a layer has been added.void
layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Notifies this listener that the order of layers was changed.void
layerRemoving(LayerManager.LayerRemoveEvent e)
Notifies this listener that a layer was just removed.void
rememberToggleDialogWidth()
Remember the current width of the (possibly resized) toggle dialog areastatic void
removeMapModeChangeListener(MapFrame.MapModeChangeListener listener)
Removes a mapMode change listenervoid
removeToggleDialog(ToggleDialog dlg)
Call this to remove existing toggle dialog from the left button-listvoid
removeTopPanel(java.lang.Class<?> type)
Remove panel from top of MapView by classboolean
selectDrawTool(boolean onlyIfModeless)
Enables the draw toolboolean
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)
Enables the select toolboolean
selectZoomTool(boolean onlyIfModeless)
Enables the zoom toolvoid
setDialogsPanelVisible(boolean visible)
Shows or hides the side dialog panelvoid
setVisible(boolean aFlag)
Fires an property changed event "visible".void
validateToolBarsVisibility()
Validate the visibility of all tool bars and hide the ones that should be hidden-
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
DEF_TOGGLE_DLG_WIDTH
public static final int DEF_TOGGLE_DLG_WIDTH
Default width of the toggle dialog area.- See Also:
- Constant Field Values
-
TOGGLE_DIALOGS_WIDTH
private static final IntegerProperty TOGGLE_DIALOGS_WIDTH
-
MODELESS
public static final BooleanProperty MODELESS
Do not require to switch modes (potlatch style workflow) for drawing/selecting map modes.- Since:
- 12347
-
TOOLBAR_VISIBLE
public static final BooleanProperty TOOLBAR_VISIBLE
Whether the toolbar is visible
-
SIDE_TOOLBAR_VISIBLE
public static final BooleanProperty SIDE_TOOLBAR_VISIBLE
Whether the side toolbar is visible
-
keyDetector
public final transient AdvancedKeyPressDetector keyDetector
This object allows to detect key press and release events
-
sideToolBar
private javax.swing.JComponent sideToolBar
The toolbar with the action icons. To add new toggle dialog buttons, use addToggleDialog, to add a new map mode button use addMapMode.
-
toolBarActionsGroup
private final javax.swing.ButtonGroup toolBarActionsGroup
-
toolBarActions
private final javax.swing.JToolBar toolBarActions
-
toolBarToggle
private final javax.swing.JToolBar toolBarToggle
-
allDialogs
private final java.util.List<ToggleDialog> allDialogs
-
allDialogButtons
private final java.util.List<IconToggleButton> allDialogButtons
-
allMapModeButtons
public final java.util.List<IconToggleButton> allMapModeButtons
All map mode buttons. Should only be read form the outside
-
listAllDialogsAction
private final MapFrame.ListAllButtonsAction listAllDialogsAction
-
listAllMapModesAction
private final MapFrame.ListAllButtonsAction listAllMapModesAction
-
conflictDialog
public final ConflictDialog conflictDialog
Conflict dialog
-
filterDialog
public final FilterDialog filterDialog
Filter dialog
-
relationListDialog
public final RelationListDialog relationListDialog
Relation list dialog
-
validatorDialog
public final ValidatorDialog validatorDialog
Validator dialog
-
selectionListDialog
public final SelectionListDialog selectionListDialog
Selection list dialog
-
propertiesDialog
public final PropertiesDialog propertiesDialog
Properties dialog
-
mapPaintDialog
public final MapPaintDialog mapPaintDialog
Map paint dialog
-
noteDialog
public final NotesDialog noteDialog
Notes dialog
-
mapModeSelect
public final SelectAction mapModeSelect
Select mode
-
mapModeDraw
public final DrawAction mapModeDraw
Draw mode
-
mapModeZoom
public final ZoomAction mapModeZoom
Zoom mode
-
mapModeDelete
public final DeleteAction mapModeDelete
Delete mode
-
mapModeSelectLasso
public final SelectLassoAction mapModeSelectLasso
Select Lasso mode
-
lastMapMode
private final transient java.util.Map<Layer,MapMode> lastMapMode
-
statusLine
public MapStatus statusLine
The status line below the map
-
splitPane
private final javax.swing.JSplitPane splitPane
The split pane with the mapview (leftPanel) and toggle dialogs (dialogsPanel).
-
leftPanel
private final javax.swing.JPanel leftPanel
-
dialogsPanel
private final DialogsPanel dialogsPanel
-
mapModeChangeListeners
private static final java.util.concurrent.CopyOnWriteArrayList<MapFrame.MapModeChangeListener> mapModeChangeListeners
the mapMode listeners
-
sidetoolbarPreferencesChangedListener
private transient AbstractProperty.ValueChangeListener<java.lang.Boolean> sidetoolbarPreferencesChangedListener
-
-
Constructor Detail
-
MapFrame
public MapFrame(ViewportData viewportData)
Constructs a newMapFrame
.- Parameters:
viewportData
- the initial viewport of the map. Can be null, then the viewport is derived from the layer data.- Since:
- 11713
-
-
Method Detail
-
selectSelectTool
public boolean selectSelectTool(boolean onlyIfModeless)
Enables the select tool- Parameters:
onlyIfModeless
- Only enable if modeless mode is active- Returns:
true
if it is selected
-
selectDrawTool
public boolean selectDrawTool(boolean onlyIfModeless)
Enables the draw tool- Parameters:
onlyIfModeless
- Only enable if modeless mode is active- Returns:
true
if it is selected
-
selectZoomTool
public boolean selectZoomTool(boolean onlyIfModeless)
Enables the zoom tool- Parameters:
onlyIfModeless
- Only enable if modeless mode is active- Returns:
true
if it is selected
-
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 interfaceDestroyable
-
getDefaultButtonAction
public javax.swing.Action getDefaultButtonAction()
Gets the action of the default (first) map mode- Returns:
- That action
-
initializeDialogsPane
public void initializeDialogsPane()
Open all ToggleDialogs that have their preferences property set. Close all others.
-
addToggleDialog
public IconToggleButton addToggleDialog(ToggleDialog dlg)
Adds a new toggle dialog to the left button list. It is displayed in expert and normal mode- Parameters:
dlg
- The dialog- Returns:
- The button
-
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.isExpert
-true
if it's reserved to expert mode- Returns:
- button allowing to toggle the dialog
-
removeToggleDialog
public void removeToggleDialog(ToggleDialog dlg)
Call this to remove existing toggle dialog from the left button-list- Parameters:
dlg
- The toggle dialog. It must be already in the list.- Since:
- 10851
-
addMapMode
public void addMapMode(IconToggleButton b)
Adds a new map mode button- Parameters:
b
- The map mode button with aMapMode
action.
-
setVisible
public void setVisible(boolean aFlag)
Fires an property changed event "visible".- Overrides:
setVisible
in classjavax.swing.JComponent
- Parameters:
aFlag
-true
if display should be visible
-
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:
newMapMode
- The new mode to set.- Returns:
true
if mode is really selected
-
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
- The new mode to set.newLayer
- newly selected layer- 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 a BorderLayout.
-
validateToolBarsVisibility
public void validateToolBarsVisibility()
Validate the visibility of all tool bars and hide the ones that should be hidden
-
getToggleDialog
public <T extends ToggleDialog> T getToggleDialog(java.lang.Class<T> type)
Replies the instance of a toggle dialog of typetype
managed by this map frame- Type Parameters:
T
- toggle dialog type- 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
-
setDialogsPanelVisible
public void setDialogsPanelVisible(boolean visible)
Shows or hides the side dialog panel- Parameters:
visible
- The new visibility
-
rememberToggleDialogWidth
public void rememberToggleDialogWidth()
Remember the current width of the (possibly resized) toggle dialog area
-
removeTopPanel
public void removeTopPanel(java.lang.Class<?> type)
Remove panel from top of MapView by class- Parameters:
type
- type of panel
-
getTopPanel
public <T> T getTopPanel(java.lang.Class<T> type)
Find panel on top of MapView by class- Type Parameters:
T
- type- Parameters:
type
- type of panel- Returns:
- found panel
-
addTopPanel
public void addTopPanel(java.awt.Component c)
Add componentc
on top of MapView- Parameters:
c
- component
-
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)
-
activeOrEditLayerChanged
public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Description copied from interface:MainLayerManager.ActiveLayerChangeListener
Called whenever the active or edit layer changed.You can be sure that this layer is still contained in this set.
Listeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
- Specified by:
activeOrEditLayerChanged
in interfaceMainLayerManager.ActiveLayerChangeListener
- Parameters:
e
- The change event.
-
getLastMapMode
private MapMode getLastMapMode(Layer newLayer)
-
layerAdded
public void layerAdded(LayerManager.LayerAddEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that a layer has been added.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerAdded
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The new added layer event
-
layerRemoving
public void layerRemoving(LayerManager.LayerRemoveEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that a layer was just removed.Listeners are called in the EDT thread after the layer was removed. Use
LayerManager.LayerRemoveEvent.scheduleRemoval(Collection)
to remove more layers. You should not do blocking or long-running tasks in this method.- Specified by:
layerRemoving
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The layer to be removed (as event)
-
layerOrderChanged
public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that the order of layers was changed.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerOrderChanged
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The order change event.
-
-