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:
ImageObserver,MenuContainer,Serializable,Accessible,LayerManager.LayerChangeListener,MainLayerManager.ActiveLayerChangeListener,Destroyable
public class MapFrame
extends 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classstatic interfaceInterface to notify listeners of the change of the mapMode.private final classNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<IconToggleButton>private final List<ToggleDialog>final List<IconToggleButton>All map mode buttons.final ConflictDialogConflict dialogstatic final intDefault width of the toggle dialog area.private final DialogsPanelfinal FilterDialogFilter dialogprivate final MapGridPaintableThe grid drawn over the map view, seeMapGridPaintablefinal AdvancedKeyPressDetectorThis object allows to detect key press and release eventsprivate final JPanelprivate final MapFrame.ListAllButtonsActionprivate final MapFrame.ListAllButtonsActionThe current mode, this frame operates.private static final CopyOnWriteArrayList<MapFrame.MapModeChangeListener>the mapMode listenersfinal DeleteActionDelete modefinal DrawActionDraw modefinal SelectActionSelect modefinal SelectLassoActionSelect Lasso modefinal ZoomActionZoom modefinal MapPaintDialogMap paint dialogfinal MapViewThe view control displayed.static final BooleanPropertyDo not require to switch modes (potlatch style workflow) for drawing/selecting map modes.final NotesDialogNotes dialogfinal PropertiesDialogProperties dialogfinal RelationListDialogRelation list dialogfinal SelectionListDialogSelection list dialogstatic final BooleanPropertyWhether the side toolbar is visibleprivate JComponentThe toolbar with the action icons.private final JSplitPaneThe split pane with the mapview (leftPanel) and toggle dialogs (dialogsPanel).The status line below the mapprivate static final IntegerPropertystatic final BooleanPropertyWhether the toolbar is visibleprivate final JToolBarprivate final ButtonGroupprivate final JToolBarfinal ValidatorDialogValidator dialogFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled whenever the active or edit layer changed.voidAdds a new map mode buttonstatic voidAdds a mapMode change listenerAdds a new toggle dialog to the left button list.addToggleDialog(ToggleDialog dlg, boolean isExpert) Call this to add new toggle dialogs to the left button-listvoidAdd componentcon top of MapViewvoiddestroy()Called as some kind of destructor when the last layer has been removed.voidFill the given panel by adding all necessary components to the different locations.protected static voidfireMapModeChanged(MapMode oldMapMode, MapMode newMapMode) Gets the action of the default (first) map modeprivate MapModegetLastMapMode(Layer newLayer) <T extends ToggleDialog>
TgetToggleDialog(Class<T> type) Replies the instance of a toggle dialog of typetypemanaged by this map frame<T> TgetTopPanel(Class<T> type) Find panel on top of MapView by classvoidOpen all ToggleDialogs that have their preferences property set.voidNotifies this listener that a layer has been added.voidNotifies this listener that the order of layers was changed.voidNotifies this listener that a layer was just removed.voidRemember the current width of the (possibly resized) toggle dialog areastatic voidRemoves a mapMode change listenervoidCall this to remove existing toggle dialog from the left button-listvoidremoveTopPanel(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".voidValidate the visibility of all tool bars and hide the ones that should be hiddenMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods 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, updateMethods 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, validateTreeMethods 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 Details
-
DEF_TOGGLE_DLG_WIDTH
Default width of the toggle dialog area.- See Also:
-
TOGGLE_DIALOGS_WIDTH
-
MODELESS
Do not require to switch modes (potlatch style workflow) for drawing/selecting map modes.- Since:
- 12347
-
TOOLBAR_VISIBLE
Whether the toolbar is visible -
SIDE_TOOLBAR_VISIBLE
Whether the side toolbar is visible -
mapMode
The current mode, this frame operates. -
mapView
The view control displayed. -
gridOverlay
The grid drawn over the map view, seeMapGridPaintable -
keyDetector
This object allows to detect key press and release events -
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
-
toolBarActions
-
toolBarToggle
-
allDialogs
-
allDialogButtons
-
allMapModeButtons
All map mode buttons. Should only be read form the outside -
listAllDialogsAction
-
listAllMapModesAction
-
conflictDialog
Conflict dialog -
filterDialog
Filter dialog -
relationListDialog
Relation list dialog -
validatorDialog
Validator dialog -
selectionListDialog
Selection list dialog -
propertiesDialog
Properties dialog -
mapPaintDialog
Map paint dialog -
noteDialog
Notes dialog -
mapModeSelect
Select mode -
mapModeDraw
Draw mode -
mapModeZoom
Zoom mode -
mapModeDelete
Delete mode -
mapModeSelectLasso
Select Lasso mode -
lastMapMode
-
statusLine
The status line below the map -
splitPane
The split pane with the mapview (leftPanel) and toggle dialogs (dialogsPanel). -
leftPanel
-
dialogsPanel
-
mapModeChangeListeners
the mapMode listeners -
sidetoolbarPreferencesChangedListener
private transient AbstractProperty.ValueChangeListener<Boolean> sidetoolbarPreferencesChangedListener
-
-
Constructor Details
-
MapFrame
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 Details
-
selectSelectTool
Enables the select tool- Parameters:
onlyIfModeless- Only enable if modeless mode is active- Returns:
trueif it is selected
-
selectDrawTool
Enables the draw tool- Parameters:
onlyIfModeless- Only enable if modeless mode is active- Returns:
trueif it is selected
-
selectZoomTool
Enables the zoom tool- Parameters:
onlyIfModeless- Only enable if modeless mode is active- Returns:
trueif it is selected
-
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
Gets the action of the default (first) map mode- Returns:
- That action
-
initializeDialogsPane
Open all ToggleDialogs that have their preferences property set. Close all others. -
addToggleDialog
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
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
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
Adds a new map mode button- Parameters:
b- The map mode button with aMapModeaction.
-
setVisible
Fires an property changed event "visible".- Overrides:
setVisiblein classJComponent- Parameters:
aFlag-trueif display should be visible
-
selectMapMode
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
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
Fill the given panel by adding all necessary components to the different locations.- Parameters:
panel- The container to fill. Must have a BorderLayout.
-
validateToolBarsVisibility
Validate the visibility of all tool bars and hide the ones that should be hidden -
getToggleDialog
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
Shows or hides the side dialog panel- Parameters:
visible- The new visibility
-
rememberToggleDialogWidth
Remember the current width of the (possibly resized) toggle dialog area -
removeTopPanel
Remove panel from top of MapView by class- Parameters:
type- type of panel
-
getTopPanel
Find panel on top of MapView by class- Type Parameters:
T- type- Parameters:
type- type of panel- Returns:
- found panel
-
addTopPanel
Add componentcon top of MapView- Parameters:
c- component
-
addMapModeChangeListener
Adds a mapMode change listener- Parameters:
listener- the listener. Ignored if null or already registered.
-
removeMapModeChangeListener
Removes a mapMode change listener- Parameters:
listener- the listener. Ignored if null or already registered.
-
fireMapModeChanged
-
activeOrEditLayerChanged
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
-
layerAdded
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
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
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.
-