public abstract class Layer extends AbstractMapViewPaintable implements Destroyable, ProjectionChangeListener
Modifier and Type | Class and Description |
---|---|
static interface |
Layer.LayerAction
Action related to a single layer.
|
static class |
Layer.LayerGpxExportAction
Action that exports the layer as gpx file
|
static class |
Layer.LayerSaveAction
The action to save a layer
|
static class |
Layer.LayerSaveAsAction
Action to save the layer in a new file
|
static interface |
Layer.MultiLayerAction
Action related to several layers.
|
static class |
Layer.SeparatorLayerAction
Special class that can be returned by getMenuEntries when JSeparator needs to be created
|
AbstractMapViewPaintable.CompatibilityModeLayerPainter
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
Modifier and Type | Field and Description |
---|---|
private java.io.File |
associatedFile
If a file is associated with this layer, this variable should be set to it.
|
private boolean |
background
The layer should be handled as a background layer in automatic handling
|
static java.lang.String |
FILTER_STATE_PROP
Property that defines the filter state.
|
private boolean |
isDestroyed |
private java.lang.String |
name
The name of this layer.
|
static java.lang.String |
NAME_PROP
The name property of the layer.
|
private double |
opacity
The opacity of the layer.
|
static java.lang.String |
OPACITY_PROP
The opacity of this layer.
|
protected java.beans.PropertyChangeSupport |
propertyChangeSupport
keeps track of property change listeners
|
private boolean |
renamed
This is set if user renamed this layer.
|
private boolean |
visible
The visibility state of the layer.
|
static java.lang.String |
VISIBLE_PROP
The visibility property for this layer.
|
Constructor and Description |
---|
Layer(java.lang.String name)
Create the layer and fill in the necessary components.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a
PropertyChangeListener |
boolean |
checkSaveConditions()
Checks whether it is ok to launch a save (whether we have data, there is no conflict etc.)
|
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. |
void |
destroy()
Called, when the layer is removed from the mapview and is going to be destroyed.
|
protected void |
fireFilterStateChanged()
fires a property change for the property
FILTER_STATE_PROP . |
protected void |
fireOpacityChanged(double oldValue,
double newValue)
fires a property change for the property
OPACITY_PROP |
protected void |
fireVisibleChanged(boolean oldValue,
boolean newValue)
fires a property change for the property
VISIBLE_PROP |
java.io.File |
getAssociatedFile()
Gets the associated file for this layer.
|
java.lang.String |
getChangesetSourceTag()
Get the source for the layer
|
java.awt.Color |
getColor()
Return the current color of the layer
|
LayerPositionStrategy |
getDefaultLayerPosition()
Gets the strategy that specifies where this layer should be inserted in a layer list.
|
abstract javax.swing.Icon |
getIcon()
Return a representative small image for this layer.
|
abstract java.lang.Object |
getInfoComponent()
Gets the layer information to display to the user.
|
abstract javax.swing.Action[] |
getMenuEntries()
Returns list of actions.
|
java.lang.String |
getName()
Replies the name of the layer
|
double |
getOpacity()
Gets the opacity of the layer, in range 0...1
|
abstract java.lang.String |
getToolTipText() |
ProjectionBounds |
getViewProjectionBounds()
Gets the
ProjectionBounds for this layer to be visible to the user. |
boolean |
hasColor() |
void |
hookUpMapView()
Initialization code, that depends on Main.map.mapView.
|
boolean |
isBackgroundLayer()
Replies true if this layer is a background layer
|
boolean |
isInfoResizable()
Determines if info dialog can be resized (false by default).
|
abstract boolean |
isMergable(Layer other) |
boolean |
isProjectionSupported(Projection proj)
allows to check whether a projection is supported or not
|
boolean |
isRenamed()
Replies true if this layer was renamed by user
|
boolean |
isSavable()
Replies the savable state of this layer (i.e if it can be saved through a "File->Save" dialog).
|
boolean |
isVisible()
Replies true if this layer is visible.
|
abstract void |
mergeFrom(Layer from)
Merges the given layer into this layer.
|
java.lang.String |
nameSupportedProjections()
Specify user information about projections
|
void |
onPostLoadFromFile()
Initializes the layer after a successful load of data from a file
|
void |
projectionChanged(Projection oldValue,
Projection newValue) |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a
PropertyChangeListener |
void |
rename(java.lang.String name)
Rename layer and set renamed flag to mark it as renamed (has user given name).
|
void |
setAssociatedFile(java.io.File file)
Sets the associated file for this layer.
|
void |
setBackgroundLayer(boolean background)
Sets whether this layer is a background layer
|
void |
setColor(java.awt.Color color)
Sets the color for this layer.
|
void |
setFilterStateChanged()
Sets new state to the layer after applying
ImageProcessor . |
void |
setName(java.lang.String name)
Sets the name of the layer
|
void |
setOpacity(double opacity)
Sets the opacity of the layer, in range 0...1
|
void |
setVisible(boolean visible)
Sets the visibility of this layer.
|
void |
toggleVisible()
Toggles the visibility state of this layer.
|
java.lang.String |
toString() |
abstract void |
visitBoundingBox(BoundingXYVisitor v)
Visits the content bounds of this layer.
|
addInvalidationListener, attachToMapView, createMapViewPainter, invalidate, removeInvalidationListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
paint
public static final java.lang.String VISIBLE_PROP
true
(visible) or false
(hidden).public static final java.lang.String OPACITY_PROP
public static final java.lang.String NAME_PROP
public static final java.lang.String FILTER_STATE_PROP
protected java.beans.PropertyChangeSupport propertyChangeSupport
private boolean visible
private double opacity
private boolean background
private java.lang.String name
private boolean renamed
private java.io.File associatedFile
private boolean isDestroyed
public Layer(java.lang.String name)
name
- Layer namepublic void hookUpMapView()
AbstractMapViewPaintable.attachToMapView(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)
public abstract javax.swing.Icon getIcon()
public boolean hasColor()
public java.awt.Color getColor()
public void setColor(java.awt.Color color)
color
- the color to be set, null
for defaultpublic abstract java.lang.String getToolTipText()
public abstract void mergeFrom(Layer from)
from
- The layer that get merged into this one. After the merge,
the other layer is not usable anymore and passing to one others
mergeFrom should be one of the last things to do with a layer.public abstract boolean isMergable(Layer other)
other
- The other layer that is tested to be mergable with this.public abstract void visitBoundingBox(BoundingXYVisitor v)
v
- The visitor that gets notified about the contents of this layer.public abstract java.lang.Object getInfoComponent()
Component
describing the layer.public boolean isInfoResizable()
true
if the info dialog can be resized, false
otherwisepublic abstract javax.swing.Action[] getMenuEntries()
Layer.SeparatorLayerAction.INSTANCE
instead of new JSeparatorpublic void destroy()
destroy
in interface Destroyable
public java.io.File getAssociatedFile()
null
if it is unset.setAssociatedFile(File)
public void setAssociatedFile(java.io.File file)
file
- The file, may be null
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the name. If null, the name is set to the empty string.public final void rename(java.lang.String name)
name
- the name. If null, the name is set to the empty string.public boolean isRenamed()
public boolean isBackgroundLayer()
public void setBackgroundLayer(boolean background)
background
- true, if this layer is a background layerpublic void setVisible(boolean visible)
VISIBLE_PROP
.visible
- true, if the layer is visible; false, otherwise.public boolean isVisible()
public double getOpacity()
public void setOpacity(double opacity)
opacity
- The opacityjava.lang.IllegalArgumentException
- if the opacity is out of rangepublic void setFilterStateChanged()
ImageProcessor
.public void toggleVisible()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
listener
- the listenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
listener
- the listenerprotected void fireVisibleChanged(boolean oldValue, boolean newValue)
VISIBLE_PROP
oldValue
- the old valuenewValue
- the new valueprotected void fireOpacityChanged(double oldValue, double newValue)
OPACITY_PROP
oldValue
- the old valuenewValue
- the new valueprotected void fireFilterStateChanged()
FILTER_STATE_PROP
.public boolean isProjectionSupported(Projection proj)
proj
- projectionpublic java.lang.String nameSupportedProjections()
public void projectionChanged(Projection oldValue, Projection newValue)
projectionChanged
in interface ProjectionChangeListener
public void onPostLoadFromFile()
public boolean isSavable()
public boolean checkSaveConditions()
true
, if it is safe to save.public java.io.File createAndOpenSaveFileChooser()
File
SaveActionBase.createAndOpenSaveFileChooser(java.lang.String, org.openstreetmap.josm.actions.ExtensionFileFilter)
public LayerPositionStrategy getDefaultLayerPosition()
public ProjectionBounds getViewProjectionBounds()
ProjectionBounds
for this layer to be visible to the user. This can be the exact bounds, the UI handles padding. Return
null
if you cannot provide this information. The default implementation uses the bounds from
visitBoundingBox(BoundingXYVisitor)
.public java.lang.String getChangesetSourceTag()
null
public java.lang.String toString()
toString
in class java.lang.Object