Class MarkerLayer
- java.lang.Object
-
- org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
-
- org.openstreetmap.josm.gui.layer.Layer
-
- org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer
-
- All Implemented Interfaces:
ProjectionChangeListener,IGeoImageLayer,JumpToMarkerActions.JumpToMarkerLayer,MapViewPaintable,Destroyable
public class MarkerLayer extends Layer implements JumpToMarkerActions.JumpToMarkerLayer, IGeoImageLayer
A layer holding markers.Markers are GPS points with a name and, optionally, a symbol code attached; marker layers can be created from waypoints when importing raw GPS data, but they may also come from other sources.
The symbol code is for future use.
The data is read only.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMarkerLayer.MarkerDatathe data of a MarkerLayerprivate classMarkerLayer.MarkerMouseAdapterprivate classMarkerLayer.MoveAudiostatic classMarkerLayer.ShowHideMarkerTextToggle visibility of the marker text and iconsprivate classMarkerLayer.SynchronizeAudio-
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.Layer
Layer.LayerAction, Layer.LayerGpxExportAction, Layer.LayerSaveAction, Layer.LayerSaveAsAction, Layer.MultiLayerAction, Layer.SeparatorLayerAction
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
AbstractMapViewPaintable.CompatibilityModeLayerPainter
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.layer.geoimage.IGeoImageLayer
IGeoImageLayer.ImageChangeListener
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Colorcolorprivate MarkercurrentMarkerMarkerLayer.MarkerDatadataA list of markers.static NamedColorPropertyDEFAULT_COLOR_PROPERTYThe default color that is used for drawing markers.GpxLayerfromLayerprivate ListenerList<IGeoImageLayer.ImageChangeListener>imageChangeListenerListenerListprivate MapViewmapView(package private) intmarkerSize(package private) java.awt.BasicStrokemarkerStrokeprivate MarkerLayer.MarkerMouseAdaptermouseAdapterprivate booleanmousePressedprivate java.awt.ColorrealcolorAudioMarkersyncAudioMarker-
Fields inherited from class org.openstreetmap.josm.gui.layer.Layer
FILTER_STATE_PROP, NAME_PROP, OPACITY_PROP, propertyChangeSupport, VISIBLE_PROP
-
-
Constructor Summary
Constructors Constructor Description MarkerLayer(GpxData indata, java.lang.String name, java.io.File associatedFile, GpxLayer fromLayer)Constructs a newMarkerLayer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AudioMarkeraddAudioMarker(double time, LatLon coor)voidaddImageChangeListener(IGeoImageLayer.ImageChangeListener listener)Add a listener for when images changeMapViewPaintable.LayerPainterattachToMapView(MapViewPaintable.MapViewEvent event)This method is called whenever this layer is added to a map view.private static booleancheckIfListContainsEntry(java.util.List<Marker> markerList, RemoteEntry imageEntry)Check if a list contains an entryvoidclearSelection()Clear the selection of the layerbooleancontainsImage(IImageEntry<?> imageEntry)Check if the layer contains the specified imagevoiddestroy()Called, when the layer is removed from the mapview and is going to be destroyed.private static MarkergetAdjacentMarker(Marker startMarker, boolean next, Layer layer)java.awt.ColorgetColor()Return the current color of the layerjavax.swing.IcongetIcon()Return a static icon.java.lang.ObjectgetInfoComponent()Gets the layer information to display to the user.javax.swing.Action[]getMenuEntries()Returns list of actions.java.util.List<? extends IImageEntry<?>>getSelection()Get the current selectionjava.lang.StringgetToolTipText()Returns a small tooltip hint about some statistics for this layer.booleanhasColor()Determines whether the layer has / can handle colors.booleanisMergable(Layer other)Determines if the other layer can be merged into this layer.private booleanisTextOrIconShown()Get state of text display.voidjumpToNextMarker()Jump (move the viewport) to the next marker.voidjumpToPreviousMarker()Jump (move the viewport) to the previous marker.voidmergeFrom(Layer from)Merges the given layer into this layer.voidpaint(java.awt.Graphics2D g, MapView mv, Bounds box)Paint the dataset using the engine set.private static voidplayAdjacentMarker(Marker startMarker, boolean next)static voidplayAudio()static voidplayNextMarker()static voidplayPreviousMarker()voidremoveImageChangeListener(IGeoImageLayer.ImageChangeListener listener)Remove a listener for when images changevoidsetColor(java.awt.Color color)Sets the color for this layer.(package private) voidsetCurrentMarker(Marker newMarker)Set the current markerprivate voidsetPrivateColors(java.awt.Color color)booleansynchronizeAudioMarkers(AudioMarker startMarker)voidvisitBoundingBox(BoundingXYVisitor v)Visits the content bounds of this layer.-
Methods inherited from class org.openstreetmap.josm.gui.layer.Layer
addPropertyChangeListener, checkSaveConditions, createAndOpenSaveFileChooser, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getAssociatedFile, getChangesetSourceTag, getDefaultLayerPosition, getLabel, getName, getOpacity, getViewProjectionBounds, hookUpMapView, isBackgroundLayer, isInfoResizable, isProjectionSupported, isRenamed, isSavable, isVisible, nameSupportedProjections, onPostLoadFromFile, projectionChanged, removePropertyChangeListener, rename, setAssociatedFile, setBackgroundLayer, setFilterStateChanged, setName, setOpacity, setVisible, toggleVisible, toString
-
Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
addInvalidationListener, createMapViewPainter, invalidate, removeInvalidationListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.gui.layer.geoimage.IGeoImageLayer
getInvalidGeoImages
-
-
-
-
Field Detail
-
data
public final MarkerLayer.MarkerData data
A list of markers.
-
mousePressed
private boolean mousePressed
-
currentMarker
private Marker currentMarker
-
syncAudioMarker
public AudioMarker syncAudioMarker
-
color
private java.awt.Color color
-
realcolor
private java.awt.Color realcolor
-
markerSize
final int markerSize
-
markerStroke
final java.awt.BasicStroke markerStroke
-
imageChangeListenerListenerList
private final ListenerList<IGeoImageLayer.ImageChangeListener> imageChangeListenerListenerList
-
mouseAdapter
private MarkerLayer.MarkerMouseAdapter mouseAdapter
-
DEFAULT_COLOR_PROPERTY
public static final NamedColorProperty DEFAULT_COLOR_PROPERTY
The default color that is used for drawing markers.
-
-
Constructor Detail
-
MarkerLayer
public MarkerLayer(GpxData indata, java.lang.String name, java.io.File associatedFile, GpxLayer fromLayer)
Constructs a newMarkerLayer.- Parameters:
indata- The GPX data for this layername- The marker layer nameassociatedFile- The associated GPX filefromLayer- The associated GPX layer
-
-
Method Detail
-
destroy
public void destroy()
Description copied from class:LayerCalled, when the layer is removed from the mapview and is going to be destroyed.This is because the Layer constructor cannot add itself safely as a listener to the layerlist dialog, because there may be no such dialog yet (loaded via command line parameter).
- Specified by:
destroyin interfaceDestroyable- Overrides:
destroyin classLayer
-
attachToMapView
public MapViewPaintable.LayerPainter attachToMapView(MapViewPaintable.MapViewEvent event)
Description copied from class:AbstractMapViewPaintableThis method is called whenever this layer is added to a map view.You need to return a painter here. The
MapViewPaintable.LayerPainter.detachFromMapView(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)method is called when the layer is removed from that map view. You are free to reuse painters.You should always call the super method. See
AbstractMapViewPaintable.createMapViewPainter(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)if you want to influence painter creation.This replaces
Layer.hookUpMapView()in the long run.- Overrides:
attachToMapViewin classAbstractMapViewPaintable- Parameters:
event- the event.- Returns:
- A layer painter.
-
getIcon
public javax.swing.Icon getIcon()
Return a static icon.
-
paint
public void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
Description copied from interface:MapViewPaintablePaint the dataset using the engine set.- Specified by:
paintin interfaceMapViewPaintable- Parameters:
g- Graphicsmv- The object that can translate GeoPoints to screen coordinates.box- Bounding box
-
getToolTipText
public java.lang.String getToolTipText()
Description copied from class:LayerReturns a small tooltip hint about some statistics for this layer.- Specified by:
getToolTipTextin classLayer- Returns:
- A small tooltip hint about some statistics for this layer.
-
mergeFrom
public void mergeFrom(Layer from)
Description copied from class:LayerMerges the given layer into this layer. Throws if the layer types are incompatible.
-
isMergable
public boolean isMergable(Layer other)
Description copied from class:LayerDetermines if the other layer can be merged into this layer.- Specified by:
isMergablein classLayer- Parameters:
other- The other layer that is tested to be mergable with this.- Returns:
- Whether the other layer can be merged into this layer.
-
visitBoundingBox
public void visitBoundingBox(BoundingXYVisitor v)
Description copied from class:LayerVisits the content bounds of this layer. The behavior of this method depends on the layer, but each implementation should attempt to cover the relevant content of the layer in this method.- Specified by:
visitBoundingBoxin classLayer- Parameters:
v- The visitor that gets notified about the contents of this layer.
-
getInfoComponent
public java.lang.Object getInfoComponent()
Description copied from class:LayerGets the layer information to display to the user. This is used if the user requests information about this layer. It should display a description of the layer content.- Specified by:
getInfoComponentin classLayer- Returns:
- Either a String or a
Componentdescribing the layer.
-
getMenuEntries
public javax.swing.Action[] getMenuEntries()
Description copied from class:LayerReturns list of actions. Action can implement LayerAction interface when it needs to be represented by other menu component than JMenuItem or when it supports multiple layers. Actions that support multiple layers should also have correct equals implementation.Use
Layer.SeparatorLayerAction.INSTANCEinstead of new JSeparator- Specified by:
getMenuEntriesin classLayer- Returns:
- menu actions for this layer
-
synchronizeAudioMarkers
public boolean synchronizeAudioMarkers(AudioMarker startMarker)
-
addAudioMarker
public AudioMarker addAudioMarker(double time, LatLon coor)
-
jumpToNextMarker
public void jumpToNextMarker()
Description copied from interface:JumpToMarkerActions.JumpToMarkerLayerJump (move the viewport) to the next marker.- Specified by:
jumpToNextMarkerin interfaceJumpToMarkerActions.JumpToMarkerLayer
-
jumpToPreviousMarker
public void jumpToPreviousMarker()
Description copied from interface:JumpToMarkerActions.JumpToMarkerLayerJump (move the viewport) to the previous marker.- Specified by:
jumpToPreviousMarkerin interfaceJumpToMarkerActions.JumpToMarkerLayer
-
setCurrentMarker
void setCurrentMarker(Marker newMarker)
Set the current marker- Parameters:
newMarker- The marker to set
-
playAudio
public static void playAudio()
-
playNextMarker
public static void playNextMarker()
-
playPreviousMarker
public static void playPreviousMarker()
-
getAdjacentMarker
private static Marker getAdjacentMarker(Marker startMarker, boolean next, Layer layer)
-
playAdjacentMarker
private static void playAdjacentMarker(Marker startMarker, boolean next)
-
isTextOrIconShown
private boolean isTextOrIconShown()
Get state of text display.- Returns:
trueif text should be shown,falseotherwise.
-
hasColor
public boolean hasColor()
Description copied from class:LayerDetermines whether the layer has / can handle colors.
-
getColor
public java.awt.Color getColor()
Description copied from class:LayerReturn the current color of the layer
-
setColor
public void setColor(java.awt.Color color)
Description copied from class:LayerSets the color for this layer. Nothing happens if not supported by the layer
-
setPrivateColors
private void setPrivateColors(java.awt.Color color)
-
clearSelection
public void clearSelection()
Description copied from interface:IGeoImageLayerClear the selection of the layer- Specified by:
clearSelectionin interfaceIGeoImageLayer
-
getSelection
public java.util.List<? extends IImageEntry<?>> getSelection()
Description copied from interface:IGeoImageLayerGet the current selection- Specified by:
getSelectionin interfaceIGeoImageLayer- Returns:
- The currently selected images
-
containsImage
public boolean containsImage(IImageEntry<?> imageEntry)
Description copied from interface:IGeoImageLayerCheck if the layer contains the specified image- Specified by:
containsImagein interfaceIGeoImageLayer- Parameters:
imageEntry- The entry to look for- Returns:
trueif this layer contains the image
-
checkIfListContainsEntry
private static boolean checkIfListContainsEntry(java.util.List<Marker> markerList, RemoteEntry imageEntry)
Check if a list contains an entry- Parameters:
markerList- The list to look throughimageEntry- The image entry to check- Returns:
trueif the entry is in the list
-
addImageChangeListener
public void addImageChangeListener(IGeoImageLayer.ImageChangeListener listener)
Description copied from interface:IGeoImageLayerAdd a listener for when images change- Specified by:
addImageChangeListenerin interfaceIGeoImageLayer- Parameters:
listener- The listener to call
-
removeImageChangeListener
public void removeImageChangeListener(IGeoImageLayer.ImageChangeListener listener)
Description copied from interface:IGeoImageLayerRemove a listener for when images change- Specified by:
removeImageChangeListenerin interfaceIGeoImageLayer- Parameters:
listener- The listener to remove
-
-