public class NoteLayer extends AbstractModifiableLayer implements java.awt.event.MouseListener, NoteData.NoteDataUpdateListener
Layer.LayerAction, Layer.LayerGpxExportAction, Layer.LayerSaveAction, Layer.LayerSaveAsAction, Layer.MultiLayerAction, Layer.SeparatorLayerAction
AbstractMapViewPaintable.CompatibilityModeLayerPainter
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
Modifier and Type | Field and Description |
---|---|
private Note |
displayedNote |
private HtmlPanel |
displayedPanel |
private javax.swing.JWindow |
displayedWindow |
private static java.util.regex.Pattern |
HTML_LINK |
private static java.util.regex.Pattern |
HTML_LINK_MARK |
private static java.util.regex.Pattern |
HTTP_LINK |
private NoteData |
noteData |
private static java.util.regex.Pattern |
SENTENCE_MARKS_EASTERN
Pattern to detect end of sentences followed by another one, or a link, in eastern script.
|
private static java.util.regex.Pattern |
SENTENCE_MARKS_WESTERN
Pattern to detect end of sentences followed by another one, or a link, in western script.
|
private static java.util.regex.Pattern |
SLASH |
FILTER_STATE_PROP, NAME_PROP, OPACITY_PROP, propertyChangeSupport, VISIBLE_PROP
Constructor and Description |
---|
NoteLayer()
Convenience constructor that creates a layer with an empty note list
|
NoteLayer(java.util.Collection<Note> notes,
java.lang.String name)
Create a new note layer with a set of notes
|
Modifier and Type | Method and Description |
---|---|
java.io.File |
createAndOpenSaveFileChooser()
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 overwrite if needed. |
AbstractIOTask |
createUploadTask(ProgressMonitor monitor)
Creates a new
AbstractIOTask for uploading data. |
void |
destroy()
Called, when the layer is removed from the mapview and is going to be destroyed.
|
private java.awt.Point |
fixPanelSizeAndLocation(MapView mv,
java.lang.String text,
int xl,
int xr,
int yt,
int yb) |
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.
|
javax.swing.Action[] |
getMenuEntries()
Returns list of actions.
|
NoteData |
getNoteData()
Returns the note data store being used by this layer
|
static java.lang.String |
getNoteToolTip(Note note)
Returns the HTML-formatted tooltip text for the given note.
|
java.lang.String |
getToolTipText() |
private void |
hideNoteWindow() |
void |
hookUpMapView()
Initialization code, that depends on Main.map.mapView.
|
(package private) 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). |
boolean |
isDownloadable()
Determines if the layer is able to download data and implements the
DownloadFromServer interface. |
boolean |
isMergable(Layer other) |
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 the
UploadToServer interface. |
void |
mergeFrom(Layer from)
Merges the given layer into this layer.
|
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
void |
noteDataUpdated(NoteData data)
Called when the note data is updated
|
void |
paint(java.awt.Graphics2D g,
MapView mv,
Bounds box)
Paint the dataset using the engine set.
|
private void |
paintSelectedNote(java.awt.Graphics2D g,
MapView mv,
int iconHeight,
int iconWidth,
Note selectedNote) |
(package private) static java.lang.String |
replaceLinks(java.lang.String htmlText) |
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.
|
void |
selectedNoteChanged(NoteData noteData)
The selected node was changed
|
void |
visitBoundingBox(BoundingXYVisitor v)
Visits the content bounds of this layer.
|
getUploadDialog, isLocked, isUploadDiscouraged, isUploadInProgress, lock, onPostSaveToFile, onPostUploadToServer, unlock
addPropertyChangeListener, checkSaveConditions, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getAssociatedFile, getBaseColorProperty, getColorProperty, getDefaultLayerPosition, getName, getOpacity, getViewProjectionBounds, isBackgroundLayer, isInfoResizable, isProjectionSupported, isRenamed, isVisible, nameSupportedProjections, onPostLoadFromFile, projectionChanged, removePropertyChangeListener, rename, setAssociatedFile, setBackgroundLayer, setFilterStateChanged, setName, setOpacity, setVisible, toggleVisible, toString
addInvalidationListener, attachToMapView, createMapViewPainter, invalidate, removeInvalidationListener
private static final java.util.regex.Pattern SENTENCE_MARKS_WESTERN
private static final java.util.regex.Pattern SENTENCE_MARKS_EASTERN
private static final java.util.regex.Pattern HTTP_LINK
private static final java.util.regex.Pattern HTML_LINK
private static final java.util.regex.Pattern HTML_LINK_MARK
private static final java.util.regex.Pattern SLASH
private Note displayedNote
private HtmlPanel displayedPanel
private javax.swing.JWindow displayedWindow
public NoteLayer(java.util.Collection<Note> notes, java.lang.String name)
notes
- A list of notes to show in this layername
- The name of the layer. Typically "Notes"public NoteLayer()
public void hookUpMapView()
Layer
AbstractMapViewPaintable.attachToMapView(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)
hookUpMapView
in class Layer
public void destroy()
Layer
destroy
in interface Destroyable
destroy
in class Layer
public NoteData getNoteData()
public boolean isModified()
AbstractModifiableLayer
isModified
in class AbstractModifiableLayer
public boolean isDownloadable()
DownloadFromServer
DownloadFromServer
interface. A layer that implements the
DownloadFromServer
interface must return true
.isDownloadable
in interface DownloadFromServer
isDownloadable
in class AbstractModifiableLayer
true
if the layer is able to download data; false
, otherwisepublic boolean isUploadable()
UploadToServer
UploadToServer
interface. A layer that implements the
UploadToServer
interface must return true
.isUploadable
in interface UploadToServer
isUploadable
in class AbstractModifiableLayer
true
if the layer is able to upload data; false
, otherwisepublic boolean requiresUploadToServer()
UploadToServer
requiresUploadToServer
in interface UploadToServer
requiresUploadToServer
in class AbstractModifiableLayer
true
if the data managed by this layer needs to be
uploaded to the server because it contains modified data;
false
, otherwisepublic boolean isSavable()
Layer
isSavable
in interface SaveToFile
isSavable
in class Layer
public boolean requiresSaveToFile()
SaveToFile
requiresSaveToFile
in interface SaveToFile
requiresSaveToFile
in class AbstractModifiableLayer
true
if the data managed by this layer needs to be saved to a file; false
, otherwisepublic void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
MapViewPaintable
paint
in interface MapViewPaintable
g
- Graphicsmv
- The object that can translate GeoPoints to screen coordinates.box
- Bounding boxprivate void hideNoteWindow()
private void paintSelectedNote(java.awt.Graphics2D g, MapView mv, int iconHeight, int iconWidth, Note selectedNote)
private java.awt.Point fixPanelSizeAndLocation(MapView mv, java.lang.String text, int xl, int xr, int yt, int yb)
static java.lang.String insertLineBreaks(java.lang.String longText)
<br>
at the end of each sentence mark
(period, interrogation mark, exclamation mark, ideographic full stop).longText
- a long text that does not fit on a single line without exceeding half of the map viewpublic static java.lang.String getNoteToolTip(Note note)
note
- note to displaystatic java.lang.String replaceLinks(java.lang.String htmlText)
public javax.swing.Icon getIcon()
Layer
public java.lang.String getToolTipText()
getToolTipText
in class Layer
public void mergeFrom(Layer from)
Layer
public boolean isMergable(Layer other)
isMergable
in class Layer
other
- The other layer that is tested to be mergable with this.public void visitBoundingBox(BoundingXYVisitor v)
Layer
visitBoundingBox
in class Layer
v
- The visitor that gets notified about the contents of this layer.public java.lang.Object getInfoComponent()
Layer
getInfoComponent
in class Layer
Component
describing the layer.public javax.swing.Action[] getMenuEntries()
Layer
Layer.SeparatorLayerAction.INSTANCE
instead of new JSeparatorgetMenuEntries
in class Layer
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public java.io.File createAndOpenSaveFileChooser()
Layer
createAndOpenSaveFileChooser
in class Layer
File
SaveActionBase.createAndOpenSaveFileChooser(java.lang.String, org.openstreetmap.josm.actions.ExtensionFileFilter)
public AbstractIOTask createUploadTask(ProgressMonitor monitor)
UploadToServer
AbstractIOTask
for uploading data.createUploadTask
in interface UploadToServer
createUploadTask
in class AbstractModifiableLayer
monitor
- The progress monitorAbstractIOTask
for uploading data, or null
if not applicablepublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void noteDataUpdated(NoteData data)
NoteData.NoteDataUpdateListener
noteDataUpdated
in interface NoteData.NoteDataUpdateListener
data
- The data that was changedpublic void selectedNoteChanged(NoteData noteData)
NoteData.NoteDataUpdateListener
selectedNoteChanged
in interface NoteData.NoteDataUpdateListener
noteData
- The data of which the selected node was changed