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 class
MarkerLayer.MarkerData
the data of a MarkerLayerprivate class
MarkerLayer.MarkerMouseAdapter
private class
MarkerLayer.MoveAudio
static class
MarkerLayer.ShowHideMarkerText
Toggle visibility of the marker text and iconsprivate class
MarkerLayer.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.Color
color
private Marker
currentMarker
MarkerLayer.MarkerData
data
A list of markers.static NamedColorProperty
DEFAULT_COLOR_PROPERTY
The default color that is used for drawing markers.GpxLayer
fromLayer
private ListenerList<IGeoImageLayer.ImageChangeListener>
imageChangeListenerListenerList
private MapView
mapView
(package private) int
markerSize
(package private) java.awt.BasicStroke
markerStroke
private MarkerLayer.MarkerMouseAdapter
mouseAdapter
private boolean
mousePressed
private java.awt.Color
realcolor
AudioMarker
syncAudioMarker
-
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 AudioMarker
addAudioMarker(double time, LatLon coor)
void
addImageChangeListener(IGeoImageLayer.ImageChangeListener listener)
Add a listener for when images changeMapViewPaintable.LayerPainter
attachToMapView(MapViewPaintable.MapViewEvent event)
This method is called whenever this layer is added to a map view.private static boolean
checkIfListContainsEntry(java.util.List<Marker> markerList, RemoteEntry imageEntry)
Check if a list contains an entryvoid
clearSelection()
Clear the selection of the layerboolean
containsImage(IImageEntry<?> imageEntry)
Check if the layer contains the specified imagevoid
destroy()
Called, when the layer is removed from the mapview and is going to be destroyed.private static Marker
getAdjacentMarker(Marker startMarker, boolean next, Layer layer)
java.awt.Color
getColor()
Return the current color of the layerjavax.swing.Icon
getIcon()
Return a static icon.java.lang.Object
getInfoComponent()
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.String
getToolTipText()
Returns a small tooltip hint about some statistics for this layer.boolean
hasColor()
Determines whether the layer has / can handle colors.boolean
isMergable(Layer other)
Determines if the other layer can be merged into this layer.private boolean
isTextOrIconShown()
Get state of text display.void
jumpToNextMarker()
Jump (move the viewport) to the next marker.void
jumpToPreviousMarker()
Jump (move the viewport) to the previous marker.void
mergeFrom(Layer from)
Merges the given layer into this layer.void
paint(java.awt.Graphics2D g, MapView mv, Bounds box)
Paint the dataset using the engine set.private static void
playAdjacentMarker(Marker startMarker, boolean next)
static void
playAudio()
static void
playNextMarker()
static void
playPreviousMarker()
void
removeImageChangeListener(IGeoImageLayer.ImageChangeListener listener)
Remove a listener for when images changevoid
setColor(java.awt.Color color)
Sets the color for this layer.(package private) void
setCurrentMarker(Marker newMarker)
Set the current markerprivate void
setPrivateColors(java.awt.Color color)
boolean
synchronizeAudioMarkers(AudioMarker startMarker)
void
visitBoundingBox(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:Layer
Called, 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:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classLayer
-
attachToMapView
public MapViewPaintable.LayerPainter attachToMapView(MapViewPaintable.MapViewEvent event)
Description copied from class:AbstractMapViewPaintable
This 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:
attachToMapView
in 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:MapViewPaintable
Paint the dataset using the engine set.- Specified by:
paint
in 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:Layer
Returns a small tooltip hint about some statistics for this layer.- Specified by:
getToolTipText
in classLayer
- Returns:
- A small tooltip hint about some statistics for this layer.
-
mergeFrom
public void mergeFrom(Layer from)
Description copied from class:Layer
Merges the given layer into this layer. Throws if the layer types are incompatible.
-
isMergable
public boolean isMergable(Layer other)
Description copied from class:Layer
Determines if the other layer can be merged into this layer.- Specified by:
isMergable
in 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:Layer
Visits 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:
visitBoundingBox
in classLayer
- Parameters:
v
- The visitor that gets notified about the contents of this layer.
-
getInfoComponent
public java.lang.Object getInfoComponent()
Description copied from class:Layer
Gets 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:
getInfoComponent
in classLayer
- Returns:
- Either a String or a
Component
describing the layer.
-
getMenuEntries
public javax.swing.Action[] getMenuEntries()
Description copied from class:Layer
Returns 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.INSTANCE
instead of new JSeparator- Specified by:
getMenuEntries
in 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.JumpToMarkerLayer
Jump (move the viewport) to the next marker.- Specified by:
jumpToNextMarker
in interfaceJumpToMarkerActions.JumpToMarkerLayer
-
jumpToPreviousMarker
public void jumpToPreviousMarker()
Description copied from interface:JumpToMarkerActions.JumpToMarkerLayer
Jump (move the viewport) to the previous marker.- Specified by:
jumpToPreviousMarker
in 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:
true
if text should be shown,false
otherwise.
-
hasColor
public boolean hasColor()
Description copied from class:Layer
Determines whether the layer has / can handle colors.
-
getColor
public java.awt.Color getColor()
Description copied from class:Layer
Return the current color of the layer
-
setColor
public void setColor(java.awt.Color color)
Description copied from class:Layer
Sets 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:IGeoImageLayer
Clear the selection of the layer- Specified by:
clearSelection
in interfaceIGeoImageLayer
-
getSelection
public java.util.List<? extends IImageEntry<?>> getSelection()
Description copied from interface:IGeoImageLayer
Get the current selection- Specified by:
getSelection
in interfaceIGeoImageLayer
- Returns:
- The currently selected images
-
containsImage
public boolean containsImage(IImageEntry<?> imageEntry)
Description copied from interface:IGeoImageLayer
Check if the layer contains the specified image- Specified by:
containsImage
in interfaceIGeoImageLayer
- Parameters:
imageEntry
- The entry to look for- Returns:
true
if 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:
true
if the entry is in the list
-
addImageChangeListener
public void addImageChangeListener(IGeoImageLayer.ImageChangeListener listener)
Description copied from interface:IGeoImageLayer
Add a listener for when images change- Specified by:
addImageChangeListener
in interfaceIGeoImageLayer
- Parameters:
listener
- The listener to call
-
removeImageChangeListener
public void removeImageChangeListener(IGeoImageLayer.ImageChangeListener listener)
Description copied from interface:IGeoImageLayer
Remove a listener for when images change- Specified by:
removeImageChangeListener
in interfaceIGeoImageLayer
- Parameters:
listener
- The listener to remove
-
-