public abstract class FLyrDefault extends 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 | Class and Description |
---|---|
static class |
FLyrDefault.RegisterMetadata |
static class |
FLyrDefault.RegisterPersistence |
Modifier and Type | Field and Description |
---|---|
protected Set<LayerListener> |
layerListeners
Array list with all listeners registered to this layer.
|
protected MetadataContainer |
metadataContainer |
METADATA_CRS, METADATA_DEFINITION_DESCRIPTION, METADATA_DEFINITION_NAME, METADATA_NAME
Constructor and Description |
---|
FLyrDefault() |
FLyrDefault(MetadataContainer metadataContainer) |
Modifier and Type | Method and Description |
---|---|
void |
activationChanged(LayerEvent e)
Called when the activation of a layer has changed.
|
void |
addError(Throwable 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()
Alwais return false
|
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(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.
|
String |
getClassName() |
ICoordTrans |
getCoordTrans()
Returns the transformation coordinates of this layer.
|
long |
getDrawVersion() |
DynClass |
getDynClass() |
Object |
getDynValue(String name) |
Throwable |
getError(int i)
Returns the specified error.
|
List<Throwable> |
getErrors()
Returns a list with all layer errors.
|
Map |
getExtendedProperties()
Returns a hash map with all new properties associated to this layer.
|
FLayerStatus |
getFLayerStatus()
Returns the status of this layer.
|
String |
getInfoString()
Returns an string with the information of this layer.
|
LayerListener[] |
getLayerListeners()
Returns all
LayerListener s of this layer as an array. |
URI[] |
getLink(Point2D point,
double tolerance)
alwais return null
|
AbstractLinkProperties |
getLinkProperties()
Alwais return null.
|
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.
|
String |
getMetadataName()
Returns the name of the Metadata, which allows to identify the type in
the Metadata registry.
|
double |
getMinScale()
Returns the minimum scale visible.
|
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. |
IProjection |
getProjection()
Returns the current projection.
|
Object |
getProperty(Object key)
Returns a reference to an object (property) associated to this layer.
|
String |
getTocImageIcon()
Returns the image icon that will be shown in the TOC next to this layer.
|
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(String name) |
boolean |
hidesThisArea(Envelope area) |
void |
implement(DynClass dynClass) |
Object |
invokeDynMethod(int code,
Object[] args) |
Object |
invokeDynMethod(String name,
Object[] args) |
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 |
isTemporary() |
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(PersistentState state)
Set the state of the object from the state passed as parameter.
|
void |
nameChanged(LayerEvent e)
Called when the name of a layer has changed.
|
ComposedLayer |
newComposedLayer()
Returns a new instance of
ComposedLayer . |
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(ICoordTrans arg0)
Changes the projection of this layer.
|
void |
saveToState(PersistentState state)
Saves the internal state of the object on the provided
PersistentState object.
|
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(ICoordTrans ct)
Sets transformation coordinates for this layer.
|
void |
setDynValue(String name,
Object value) |
void |
setEditing(boolean b)
Do nothing.
|
void |
setError(Throwable ex) |
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(String name)
Sets a name to this layer.
|
void |
setParentLayer(FLayers root)
Inserts the parent
FLayers node of the layer. |
void |
setProjection(IProjection proj)
Inserts the projection to this layer.
|
void |
setProperty(Object key,
Object val)
Inserts an object as a property to this layer.
|
void |
setTemporary(boolean temporary) |
void |
setTocStatusImage(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.
|
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()
Deprecated.
no deberia ser necesario llamar a esto, la capa debe comportarse correctamente sin necesidad de llamarlo.
|
dispose, dispose, doDispose
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
draw, getFullEnvelope, print
getMetadataChildren, getMetadataID
dispose
protected Set<LayerListener> layerListeners
protected MetadataContainer metadataContainer
public FLyrDefault(MetadataContainer metadataContainer)
public FLyrDefault()
public Object getProperty(Object key)
ExtendedPropertiesSupport
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 ExtendedPropertiesSupport
key
- the key associated to the propertynull
if key is not foundExtendedPropertiesSupport.getExtendedProperties()
,
ExtendedPropertiesSupport.setProperty(Object, Object)
public void setProperty(Object key, Object val)
ExtendedPropertiesSupport
setProperty
in interface ExtendedPropertiesSupport
key
- the key associated to the propertyval
- the propertyExtendedPropertiesSupport.getProperty(Object)
,
ExtendedPropertiesSupport.getExtendedProperties()
public Map getExtendedProperties()
ExtendedPropertiesSupport
getExtendedProperties
in interface ExtendedPropertiesSupport
ExtendedPropertiesSupport.getProperty(Object)
,
ExtendedPropertiesSupport.setProperty(Object, Object)
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 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 void setName(String name)
FLayer
setName
in interface FLayer
name
- the string that is to be this layer's nameFLayer.getName()
public String getName()
FLayer
getName
in interface FLayer
FLayer.setName(String)
public 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
- if fails loading the layer.FLayer.reload()
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 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 FLayers getParentLayer()
FLayer
FLayers
node of this layer.getParentLayer
in interface FLayer
null
if hasn't parentFLayer.setParentLayer(FLayers)
public void setParentLayer(FLayers root)
FLayer
FLayers
node of the layer.setParentLayer
in interface FLayer
root
- a FLayers
objectFLayer.getParentLayer()
public void setProjection(IProjection proj)
Inserts the projection to this layer.
setProjection
in interface FLayer
proj
- information about the new projection#isReprojectable()
,
#reProject(MapControl)
public IProjection getProjection()
Projected
Returns the current projection.
getProjection
in interface Projected
Projected.reProject(ICoordTrans)
public void reProject(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 Projected
mapC
- MapControl
instance that will reproject this layer#isReprojectable()
,
setProjection(IProjection)
public int getTransparency()
setTransparency(int)
public void setTransparency(int trans)
trans
- the transparency levelgetTransparency()
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 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 LayerListener[] getLayerListeners()
FLayer
LayerListener
s of this layer as an array.getLayerListeners
in interface FLayer
FLayer.addLayerListener(LayerListener)
,
FLayer.removeLayerListener(LayerListener)
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 setCoordTrans(ICoordTrans ct)
setCoordTrans
in interface FLayer
ct
- an object that implements the ICoordTrans
interface, and with the transformation coordinatesgetCoordTrans()
public ICoordTrans getCoordTrans()
getCoordTrans
in interface FLayer
ICoordTrans
interface, and with the transformation coordinatessetCoordTrans(ICoordTrans)
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
public double getMinScale()
FLayer
getMinScale
in interface FLayer
FLayer.setMinScale(double)
public double getMaxScale()
FLayer
getMaxScale
in interface FLayer
FLayer.setMaxScale(double)
public void setMinScale(double minScale)
FLayer
setMinScale
in interface FLayer
minScale
- the scale > 0, -1 if not definedFLayer.getMinScale()
public void setMaxScale(double maxScale)
FLayer
setMaxScale
in interface FLayer
maxScale
- the scale > 0, -1 if not definedFLayer.getMaxScale()
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 void setEditing(boolean b) throws StartEditionLayerException
FLayer
setEditing
in interface FLayer
StartEditionLayerException
protected void callEditionChanged(LayerEvent e)
e
- a layer event with the name of the property that has changedsetEditing(boolean)
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 String getTocImageIcon()
FLayer
getTocImageIcon
in interface FLayer
null
if there isn't anypublic boolean isInTOC()
FLayer
Returns if this layer appears in the TOC.
If doesn't appears, remains in the view and in the project.
public void setInTOC(boolean b)
FLayer
Sets that this layer appears or not in the TOC.
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 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
available
- the boolean to be setFLayer.isAvailable()
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 FLayerStatus getFLayerStatus()
FLayer
getFLayerStatus
in interface FLayer
FLayerStatus
objectFLayer.setFLayerStatus(FLayerStatus)
public void setFLayerStatus(FLayerStatus status)
FLayer
setFLayerStatus
in interface FLayer
status
- information of the status for this layerFLayer.getFLayerStatus()
public boolean isOk()
FLayer
Returns if this layer hasn't got errors.
public int getNumErrors()
FLayer
getNumErrors
in interface FLayer
FLayer.getError(int)
,
FLayer.getErrors()
public Throwable getError(int i)
FLayer
getError
in interface FLayer
i
- index of the error >= 0 && < getNumErrors
FLayer.getNumErrors()
,
FLayer.getErrors()
public List<Throwable> getErrors()
FLayer
getErrors
in interface FLayer
ArrayList
with the errorsFLayer.getError(int)
,
FLayer.getNumErrors()
public void addError(Throwable exception)
FLayer
addError
in interface FLayer
exception
- a BaseException
with the information of the errorFLayer.getNumErrors()
,
FLayer.getError(int)
,
FLayer.getErrors()
public 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 String getInfoString()
FLayer
getInfoString
in interface FLayer
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 FLayer cloneLayer() throws 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
Exception
- any exception produced during the cloning of this layer.public Image getTocStatusImage()
FLayer
getTocStatusImage
in interface FLayer
public void setTocStatusImage(Image tocStatusImage)
tocStatusImage
- the imagegetTocStatusImage()
public 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 boolean allowLinks()
FLayer
allowLinks
in interface FLayer
public AbstractLinkProperties getLinkProperties()
FLayer
getLinkProperties
in interface FLayer
public URI[] getLink(Point2D point, double tolerance) throws ReadException
FLayer
getLink
in interface FLayer
ReadException
public void addLegendListener(LegendListener listener)
protected void callLegendChanged(LegendChangedEvent e)
e
- LayerChangeSupport.callLegendChanged(LegendChangedEvent)
public void removeLegendListener(LegendListener listener)
public String getClassName()
public DynClass getDynClass()
getDynClass
in interface DynObject
public Object getDynValue(String name) throws DynFieldNotFoundException
getDynValue
in interface DynObject
DynFieldNotFoundException
public boolean hasDynValue(String name)
hasDynValue
in interface DynObject
public Object invokeDynMethod(int code, Object[] args) throws DynMethodException
invokeDynMethod
in interface DynObject
DynMethodException
public Object invokeDynMethod(String name, Object[] args) throws DynMethodException
invokeDynMethod
in interface DynObject
DynMethodException
public void setDynValue(String name, Object value) throws DynFieldNotFoundException
setDynValue
in interface DynObject
DynFieldNotFoundException
public long getDrawVersion()
getDrawVersion
in interface FLayer
protected void updateDrawVersion()
public boolean hasChangedForDrawing(long value)
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 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 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 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 void saveToState(PersistentState state) throws PersistenceException
Persistent
saveToState
in interface Persistent
PersistenceException
public void loadFromState(PersistentState state) throws PersistenceException
Persistent
loadFromState
in interface Persistent
PersistenceException
public String getMetadataName() throws MetadataException
Metadata
getMetadataName
in interface Metadata
MetadataException
public boolean hidesThisArea(Envelope area)
hidesThisArea
in interface FLayerHidesArea
public boolean isTemporary()
isTemporary
in interface FLayer
public void setTemporary(boolean temporary)
setTemporary
in interface FLayer