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) classMapFrame.ListAllButtonsActionstatic interfaceMapFrame.MapModeChangeListenerInterface to notify listeners of the change of the mapMode.private classMapFrame.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>allDialogButtonsprivate java.util.List<ToggleDialog>allDialogsjava.util.List<IconToggleButton>allMapModeButtonsAll map mode buttons.ConflictDialogconflictDialogConflict dialogstatic intDEF_TOGGLE_DLG_WIDTHDefault width of the toggle dialog area.private DialogsPaneldialogsPanelFilterDialogfilterDialogFilter dialogAdvancedKeyPressDetectorkeyDetectorThis object allows to detect key press and release eventsprivate java.util.Map<Layer,MapMode>lastMapModeprivate javax.swing.JPanelleftPanelprivate MapFrame.ListAllButtonsActionlistAllDialogsActionprivate MapFrame.ListAllButtonsActionlistAllMapModesActionMapModemapModeThe current mode, this frame operates.private static java.util.concurrent.CopyOnWriteArrayList<MapFrame.MapModeChangeListener>mapModeChangeListenersthe mapMode listenersDeleteActionmapModeDeleteDelete modeDrawActionmapModeDrawDraw modeSelectActionmapModeSelectSelect modeSelectLassoActionmapModeSelectLassoSelect Lasso modeZoomActionmapModeZoomZoom modeMapPaintDialogmapPaintDialogMap paint dialogMapViewmapViewThe view control displayed.static BooleanPropertyMODELESSDo not require to switch modes (potlatch style workflow) for drawing/selecting map modes.NotesDialognoteDialogNotes dialogPropertiesDialogpropertiesDialogProperties dialogRelationListDialogrelationListDialogRelation list dialogSelectionListDialogselectionListDialogSelection list dialogstatic BooleanPropertySIDE_TOOLBAR_VISIBLEWhether the side toolbar is visibleprivate javax.swing.JComponentsideToolBarThe toolbar with the action icons.private AbstractProperty.ValueChangeListener<java.lang.Boolean>sidetoolbarPreferencesChangedListenerprivate javax.swing.JSplitPanesplitPaneThe split pane with the mapview (leftPanel) and toggle dialogs (dialogsPanel).MapStatusstatusLineThe status line below the mapprivate static IntegerPropertyTOGGLE_DIALOGS_WIDTHstatic BooleanPropertyTOOLBAR_VISIBLEWhether the toolbar is visibleprivate javax.swing.JToolBartoolBarActionsprivate javax.swing.ButtonGrouptoolBarActionsGroupprivate javax.swing.JToolBartoolBarToggleValidatorDialogvalidatorDialogValidator 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 voidactiveOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)Called whenever the active or edit layer changed.voidaddMapMode(IconToggleButton b)Adds a new map mode buttonstatic voidaddMapModeChangeListener(MapFrame.MapModeChangeListener listener)Adds a mapMode change listenerIconToggleButtonaddToggleDialog(ToggleDialog dlg)Adds a new toggle dialog to the left button list.IconToggleButtonaddToggleDialog(ToggleDialog dlg, boolean isExpert)Call this to add new toggle dialogs to the left button-listvoidaddTopPanel(java.awt.Component c)Add componentcon top of MapViewvoiddestroy()Called as some kind of destructor when the last layer has been removed.voidfillPanel(java.awt.Container panel)Fill the given panel by adding all necessary components to the different locations.protected static voidfireMapModeChanged(MapMode oldMapMode, MapMode newMapMode)javax.swing.ActiongetDefaultButtonAction()Gets the action of the default (first) map modeprivate MapModegetLastMapMode(Layer newLayer)<T extends ToggleDialog>
TgetToggleDialog(java.lang.Class<T> type)Replies the instance of a toggle dialog of typetypemanaged by this map frame<T> TgetTopPanel(java.lang.Class<T> type)Find panel on top of MapView by classvoidinitializeDialogsPane()Open all ToggleDialogs that have their preferences property set.voidlayerAdded(LayerManager.LayerAddEvent e)Notifies this listener that a layer has been added.voidlayerOrderChanged(LayerManager.LayerOrderChangeEvent e)Notifies this listener that the order of layers was changed.voidlayerRemoving(LayerManager.LayerRemoveEvent e)Notifies this listener that a layer was just removed.voidrememberToggleDialogWidth()Remember the current width of the (possibly resized) toggle dialog areastatic voidremoveMapModeChangeListener(MapFrame.MapModeChangeListener listener)Removes a mapMode change listenervoidremoveToggleDialog(ToggleDialog dlg)Call this to remove existing toggle dialog from the left button-listvoidremoveTopPanel(java.lang.Class<?> type)Remove panel from top of MapView by classbooleanselectDrawTool(boolean onlyIfModeless)Enables the draw toolbooleanselectMapMode(MapMode newMapMode)Change the operating map mode for the view.booleanselectMapMode(MapMode newMapMode, Layer newLayer)Another version of the selectMapMode for changing layer action.booleanselectSelectTool(boolean onlyIfModeless)Enables the select toolbooleanselectZoomTool(boolean onlyIfModeless)Enables the zoom toolvoidsetDialogsPanelVisible(boolean visible)Shows or hides the side dialog panelvoidsetVisible(boolean aFlag)Fires an property changed event "visible".voidvalidateToolBarsVisibility()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:
trueif it is selected
-
selectDrawTool
public boolean selectDrawTool(boolean onlyIfModeless)
Enables the draw tool- Parameters:
onlyIfModeless- Only enable if modeless mode is active- Returns:
trueif it is selected
-
selectZoomTool
public boolean selectZoomTool(boolean onlyIfModeless)
Enables the zoom tool- Parameters:
onlyIfModeless- Only enable if modeless mode is active- Returns:
trueif 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:
destroyin 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-trueif 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 aMapModeaction.
-
setVisible
public void setVisible(boolean aFlag)
Fires an property changed event "visible".- Overrides:
setVisiblein classjavax.swing.JComponent- Parameters:
aFlag-trueif 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:
trueif 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:
trueif 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 typetypemanaged 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
typemanaged 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 componentcon 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.ActiveLayerChangeListenerCalled 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:
activeOrEditLayerChangedin 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.LayerChangeListenerNotifies 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:
layerAddedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The new added layer event
-
layerRemoving
public void layerRemoving(LayerManager.LayerRemoveEvent e)
Description copied from interface:LayerManager.LayerChangeListenerNotifies 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:
layerRemovingin interfaceLayerManager.LayerChangeListener- Parameters:
e- The layer to be removed (as event)
-
layerOrderChanged
public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Description copied from interface:LayerManager.LayerChangeListenerNotifies 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:
layerOrderChangedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The order change event.
-
-