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:
java.awt.event.MouseListener,java.util.EventListener,Lockable,NoteData.NoteDataUpdateListener,ProjectionChangeListener,DownloadFromServer,MapViewPaintable,SaveToFile,UploadToServer,Destroyable
public class NoteLayer extends AbstractModifiableLayer implements java.awt.event.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.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.MapViewPaintable
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
-
-
Field Summary
Fields Modifier and Type Field Description private NotedisplayedNoteprivate HtmlPaneldisplayedPanelprivate javax.swing.JWindowdisplayedWindowprivate static java.util.regex.PatternHTML_LINKprivate static java.util.regex.PatternHTML_LINK_MARKprivate static java.util.regex.PatternHTTP_LINKprivate NoteDatanoteDataprivate static java.util.regex.PatternSENTENCE_MARKS_EASTERNPattern to detect end of sentences followed by another one, or a link, in eastern script.private static java.util.regex.PatternSENTENCE_MARKS_WESTERNPattern to detect end of sentences followed by another one, or a link, in western script.private static java.util.regex.PatternSLASH-
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 NoteLayer()Convenience constructor that creates a layer with an empty note listNoteLayer(java.util.Collection<Note> notes, java.lang.String name)Create a new note layer with a set of notesNoteLayer(NoteData noteData, java.lang.String name)Create a new note layer with a notes data
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanautosave(java.io.File file)Perform the autosave action for the layerjava.io.FilecreateAndOpenSaveFileChooser()Creates a new "Save" dialog for this layer and makes it visible.AbstractIOTaskcreateUploadTask(ProgressMonitor monitor)Creates a newAbstractIOTaskfor uploading data.voiddestroy()Called, when the layer is removed from the mapview and is going to be destroyed.private java.awt.PointfixPanelSizeAndLocation(MapView mv, java.lang.String text, int xl, int xr, int yt, int yb)java.lang.StringgetChangesetSourceTag()Get the source for the layerDatagetData()Get the data for the modifiable layerjavax.swing.IcongetIcon()Return a representative small image for this layer.java.lang.ObjectgetInfoComponent()Gets the layer information to display to the user.javax.swing.Action[]getMenuEntries()Returns list of actions.NoteDatagetNoteData()Returns the note data store being used by this layerstatic java.lang.StringgetNoteToolTip(Note note)Returns the HTML-formatted tooltip text for the given note.java.lang.StringgetToolTipText()Returns a small tooltip hint about some statistics for this layer.private voidhideNoteWindow()voidhookUpMapView()Initialization code, that depends on Main.map.mapView.(package private) static java.lang.StringinsertLineBreaks(java.lang.String longText)Inserts HTML line breaks (<br>at the end of each sentence mark (period, interrogation mark, exclamation mark, ideographic full stop).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.voidmergeFrom(Layer from)Merges the given layer into this layer.voidmouseClicked(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidnoteDataUpdated(NoteData data)Called when the note data is updatedvoidpaint(java.awt.Graphics2D g, MapView mv, Bounds box)Paint the dataset using the engine set.private voidpaintSelectedNote(java.awt.Graphics2D g, MapView mv, int iconHeight, int iconWidth, Note selectedNote)(package private) static java.lang.StringreplaceLinks(java.lang.String htmlText)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.voidselectedNoteChanged(NoteData noteData)The selected node was changedvoidvisitBoundingBox(BoundingXYVisitor v)Visits the content bounds of this layer.-
Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
getUploadDialog, isDirty, isLocked, isUploadDiscouraged, isUploadInProgress, lock, onPostSaveToFile, onPostUploadToServer, unlock
-
Methods 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, toString
-
Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
addInvalidationListener, attachToMapView, createMapViewPainter, invalidate, removeInvalidationListener
-
-
-
-
Field Detail
-
SENTENCE_MARKS_WESTERN
private static final java.util.regex.Pattern 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
private static final java.util.regex.Pattern 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
private static final java.util.regex.Pattern HTTP_LINK
-
HTML_LINK
private static final java.util.regex.Pattern HTML_LINK
-
HTML_LINK_MARK
private static final java.util.regex.Pattern HTML_LINK_MARK
-
SLASH
private static final java.util.regex.Pattern SLASH
-
displayedNote
private Note displayedNote
-
displayedPanel
private HtmlPanel displayedPanel
-
displayedWindow
private javax.swing.JWindow displayedWindow
-
-
Constructor Detail
-
NoteLayer
public NoteLayer(java.util.Collection<Note> notes, java.lang.String name)
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
public NoteLayer(NoteData noteData, java.lang.String name)
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 Detail
-
hookUpMapView
public void 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
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
-
getNoteData
public NoteData getNoteData()
Returns the note data store being used by this layer- Returns:
- noteData containing layer notes
-
isModified
public 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
-
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
-
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
-
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
-
paint
public void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
Description copied from interface:MapViewPaintablePaint the dataset using the engine set.- Specified by:
paintin interfaceMapViewPaintable- Parameters:
g- Graphicsmv- The object that can translate GeoPoints to screen coordinates.box- Bounding box
-
hideNoteWindow
private void hideNoteWindow()
-
paintSelectedNote
private void paintSelectedNote(java.awt.Graphics2D g, MapView mv, int iconHeight, int iconWidth, Note selectedNote)
-
fixPanelSizeAndLocation
private java.awt.Point fixPanelSizeAndLocation(MapView mv, java.lang.String text, int xl, int xr, int yt, int yb)
-
insertLineBreaks
static java.lang.String insertLineBreaks(java.lang.String longText)
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
public static java.lang.String getNoteToolTip(Note note)
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
static java.lang.String replaceLinks(java.lang.String htmlText)
-
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.
-
getToolTipText
public java.lang.String getToolTipText()
Description copied from class:LayerReturns a small tooltip hint about some statistics for this layer.- Specified by:
getToolTipTextin classLayer- Returns:
- A small tooltip hint about some statistics for this layer.
-
mergeFrom
public void mergeFrom(Layer from)
Description copied from class:LayerMerges the given layer into this layer. Throws if the layer types are incompatible.
-
isMergable
public boolean isMergable(Layer other)
Description copied from class:LayerDetermines if the other layer can be merged into this layer.- Specified by:
isMergablein classLayer- Parameters:
other- The other layer that is tested to be mergable with this.- Returns:
- Whether the other layer can be merged into this layer.
-
visitBoundingBox
public void visitBoundingBox(BoundingXYVisitor v)
Description copied from class:LayerVisits the content bounds of this layer. The behavior of this method depends on the layer, but each implementation should attempt to cover the relevant content of the layer in this method.- Specified by:
visitBoundingBoxin classLayer- Parameters:
v- The visitor that gets notified about the contents of this layer.
-
getInfoComponent
public java.lang.Object getInfoComponent()
Description copied from class:LayerGets the layer information to display to the user. This is used if the user requests information about this layer. It should display a description of the layer content.- Specified by:
getInfoComponentin classLayer- Returns:
- Either a String or a
Componentdescribing the layer.
-
getMenuEntries
public javax.swing.Action[] getMenuEntries()
Description copied from class:LayerReturns list of actions. Action can implement LayerAction interface when it needs to be represented by other menu component than JMenuItem or when it supports multiple layers. Actions that support multiple layers should also have correct equals implementation.Use
Layer.SeparatorLayerAction.INSTANCEinstead of new JSeparator- Specified by:
getMenuEntriesin classLayer- Returns:
- menu actions for this layer
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
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
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
noteDataUpdated
public void noteDataUpdated(NoteData data)
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
public void selectedNoteChanged(NoteData noteData)
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
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
-
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
-
getData
public Data getData()
Description copied from class:AbstractModifiableLayerGet the data for the modifiable layer- Overrides:
getDatain classAbstractModifiableLayer- Returns:
- The data object
-
-