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:
- 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.(package private) static class
MapFrame.NoBorderSplitPaneUI
private class
MapFrame.SideToolbarPopupMenu
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
-
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
-
Fields inherited from class java.awt.Component
accessibleContext, 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
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(Component c)
Add componentc
on top of MapViewvoid
destroy()
Called as some kind of destructor when the last layer has been removed.void
fillPanel(Container panel)
Fill the given panel by adding all necessary components to the different locations.protected static void
fireMapModeChanged(MapMode oldMapMode, MapMode newMapMode)
Action
getDefaultButtonAction()
Gets the action of the default (first) map modeprivate MapMode
getLastMapMode(Layer newLayer)
<T extends ToggleDialog>
TgetToggleDialog(Class<T> type)
Replies the instance of a toggle dialog of typetype
managed by this map frame<T> T
getTopPanel(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(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 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 ButtonGroup toolBarActionsGroup
-
toolBarActions
private final JToolBar toolBarActions
-
toolBarToggle
private final JToolBar toolBarToggle
-
allDialogs
private final List<ToggleDialog> allDialogs
-
allDialogButtons
private final List<IconToggleButton> allDialogButtons
-
allMapModeButtons
public final 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 Map<Layer,MapMode> lastMapMode
-
statusLine
public MapStatus statusLine
The status line below the map
-
splitPane
private final JSplitPane splitPane
The split pane with the mapview (leftPanel) and toggle dialogs (dialogsPanel).
-
dialogsPanel
private final DialogsPanel dialogsPanel
-
mapModeChangeListeners
private static final CopyOnWriteArrayList<MapFrame.MapModeChangeListener> mapModeChangeListeners
the mapMode listeners
-
sidetoolbarPreferencesChangedListener
private transient AbstractProperty.ValueChangeListener<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 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 classJComponent
- 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(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(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(Class<?> type)
Remove panel from top of MapView by class- Parameters:
type
- type of panel
-
getTopPanel
public <T> T getTopPanel(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(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.
-
-