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 classOsmDataLayer.ConsistencyTestActionclassOsmDataLayer.ConvertToGpxLayerActionAction that converts this OSM layer to a GPX layer.static classOsmDataLayer.DataCountVisitorA listener that counts the number of primitives it encountersstatic interfaceOsmDataLayer.LayerStateChangeListenerListener 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>cacheA cache used for paintingDataSetdataThe data behind this layer.private static java.util.concurrent.atomic.AtomicIntegerdataLayerCounterthe global counter for created data layersprivate DataSetListenerAdapterdataSetListenerAdapterstatic intDEFAULT_RECENT_RELATIONS_NUMBERThe default number of relations in the recent relations cache.private static java.awt.image.BufferedImagehatcheda texture for non-downloaded areaprivate static intHATCHED_SIZEprivate booleanhoverListenerAddedprivate static java.lang.StringIS_EMPTY_SYMBOLprivate java.util.concurrent.atomic.AtomicBooleanisUploadInProgressFlag used to know if the layer is being uploadedprivate intlastDataIdxThe map paint index that was painted (used to invalidatecache)private intlastZoomThe last zoom level (we invalidate all tiles when switching layers)private java.util.concurrent.CopyOnWriteArrayList<OsmDataLayer.LayerStateChangeListener>layerStateChangeListenersprivate static intMAX_ZOOMprivate static intOVER_ZOOMprivate static NamedColorPropertyPROPERTY_BACKGROUND_COLORstatic BooleanPropertyPROPERTY_HIDE_LABELS_WHILE_DRAGGINGProperty to determine if labels must be hidden while dragging the map.private static NamedColorPropertyPROPERTY_OUTSIDE_COLORstatic IntegerPropertyPROPERTY_RECENT_RELATIONS_NUMBERThe number of relations to use in the recent relations cache.static StringPropertyPROPERTY_SAVE_EXTENSIONThe extension that should be used when saving the OSM file.private java.util.Map<Relation,java.lang.Void>recentRelationsList of recent relationsstatic java.lang.StringREQUIRES_UPLOAD_TO_SERVER_PROPProperty used to know if this layer has to be uploadedprivate booleanrequiresSaveToFileprivate booleanrequiresUploadToServerjava.util.List<TestError>validationErrorsList 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 voidaddConditionalInformation(javax.swing.JPanel p, java.lang.String text, boolean condition)private static voidaddDoubleIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey)private static voidaddIntegerIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey)voidaddLayerStateChangeListener(OsmDataLayer.LayerStateChangeListener listener)Adds a layer state change listenerprivate static voidaddStringIfPresent(WayPoint wpt, OsmPrimitive p, java.lang.String gpxPrefix, java.lang.String gpxKey, java.lang.String osmKey, java.lang.String osmKey2)booleanautosave(java.io.File file)Perform the autosave action for the layerbooleancheckSaveConditions()Checks whether it is ok to launch a save (whether we have data, there is no conflict etc.)voidcleanupAfterUpload(java.util.Collection<? extends IPrimitive> processed)Clean out the data behind the layer.private static booleancontainsOnlyGpxTags(Tagged t, java.lang.String gpxPrefix)booleancontainsPoint(LatLon coor)Determines if this layer contains data at the given coordinate.private static java.lang.StringcounterText(java.lang.String text, int deleted, int incomplete)java.io.FilecreateAndOpenSaveFileChooser()Creates a new "Save" dialog for this layer and makes it visible.static voidcreateHatchTexture()Initialize the hatch pattern used to paint the non-downloaded area(package private) static java.lang.StringcreateLayerName(java.lang.Object arg)static java.lang.StringcreateNewName()Replies a new unique name for a data layerAbstractIOTaskcreateUploadTask(ProgressMonitor monitor)Creates a newAbstractIOTaskfor uploading data.voiddestroy()Called, when the layer is removed from the mapview and is going to be destroyed.private voiddirtyAll()OsmDataLayerduplicate(java.lang.String newName)Duplicates this layer with a new name and a copy of this layer dataset.protected static voidfillGpxData(GpxData gpxData, DataSet data, java.io.File file, java.lang.String gpxPrefix)static java.awt.ColorgetBackgroundColor()Replies background color for downloaded areas.protected ImageProvidergetBaseIconProvider()Return the image provider to get the base iconjava.lang.StringgetChangesetSourceTag()Get the source for the layerConflictCollectiongetConflicts()Replies the set of conflicts currently managed in this layer.DatagetData()Get the data for the modifiable layerDataSetgetDataSet()Returns theDataSetbehind this layer.javax.swing.IcongetIcon()Return a representative small image for this layer.java.lang.ObjectgetInfoComponent()Gets the layer information to display to the user.private BBoxgetInvalidatedBBox(INode first, INode second)java.lang.StringgetLabel()Replies a label for this layer useful for UI elements.javax.swing.Action[]getMenuEntries()Returns list of actions.static java.awt.ColorgetOutsideColor()Replies background color for non-downloaded areas.java.util.List<Relation>getRecentRelations()Returns list of recently closed relations or null if none.java.lang.StringgetToolTipText()Returns a small tooltip hint about some statistics for this layer.AbstractUploadDialoggetUploadDialog()Returns the upload dialog for this layer.ProjectionBoundsgetViewProjectionBounds()Gets theProjectionBoundsfor this layer to be visible to the user.private static intgetZoom(NavigatableComponent navigatableComponent)Get the zoom for aNavigatableComponentprivate static java.lang.StringgpxVal(OsmPrimitive prim, java.lang.String gpxPrefix, java.lang.String key)Reads the Gpx key from the givenOsmPrimitive, with or without "gpx:" prefixvoidhighlightUpdated(HighlightUpdateListener.HighlightUpdateEvent e)Called whenever the highlighting of way segments in the dataset changed.private booleanisDataSetEmpty()Check the data set if it would be empty on save.booleanisDownloadable()Determines if the layer is able to download data and implements theDownloadFromServerinterface.booleanisMergable(Layer other)Determines if the other layer can be merged into this layer.booleanisModified()Determines if data managed by this layer has been modified.booleanisSavable()Replies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).booleanisUploadable()Determines if the layer is able to upload data and implements theUploadToServerinterface.booleanisUploadDiscouraged()Determines if upload of data managed by this layer is discouraged.booleanisUploadInProgress()Determines if upload of data managed by this layer is currently in progress.voidmergeFrom(DataSet from)merges the primitives in datasetfrominto the dataset of this layervoidmergeFrom(DataSet from, ProgressMonitor progressMonitor)merges the primitives in datasetfrominto the dataset of this layervoidmergeFrom(Layer from)Merges the given layer into this layer.private static voidnodesToGpxData(java.util.Collection<Node> nodes, GpxData gpxData, java.util.Set<Node> doneNodes, java.lang.String gpxPrefix)static WayPointnodeToWayPoint(Node n, long time)Converts a node to a waypoint with defaultGpxConstants.GPX_PREFIXfor tags.static WayPointnodeToWayPoint(Node n, long time, java.lang.String gpxPrefix)Converts a node to a waypoint with a configurable GPX prefix for tags.voidonPostDownloadFromServer()Actions run after data has been downloaded to this layer.voidonPostLoadFromFile()Initializes the layer after a successful load of data from a filevoidonPostSaveToFile()Initializes the layer after a successful save of data to a file.voidonPostUploadToServer()Initializes the layer after a successful upload to the server.voidpaint(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 voidpaintData(java.awt.Graphics2D g, MapView mv, Bounds box, boolean inactive, boolean virtual)private voidpaintHatch(java.awt.Graphics2D g, MapView mv, boolean active)voidprimitiveHovered(PrimitiveHoverListener.PrimitiveHoverEvent e)Method called when the primitive under the mouse pointer changes.voidprocessDatasetEvent(AbstractDatasetChangedEvent event)Called when notified about any type of dataset change event.voidprojectionChanged(Projection oldValue, Projection newValue)protected static voidremoveClipboardDataFor(OsmDataLayer osm)voidremoveLayerStateChangeListener(OsmDataLayer.LayerStateChangeListener listener)Removes a layer state change listenervoidremoveRecentRelation(Relation relation)Remove relation from list of recent relations.booleanrequiresSaveToFile()Determines if the data managed by this layer needs to be saved to a file.booleanrequiresUploadToServer()Determines if the data managed by this layer needs to be uploaded to the server because it contains modified data.private voidresetBounds(double minLat, double minLon, double maxLat, double maxLon)private voidresetBounds(IBounds bbox)private voidresetTiles(java.util.Collection<? extends IPrimitive> primitives)private voidresetTiles(IPrimitive p)voidselectionChanged(DataSelectionListener.SelectionChangeEvent event)Called whenever the selection is changed.voidsetName(java.lang.String name)Sets the name of the layervoidsetRecentRelation(Relation relation)Adds recently closed relation.protected voidsetRequiresSaveToFile(boolean newValue)protected voidsetRequiresUploadToServer(boolean newValue)voidsetUploadDiscouraged(boolean uploadDiscouraged)Sets the "discouraged upload" flag.voidsetUploadInProgress()Sets the "upload in progress" flag, which will result in displaying a new icon and forbid to remove the layer.GpxDatatoGpxData()Converts OSM data behind this layer to GPX data.static GpxDatatoGpxData(DataSet data, java.io.File file)Converts given OSM dataset to GPX data.voidunsetUploadInProgress()Unsets the "upload in progress" flag, which will result in displaying the standard icon and allow to remove the layer.voidvisitBoundingBox(BoundingXYVisitor v)Visits the content bounds of this layer.private static voidwaysToGpxData(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
nullif 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 theDataSetbehind this layer.- Specified by:
getDataSetin classAbstractOsmDataLayer- Returns:
- the
DataSetbehind 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:LayerReturn 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:
paintin 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: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.
-
mergeFrom
public void mergeFrom(DataSet from)
merges the primitives in datasetfrominto the dataset of this layer- Parameters:
from- the source data set
-
mergeFrom
public void mergeFrom(DataSet from, ProgressMonitor progressMonitor)
merges the primitives in datasetfrominto 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: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.
-
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: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.
-
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: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
-
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
nullif not present
-
nodeToWayPoint
public static WayPoint nodeToWayPoint(Node n, long time)
Converts a node to a waypoint with defaultGpxConstants.GPX_PREFIXfor tags.- Parameters:
n- theNodeto converttime- a timestamp value in milliseconds from the epoch.- Returns:
WayPointobject- 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- theNodeto converttime- a timestamp value in milliseconds from the epoch.gpxPrefix- the GPX prefix for tags- Returns:
WayPointobject- 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:
trueif 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:DownloadFromServerDetermines if the layer is able to download data and implements theDownloadFromServerinterface. A layer that implements theDownloadFromServerinterface must returntrue.- Specified by:
isDownloadablein interfaceDownloadFromServer- Overrides:
isDownloadablein classAbstractModifiableLayer- Returns:
trueif the layer is able to download data;false, otherwise
-
isUploadable
public boolean isUploadable()
Description copied from interface:UploadToServerDetermines if the layer is able to upload data and implements theUploadToServerinterface. A layer that implements theUploadToServerinterface must returntrue.- Specified by:
isUploadablein interfaceUploadToServer- Overrides:
isUploadablein classAbstractModifiableLayer- Returns:
trueif the layer is able to upload data;false, otherwise
-
requiresUploadToServer
public boolean requiresUploadToServer()
Description copied from interface:UploadToServerDetermines if the data managed by this layer needs to be uploaded to the server because it contains modified data.- Specified by:
requiresUploadToServerin interfaceUploadToServer- Overrides:
requiresUploadToServerin classAbstractModifiableLayer- Returns:
trueif 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:SaveToFileDetermines 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:
requiresSaveToFilein interfaceSaveToFile- Overrides:
requiresSaveToFilein classAbstractModifiableLayer- Returns:
trueif 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:LayerReplies a label for this layer useful for UI elements. Defaults to the layer name
-
onPostLoadFromFile
public void onPostLoadFromFile()
Description copied from class:LayerInitializes the layer after a successful load of data from a file- Overrides:
onPostLoadFromFilein classLayer
-
onPostDownloadFromServer
public void onPostDownloadFromServer()
Actions run after data has been downloaded to this layer.
-
onPostSaveToFile
public void onPostSaveToFile()
Description copied from interface:SaveToFileInitializes the layer after a successful save of data to a file.- Specified by:
onPostSaveToFilein interfaceSaveToFile- Overrides:
onPostSaveToFilein classAbstractModifiableLayer
-
onPostUploadToServer
public void onPostUploadToServer()
Description copied from class:AbstractModifiableLayerInitializes the layer after a successful upload to the server.- Specified by:
onPostUploadToServerin interfaceUploadToServer- Overrides:
onPostUploadToServerin classAbstractModifiableLayer
-
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
-
removeClipboardDataFor
protected static void removeClipboardDataFor(OsmDataLayer osm)
-
processDatasetEvent
public void processDatasetEvent(AbstractDatasetChangedEvent event)
Description copied from interface:DataSetListenerAdapter.ListenerCalled when notified about any type of dataset change event.- Specified by:
processDatasetEventin interfaceDataSetListenerAdapter.Listener- Parameters:
event- dataset change event
-
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
-
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:
projectionChangedin interfaceProjectionChangeListener- Overrides:
projectionChangedin classLayer
-
isUploadDiscouraged
public final boolean isUploadDiscouraged()
Description copied from interface:UploadToServerDetermines if upload of data managed by this layer is discouraged. This feature allows to use "private" data layers.- Specified by:
isUploadDiscouragedin interfaceUploadToServer- Overrides:
isUploadDiscouragedin classAbstractModifiableLayer- Returns:
trueif upload is discouraged for this layer;false, otherwise
-
setUploadDiscouraged
public final void setUploadDiscouraged(boolean uploadDiscouraged)
Sets the "discouraged upload" flag.- Parameters:
uploadDiscouraged-trueif 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:AbstractModifiableLayerDetermines if data managed by this layer has been modified.- Specified by:
isModifiedin classAbstractModifiableLayer- Returns:
- true if data has been modified; false, otherwise
-
isSavable
public boolean isSavable()
Description copied from class:LayerReplies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).- Specified by:
isSavablein interfaceSaveToFile- Overrides:
isSavablein classLayer- Returns:
- true if this layer can be saved to a file
-
checkSaveConditions
public boolean checkSaveConditions()
Description copied from class:LayerChecks whether it is ok to launch a save (whether we have data, there is no conflict etc.)- Overrides:
checkSaveConditionsin 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:LayerCreates 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:
createAndOpenSaveFileChooserin 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:UploadToServerCreates a newAbstractIOTaskfor uploading data.- Specified by:
createUploadTaskin interfaceUploadToServer- Overrides:
createUploadTaskin classAbstractModifiableLayer- Parameters:
monitor- The progress monitor- Returns:
- a new
AbstractIOTaskfor uploading data, ornullif not applicable
-
getChangesetSourceTag
public java.lang.String getChangesetSourceTag()
Description copied from class:LayerGet the source for the layer- Overrides:
getChangesetSourceTagin classLayer- Returns:
- The string for the changeset source tag or
null
-
getUploadDialog
public AbstractUploadDialog getUploadDialog()
Description copied from interface:UploadToServerReturns the upload dialog for this layer.- Specified by:
getUploadDialogin interfaceUploadToServer- Overrides:
getUploadDialogin classAbstractModifiableLayer- Returns:
- the upload dialog for this layer, or
nullif not applicable
-
getViewProjectionBounds
public ProjectionBounds getViewProjectionBounds()
Description copied from class:LayerGets theProjectionBoundsfor this layer to be visible to the user. This can be the exact bounds, the UI handles padding. Returnnullif you cannot provide this information. The default implementation uses the bounds fromLayer.visitBoundingBox(BoundingXYVisitor).- Overrides:
getViewProjectionBoundsin classLayer- Returns:
- The bounds for this layer.
-
highlightUpdated
public void highlightUpdated(HighlightUpdateListener.HighlightUpdateEvent e)
Description copied from interface:HighlightUpdateListenerCalled whenever the highlighting of way segments in the dataset changed.- Specified by:
highlightUpdatedin interfaceHighlightUpdateListener- Parameters:
e- The dataset highlight event.
-
primitiveHovered
public void primitiveHovered(PrimitiveHoverListener.PrimitiveHoverEvent e)
Description copied from interface:PrimitiveHoverListenerMethod called when the primitive under the mouse pointer changes.- Specified by:
primitiveHoveredin interfacePrimitiveHoverListener- Parameters:
e- Event object describing the hovered primitive and related information
-
setName
public void setName(java.lang.String name)
Description copied from class:LayerSets 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:UploadToServerDetermines if upload of data managed by this layer is currently in progress.- Specified by:
isUploadInProgressin interfaceUploadToServer- Overrides:
isUploadInProgressin classAbstractModifiableLayer- Returns:
trueif upload is in progress
-
getData
public Data getData()
Description copied from class:AbstractModifiableLayerGet the data for the modifiable layer- Overrides:
getDatain classAbstractModifiableLayer- Returns:
- The data object
-
autosave
public boolean autosave(java.io.File file) throws java.io.IOException
Description copied from class:AbstractModifiableLayerPerform the autosave action for the layer- Overrides:
autosavein classAbstractModifiableLayer- Parameters:
file- The file to save to- Returns:
trueif 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
-
-