Package org.openstreetmap.josm.gui
Class MapStatus
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.openstreetmap.josm.gui.MapStatus
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,DataSelectionListener
,DataSetListener
,SystemOfMeasurement.SoMChangeListener
,Helpful
,NavigatableComponent.ZoomChangeListener
,PreferenceChangedListener
,Destroyable
public final class MapStatus extends javax.swing.JPanel implements Helpful, Destroyable, PreferenceChangedListener, SystemOfMeasurement.SoMChangeListener, DataSelectionListener, DataSetListener, NavigatableComponent.ZoomChangeListener
A component that manages some status information display about the map. It keeps a status line below the map up to date and displays some tooltip information if the user hold the mouse long enough at some point.All this is done in background to not disturb other processes.
The background thread does not alter any data of the map (read only thread). Also it is rather fail safe. In case of some error in the data, it just does nothing instead of whining and complaining.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
MapStatus.BackgroundProgressMonitor
The progress monitor that is used to display the progress if the user selects to run in backgroundprivate class
MapStatus.Collector
The collector class that waits for notification and then update the display objects.(package private) static class
MapStatus.JumpToOnLeftClickMouseAdapter
private class
MapStatus.MapStatusPopupMenu
private static class
MapStatus.MouseState
Everything, the collector is interested of.(package private) static class
MapStatus.ShowMonitorDialogMouseAdapter
protected static class
MapStatus.StatusTextHistory
-
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
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.osm.DataSelectionListener
DataSelectionListener.AbstractSelectionEvent, DataSelectionListener.SelectionAddEvent, DataSelectionListener.SelectionChangeEvent, DataSelectionListener.SelectionRemoveEvent, DataSelectionListener.SelectionReplaceEvent, DataSelectionListener.SelectionToggleEvent
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
angleEnabled
private ImageLabel
angleText
private boolean
autoLength
see #19887: determine if thedistValue
field should be filled with length of selected objectprivate java.awt.event.AWTEventListener
awtListener
private MapStatus.Collector
collector
private java.text.DecimalFormat
DECIMAL_FORMAT
private static AbstractProperty<java.lang.Double>
DISTANCE_THRESHOLD
private ImageLabel
distText
private double
distValue
private ImageLabel
headingText
private JosmTextField
helpText
private java.awt.event.KeyAdapter
keyAdapter
private ImageLabel
latText
private ImageLabel
lonText
private java.awt.event.MouseMotionListener
mouseMotionListener
private MapView
mv
The MapView this status belongs to.private java.awt.event.ComponentAdapter
mvComponentAdapter
private ImageLabel
nameText
private ICoordinateFormat
previousCoordinateFormat
TheICoordinateFormat
set in the previous updateprivate javax.swing.JProgressBar
progressBar
MapStatus.BackgroundProgressMonitor
progressMonitor
The progress monitor for displaying a background progressstatic NamedColorProperty
PROP_ACTIVE_BACKGROUND_COLOR
Property for map status background color (active state).static NamedColorProperty
PROP_ACTIVE_FOREGROUND_COLOR
Property for map status foreground color (active state).static NamedColorProperty
PROP_BACKGROUND_COLOR
Property for map status background color.static NamedColorProperty
PROP_FOREGROUND_COLOR
Property for map status foreground color.private static AbstractProperty<java.lang.Boolean>
SHOW_ID
private static java.util.List<SystemOfMeasurement>
SORTED_SYSTEM_OF_MEASUREMENTS
private java.util.List<MapStatus.StatusTextHistory>
statusText
private java.lang.Thread
thread
This is the thread that runs in the background and collects the information displayed.-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateAnglePanel(boolean activeFlag)
Activates the angle panel.void
addMouseListener(java.awt.event.MouseListener ml)
void
dataChanged(DataChangedEvent event)
Called after big changes in dataset.void
destroy()
Called when the object has been destroyed.javax.swing.JPanel
getAnglePanel()
Gets the panel that displays the anglestatic void
getColors()
Loads all colors from preferences.private static int
getNameLabelCharacterCount(java.awt.Component parent)
java.lang.String
helpTopic()
Returns the help topic on JOSM wiki for this feature.void
nodeMoved(NodeMovedEvent event)
A node's coordinates were modified.void
otherDatasetChange(AbstractDatasetChangedEvent event)
Minor dataset change, currently only changeset id changed is supported, but can be extended in future.void
preferenceChanged(PreferenceChangeEvent e)
Triggered when a preference entry value changes.void
primitivesAdded(PrimitivesAddedEvent event)
A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.void
primitivesRemoved(PrimitivesRemovedEvent event)
A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.private void
refreshAnglePanel()
private void
refreshDistText(java.util.Collection<? extends OsmPrimitive> newSelection)
private void
registerListeners()
void
relationMembersChanged(RelationMembersChangedEvent event)
A relation's members have changed.void
resetHelpText(java.lang.Object id)
Removes a help text and restores the previous onevoid
selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Called whenever the selection is changed.void
setAngle(double a)
Sets the angle to display in the angle panel.void
setAngleNaN(double a)
Sets the angle to display in the angle panel.void
setAngleText(java.lang.String text)
Sets the angle to display in the angle panelvoid
setAutoLength(boolean b)
Enable or disable the automatic refresh of the length field.void
setDist(double dist)
Sets the distance text to the given valuevoid
setDist(java.util.Collection<Way> ways)
Sets the distance text to the total sum of given ways lengthvoid
setHeading(double h)
Sets the heading to display in the heading panelvoid
setHelpText(java.lang.Object id, java.lang.String text)
Sets the help status text to displayvoid
setHelpText(java.lang.String text)
Sets the help text in the status panelvoid
systemOfMeasurementChanged(java.lang.String oldSoM, java.lang.String newSoM)
The current SoM has changed.void
tagsChanged(TagsChangedEvent event)
There was some change in the tag set of a primitive.private void
unregisterListeners()
private void
updateLatLonText(int x, int y)
void
updateSystemOfMeasurement(SystemOfMeasurement som)
Updates the system of measurement and displays a notification.void
wayNodesChanged(WayNodesChangedEvent event)
A way's node list was changed.void
zoomChanged()
Method called when the zoom area has changed.-
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, setVisible, 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, 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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.osm.event.DataSetListener
dataChangedIndividualEvents
-
-
-
-
Field Detail
-
DECIMAL_FORMAT
private final java.text.DecimalFormat DECIMAL_FORMAT
-
DISTANCE_THRESHOLD
private static final AbstractProperty<java.lang.Double> DISTANCE_THRESHOLD
-
SHOW_ID
private static final AbstractProperty<java.lang.Boolean> SHOW_ID
-
SORTED_SYSTEM_OF_MEASUREMENTS
private static final java.util.List<SystemOfMeasurement> SORTED_SYSTEM_OF_MEASUREMENTS
-
PROP_BACKGROUND_COLOR
public static final NamedColorProperty PROP_BACKGROUND_COLOR
Property for map status background color.- Since:
- 6789
-
PROP_ACTIVE_BACKGROUND_COLOR
public static final NamedColorProperty PROP_ACTIVE_BACKGROUND_COLOR
Property for map status background color (active state).- Since:
- 6789
-
PROP_FOREGROUND_COLOR
public static final NamedColorProperty PROP_FOREGROUND_COLOR
Property for map status foreground color.- Since:
- 6789
-
PROP_ACTIVE_FOREGROUND_COLOR
public static final NamedColorProperty PROP_ACTIVE_FOREGROUND_COLOR
Property for map status foreground color (active state).- Since:
- 6789
-
collector
private final transient MapStatus.Collector collector
-
previousCoordinateFormat
private transient ICoordinateFormat previousCoordinateFormat
TheICoordinateFormat
set in the previous update
-
latText
private final ImageLabel latText
-
lonText
private final ImageLabel lonText
-
headingText
private final ImageLabel headingText
-
angleText
private final ImageLabel angleText
-
distText
private final ImageLabel distText
-
nameText
private final ImageLabel nameText
-
helpText
private final JosmTextField helpText
-
progressBar
private final javax.swing.JProgressBar progressBar
-
mvComponentAdapter
private final transient java.awt.event.ComponentAdapter mvComponentAdapter
-
progressMonitor
public final transient MapStatus.BackgroundProgressMonitor progressMonitor
The progress monitor for displaying a background progress
-
distValue
private double distValue
-
angleEnabled
private boolean angleEnabled
-
thread
private final transient java.lang.Thread thread
This is the thread that runs in the background and collects the information displayed. It gets destroyed by destroy() when the MapFrame itself is destroyed.
-
statusText
private final transient java.util.List<MapStatus.StatusTextHistory> statusText
-
awtListener
private final transient java.awt.event.AWTEventListener awtListener
-
mouseMotionListener
private final transient java.awt.event.MouseMotionListener mouseMotionListener
-
keyAdapter
private final transient java.awt.event.KeyAdapter keyAdapter
-
autoLength
private boolean autoLength
see #19887: determine if thedistValue
field should be filled with length of selected object
-
-
Method Detail
-
registerListeners
private void registerListeners()
-
unregisterListeners
private void unregisterListeners()
-
updateLatLonText
private void updateLatLonText(int x, int y)
-
systemOfMeasurementChanged
public void systemOfMeasurementChanged(java.lang.String oldSoM, java.lang.String newSoM)
Description copied from interface:SystemOfMeasurement.SoMChangeListener
The current SoM has changed.- Specified by:
systemOfMeasurementChanged
in interfaceSystemOfMeasurement.SoMChangeListener
- Parameters:
oldSoM
- The old system of measurementnewSoM
- The new (current) system of measurement
-
updateSystemOfMeasurement
public void updateSystemOfMeasurement(SystemOfMeasurement som)
Updates the system of measurement and displays a notification.- Parameters:
som
- The new system of measurement to set- Since:
- 6960
-
getAnglePanel
public javax.swing.JPanel getAnglePanel()
Gets the panel that displays the angle- Returns:
- The angle panel
-
helpTopic
public java.lang.String helpTopic()
Description copied from interface:Helpful
Returns the help topic on JOSM wiki for this feature.
-
addMouseListener
public void addMouseListener(java.awt.event.MouseListener ml)
- Overrides:
addMouseListener
in classjava.awt.Component
-
setHelpText
public void setHelpText(java.lang.String text)
Sets the help text in the status panel- Parameters:
text
- The text
-
setHelpText
public void setHelpText(java.lang.Object id, java.lang.String text)
Sets the help status text to display- Parameters:
id
- The object that caused the status update (or a id object it selects). May benull
text
- The text
-
resetHelpText
public void resetHelpText(java.lang.Object id)
Removes a help text and restores the previous one- Parameters:
id
- The id passed tosetHelpText(Object, String)
-
setAngle
public void setAngle(double a)
Sets the angle to display in the angle panel. Values less than 0 yield "--".- Parameters:
a
- The angle- See Also:
setAngleNaN(double)
,setAngleText(java.lang.String)
-
setAngleNaN
public void setAngleNaN(double a)
Sets the angle to display in the angle panel. NaN yields "--".- Parameters:
a
- The angle- See Also:
setAngle(double)
,setAngleText(java.lang.String)
-
setAngleText
public void setAngleText(java.lang.String text)
Sets the angle to display in the angle panel- Parameters:
text
- The angle text
-
setHeading
public void setHeading(double h)
Sets the heading to display in the heading panel- Parameters:
h
- The heading
-
setDist
public void setDist(double dist)
Sets the distance text to the given value- Parameters:
dist
- The distance value to display, in meters
-
setDist
public void setDist(java.util.Collection<Way> ways)
Sets the distance text to the total sum of given ways length- Parameters:
ways
- The ways to consider for the total distance- Since:
- 5991
-
activateAnglePanel
public void activateAnglePanel(boolean activeFlag)
Activates the angle panel.- Parameters:
activeFlag
-true
to activate it,false
to deactivate it
-
refreshAnglePanel
private void refreshAnglePanel()
-
destroy
public void destroy()
Description copied from interface:Destroyable
Called when the object has been destroyed.- Specified by:
destroy
in interfaceDestroyable
-
preferenceChanged
public void preferenceChanged(PreferenceChangeEvent e)
Description copied from interface:PreferenceChangedListener
Triggered when a preference entry value changes.- Specified by:
preferenceChanged
in interfacePreferenceChangedListener
- Parameters:
e
- the preference change event
-
getColors
public static void getColors()
Loads all colors from preferences.- Since:
- 6789
-
getNameLabelCharacterCount
private static int getNameLabelCharacterCount(java.awt.Component parent)
-
refreshDistText
private void refreshDistText(java.util.Collection<? extends OsmPrimitive> newSelection)
-
selectionChanged
public void selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Description copied from interface:DataSelectionListener
Called whenever the selection is changed. You get notified about the new selection, the elements that were added and removed and the layer that triggered the event.- Specified by:
selectionChanged
in interfaceDataSelectionListener
- Parameters:
event
- The selection change event.- See Also:
DataSelectionListener.SelectionChangeEvent
-
zoomChanged
public void zoomChanged()
Description copied from interface:NavigatableComponent.ZoomChangeListener
Method called when the zoom area has changed.- Specified by:
zoomChanged
in interfaceNavigatableComponent.ZoomChangeListener
-
wayNodesChanged
public void wayNodesChanged(WayNodesChangedEvent event)
Description copied from interface:DataSetListener
A way's node list was changed.- Specified by:
wayNodesChanged
in interfaceDataSetListener
- Parameters:
event
- The event for the way that was modified.
-
nodeMoved
public void nodeMoved(NodeMovedEvent event)
Description copied from interface:DataSetListener
A node's coordinates were modified.- Specified by:
nodeMoved
in interfaceDataSetListener
- Parameters:
event
- The event for the node that was moved.
-
primitivesAdded
public void primitivesAdded(PrimitivesAddedEvent event)
Description copied from interface:DataSetListener
A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.- Specified by:
primitivesAdded
in interfaceDataSetListener
- Parameters:
event
- An event for an collection of newly-visible primitives
-
primitivesRemoved
public void primitivesRemoved(PrimitivesRemovedEvent event)
Description copied from interface:DataSetListener
A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.- Specified by:
primitivesRemoved
in interfaceDataSetListener
- Parameters:
event
- An event for an collection of newly-invisible primitives
-
tagsChanged
public void tagsChanged(TagsChangedEvent event)
Description copied from interface:DataSetListener
There was some change in the tag set of a primitive. It can have been a tag addition, tag removal or change in tag value.- Specified by:
tagsChanged
in interfaceDataSetListener
- Parameters:
event
- the event for the primitive, whose tags were affected.
-
relationMembersChanged
public void relationMembersChanged(RelationMembersChangedEvent event)
Description copied from interface:DataSetListener
A relation's members have changed.- Specified by:
relationMembersChanged
in interfaceDataSetListener
- Parameters:
event
- The event for the relation that was modified.
-
otherDatasetChange
public void otherDatasetChange(AbstractDatasetChangedEvent event)
Description copied from interface:DataSetListener
Minor dataset change, currently only changeset id changed is supported, but can be extended in future.- Specified by:
otherDatasetChange
in interfaceDataSetListener
- Parameters:
event
- the event for data modification
-
dataChanged
public void dataChanged(DataChangedEvent event)
Description copied from interface:DataSetListener
Called after big changes in dataset. Usually other events are stopped using Dataset.beginUpdate() and after operation is completed (Dataset.endUpdate()),DataSetListener.dataChanged(DataChangedEvent event)
is called.- Specified by:
dataChanged
in interfaceDataSetListener
- Parameters:
event
- data change event
-
setAutoLength
public void setAutoLength(boolean b)
Enable or disable the automatic refresh of the length field.- Parameters:
b
- iftrue
the automatic refresh is enabled, else disabled- Since:
- 17108
-
-