public abstract class FLyrDefault extends org.gvsig.tools.dispose.impl.AbstractDisposable implements FLayer, FLayerHidesArea, LayerListener
Implementation of the common characteristics of all layers: visibility, activation, name, ...
Represents the definition of a basic layer, implementing FLayer
, and new functionality:
Each graphical layer will inherit from this class and adapt to its particular logic and model according its nature.
FLayer
,
FLayerStatus
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList |
layerListeners
Array list with all listeners registered to this layer.
|
protected org.gvsig.metadata.MetadataContainer |
metadataContainer |
METADATA_CRS, METADATA_DEFINITION_DESCRIPTION, METADATA_DEFINITION_NAME, METADATA_NAME
Constructor and Description |
---|
FLyrDefault() |
FLyrDefault(org.gvsig.metadata.MetadataContainer metadataContainer) |
Modifier and Type | Method and Description |
---|---|
void |
activationChanged(LayerEvent e)
Called when the activation of a layer has changed.
|
void |
addError(org.gvsig.tools.exception.BaseException exception)
Adds an error reason that describes this layer's wrong status.
|
boolean |
addLayerListener(LayerListener o)
Adds a
LayerListener to the listener list. |
void |
addLegendListener(LegendListener listener) |
boolean |
allowLinks()
Returns information about if the layer allows HyperLink or not
|
protected void |
callEditionChanged(LayerEvent e)
Called by some version of the method setEditing(boolean) overwritten.
|
protected void |
callLegendChanged(LegendChangedEvent e) |
void |
clear() |
FLayer |
cloneLayer()
This method can be used to have a fast cloned layer.
|
void |
delegate(org.gvsig.tools.dynobject.DynObject dynObject) |
void |
drawValueChanged(LayerEvent e)
Called when a draw value of a layer has changed.
|
void |
editionChanged(LayerEvent e)
Called when the edition of a layer has changed.
|
java.lang.String |
getClassName() |
org.cresques.cts.ICoordTrans |
getCoordTrans()
Returns the transformation coordinates of this layer.
|
long |
getDrawVersion() |
org.gvsig.tools.dynobject.DynClass |
getDynClass() |
java.lang.Object |
getDynValue(java.lang.String name) |
org.gvsig.tools.exception.BaseException |
getError(int i)
Returns the specified error.
|
java.util.List |
getErrors()
Returns a list with all layer errors.
|
java.util.Map |
getExtendedProperties()
Returns a hash map with all new properties associated to this layer.
|
FLayerStatus |
getFLayerStatus()
Returns the status of this layer.
|
java.lang.String |
getInfoString()
Returns an string with the information of this layer.
|
LayerListener[] |
getLayerListeners()
Returns all
LayerListener s of this layer as an array. |
java.net.URI[] |
getLink(java.awt.geom.Point2D point,
double tolerance)
Provides an array with URIs.
|
org.gvsig.fmap.mapcontext.layers.AbstractLinkProperties |
getLinkProperties()
Returns an instance of AbstractLinkProperties that contains the information
of the HyperLink
|
MapContext |
getMapContext()
Returns a reference to the model of this layer, or null if this layer has no model.
|
double |
getMaxScale()
Returns the maximum scale visible.
|
java.lang.String |
getMetadataName() |
double |
getMinScale()
Returns the minimum scale visible.
|
java.lang.String |
getName()
Returns the name of this layer.
|
int |
getNumErrors()
Returns the number of errors which causes this layer to be in unavailable status.
|
FLayers |
getParentLayer()
Returns the parent
FLayers node of this layer. |
org.cresques.cts.IProjection |
getProjection() |
java.lang.Object |
getProperty(java.lang.Object key)
Returns a reference to an object (property) associated to this layer.
|
java.lang.String |
getTocImageIcon()
Returns the image icon that will be shown in the TOC next to this layer.
|
java.awt.Image |
getTocStatusImage()
Returns the image icon that will be shown in the TOC next to this layer, according its status.
|
int |
getTransparency()
Returns the transparency level of this layer, in the range 0-255 .
|
boolean |
hasChangedForDrawing(long value) |
boolean |
hasDynValue(java.lang.String name) |
boolean |
hidesThisArea(org.gvsig.fmap.geom.primitive.Envelope area) |
void |
implement(org.gvsig.tools.dynobject.DynClass dynClass) |
java.lang.Object |
invokeDynMethod(int code,
org.gvsig.tools.dynobject.DynObject context) |
java.lang.Object |
invokeDynMethod(java.lang.String name,
org.gvsig.tools.dynobject.DynObject context) |
boolean |
isActive()
Returns if this layer is active or not in TOC.
|
boolean |
isAvailable()
Returns the status of availability of this layer.
|
boolean |
isEditing()
Returns if this layer is editable.
|
boolean |
isInTOC()
Returns if this layer appears in the TOC.
|
boolean |
isOk()
Returns if this layer hasn't got errors.
|
boolean |
isVisible()
Returns if this layer is visible and available.
|
boolean |
isWithinScale(double scale)
Returns if the value of
scale argument
is within the maximum and minimum scale of this layer. |
boolean |
isWritable()
Returns the writing status of this layer.
|
void |
load()
Executes the initialization operations of this layer.
|
void |
loadFromState(org.gvsig.tools.persistence.PersistentState state) |
void |
nameChanged(LayerEvent e)
Called when the name of a layer has changed.
|
ComposedLayer |
newComposedLayer()
Returns a new instance of
ComposedLayer . |
static void |
registerMetadata() |
static void |
registerPersistent() |
void |
reload()
Tries recover a layer of a possible error.
|
boolean |
removeLayerListener(LayerListener o)
Removes the
LayerListener argument from this layer. |
void |
removeLegendListener(LegendListener listener) |
void |
reProject(org.cresques.cts.ICoordTrans arg0)
Changes the projection of this layer.
|
void |
saveToState(org.gvsig.tools.persistence.PersistentState state) |
void |
setActive(boolean selected)
Changes the status of this layer to active or inactive.
|
void |
setAvailable(boolean available)
Changes the status of availability of this layer.
|
void |
setCoordTrans(org.cresques.cts.ICoordTrans ct)
Sets transformation coordinates for this layer.
|
void |
setDynValue(java.lang.String name,
java.lang.Object value) |
void |
setEditing(boolean b)
Changes the status of this layer to editable or not.
|
void |
setFLayerStatus(FLayerStatus status)
Sets the status of this layer.
|
void |
setInTOC(boolean b)
Sets that this layer appears or not in the TOC.
|
void |
setMaxScale(double maxScale)
Sets the maximum scale visible.
|
void |
setMinScale(double minScale)
Sets the minimum scale visible.
|
void |
setName(java.lang.String name)
Sets a name to this layer.
|
void |
setParentLayer(FLayers root)
Inserts the parent
FLayers node of the layer. |
void |
setProjection(org.cresques.cts.IProjection proj)
Inserts the projection to this layer.
|
void |
setProperty(java.lang.Object key,
java.lang.Object val)
Insets an object as a property to this layer.
|
void |
setTocStatusImage(java.awt.Image tocStatusImage)
Inserts the image icon that will be shown in the TOC next to this layer, according its status.
|
void |
setTransparency(int trans)
Inserts the transparency level for this layer, the range allowed is 0-255 .
|
void |
setVisible(boolean visibility)
Changes the status of this layer to visible or not.
|
java.lang.String |
toString() |
protected void |
updateDrawVersion() |
void |
visibilityChanged(LayerEvent e)
Called when the visibility of a layer has changed.
|
boolean |
visibleRequired()
Returns
true if this layer has the visible status enabled. |
void |
wakeUp()
Method called by
FLayers to notify this layer that is going to be added. |
dispose, dispose, doDispose
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
draw, getFullEnvelope, print
protected java.util.ArrayList layerListeners
protected org.gvsig.metadata.MetadataContainer metadataContainer
public FLyrDefault()
public FLyrDefault(org.gvsig.metadata.MetadataContainer metadataContainer)
public void activationChanged(LayerEvent e)
LayerListener
Called when the activation of a layer has changed.
activationChanged
in interface LayerListener
e
- an activation changed layer event objectpublic void addError(org.gvsig.tools.exception.BaseException exception)
FLayer
addError
in interface FLayer
FLayer.getNumErrors()
,
FLayer.getError(int)
,
FLayer.getErrors()
public boolean addLayerListener(LayerListener o)
FLayer
LayerListener
to the listener list.addLayerListener
in interface FLayer
o
- a layer listenertrue
if hasn't been any problem during the insertion of the listenerFLayer.getLayerListeners()
,
FLayer.removeLayerListener(LayerListener)
public void addLegendListener(LegendListener listener)
public boolean allowLinks()
FLayer
allowLinks
in interface FLayer
protected void callEditionChanged(LayerEvent e)
e
- a layer event with the name of the property that has changedsetEditing(boolean)
protected void callLegendChanged(LegendChangedEvent e)
public void clear()
clear
in interface org.gvsig.tools.dynobject.DynObject
public FLayer cloneLayer() throws java.lang.Exception
FLayer
This method can be used to have a fast cloned layer.
The implementations should take care of not recreate this layer. Instead of this, is better to use the same source (driver) and deepclone the legend. Exception: the labels aren't deepcloned to avoid memory consumption.
Note: Labels are memory consuming to speed up layers like PostGIS and so on.
cloneLayer
in interface FLayer
java.lang.Exception
- any exception produced during the cloning of this layer.public void delegate(org.gvsig.tools.dynobject.DynObject dynObject)
delegate
in interface org.gvsig.tools.dynobject.DynObject
public void drawValueChanged(LayerEvent e)
LayerListener
Called when a draw value of a layer has changed.
drawValueChanged
in interface LayerListener
e
- an edition changed layer event objectpublic void editionChanged(LayerEvent e)
LayerListener
Called when the edition of a layer has changed.
editionChanged
in interface LayerListener
e
- an edition changed layer event objectpublic java.lang.String getClassName()
public org.cresques.cts.ICoordTrans getCoordTrans()
getCoordTrans
in interface FLayer
ICoordTrans
interface, and with the transformation coordinatessetCoordTrans(ICoordTrans)
public long getDrawVersion()
getDrawVersion
in interface FLayer
public org.gvsig.tools.dynobject.DynClass getDynClass()
getDynClass
in interface org.gvsig.tools.dynobject.DynObject
public java.lang.Object getDynValue(java.lang.String name) throws org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
getDynValue
in interface org.gvsig.tools.dynobject.DynObject
org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
public org.gvsig.tools.exception.BaseException getError(int i)
FLayer
getError
in interface FLayer
i
- index of the error >= 0 && < getNumErrors
FLayer.getNumErrors()
,
FLayer.getErrors()
public java.util.List getErrors()
FLayer
getErrors
in interface FLayer
ArrayList
with the errorsFLayer.getError(int)
,
FLayer.getNumErrors()
public java.util.Map getExtendedProperties()
FLayer
getExtendedProperties
in interface FLayer
FLayer.getProperty(Object)
,
FLayer.setProperty(Object, Object)
public FLayerStatus getFLayerStatus()
FLayer
getFLayerStatus
in interface FLayer
FLayerStatus
objectFLayer.setFLayerStatus(FLayerStatus)
public java.lang.String getInfoString()
FLayer
getInfoString
in interface FLayer
public LayerListener[] getLayerListeners()
FLayer
LayerListener
s of this layer as an array.getLayerListeners
in interface FLayer
FLayer.addLayerListener(LayerListener)
,
FLayer.removeLayerListener(LayerListener)
public java.net.URI[] getLink(java.awt.geom.Point2D point, double tolerance) throws org.gvsig.fmap.dal.exception.ReadException
FLayer
public org.gvsig.fmap.mapcontext.layers.AbstractLinkProperties getLinkProperties()
FLayer
getLinkProperties
in interface FLayer
public MapContext getMapContext()
FLayer
Returns a reference to the model of this layer, or null if this layer has no model.
getMapContext
in interface FLayer
public double getMaxScale()
FLayer
getMaxScale
in interface FLayer
FLayer.setMaxScale(double)
public java.lang.String getMetadataName() throws org.gvsig.metadata.exceptions.MetadataException
getMetadataName
in interface org.gvsig.metadata.Metadata
org.gvsig.metadata.exceptions.MetadataException
public double getMinScale()
FLayer
getMinScale
in interface FLayer
FLayer.setMinScale(double)
public java.lang.String getName()
FLayer
getName
in interface FLayer
FLayer.setName(String)
public int getNumErrors()
FLayer
getNumErrors
in interface FLayer
FLayer.getError(int)
,
FLayer.getErrors()
public FLayers getParentLayer()
FLayer
FLayers
node of this layer.getParentLayer
in interface FLayer
null
if hasn't parentFLayer.setParentLayer(FLayers)
public org.cresques.cts.IProjection getProjection()
getProjection
in interface org.cresques.geo.Projected
public java.lang.Object getProperty(java.lang.Object key)
FLayer
Returns a reference to an object (property) associated to this layer.
For example, you can attach a network definition to key "network" and check if a layer has a network loaded using getAssociatedObject("network") and that it's not null.
getProperty
in interface FLayer
key
- the key associated to the propertynull
if key is not foundFLayer.getExtendedProperties()
,
FLayer.setProperty(Object, Object)
public java.lang.String getTocImageIcon()
FLayer
getTocImageIcon
in interface FLayer
null
if there isn't anypublic java.awt.Image getTocStatusImage()
FLayer
getTocStatusImage
in interface FLayer
public int getTransparency()
setTransparency(int)
public boolean hasChangedForDrawing(long value)
public boolean hasDynValue(java.lang.String name)
hasDynValue
in interface org.gvsig.tools.dynobject.DynObject
public boolean hidesThisArea(org.gvsig.fmap.geom.primitive.Envelope area)
hidesThisArea
in interface FLayerHidesArea
public void implement(org.gvsig.tools.dynobject.DynClass dynClass)
implement
in interface org.gvsig.tools.dynobject.DynObject
public java.lang.Object invokeDynMethod(int code, org.gvsig.tools.dynobject.DynObject context) throws org.gvsig.tools.dynobject.exception.DynMethodException
invokeDynMethod
in interface org.gvsig.tools.dynobject.DynObject
org.gvsig.tools.dynobject.exception.DynMethodException
public java.lang.Object invokeDynMethod(java.lang.String name, org.gvsig.tools.dynobject.DynObject context) throws org.gvsig.tools.dynobject.exception.DynMethodException
invokeDynMethod
in interface org.gvsig.tools.dynobject.DynObject
org.gvsig.tools.dynobject.exception.DynMethodException
public boolean isActive()
FLayer
Returns if this layer is active or not in TOC.
One layer is active if is selected in TOC.
isActive
in interface FLayer
true
if this layer is active; false
otherwiseFLayer.setActive(boolean)
public boolean isAvailable()
FLayer
Returns the status of availability of this layer.
One layer is available if the source of data is on-line.
isAvailable
in interface FLayer
true
if the source of data is on-line; false
otherwiseFLayer.setAvailable(boolean)
,
FLayer.isVisible()
public boolean isEditing()
FLayer
Returns if this layer is editable.
One layer is editable if user can modify its information with graphical tools.
isEditing
in interface FLayer
true
if this layer is editable; false
otherwiseFLayer.setEditing(boolean)
public boolean isInTOC()
FLayer
Returns if this layer appears in the TOC.
If doesn't appears, remains in the view and in the project.
public boolean isOk()
FLayer
Returns if this layer hasn't got errors.
public boolean isVisible()
FLayer
Returns if this layer is visible and available.
One layer is visible if it's check box associated is selected. This means that layer will tried to be painted.
One layer is available if the source of data is on-line.
It's probably that one layer selected hadn't available it's data, for example in a remote service.
isVisible
in interface FLayer
true
if this layer is visible and available; false
otherwiseFLayer.isAvailable()
,
FLayer.setAvailable(boolean)
,
FLayer.visibleRequired()
public boolean isWithinScale(double scale)
FLayer
Returns if the value of scale
argument
is within the maximum and minimum scale of this layer.
isWithinScale
in interface FLayer
scale
- the scale > 0true
if the scale
argument is within the range of scales of this layer; false
otherwiseFLayer.setMinScale(double)
,
FLayer.setMaxScale(double)
public boolean isWritable()
FLayer
Returns the writing status of this layer.
One layer is writable if there is a writing driver for this layer.
isWritable
in interface FLayer
true
if there is a writing driver for this layer; false
otherwisepublic void load() throws LoadLayerException
FLayer
Executes the initialization operations of this layer. This method is invoked only one time during the life of this layer and just before visualize it.
load
in interface FLayer
LoadLayerException
FLayer.reload()
public void loadFromState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException
loadFromState
in interface org.gvsig.tools.persistence.Persistent
org.gvsig.tools.persistence.exception.PersistenceException
public void nameChanged(LayerEvent e)
LayerListener
Called when the name of a layer has changed.
nameChanged
in interface LayerListener
e
- a name changed layer event objectpublic ComposedLayer newComposedLayer()
FLayer
Returns a new instance of ComposedLayer
.
This allows make a single draw for a group of layers with the same source.
If this operation isn't applicable for this kind of layer, this method returns null.
By default this operation is not supported.
newComposedLayer
in interface FLayer
null
if not supportedComposedLayer
public static void registerMetadata()
public static void registerPersistent()
public void reload() throws ReloadLayerException
FLayer
Tries recover a layer of a possible error.
If it has any problem during the load, marks the availability to false and throws an exception.
reload
in interface FLayer
ReloadLayerException
- if it's thrown a ReadException
or an
IOException
during the load of this layer.FLayer.load()
public boolean removeLayerListener(LayerListener o)
FLayer
LayerListener
argument from this layer.removeLayerListener
in interface FLayer
o
- a layer listenertrue
if hasn't been any problem doing this processFLayer.addLayerListener(LayerListener)
,
FLayer.getLayerListeners()
public void removeLegendListener(LegendListener listener)
public void reProject(org.cresques.cts.ICoordTrans arg0)
Changes the projection of this layer.
This method will be overloaded in each kind of layer, according its specific nature.
reProject
in interface org.cresques.geo.Projected
mapC
- MapControl
instance that will reproject this layer#isReprojectable()
,
setProjection(IProjection)
public void saveToState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException
saveToState
in interface org.gvsig.tools.persistence.Persistent
org.gvsig.tools.persistence.exception.PersistenceException
public void setActive(boolean selected)
FLayer
Changes the status of this layer to active or inactive.
One layer is active if is selected in TOC.
setActive
in interface FLayer
selected
- the boolean to be setFLayer.isActive()
public void setAvailable(boolean available)
FLayer
Changes the status of availability of this layer.
One layer is available if the source of data is on-line.
setAvailable
in interface FLayer
FLayer.isAvailable()
public void setCoordTrans(org.cresques.cts.ICoordTrans ct)
setCoordTrans
in interface FLayer
ct
- an object that implements the ICoordTrans
interface, and with the transformation coordinatesgetCoordTrans()
public void setDynValue(java.lang.String name, java.lang.Object value) throws org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
setDynValue
in interface org.gvsig.tools.dynobject.DynObject
org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
public void setEditing(boolean b) throws StartEditionLayerException
FLayer
Changes the status of this layer to editable or not.
One layer is editable if user can modify its information with graphical tools.
setEditing
in interface FLayer
b
- the boolean to be setStartEditionLayerException
FLayer.isEditing()
public void setFLayerStatus(FLayerStatus status)
FLayer
setFLayerStatus
in interface FLayer
status
- information of the status for this layerFLayer.getFLayerStatus()
public void setInTOC(boolean b)
FLayer
Sets that this layer appears or not in the TOC.
public void setMaxScale(double maxScale)
FLayer
setMaxScale
in interface FLayer
maxScale
- the scale > 0, -1 if not definedFLayer.getMaxScale()
public void setMinScale(double minScale)
FLayer
setMinScale
in interface FLayer
minScale
- the scale > 0, -1 if not definedFLayer.getMinScale()
public void setName(java.lang.String name)
FLayer
setName
in interface FLayer
name
- the string that is to be this layer's nameFLayer.getName()
public void setParentLayer(FLayers root)
FLayer
FLayers
node of the layer.setParentLayer
in interface FLayer
root
- a FLayers
objectFLayer.getParentLayer()
public void setProjection(org.cresques.cts.IProjection proj)
Inserts the projection to this layer.
setProjection
in interface FLayer
proj
- information about the new projection#isReprojectable()
,
#reProject(MapControl)
public void setProperty(java.lang.Object key, java.lang.Object val)
FLayer
setProperty
in interface FLayer
key
- the key associated to the propertyval
- the propertyFLayer.getProperty(Object)
,
FLayer.getExtendedProperties()
public void setTocStatusImage(java.awt.Image tocStatusImage)
tocStatusImage
- the imagegetTocStatusImage()
public void setTransparency(int trans)
trans
- the transparency levelgetTransparency()
public void setVisible(boolean visibility)
FLayer
Changes the status of this layer to visible or not.
One layer is visible if it's check box associated is selected. This means
that layer will tried to be painted. If the data associated isn't available,
then this property will change to false
.
setVisible
in interface FLayer
visibility
- the boolean to be setFLayer.isVisible()
,
FLayer.visibleRequired()
,
FLayer.isAvailable()
public java.lang.String toString()
toString
in class java.lang.Object
protected void updateDrawVersion()
public void visibilityChanged(LayerEvent e)
LayerListener
Called when the visibility of a layer has changed.
visibilityChanged
in interface LayerListener
e
- a visibility changed layer event objectpublic boolean visibleRequired()
FLayer
true
if this layer has the visible status enabled.visibleRequired
in interface FLayer
true
if visible this layer has the visible status enabled, otherwise false
FLayer.isVisible()
,
FLayer.setVisible(boolean)
public void wakeUp() throws LoadLayerException
Method called by FLayers
to notify this layer that is going to be added.
This previous notification is useful for the layers that need do something before being added. For
example, the raster needs reopen a file that could have been closed recently.
LoadLayerException
Copyright © 2013 gvSIG Association. All rights reserved.