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 classMapStatus.BackgroundProgressMonitorThe progress monitor that is used to display the progress if the user selects to run in backgroundprivate classMapStatus.CollectorThe collector class that waits for notification and then update the display objects.(package private) static classMapStatus.JumpToOnLeftClickMouseAdapterprivate classMapStatus.MapStatusPopupMenuprivate static classMapStatus.MouseStateEverything, the collector is interested of.(package private) static classMapStatus.ShowMonitorDialogMouseAdapterprotected static classMapStatus.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 booleanangleEnabledprivate ImageLabelangleTextprivate booleanautoLengthsee #19887: determine if thedistValuefield should be filled with length of selected objectprivate java.awt.event.AWTEventListenerawtListenerprivate MapStatus.Collectorcollectorprivate java.text.DecimalFormatDECIMAL_FORMATprivate static AbstractProperty<java.lang.Double>DISTANCE_THRESHOLDprivate ImageLabeldistTextprivate doubledistValueprivate ImageLabelheadingTextprivate JosmTextFieldhelpTextprivate java.awt.event.KeyAdapterkeyAdapterprivate ImageLabellatTextprivate ImageLabellonTextprivate java.awt.event.MouseMotionListenermouseMotionListenerprivate MapViewmvThe MapView this status belongs to.private java.awt.event.ComponentAdaptermvComponentAdapterprivate ImageLabelnameTextprivate ICoordinateFormatpreviousCoordinateFormatTheICoordinateFormatset in the previous updateprivate javax.swing.JProgressBarprogressBarMapStatus.BackgroundProgressMonitorprogressMonitorThe progress monitor for displaying a background progressstatic NamedColorPropertyPROP_ACTIVE_BACKGROUND_COLORProperty for map status background color (active state).static NamedColorPropertyPROP_ACTIVE_FOREGROUND_COLORProperty for map status foreground color (active state).static NamedColorPropertyPROP_BACKGROUND_COLORProperty for map status background color.static NamedColorPropertyPROP_FOREGROUND_COLORProperty for map status foreground color.private static AbstractProperty<java.lang.Boolean>SHOW_IDprivate static java.util.List<SystemOfMeasurement>SORTED_SYSTEM_OF_MEASUREMENTSprivate java.util.List<MapStatus.StatusTextHistory>statusTextprivate java.lang.ThreadthreadThis 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 voidactivateAnglePanel(boolean activeFlag)Activates the angle panel.voidaddMouseListener(java.awt.event.MouseListener ml)voiddataChanged(DataChangedEvent event)Called after big changes in dataset.voiddestroy()Called when the object has been destroyed.javax.swing.JPanelgetAnglePanel()Gets the panel that displays the anglestatic voidgetColors()Loads all colors from preferences.private static intgetNameLabelCharacterCount(java.awt.Component parent)java.lang.StringhelpTopic()Returns the help topic on JOSM wiki for this feature.voidnodeMoved(NodeMovedEvent event)A node's coordinates were modified.voidotherDatasetChange(AbstractDatasetChangedEvent event)Minor dataset change, currently only changeset id changed is supported, but can be extended in future.voidpreferenceChanged(PreferenceChangeEvent e)Triggered when a preference entry value changes.voidprimitivesAdded(PrimitivesAddedEvent event)A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.voidprimitivesRemoved(PrimitivesRemovedEvent event)A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.private voidrefreshAnglePanel()private voidrefreshDistText(java.util.Collection<? extends OsmPrimitive> newSelection)private voidregisterListeners()voidrelationMembersChanged(RelationMembersChangedEvent event)A relation's members have changed.voidresetHelpText(java.lang.Object id)Removes a help text and restores the previous onevoidselectionChanged(DataSelectionListener.SelectionChangeEvent event)Called whenever the selection is changed.voidsetAngle(double a)Sets the angle to display in the angle panel.voidsetAngleNaN(double a)Sets the angle to display in the angle panel.voidsetAngleText(java.lang.String text)Sets the angle to display in the angle panelvoidsetAutoLength(boolean b)Enable or disable the automatic refresh of the length field.voidsetDist(double dist)Sets the distance text to the given valuevoidsetDist(java.util.Collection<Way> ways)Sets the distance text to the total sum of given ways lengthvoidsetHeading(double h)Sets the heading to display in the heading panelvoidsetHelpText(java.lang.Object id, java.lang.String text)Sets the help status text to displayvoidsetHelpText(java.lang.String text)Sets the help text in the status panelvoidsystemOfMeasurementChanged(java.lang.String oldSoM, java.lang.String newSoM)The current SoM has changed.voidtagsChanged(TagsChangedEvent event)There was some change in the tag set of a primitive.private voidunregisterListeners()private voidupdateLatLonText(int x, int y)voidupdateSystemOfMeasurement(SystemOfMeasurement som)Updates the system of measurement and displays a notification.voidwayNodesChanged(WayNodesChangedEvent event)A way's node list was changed.voidzoomChanged()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
TheICoordinateFormatset 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 thedistValuefield 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.SoMChangeListenerThe current SoM has changed.- Specified by:
systemOfMeasurementChangedin 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:HelpfulReturns the help topic on JOSM wiki for this feature.
-
addMouseListener
public void addMouseListener(java.awt.event.MouseListener ml)
- Overrides:
addMouseListenerin 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 benulltext- 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-trueto activate it,falseto deactivate it
-
refreshAnglePanel
private void refreshAnglePanel()
-
destroy
public void destroy()
Description copied from interface:DestroyableCalled when the object has been destroyed.- Specified by:
destroyin interfaceDestroyable
-
preferenceChanged
public void preferenceChanged(PreferenceChangeEvent e)
Description copied from interface:PreferenceChangedListenerTriggered when a preference entry value changes.- Specified by:
preferenceChangedin 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:DataSelectionListenerCalled 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:
selectionChangedin interfaceDataSelectionListener- Parameters:
event- The selection change event.- See Also:
DataSelectionListener.SelectionChangeEvent
-
zoomChanged
public void zoomChanged()
Description copied from interface:NavigatableComponent.ZoomChangeListenerMethod called when the zoom area has changed.- Specified by:
zoomChangedin interfaceNavigatableComponent.ZoomChangeListener
-
wayNodesChanged
public void wayNodesChanged(WayNodesChangedEvent event)
Description copied from interface:DataSetListenerA way's node list was changed.- Specified by:
wayNodesChangedin interfaceDataSetListener- Parameters:
event- The event for the way that was modified.
-
nodeMoved
public void nodeMoved(NodeMovedEvent event)
Description copied from interface:DataSetListenerA node's coordinates were modified.- Specified by:
nodeMovedin interfaceDataSetListener- Parameters:
event- The event for the node that was moved.
-
primitivesAdded
public void primitivesAdded(PrimitivesAddedEvent event)
Description copied from interface:DataSetListenerA bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.- Specified by:
primitivesAddedin interfaceDataSetListener- Parameters:
event- An event for an collection of newly-visible primitives
-
primitivesRemoved
public void primitivesRemoved(PrimitivesRemovedEvent event)
Description copied from interface:DataSetListenerA bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.- Specified by:
primitivesRemovedin interfaceDataSetListener- Parameters:
event- An event for an collection of newly-invisible primitives
-
tagsChanged
public void tagsChanged(TagsChangedEvent event)
Description copied from interface:DataSetListenerThere 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:
tagsChangedin interfaceDataSetListener- Parameters:
event- the event for the primitive, whose tags were affected.
-
relationMembersChanged
public void relationMembersChanged(RelationMembersChangedEvent event)
Description copied from interface:DataSetListenerA relation's members have changed.- Specified by:
relationMembersChangedin interfaceDataSetListener- Parameters:
event- The event for the relation that was modified.
-
otherDatasetChange
public void otherDatasetChange(AbstractDatasetChangedEvent event)
Description copied from interface:DataSetListenerMinor dataset change, currently only changeset id changed is supported, but can be extended in future.- Specified by:
otherDatasetChangein interfaceDataSetListener- Parameters:
event- the event for data modification
-
dataChanged
public void dataChanged(DataChangedEvent event)
Description copied from interface:DataSetListenerCalled 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:
dataChangedin interfaceDataSetListener- Parameters:
event- data change event
-
setAutoLength
public void setAutoLength(boolean b)
Enable or disable the automatic refresh of the length field.- Parameters:
b- iftruethe automatic refresh is enabled, else disabled- Since:
- 17108
-
-