Package org.openstreetmap.josm.gui.layer
Class OsmDataLayer
- java.lang.Object
-
- All Implemented Interfaces:
DataSelectionListener
,DataSetListenerAdapter.Listener
,HighlightUpdateListener
,Lockable
,ProjectionChangeListener
,DownloadFromServer
,MapViewPaintable
,SaveToFile
,UploadToServer
,PrimitiveHoverListener
,Destroyable
- Direct Known Subclasses:
AdvancedPreference.UnclearableOsmDataLayer
,CorrelationSupportLayer
public class OsmDataLayer extends AbstractOsmDataLayer implements DataSetListenerAdapter.Listener, DataSelectionListener, HighlightUpdateListener, PrimitiveHoverListener
A layer that holds OSM data from a specific dataset. The data can be fully edited.- Since:
- 17
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
OsmDataLayer.ConsistencyTestAction
class
OsmDataLayer.ConvertToGpxLayerAction
Action that converts this OSM layer to a GPX layer.static class
OsmDataLayer.DataCountVisitor
A listener that counts the number of primitives it encountersstatic interface
OsmDataLayer.LayerStateChangeListener
Listener called when a state of this layer has changed.-
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.data.osm.DataSelectionListener
DataSelectionListener.AbstractSelectionEvent, DataSelectionListener.SelectionAddEvent, DataSelectionListener.SelectionChangeEvent, DataSelectionListener.SelectionRemoveEvent, DataSelectionListener.SelectionReplaceEvent, DataSelectionListener.SelectionToggleEvent
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.osm.HighlightUpdateListener
HighlightUpdateListener.HighlightUpdateEvent
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.PrimitiveHoverListener
PrimitiveHoverListener.PrimitiveHoverEvent
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.commons.jcs3.access.CacheAccess<TileZXY,ImageCache>
cache
A cache used for paintingDataSet
data
The data behind this layer.private static java.util.concurrent.atomic.AtomicInteger
dataLayerCounter
the global counter for created data layersprivate DataSetListenerAdapter
dataSetListenerAdapter
static int
DEFAULT_RECENT_RELATIONS_NUMBER
The default number of relations in the recent relations cache.private static java.awt.image.BufferedImage
hatched
a texture for non-downloaded areaprivate static int
HATCHED_SIZE
private boolean
hoverListenerAdded
private static java.lang.String
IS_EMPTY_SYMBOL
private java.util.concurrent.atomic.AtomicBoolean
isUploadInProgress
Flag used to know if the layer is being uploadedprivate int
lastDataIdx
The map paint index that was painted (used to invalidatecache
)private int
lastZoom
The last zoom level (we invalidate all tiles when switching layers)private java.util.concurrent.CopyOnWriteArrayList<OsmDataLayer.LayerStateChangeListener>
layerStateChangeListeners
private static int
MAX_ZOOM
private static int
OVER_ZOOM
private static NamedColorProperty
PROPERTY_BACKGROUND_COLOR
static BooleanProperty
PROPERTY_HIDE_LABELS_WHILE_DRAGGING
Property to determine if labels must be hidden while dragging the map.private static NamedColorProperty
PROPERTY_OUTSIDE_COLOR
static IntegerProperty
PROPERTY_RECENT_RELATIONS_NUMBER
The number of relations to use in the recent relations cache.static StringProperty
PROPERTY_SAVE_EXTENSION
The extension that should be used when saving the OSM file.private java.util.Map<Relation,java.lang.Void>
recentRelations
List of recent relationsstatic java.lang.String
REQUIRES_UPLOAD_TO_SERVER_PROP
Property used to know if this layer has to be uploadedprivate boolean
requiresSaveToFile
private boolean
requiresUploadToServer
java.util.List<TestError>
validationErrors
List of validation errors in this layer.-
Fields inherited from class org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
IS_DIRTY_SYMBOL, REQUIRES_SAVE_TO_DISK_PROP
-
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 OsmDataLayer(DataSet data, java.lang.String name, java.io.File associatedFile)
Construct a newOsmDataLayer
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
addConditionalInformation(javax.swing.JPanel p, java.lang.String text, boolean condition)
private static void
addDoubleIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey)
private static void
addIntegerIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey)
void
addLayerStateChangeListener(OsmDataLayer.LayerStateChangeListener listener)
Adds a layer state change listenerprivate static void
addStringIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey, java.lang.String osmKey2)
boolean
autosave(java.io.File file)
Perform the autosave action for the layerboolean
checkSaveConditions()
Checks whether it is ok to launch a save (whether we have data, there is no conflict etc.)void
cleanupAfterUpload(java.util.Collection<? extends IPrimitive> processed)
Clean out the data behind the layer.private static boolean
containsOnlyGpxTags(Tagged t, java.lang.String gpxPrefix)
boolean
containsPoint(LatLon coor)
Determines if this layer contains data at the given coordinate.private static java.lang.String
counterText(java.lang.String text, int deleted, int incomplete)
java.io.File
createAndOpenSaveFileChooser()
Creates a new "Save" dialog for this layer and makes it visible.static void
createHatchTexture()
Initialize the hatch pattern used to paint the non-downloaded area(package private) static java.lang.String
createLayerName(java.lang.Object arg)
static java.lang.String
createNewName()
Replies a new unique name for a data layerAbstractIOTask
createUploadTask(ProgressMonitor monitor)
Creates a newAbstractIOTask
for uploading data.void
destroy()
Called, when the layer is removed from the mapview and is going to be destroyed.private void
dirtyAll()
OsmDataLayer
duplicate(java.lang.String newName)
Duplicates this layer with a new name and a copy of this layer dataset.protected static void
fillGpxData(GpxData gpxData, DataSet data, java.io.File file, java.lang.String gpxPrefix)
static java.awt.Color
getBackgroundColor()
Replies background color for downloaded areas.protected ImageProvider
getBaseIconProvider()
Return the image provider to get the base iconjava.lang.String
getChangesetSourceTag()
Get the source for the layerConflictCollection
getConflicts()
Replies the set of conflicts currently managed in this layer.Data
getData()
Get the data for the modifiable layerDataSet
getDataSet()
Returns theDataSet
behind this layer.javax.swing.Icon
getIcon()
Return a representative small image for this layer.java.lang.Object
getInfoComponent()
Gets the layer information to display to the user.private BBox
getInvalidatedBBox(INode first, INode second)
java.lang.String
getLabel()
Replies a label for this layer useful for UI elements.javax.swing.Action[]
getMenuEntries()
Returns list of actions.static java.awt.Color
getOutsideColor()
Replies background color for non-downloaded areas.java.util.List<Relation>
getRecentRelations()
Returns list of recently closed relations or null if none.java.lang.String
getToolTipText()
Returns a small tooltip hint about some statistics for this layer.AbstractUploadDialog
getUploadDialog()
Returns the upload dialog for this layer.ProjectionBounds
getViewProjectionBounds()
Gets theProjectionBounds
for this layer to be visible to the user.private static int
getZoom(NavigatableComponent navigatableComponent)
Get the zoom for aNavigatableComponent
private static java.lang.String
gpxVal(OsmPrimitive prim, java.lang.String gpxPrefix, java.lang.String key)
Reads the Gpx key from the givenOsmPrimitive
, with or without "gpx:" prefixvoid
highlightUpdated(HighlightUpdateListener.HighlightUpdateEvent e)
Called whenever the highlighting of way segments in the dataset changed.private boolean
isDataSetEmpty()
Check the data set if it would be empty on save.boolean
isDownloadable()
Determines if the layer is able to download data and implements theDownloadFromServer
interface.boolean
isMergable(Layer other)
Determines if the other layer can be merged into this layer.boolean
isModified()
Determines if data managed by this layer has been modified.boolean
isSavable()
Replies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).boolean
isUploadable()
Determines if the layer is able to upload data and implements theUploadToServer
interface.boolean
isUploadDiscouraged()
Determines if upload of data managed by this layer is discouraged.boolean
isUploadInProgress()
Determines if upload of data managed by this layer is currently in progress.void
mergeFrom(DataSet from)
merges the primitives in datasetfrom
into the dataset of this layervoid
mergeFrom(DataSet from, ProgressMonitor progressMonitor)
merges the primitives in datasetfrom
into the dataset of this layervoid
mergeFrom(Layer from)
Merges the given layer into this layer.private static void
nodesToGpxData(java.util.Collection<Node> nodes, GpxData gpxData, java.util.Set<Node> doneNodes, java.lang.String gpxPrefix)
static WayPoint
nodeToWayPoint(Node n, long time)
Converts a node to a waypoint with defaultGpxConstants.GPX_PREFIX
for tags.static WayPoint
nodeToWayPoint(Node n, long time, java.lang.String gpxPrefix)
Converts a node to a waypoint with a configurable GPX prefix for tags.void
onPostDownloadFromServer()
Actions run after data has been downloaded to this layer.void
onPostLoadFromFile()
Initializes the layer after a successful load of data from a filevoid
onPostSaveToFile()
Initializes the layer after a successful save of data to a file.void
onPostUploadToServer()
Initializes the layer after a successful upload to the server.void
paint(java.awt.Graphics2D g, MapView mv, Bounds box)
Draw all primitives in this layer but do not draw modified ones (they are drawn by the edit layer).private void
paintData(java.awt.Graphics2D g, MapView mv, Bounds box, boolean inactive, boolean virtual)
private void
paintHatch(java.awt.Graphics2D g, MapView mv, boolean active)
void
primitiveHovered(PrimitiveHoverListener.PrimitiveHoverEvent e)
Method called when the primitive under the mouse pointer changes.void
processDatasetEvent(AbstractDatasetChangedEvent event)
Called when notified about any type of dataset change event.void
projectionChanged(Projection oldValue, Projection newValue)
protected static void
removeClipboardDataFor(OsmDataLayer osm)
void
removeLayerStateChangeListener(OsmDataLayer.LayerStateChangeListener listener)
Removes a layer state change listenervoid
removeRecentRelation(Relation relation)
Remove relation from list of recent relations.boolean
requiresSaveToFile()
Determines if the data managed by this layer needs to be saved to a file.boolean
requiresUploadToServer()
Determines if the data managed by this layer needs to be uploaded to the server because it contains modified data.private void
resetBounds(double minLat, double minLon, double maxLat, double maxLon)
private void
resetBounds(IBounds bbox)
private void
resetTiles(java.util.Collection<? extends IPrimitive> primitives)
private void
resetTiles(IPrimitive p)
void
selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Called whenever the selection is changed.void
setName(java.lang.String name)
Sets the name of the layervoid
setRecentRelation(Relation relation)
Adds recently closed relation.protected void
setRequiresSaveToFile(boolean newValue)
protected void
setRequiresUploadToServer(boolean newValue)
void
setUploadDiscouraged(boolean uploadDiscouraged)
Sets the "discouraged upload" flag.void
setUploadInProgress()
Sets the "upload in progress" flag, which will result in displaying a new icon and forbid to remove the layer.GpxData
toGpxData()
Converts OSM data behind this layer to GPX data.static GpxData
toGpxData(DataSet data, java.io.File file)
Converts given OSM dataset to GPX data.void
unsetUploadInProgress()
Unsets the "upload in progress" flag, which will result in displaying the standard icon and allow to remove the layer.void
visitBoundingBox(BoundingXYVisitor v)
Visits the content bounds of this layer.private static void
waysToGpxData(java.util.Collection<Way> ways, GpxData gpxData, java.util.Set<Node> doneNodes, java.lang.String gpxPrefix)
-
Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractOsmDataLayer
clear, isLocked, lock, unlock
-
Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
isDirty
-
Methods inherited from class org.openstreetmap.josm.gui.layer.Layer
addPropertyChangeListener, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getAssociatedFile, getColor, getDefaultLayerPosition, getName, getOpacity, hasColor, hookUpMapView, isBackgroundLayer, isInfoResizable, isProjectionSupported, isRenamed, isVisible, nameSupportedProjections, removePropertyChangeListener, rename, setAssociatedFile, setBackgroundLayer, setColor, setFilterStateChanged, setOpacity, setVisible, toggleVisible, toString
-
Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
addInvalidationListener, attachToMapView, createMapViewPainter, invalidate, removeInvalidationListener
-
-
-
-
Field Detail
-
MAX_ZOOM
private static final int MAX_ZOOM
- See Also:
- Constant Field Values
-
OVER_ZOOM
private static final int OVER_ZOOM
- See Also:
- Constant Field Values
-
HATCHED_SIZE
private static final int HATCHED_SIZE
- See Also:
- Constant Field Values
-
IS_EMPTY_SYMBOL
private static final java.lang.String IS_EMPTY_SYMBOL
- See Also:
- Constant Field Values
-
REQUIRES_UPLOAD_TO_SERVER_PROP
public static final java.lang.String REQUIRES_UPLOAD_TO_SERVER_PROP
Property used to know if this layer has to be uploaded
-
requiresSaveToFile
private boolean requiresSaveToFile
-
requiresUploadToServer
private boolean requiresUploadToServer
-
isUploadInProgress
private final java.util.concurrent.atomic.AtomicBoolean isUploadInProgress
Flag used to know if the layer is being uploaded
-
cache
private final org.apache.commons.jcs3.access.CacheAccess<TileZXY,ImageCache> cache
A cache used for painting
-
lastDataIdx
private int lastDataIdx
The map paint index that was painted (used to invalidatecache
)
-
lastZoom
private int lastZoom
The last zoom level (we invalidate all tiles when switching layers)
-
hoverListenerAdded
private boolean hoverListenerAdded
-
validationErrors
public final java.util.List<TestError> validationErrors
List of validation errors in this layer.- Since:
- 3669
-
DEFAULT_RECENT_RELATIONS_NUMBER
public static final int DEFAULT_RECENT_RELATIONS_NUMBER
The default number of relations in the recent relations cache.- See Also:
getRecentRelations()
, Constant Field Values
-
PROPERTY_RECENT_RELATIONS_NUMBER
public static final IntegerProperty PROPERTY_RECENT_RELATIONS_NUMBER
The number of relations to use in the recent relations cache.- See Also:
getRecentRelations()
-
PROPERTY_SAVE_EXTENSION
public static final StringProperty PROPERTY_SAVE_EXTENSION
The extension that should be used when saving the OSM file.
-
PROPERTY_HIDE_LABELS_WHILE_DRAGGING
public static final BooleanProperty PROPERTY_HIDE_LABELS_WHILE_DRAGGING
Property to determine if labels must be hidden while dragging the map.
-
PROPERTY_BACKGROUND_COLOR
private static final NamedColorProperty PROPERTY_BACKGROUND_COLOR
-
PROPERTY_OUTSIDE_COLOR
private static final NamedColorProperty PROPERTY_OUTSIDE_COLOR
-
recentRelations
private final java.util.Map<Relation,java.lang.Void> recentRelations
List of recent relations
-
dataLayerCounter
private static final java.util.concurrent.atomic.AtomicInteger dataLayerCounter
the global counter for created data layers
-
layerStateChangeListeners
private final java.util.concurrent.CopyOnWriteArrayList<OsmDataLayer.LayerStateChangeListener> layerStateChangeListeners
-
dataSetListenerAdapter
private final DataSetListenerAdapter dataSetListenerAdapter
-
hatched
private static volatile java.awt.image.BufferedImage hatched
a texture for non-downloaded area
-
-
Constructor Detail
-
OsmDataLayer
public OsmDataLayer(DataSet data, java.lang.String name, java.io.File associatedFile)
Construct a newOsmDataLayer
.- Parameters:
data
- OSM dataname
- Layer nameassociatedFile
- Associated .osm file (can be null)
-
-
Method Detail
-
getRecentRelations
public java.util.List<Relation> getRecentRelations()
Returns list of recently closed relations or null if none.- Returns:
- list of recently closed relations or
null
if none - Since:
- 12291 (signature), 9668
-
setRecentRelation
public void setRecentRelation(Relation relation)
Adds recently closed relation.- Parameters:
relation
- new entry for the list of recently closed relations- Since:
- 9668
- See Also:
PROPERTY_RECENT_RELATIONS_NUMBER
-
removeRecentRelation
public void removeRecentRelation(Relation relation)
Remove relation from list of recent relations.- Parameters:
relation
- relation to remove- Since:
- 9668
-
setRequiresSaveToFile
protected void setRequiresSaveToFile(boolean newValue)
-
setRequiresUploadToServer
protected void setRequiresUploadToServer(boolean newValue)
-
createNewName
public static java.lang.String createNewName()
Replies a new unique name for a data layer- Returns:
- a new unique name for a data layer
-
createLayerName
static java.lang.String createLayerName(java.lang.Object arg)
-
addLayerStateChangeListener
public void addLayerStateChangeListener(OsmDataLayer.LayerStateChangeListener listener)
Adds a layer state change listener- Parameters:
listener
- the listener. Ignored if null or already registered.- Since:
- 5519
-
removeLayerStateChangeListener
public void removeLayerStateChangeListener(OsmDataLayer.LayerStateChangeListener listener)
Removes a layer state change listener- Parameters:
listener
- the listener. Ignored if null or already registered.- Since:
- 10340
-
getBackgroundColor
public static java.awt.Color getBackgroundColor()
Replies background color for downloaded areas.- Returns:
- background color for downloaded areas. Black by default
-
getOutsideColor
public static java.awt.Color getOutsideColor()
Replies background color for non-downloaded areas.- Returns:
- background color for non-downloaded areas. Yellow by default
-
createHatchTexture
public static void createHatchTexture()
Initialize the hatch pattern used to paint the non-downloaded area
-
getDataSet
public DataSet getDataSet()
Returns theDataSet
behind this layer.- Specified by:
getDataSet
in classAbstractOsmDataLayer
- Returns:
- the
DataSet
behind this layer. - Since:
- 13558
-
getBaseIconProvider
protected ImageProvider getBaseIconProvider()
Return the image provider to get the base icon- Returns:
- image provider class which can be modified
- Since:
- 8323
-
getIcon
public javax.swing.Icon getIcon()
Description copied from class:Layer
Return a representative small image for this layer. The image must not be larger than 64 pixel in any dimension.
-
paint
public void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
Draw all primitives in this layer but do not draw modified ones (they are drawn by the edit layer). Draw nodes last to overlap the ways they belong to.- Specified by:
paint
in interfaceMapViewPaintable
- Parameters:
g
- Graphicsmv
- The object that can translate GeoPoints to screen coordinates.box
- Bounding box
-
paintHatch
private void paintHatch(java.awt.Graphics2D g, MapView mv, boolean active)
-
paintData
private void paintData(java.awt.Graphics2D g, MapView mv, Bounds box, boolean inactive, boolean virtual)
-
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.
-
mergeFrom
public void mergeFrom(DataSet from)
merges the primitives in datasetfrom
into the dataset of this layer- Parameters:
from
- the source data set
-
mergeFrom
public void mergeFrom(DataSet from, ProgressMonitor progressMonitor)
merges the primitives in datasetfrom
into the dataset of this layer- Parameters:
from
- the source data setprogressMonitor
- the progress monitor, can benull
-
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.
-
cleanupAfterUpload
public void cleanupAfterUpload(java.util.Collection<? extends IPrimitive> processed)
Clean out the data behind the layer. This means clearing the redo/undo lists, really deleting all deleted objects and reset the modified flags. This should be done after an upload, even after a partial upload.- Parameters:
processed
- A list of all objects that were actually uploaded. May benull
, which means nothing has been uploaded
-
counterText
private static java.lang.String counterText(java.lang.String text, int deleted, int incomplete)
-
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.
-
addConditionalInformation
private static void addConditionalInformation(javax.swing.JPanel p, java.lang.String text, boolean condition)
-
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
-
toGpxData
public static GpxData toGpxData(DataSet data, java.io.File file)
Converts given OSM dataset to GPX data.- Parameters:
data
- OSM datasetfile
- output .gpx file- Returns:
- GPX data
-
fillGpxData
protected static void fillGpxData(GpxData gpxData, DataSet data, java.io.File file, java.lang.String gpxPrefix)
-
waysToGpxData
private static void waysToGpxData(java.util.Collection<Way> ways, GpxData gpxData, java.util.Set<Node> doneNodes, java.lang.String gpxPrefix)
-
containsOnlyGpxTags
private static boolean containsOnlyGpxTags(Tagged t, java.lang.String gpxPrefix)
-
gpxVal
private static java.lang.String gpxVal(OsmPrimitive prim, java.lang.String gpxPrefix, java.lang.String key)
Reads the Gpx key from the givenOsmPrimitive
, with or without "gpx:" prefix- Parameters:
prim
- OSM primitivegpxPrefix
- the GPX prefixkey
- GPX key without prefix- Returns:
- the value or
null
if not present
-
nodeToWayPoint
public static WayPoint nodeToWayPoint(Node n, long time)
Converts a node to a waypoint with defaultGpxConstants.GPX_PREFIX
for tags.- Parameters:
n
- theNode
to converttime
- a timestamp value in milliseconds from the epoch.- Returns:
WayPoint
object- Since:
- 13210
-
nodeToWayPoint
public static WayPoint nodeToWayPoint(Node n, long time, java.lang.String gpxPrefix)
Converts a node to a waypoint with a configurable GPX prefix for tags.- Parameters:
n
- theNode
to converttime
- a timestamp value in milliseconds from the epoch.gpxPrefix
- the GPX prefix for tags- Returns:
WayPoint
object- Since:
- 18078
-
nodesToGpxData
private static void nodesToGpxData(java.util.Collection<Node> nodes, GpxData gpxData, java.util.Set<Node> doneNodes, java.lang.String gpxPrefix)
-
addIntegerIfPresent
private static void addIntegerIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey)
-
addDoubleIfPresent
private static void addDoubleIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey)
-
addStringIfPresent
private static void addStringIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey, java.lang.String osmKey2)
-
toGpxData
public GpxData toGpxData()
Converts OSM data behind this layer to GPX data.- Returns:
- GPX data
-
containsPoint
public boolean containsPoint(LatLon coor)
Determines if this layer contains data at the given coordinate.- Parameters:
coor
- the coordinate- Returns:
true
if data sources bounding boxes containcoor
-
getConflicts
public ConflictCollection getConflicts()
Replies the set of conflicts currently managed in this layer.- Returns:
- the set of conflicts currently managed in this layer
-
isDownloadable
public boolean isDownloadable()
Description copied from interface:DownloadFromServer
Determines if the layer is able to download data and implements theDownloadFromServer
interface. A layer that implements theDownloadFromServer
interface must returntrue
.- Specified by:
isDownloadable
in interfaceDownloadFromServer
- Overrides:
isDownloadable
in classAbstractModifiableLayer
- Returns:
true
if the layer is able to download data;false
, otherwise
-
isUploadable
public boolean isUploadable()
Description copied from interface:UploadToServer
Determines if the layer is able to upload data and implements theUploadToServer
interface. A layer that implements theUploadToServer
interface must returntrue
.- Specified by:
isUploadable
in interfaceUploadToServer
- Overrides:
isUploadable
in classAbstractModifiableLayer
- Returns:
true
if the layer is able to upload data;false
, otherwise
-
requiresUploadToServer
public boolean requiresUploadToServer()
Description copied from interface:UploadToServer
Determines if the data managed by this layer needs to be uploaded to the server because it contains modified data.- Specified by:
requiresUploadToServer
in interfaceUploadToServer
- Overrides:
requiresUploadToServer
in classAbstractModifiableLayer
- Returns:
true
if the data managed by this layer needs to be uploaded to the server because it contains modified data;false
, otherwise
-
requiresSaveToFile
public boolean requiresSaveToFile()
Description copied from interface:SaveToFile
Determines if the data managed by this layer needs to be saved to a file. Only replies true if a file is assigned to this layer and if the data managed by this layer has been modified since the last save operation to the file.- Specified by:
requiresSaveToFile
in interfaceSaveToFile
- Overrides:
requiresSaveToFile
in classAbstractModifiableLayer
- Returns:
true
if the data managed by this layer needs to be saved to a file;false
, otherwise
-
getLabel
public java.lang.String getLabel()
Description copied from class:Layer
Replies a label for this layer useful for UI elements. Defaults to the layer name
-
onPostLoadFromFile
public void onPostLoadFromFile()
Description copied from class:Layer
Initializes the layer after a successful load of data from a file- Overrides:
onPostLoadFromFile
in classLayer
-
onPostDownloadFromServer
public void onPostDownloadFromServer()
Actions run after data has been downloaded to this layer.
-
onPostSaveToFile
public void onPostSaveToFile()
Description copied from interface:SaveToFile
Initializes the layer after a successful save of data to a file.- Specified by:
onPostSaveToFile
in interfaceSaveToFile
- Overrides:
onPostSaveToFile
in classAbstractModifiableLayer
-
onPostUploadToServer
public void onPostUploadToServer()
Description copied from class:AbstractModifiableLayer
Initializes the layer after a successful upload to the server.- Specified by:
onPostUploadToServer
in interfaceUploadToServer
- Overrides:
onPostUploadToServer
in classAbstractModifiableLayer
-
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
-
removeClipboardDataFor
protected static void removeClipboardDataFor(OsmDataLayer osm)
-
processDatasetEvent
public void processDatasetEvent(AbstractDatasetChangedEvent event)
Description copied from interface:DataSetListenerAdapter.Listener
Called when notified about any type of dataset change event.- Specified by:
processDatasetEvent
in interfaceDataSetListenerAdapter.Listener
- Parameters:
event
- dataset change event
-
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
-
resetTiles
private void resetTiles(java.util.Collection<? extends IPrimitive> primitives)
-
resetTiles
private void resetTiles(IPrimitive p)
-
getInvalidatedBBox
private BBox getInvalidatedBBox(INode first, INode second)
-
resetBounds
private void resetBounds(IBounds bbox)
-
resetBounds
private void resetBounds(double minLat, double minLon, double maxLat, double maxLon)
-
dirtyAll
private void dirtyAll()
-
getZoom
private static int getZoom(NavigatableComponent navigatableComponent)
Get the zoom for aNavigatableComponent
- Parameters:
navigatableComponent
- The component to get the zoom from- Returns:
- The zoom for the navigatable component
-
projectionChanged
public void projectionChanged(Projection oldValue, Projection newValue)
- Specified by:
projectionChanged
in interfaceProjectionChangeListener
- Overrides:
projectionChanged
in classLayer
-
isUploadDiscouraged
public final boolean isUploadDiscouraged()
Description copied from interface:UploadToServer
Determines if upload of data managed by this layer is discouraged. This feature allows to use "private" data layers.- Specified by:
isUploadDiscouraged
in interfaceUploadToServer
- Overrides:
isUploadDiscouraged
in classAbstractModifiableLayer
- Returns:
true
if upload is discouraged for this layer;false
, otherwise
-
setUploadDiscouraged
public final void setUploadDiscouraged(boolean uploadDiscouraged)
Sets the "discouraged upload" flag.- Parameters:
uploadDiscouraged
-true
if upload of data managed by this layer is discouraged. This feature allows to use "private" data layers.
-
isModified
public final boolean isModified()
Description copied from class:AbstractModifiableLayer
Determines if data managed by this layer has been modified.- Specified by:
isModified
in classAbstractModifiableLayer
- Returns:
- true if data has been modified; false, otherwise
-
isSavable
public boolean isSavable()
Description copied from class:Layer
Replies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).- Specified by:
isSavable
in interfaceSaveToFile
- Overrides:
isSavable
in classLayer
- Returns:
- true if this layer can be saved to a file
-
checkSaveConditions
public boolean checkSaveConditions()
Description copied from class:Layer
Checks whether it is ok to launch a save (whether we have data, there is no conflict etc.)- Overrides:
checkSaveConditions
in classLayer
- Returns:
true
, if it is safe to save.
-
isDataSetEmpty
private boolean isDataSetEmpty()
Check the data set if it would be empty on save. It is empty, if it contains no objects (after all objects that are created and deleted without being transferred to the server have been removed).- Returns:
true
, if a save result in an empty data set.
-
createAndOpenSaveFileChooser
public java.io.File createAndOpenSaveFileChooser()
Description copied from class:Layer
Creates a new "Save" dialog for this layer and makes it visible.When the user has chosen a file, checks the file extension, and confirms overwriting if needed.
- Overrides:
createAndOpenSaveFileChooser
in classLayer
- Returns:
- The output
File
- See Also:
SaveActionBase.createAndOpenSaveFileChooser(java.lang.String, org.openstreetmap.josm.actions.ExtensionFileFilter)
-
createUploadTask
public AbstractIOTask createUploadTask(ProgressMonitor monitor)
Description copied from interface:UploadToServer
Creates a newAbstractIOTask
for uploading data.- Specified by:
createUploadTask
in interfaceUploadToServer
- Overrides:
createUploadTask
in classAbstractModifiableLayer
- Parameters:
monitor
- The progress monitor- Returns:
- a new
AbstractIOTask
for uploading data, ornull
if not applicable
-
getChangesetSourceTag
public java.lang.String getChangesetSourceTag()
Description copied from class:Layer
Get the source for the layer- Overrides:
getChangesetSourceTag
in classLayer
- Returns:
- The string for the changeset source tag or
null
-
getUploadDialog
public AbstractUploadDialog getUploadDialog()
Description copied from interface:UploadToServer
Returns the upload dialog for this layer.- Specified by:
getUploadDialog
in interfaceUploadToServer
- Overrides:
getUploadDialog
in classAbstractModifiableLayer
- Returns:
- the upload dialog for this layer, or
null
if not applicable
-
getViewProjectionBounds
public ProjectionBounds getViewProjectionBounds()
Description copied from class:Layer
Gets theProjectionBounds
for this layer to be visible to the user. This can be the exact bounds, the UI handles padding. Returnnull
if you cannot provide this information. The default implementation uses the bounds fromLayer.visitBoundingBox(BoundingXYVisitor)
.- Overrides:
getViewProjectionBounds
in classLayer
- Returns:
- The bounds for this layer.
-
highlightUpdated
public void highlightUpdated(HighlightUpdateListener.HighlightUpdateEvent e)
Description copied from interface:HighlightUpdateListener
Called whenever the highlighting of way segments in the dataset changed.- Specified by:
highlightUpdated
in interfaceHighlightUpdateListener
- Parameters:
e
- The dataset highlight event.
-
primitiveHovered
public void primitiveHovered(PrimitiveHoverListener.PrimitiveHoverEvent e)
Description copied from interface:PrimitiveHoverListener
Method called when the primitive under the mouse pointer changes.- Specified by:
primitiveHovered
in interfacePrimitiveHoverListener
- Parameters:
e
- Event object describing the hovered primitive and related information
-
setName
public void setName(java.lang.String name)
Description copied from class:Layer
Sets the name of the layer
-
setUploadInProgress
public void setUploadInProgress()
Sets the "upload in progress" flag, which will result in displaying a new icon and forbid to remove the layer.- Since:
- 13434
-
unsetUploadInProgress
public void unsetUploadInProgress()
Unsets the "upload in progress" flag, which will result in displaying the standard icon and allow to remove the layer.- Since:
- 13434
-
isUploadInProgress
public boolean isUploadInProgress()
Description copied from interface:UploadToServer
Determines if upload of data managed by this layer is currently in progress.- Specified by:
isUploadInProgress
in interfaceUploadToServer
- Overrides:
isUploadInProgress
in classAbstractModifiableLayer
- Returns:
true
if upload is in progress
-
getData
public Data getData()
Description copied from class:AbstractModifiableLayer
Get the data for the modifiable layer- Overrides:
getData
in classAbstractModifiableLayer
- Returns:
- The data object
-
autosave
public boolean autosave(java.io.File file) throws java.io.IOException
Description copied from class:AbstractModifiableLayer
Perform the autosave action for the layer- Overrides:
autosave
in classAbstractModifiableLayer
- Parameters:
file
- The file to save to- Returns:
true
if the layer was successfully saved- Throws:
java.io.IOException
- If there was an IO exception from saving
-
duplicate
public OsmDataLayer duplicate(java.lang.String newName)
Duplicates this layer with a new name and a copy of this layer dataset.- Parameters:
newName
- name of new layer- Returns:
- A copy of this layer
- Since:
- 18233
-
-