|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.gui.layer.Layer
public abstract class Layer
A layer encapsulates the gui component of one dataset and its representation. Some layers may display data directly imported from OSM server. Other only display background images. Some can be edited, some not. Some are static and other changes dynamically (auto-updated). Layers can be visible or not. Most actions the user can do applies only on selected layers. The available actions depend on the selected layers too. All layers are managed by the MapView. They are displayed in a list to the right of the screen.
Nested Class Summary | |
---|---|
static interface |
Layer.LayerAction
|
static class |
Layer.LayerGpxExportAction
|
static class |
Layer.LayerSaveAction
The action to save a layer |
static class |
Layer.LayerSaveAsAction
|
static interface |
Layer.MultiLayerAction
|
static class |
Layer.SeparatorLayerAction
Special class that can be returned by getMenuEntries when JSeparator needs to be created |
Field Summary | |
---|---|
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 int |
ICON_SIZE
|
private java.lang.String |
name
The name of this layer. |
static java.lang.String |
NAME_PROP
|
private double |
opacity
The opacity of the layer. |
static java.lang.String |
OPACITY_PROP
|
protected java.beans.PropertyChangeSupport |
propertyChangeSupport
keeps track of property change listeners |
private boolean |
visible
The visibility state of the layer. |
static java.lang.String |
VISIBLE_PROP
|
Constructor Summary | |
---|---|
Layer(java.lang.String name)
Create the layer and fill in the necessary components. |
Method Summary | |
---|---|
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 |
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()
|
java.awt.Color |
getColor(boolean ignoreCustom)
Return a Color for this layer. |
abstract javax.swing.Icon |
getIcon()
Return a representative small image for this layer. |
abstract java.lang.Object |
getInfoComponent()
|
abstract javax.swing.Action[] |
getMenuEntries()
Returns list of actions. |
java.lang.String |
getName()
Replies the name of the layer |
double |
getOpacity()
|
abstract java.lang.String |
getToolTipText()
|
void |
hookUpMapView()
Initialization code, that depends on Main.map.mapView. |
boolean |
isBackgroundLayer()
Replies true if this layer is a background layer |
boolean |
isChanged()
Check changed status of layer |
abstract boolean |
isMergable(Layer other)
|
boolean |
isProjectionSupported(Projection proj)
allows to check whether a projection is supported or not |
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 |
abstract void |
paint(java.awt.Graphics2D g,
MapView mv,
Bounds box)
Paint the dataset using the engine set. |
void |
projectionChanged(Projection oldValue,
Projection newValue)
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener |
void |
setAssociatedFile(java.io.File file)
|
void |
setBackgroundLayer(boolean background)
Sets whether this layer is a background layer |
void |
setName(java.lang.String name)
Sets the name of the layer |
void |
setOpacity(double opacity)
|
void |
setVisible(boolean visible)
Sets the visibility of this layer. |
void |
toggleVisible()
Toggles the visibility state of this layer. |
abstract void |
visitBoundingBox(BoundingXYVisitor v)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String VISIBLE_PROP
public static final java.lang.String OPACITY_PROP
public static final java.lang.String NAME_PROP
public static final int ICON_SIZE
protected java.beans.PropertyChangeSupport propertyChangeSupport
private boolean visible
private double opacity
private boolean background
private java.lang.String name
private java.io.File associatedFile
Constructor Detail |
---|
public Layer(java.lang.String name)
Method Detail |
---|
public void hookUpMapView()
public abstract void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
paint
in interface MapViewPaintable
mv
- The object that can translate GeoPoints to screen coordinates.public abstract javax.swing.Icon getIcon()
public java.awt.Color getColor(boolean ignoreCustom)
ignoreCustom
- Custom color should return null, as no default color
is used. When this is true, then even for custom coloring the base
color is returned - mainly for layer internal use.public 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)
public abstract java.lang.Object getInfoComponent()
public abstract javax.swing.Action[] getMenuEntries()
public void destroy()
destroy
in interface Destroyable
public java.io.File getAssociatedFile()
public void setAssociatedFile(java.io.File file)
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 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)
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 valuepublic boolean isChanged()
public boolean isProjectionSupported(Projection proj)
public 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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |