Package org.openstreetmap.josm.gui.layer
Class NoteLayer
java.lang.Object
org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
org.openstreetmap.josm.gui.layer.Layer
org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
org.openstreetmap.josm.gui.layer.NoteLayer
- All Implemented Interfaces:
MouseListener,EventListener,Lockable,NoteData.NoteDataUpdateListener,ProjectionChangeListener,DownloadFromServer,MapViewPaintable,SaveToFile,UploadToServer,Destroyable
public class NoteLayer
extends AbstractModifiableLayer
implements MouseListener, NoteData.NoteDataUpdateListener
A layer to hold Note objects.
- Since:
- 7522
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.Layer
Layer.LayerAction, Layer.LayerGpxExportAction, Layer.LayerSaveAction, Layer.LayerSaveAsAction, Layer.MultiLayerAction, Layer.SeparatorLayerActionNested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
AbstractMapViewPaintable.CompatibilityModeLayerPainterNested classes/interfaces inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Noteprivate HtmlPanelprivate JWindowprivate static final Patternprivate static final Patternprivate static final Patternprivate final NoteDataprivate static final PatternPattern to detect end of sentences followed by another one, or a link, in eastern script.private static final PatternPattern to detect end of sentences followed by another one, or a link, in western script.private static final PatternFields inherited from class org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
IS_DIRTY_SYMBOL, REQUIRES_SAVE_TO_DISK_PROPFields inherited from class org.openstreetmap.josm.gui.layer.Layer
FILTER_STATE_PROP, NAME_PROP, OPACITY_PROP, propertyChangeSupport, VISIBLE_PROP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanPerform the autosave action for the layerCreates a new "Save" dialog for this layer and makes it visible.createUploadTask(ProgressMonitor monitor) Creates a newAbstractIOTaskfor uploading data.voiddestroy()Called, when the layer is removed from the mapview and is going to be destroyed.private PointfixPanelSizeAndLocation(MapView mv, String text, int xl, int xr, int yt, int yb) Get the source for the layergetData()Get the data for the modifiable layergetIcon()Return a representative small image for this layer.Gets the layer information to display to the user.Action[]Returns list of actions.Returns the note data store being used by this layerstatic StringgetNoteToolTip(Note note) Returns the HTML-formatted tooltip text for the given note.Returns a small tooltip hint about some statistics for this layer.private voidvoidInitialization code, that depends on Main.map.mapView.(package private) static StringinsertLineBreaks(String longText) Inserts HTML line breaks (<br>at the end of each sentence mark (period, interrogation mark, exclamation mark, ideographic full stop).booleanDetermines 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.booleanDetermines if data managed by this layer has been modified.booleanReplies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).booleanDetermines if the layer is able to upload data and implements theUploadToServerinterface.voidMerges the given layer into this layer.voidvoidvoidvoidvoidvoidnoteDataUpdated(NoteData data) Called when the note data is updatedvoidpaint(Graphics2D g, MapView mv, Bounds box) Paint the dataset using the engine set.private voidpaintSelectedNote(Graphics2D g, MapView mv, int iconHeight, int iconWidth, Note selectedNote) (package private) static StringreplaceLinks(String htmlText) booleanDetermines if the data managed by this layer needs to be saved to a file.booleanDetermines if the data managed by this layer needs to be uploaded to the server because it contains modified data.voidselectedNoteChanged(NoteData noteData) The selected node was changedvoidVisits the content bounds of this layer.Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
getUploadDialog, isDirty, isLocked, isUploadDiscouraged, isUploadInProgress, lock, onPostSaveToFile, onPostUploadToServer, unlockMethods inherited from class org.openstreetmap.josm.gui.layer.Layer
addPropertyChangeListener, checkSaveConditions, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getAssociatedFile, getColor, getDefaultLayerPosition, getLabel, getName, getOpacity, getViewProjectionBounds, hasColor, isBackgroundLayer, isInfoResizable, isProjectionSupported, isRenamed, isVisible, nameSupportedProjections, onPostLoadFromFile, projectionChanged, removePropertyChangeListener, rename, setAssociatedFile, setBackgroundLayer, setColor, setFilterStateChanged, setName, setOpacity, setVisible, toggleVisible, toStringMethods inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
addInvalidationListener, attachToMapView, createMapViewPainter, invalidate, removeInvalidationListener
-
Field Details
-
SENTENCE_MARKS_WESTERN
Pattern to detect end of sentences followed by another one, or a link, in western script. Group 1 (capturing): period, interrogation mark, exclamation mark Group non capturing: at least one horizontal or vertical whitespace Group 2 (capturing): a letter (any script), or any punctuation -
SENTENCE_MARKS_EASTERN
Pattern to detect end of sentences followed by another one, or a link, in eastern script. Group 1 (capturing): ideographic full stop Group 2 (capturing): a letter (any script), or any punctuation -
HTTP_LINK
-
HTML_LINK
-
HTML_LINK_MARK
-
SLASH
-
noteData
-
displayedNote
-
displayedPanel
-
displayedWindow
-
-
Constructor Details
-
NoteLayer
Create a new note layer with a set of notes- Parameters:
notes- A list of notes to show in this layername- The name of the layer. Typically "Notes"
-
NoteLayer
Create a new note layer with a notes data- Parameters:
noteData- Notes dataname- The name of the layer. Typically "Notes"- Since:
- 14101
-
NoteLayer
public NoteLayer()Convenience constructor that creates a layer with an empty note list
-
-
Method Details
-
hookUpMapView
Description copied from class:LayerInitialization code, that depends on Main.map.mapView.It is always called in the event dispatching thread. Note that Main.map is null as long as no layer has been added, so do not execute code in the constructor, that assumes Main.map.mapView is not null.
If you need to execute code when this layer is added to the map view, use
AbstractMapViewPaintable.attachToMapView(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)- Overrides:
hookUpMapViewin classLayer
-
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
-
getNoteData
Returns the note data store being used by this layer- Returns:
- noteData containing layer notes
-
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
-
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
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
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
-
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
-
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
-
paint
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
-
hideNoteWindow
-
paintSelectedNote
private void paintSelectedNote(Graphics2D g, MapView mv, int iconHeight, int iconWidth, Note selectedNote) -
fixPanelSizeAndLocation
-
insertLineBreaks
Inserts HTML line breaks (<br>at the end of each sentence mark (period, interrogation mark, exclamation mark, ideographic full stop).- Parameters:
longText- a long text that does not fit on a single line without exceeding half of the map view- Returns:
- text with line breaks
-
getNoteToolTip
Returns the HTML-formatted tooltip text for the given note.- Parameters:
note- note to display- Returns:
- the HTML-formatted tooltip text for the given note
- Since:
- 13111
-
replaceLinks
-
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. -
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
Description copied from class:LayerMerges the given layer into this layer. Throws if the layer types are incompatible. -
isMergable
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
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
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
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
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
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:
-
createUploadTask
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
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
noteDataUpdated
Description copied from interface:NoteData.NoteDataUpdateListenerCalled when the note data is updated- Specified by:
noteDataUpdatedin interfaceNoteData.NoteDataUpdateListener- Parameters:
data- The data that was changed
-
selectedNoteChanged
Description copied from interface:NoteData.NoteDataUpdateListenerThe selected node was changed- Specified by:
selectedNoteChangedin interfaceNoteData.NoteDataUpdateListener- Parameters:
noteData- The data of which the selected node was changed
-
getChangesetSourceTag
Description copied from class:LayerGet the source for the layer- Overrides:
getChangesetSourceTagin classLayer- Returns:
- The string for the changeset source tag or
null
-
autosave
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:
IOException- If there was an IO exception from saving
-
getData
Description copied from class:AbstractModifiableLayerGet the data for the modifiable layer- Overrides:
getDatain classAbstractModifiableLayer- Returns:
- The data object
-