Class FLyrDefault
- All Implemented Interfaces:
ExtendedPropertiesSupport,FLayer,FLayerHidesArea,LayerListener,Projected,org.gvsig.metadata.Metadata,org.gvsig.tools.dispose.Disposable,org.gvsig.tools.dynobject.DynObject,org.gvsig.tools.persistence.Persistent
Implementation of the common characteristics of all layers: visibility, activation, name, ...
Represents the definition of a basic layer, implementing
FLayer, and new functionality:
- Supports transparency.
- Notification of evens produced using this layer.
- Can have internal virtual layers.
- Can have a text layer.
- Supports an strategy for visit its geometries.
- Can have an image in the TOC (table of contents) associated to the state of this layer.
Each graphical layer will inherit from this class and adapt to its particular logic and model according its nature.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longDraw version of the context.protected Set<LayerListener> Array list with all listeners registered to this layer.protected org.gvsig.metadata.MetadataContainerprotected ExtendedPropertiesHelperFields inherited from interface org.gvsig.fmap.mapcontext.layers.FLayer
METADATA_CRS, METADATA_DEFINITION_DESCRIPTION, METADATA_DEFINITION_NAME, METADATA_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the activation of a layer has changed.voidAdds an error reason that describes this layer's wrong status.booleanAdds aLayerListenerto the listener list.voidaddLegendListener(LegendListener listener) booleanAlwais return falseprotected voidCalled by some version of the method setEditing(boolean) overwritten.protected voidvoidclear()This method can be used to have a fast cloned layer.voiddelegate(org.gvsig.tools.dynobject.DynObject dynObject) voidCalled when a draw value of a layer has changed.voidCalled when the edition of a layer has changed.org.gvsig.crs.projection.lib.CoordinateTransformationReturns the transformation coordinates of this layer.intReturns layer tolerance in pixelslongorg.gvsig.tools.dynobject.DynClassgetDynValue(String name) getError(int i) Returns the specified error.Returns a list with all layer errors.Returns a hash map with all new properties associated to this layer.Returns the status of this layer.Returns an string with the information of this layer.Returns allLayerListeners of this layer as an array.URI[]alwais return nullAlwais return null.Returns a reference to the model of this layer, or null if this layer has no model.doubleReturns the maximum scale visible.doubleReturns the minimum scale visible.getName()Returns the name of this layer.intReturns the number of errors which causes this layer to be in unavailable status.Returns the parentFLayersnode of this layer.org.gvsig.crs.projection.lib.ProjectionReturns the current projection.getProperty(Object key) Returns a reference to an object (property) associated to this layer.Returns the image icon that will be shown in the TOC next to this layer.Returns the image icon that will be shown in the TOC next to this layer, according its status.intReturns the transparency level of this layer, in the range 0-255 .booleanhasChangedForDrawing(long value) booleanhasDynValue(String name) booleanhidesThisArea(org.gvsig.fmap.geom.primitive.Envelope area) voidimplement(org.gvsig.tools.dynobject.DynClass dynClass) voidinvokeDynMethod(int code, Object[] args) invokeDynMethod(String name, Object[] args) booleanisActive()Returns if this layer is active or not in TOC.booleanReturns the status of availability of this layer.booleanReturns if this layer is editable.booleanisInTOC()Returns if this layer appears in the TOC.booleanisOk()Returns if this layer hasn't got errors.booleanbooleanReturns if this layer is visible and available.booleanisWithinScale(double scale) Returns if the value ofscaleargument is within the maximum and minimum scale of this layer.booleanReturns the writing status of this layer.voidload()Executes the initialization operations of this layer.voidloadFromState(org.gvsig.tools.persistence.PersistentState state) voidCalled when the name of a layer has changed.Returns a new instance ofComposedLayer.voidreload()Tries recover a layer of a possible error.booleanRemoves theLayerListenerargument from this layer.voidremoveLegendListener(LegendListener listener) voidreProject(org.gvsig.crs.projection.lib.CoordinateTransformation arg0) Changes the projection of this layer.voidsaveToState(org.gvsig.tools.persistence.PersistentState state) voidsetActive(boolean selected) Changes the status of this layer to active or inactive.voidsetAvailable(boolean available) Changes the status of availability of this layer.voidsetCoordTrans(org.gvsig.crs.projection.lib.CoordinateTransformation ct) Sets transformation coordinates for this layer.voidsetDynValue(String name, Object value) voidsetEditing(boolean b) Do nothing.voidvoidsetFLayerStatus(FLayerStatus status) Sets the status of this layer.voidsetInTOC(boolean b) Sets that this layer appears or not in the TOC.voidsetMaxScale(double maxScale) Sets the maximum scale visible.voidsetMinScale(double minScale) Sets the minimum scale visible.voidSets a name to this layer.voidsetParentLayer(FLayers root) Inserts the parentFLayersnode of the layer.voidsetProjection(org.gvsig.crs.projection.lib.Projection proj) Inserts the projection to this layer.voidsetProperty(Object key, Object val) Inserts an object as a property to this layer.voidsetTemporary(boolean temporary) voidsetTocStatusImage(Image tocStatusImage) Inserts the image icon that will be shown in the TOC next to this layer, according its status.voidsetTransparency(int trans) Inserts the transparency level for this layer, the range allowed is 0-255 .voidsetVisible(boolean visibility) Changes the status of this layer to visible or not.toString()protected voidprotected voidupdateDrawVersion(boolean fireEvents) voidCalled when the visibility of a layer has changed.booleanReturnstrueif this layer has the visible status enabled.voidwakeUp()Method called byFLayersto notify this layer that is going to be added.This previous notification is useful for the layers that need do something before being added.Methods inherited from class org.gvsig.tools.dispose.impl.AbstractDisposable
dispose, dispose, doDisposeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.gvsig.tools.dispose.Disposable
disposeMethods inherited from interface org.gvsig.fmap.mapcontext.layers.FLayer
draw, getFullEnvelope, printMethods inherited from interface org.gvsig.metadata.Metadata
getMetadataChildren, getMetadataID
-
Field Details
-
layerListeners
Array list with all listeners registered to this layer.- See Also:
-
metadataContainer
protected org.gvsig.metadata.MetadataContainer metadataContainer -
drawVersion
protected long drawVersionDraw version of the context. It's used for know when de componend has changed any visualization property- See Also:
-
properties
-
-
Constructor Details
-
FLyrDefault
public FLyrDefault(org.gvsig.metadata.MetadataContainer metadataContainer) -
FLyrDefault
public FLyrDefault()
-
-
Method Details
-
getProperty
Description copied from interface:ExtendedPropertiesSupportReturns 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.
- Specified by:
getPropertyin interfaceExtendedPropertiesSupport- Parameters:
key- the key associated to the property- Returns:
nullif key is not found- See Also:
-
setProperty
Description copied from interface:ExtendedPropertiesSupportInserts an object as a property to this layer.- Specified by:
setPropertyin interfaceExtendedPropertiesSupport- Parameters:
key- the key associated to the propertyval- the property- See Also:
-
getExtendedProperties
Description copied from interface:ExtendedPropertiesSupportReturns a hash map with all new properties associated to this layer.- Specified by:
getExtendedPropertiesin interfaceExtendedPropertiesSupport- Returns:
- hash table with the added properties
- See Also:
-
setActive
public void setActive(boolean selected) Description copied from interface:FLayerChanges the status of this layer to active or inactive.
One layer is active if is selected in TOC.
-
isActive
public boolean isActive()Description copied from interface:FLayerReturns if this layer is active or not in TOC.
One layer is active if is selected in TOC.
-
setName
Description copied from interface:FLayerSets a name to this layer. -
getName
Description copied from interface:FLayerReturns the name of this layer. -
load
Description copied from interface:FLayerExecutes the initialization operations of this layer. This method is invoked only one time during the life of this layer and just before visualize it.
- Specified by:
loadin interfaceFLayer- Throws:
LoadLayerException- if fails loading the layer.- See Also:
-
setVisible
public void setVisible(boolean visibility) Description copied from interface:FLayerChanges 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.- Specified by:
setVisiblein interfaceFLayer- Parameters:
visibility- the boolean to be set- See Also:
-
isVisible
public boolean isVisible()Description copied from interface:FLayerReturns 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.
-
getParentLayer
Description copied from interface:FLayerReturns the parentFLayersnode of this layer.- Specified by:
getParentLayerin interfaceFLayer- Returns:
- the parent of this layer, or
nullif hasn't parent - See Also:
-
setParentLayer
Description copied from interface:FLayerInserts the parentFLayersnode of the layer.- Specified by:
setParentLayerin interfaceFLayer- Parameters:
root- aFLayersobject- See Also:
-
setProjection
public void setProjection(org.gvsig.crs.projection.lib.Projection proj) Inserts the projection to this layer.- Specified by:
setProjectionin interfaceFLayer- Parameters:
proj- information about the new projection- See Also:
-
getProjection
public org.gvsig.crs.projection.lib.Projection getProjection()Description copied from interface:ProjectedReturns the current projection.
- Specified by:
getProjectionin interfaceProjected- Returns:
- current projection
- See Also:
-
reProject
public void reProject(org.gvsig.crs.projection.lib.CoordinateTransformation arg0) Changes the projection of this layer.
This method will be overloaded in each kind of layer, according its specific nature.
-
getTransparency
public int getTransparency()Returns the transparency level of this layer, in the range 0-255 .- Returns:
- the transparency level
- See Also:
-
setTransparency
public void setTransparency(int trans) Inserts the transparency level for this layer, the range allowed is 0-255 .- Parameters:
trans- the transparency level- See Also:
-
getMapContext
Description copied from interface:FLayerReturns a reference to the model of this layer, or null if this layer has no model.
- Specified by:
getMapContextin interfaceFLayer- Returns:
- the model of this layer
-
addLayerListener
Description copied from interface:FLayerAdds aLayerListenerto the listener list.- Specified by:
addLayerListenerin interfaceFLayer- Parameters:
o- a layer listener- Returns:
trueif hasn't been any problem during the insertion of the listener- See Also:
-
getLayerListeners
Description copied from interface:FLayerReturns allLayerListeners of this layer as an array.- Specified by:
getLayerListenersin interfaceFLayer- Returns:
- an array with all layer listeners associated to this layer
- See Also:
-
removeLayerListener
Description copied from interface:FLayerRemoves theLayerListenerargument from this layer.- Specified by:
removeLayerListenerin interfaceFLayer- Parameters:
o- a layer listener- Returns:
trueif hasn't been any problem doing this process- See Also:
-
setCoordTrans
public void setCoordTrans(org.gvsig.crs.projection.lib.CoordinateTransformation ct) Sets transformation coordinates for this layer.- Specified by:
setCoordTransin interfaceFLayer- Parameters:
ct- an object that implements theCoordinateTransformationinterface, and with the transformation coordinates- See Also:
-
getCoordTrans
public org.gvsig.crs.projection.lib.CoordinateTransformation getCoordTrans()Returns the transformation coordinates of this layer.- Specified by:
getCoordTransin interfaceFLayer- Returns:
- an object that implements the
CoordinateTransformationinterface, and with the transformation coordinates - See Also:
-
wakeUp
Method called by
FLayersto 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.- Throws:
LoadLayerException
-
getMinScale
public double getMinScale()Description copied from interface:FLayerReturns the minimum scale visible. Lower scales won't be drawn.- Specified by:
getMinScalein interfaceFLayer- Returns:
- the minimum scale > 0, -1 if not defined
- See Also:
-
getMaxScale
public double getMaxScale()Description copied from interface:FLayerReturns the maximum scale visible. Higher scales won't be drawn.- Specified by:
getMaxScalein interfaceFLayer- Returns:
- the maximum scale > 0, -1 if not defined
- See Also:
-
setMinScale
public void setMinScale(double minScale) Description copied from interface:FLayerSets the minimum scale visible. Lower scales won't be drawn.- Specified by:
setMinScalein interfaceFLayer- Parameters:
minScale- the scale > 0, -1 if not defined- See Also:
-
setMaxScale
public void setMaxScale(double maxScale) Description copied from interface:FLayerSets the maximum scale visible. Higher scales won't be drawn.- Specified by:
setMaxScalein interfaceFLayer- Parameters:
maxScale- the scale > 0, -1 if not defined- See Also:
-
isWithinScale
public boolean isWithinScale(double scale) Description copied from interface:FLayerReturns if the value of
scaleargument is within the maximum and minimum scale of this layer.- Specified by:
isWithinScalein interfaceFLayer- Parameters:
scale- the scale > 0- Returns:
trueif thescaleargument is within the range of scales of this layer;falseotherwise- See Also:
-
setEditing
Description copied from interface:FLayerDo nothing.- Specified by:
setEditingin interfaceFLayer- Parameters:
b-- Throws:
StartEditionLayerException
-
callEditionChanged
Called by some version of the method setEditing(boolean) overwritten. Notifies all listeners associated to this layer, that its edition state has changed.- Parameters:
e- a layer event with the name of the property that has changed- See Also:
-
isEditing
public boolean isEditing()Description copied from interface:FLayerReturns if this layer is editable.
One layer is editable if user can modify its information with graphical tools.
-
getTocImageIcon
Description copied from interface:FLayerReturns the image icon that will be shown in the TOC next to this layer.- Specified by:
getTocImageIconin interfaceFLayer- Returns:
- a String reference to the image icon, or
nullif there isn't any
-
isInTOC
public boolean isInTOC()Description copied from interface:FLayerReturns if this layer appears in the TOC.
If doesn't appears, remains in the view and in the project.
-
setInTOC
public void setInTOC(boolean b) Description copied from interface:FLayerSets that this layer appears or not in the TOC.
-
isAvailable
public boolean isAvailable()Description copied from interface:FLayerReturns the status of availability of this layer.
One layer is available if the source of data is on-line.
- Specified by:
isAvailablein interfaceFLayer- Returns:
trueif the source of data is on-line;falseotherwise- See Also:
-
setAvailable
public void setAvailable(boolean available) Description copied from interface:FLayerChanges the status of availability of this layer.
One layer is available if the source of data is on-line.
- Specified by:
setAvailablein interfaceFLayer- Parameters:
available- the boolean to be set- See Also:
-
reload
Description copied from interface:FLayerTries recover a layer of a possible error.
If it has any problem during the load, marks the availability to false and throws an exception.
- Specified by:
reloadin interfaceFLayer- Throws:
ReloadLayerException- if it's thrown aReadExceptionor anIOExceptionduring the load of this layer.- See Also:
-
getFLayerStatus
Description copied from interface:FLayerReturns the status of this layer.- Specified by:
getFLayerStatusin interfaceFLayer- Returns:
- the status stored in a
FLayerStatusobject - See Also:
-
setFLayerStatus
Description copied from interface:FLayerSets the status of this layer.- Specified by:
setFLayerStatusin interfaceFLayer- Parameters:
status- information of the status for this layer- See Also:
-
isOk
public boolean isOk()Description copied from interface:FLayerReturns if this layer hasn't got errors.
-
getNumErrors
public int getNumErrors()Description copied from interface:FLayerReturns the number of errors which causes this layer to be in unavailable status.- Specified by:
getNumErrorsin interfaceFLayer- Returns:
- number of errors >= 0
- See Also:
-
getError
Description copied from interface:FLayerReturns the specified error. -
getErrors
Description copied from interface:FLayerReturns a list with all layer errors. -
addError
Description copied from interface:FLayerAdds an error reason that describes this layer's wrong status. -
setError
-
visibleRequired
public boolean visibleRequired()Description copied from interface:FLayerReturnstrueif this layer has the visible status enabled.- Specified by:
visibleRequiredin interfaceFLayer- Returns:
trueif visible this layer has the visible status enabled, otherwisefalse- See Also:
-
getInfoString
Description copied from interface:FLayerReturns an string with the information of this layer.- Specified by:
getInfoStringin interfaceFLayer- Returns:
- the string that is to be this component's information
-
isWritable
public boolean isWritable()Description copied from interface:FLayerReturns the writing status of this layer.
One layer is writable if there is a writing driver for this layer.
- Specified by:
isWritablein interfaceFLayer- Returns:
trueif there is a writing driver for this layer;falseotherwise
-
cloneLayer
Description copied from interface:FLayerThis 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.
- Specified by:
cloneLayerin interfaceFLayer- Returns:
- a layer that is a clonation of this layer
- Throws:
Exception- any exception produced during the cloning of this layer.
-
getTocStatusImage
Description copied from interface:FLayerReturns the image icon that will be shown in the TOC next to this layer, according its status.- Specified by:
getTocStatusImagein interfaceFLayer- Returns:
- the image
-
setTocStatusImage
Inserts the image icon that will be shown in the TOC next to this layer, according its status.- Parameters:
tocStatusImage- the image- See Also:
-
newComposedLayer
Description copied from interface:FLayerReturns 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.
- Specified by:
newComposedLayerin interfaceFLayer- Returns:
- a new composed layer or
nullif not supported - See Also:
-
allowLinks
public boolean allowLinks()Description copied from interface:FLayerAlwais return false- Specified by:
allowLinksin interfaceFLayer- Returns:
- false
-
getLinkProperties
Description copied from interface:FLayerAlwais return null.- Specified by:
getLinkPropertiesin interfaceFLayer- Returns:
- null
-
getLink
public URI[] getLink(Point2D point, double tolerance) throws org.gvsig.fmap.dal.exception.ReadException Description copied from interface:FLayeralwais return null -
addLegendListener
-
callLegendChanged
- Parameters:
e-- See Also:
-
removeLegendListener
- Parameters:
listener-- See Also:
-
getClassName
-
delegate
public void delegate(org.gvsig.tools.dynobject.DynObject dynObject) - Specified by:
delegatein interfaceorg.gvsig.tools.dynobject.DynObject
-
getDynClass
public org.gvsig.tools.dynobject.DynClass getDynClass()- Specified by:
getDynClassin interfaceorg.gvsig.tools.dynobject.DynObject
-
getDynValue
public Object getDynValue(String name) throws org.gvsig.tools.dynobject.exception.DynFieldNotFoundException - Specified by:
getDynValuein interfaceorg.gvsig.tools.dynobject.DynObject- Throws:
org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
-
hasDynValue
- Specified by:
hasDynValuein interfaceorg.gvsig.tools.dynobject.DynObject
-
implement
public void implement(org.gvsig.tools.dynobject.DynClass dynClass) - Specified by:
implementin interfaceorg.gvsig.tools.dynobject.DynObject
-
invokeDynMethod
public Object invokeDynMethod(int code, Object[] args) throws org.gvsig.tools.dynobject.exception.DynMethodException - Specified by:
invokeDynMethodin interfaceorg.gvsig.tools.dynobject.DynObject- Throws:
org.gvsig.tools.dynobject.exception.DynMethodException
-
invokeDynMethod
public Object invokeDynMethod(String name, Object[] args) throws org.gvsig.tools.dynobject.exception.DynMethodException - Specified by:
invokeDynMethodin interfaceorg.gvsig.tools.dynobject.DynObject- Throws:
org.gvsig.tools.dynobject.exception.DynMethodException
-
setDynValue
public void setDynValue(String name, Object value) throws org.gvsig.tools.dynobject.exception.DynFieldNotFoundException - Specified by:
setDynValuein interfaceorg.gvsig.tools.dynobject.DynObject- Throws:
org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
-
getDrawVersion
public long getDrawVersion()- Specified by:
getDrawVersionin interfaceFLayer
-
updateDrawVersion
protected void updateDrawVersion() -
updateDrawVersion
protected void updateDrawVersion(boolean fireEvents) -
hasChangedForDrawing
public boolean hasChangedForDrawing(long value) -
activationChanged
Description copied from interface:LayerListenerCalled when the activation of a layer has changed.
- Specified by:
activationChangedin interfaceLayerListener- Parameters:
e- an activation changed layer event object
-
drawValueChanged
Description copied from interface:LayerListenerCalled when a draw value of a layer has changed.
- Specified by:
drawValueChangedin interfaceLayerListener- Parameters:
e- an edition changed layer event object
-
editionChanged
Description copied from interface:LayerListenerCalled when the edition of a layer has changed.
- Specified by:
editionChangedin interfaceLayerListener- Parameters:
e- an edition changed layer event object
-
nameChanged
Description copied from interface:LayerListenerCalled when the name of a layer has changed.
- Specified by:
nameChangedin interfaceLayerListener- Parameters:
e- a name changed layer event object
-
visibilityChanged
Description copied from interface:LayerListenerCalled when the visibility of a layer has changed.
- Specified by:
visibilityChangedin interfaceLayerListener- Parameters:
e- a visibility changed layer event object
-
saveToState
public void saveToState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException - Specified by:
saveToStatein interfaceorg.gvsig.tools.persistence.Persistent- Throws:
org.gvsig.tools.persistence.exception.PersistenceException
-
loadFromState
public void loadFromState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException - Specified by:
loadFromStatein interfaceorg.gvsig.tools.persistence.Persistent- Throws:
org.gvsig.tools.persistence.exception.PersistenceException
-
clear
public void clear()- Specified by:
clearin interfaceorg.gvsig.tools.dynobject.DynObject
-
getMetadataName
- Specified by:
getMetadataNamein interfaceorg.gvsig.metadata.Metadata- Throws:
org.gvsig.metadata.exceptions.MetadataException
-
toString
-
hidesThisArea
public boolean hidesThisArea(org.gvsig.fmap.geom.primitive.Envelope area) - Specified by:
hidesThisAreain interfaceFLayerHidesArea
-
isTemporary
public boolean isTemporary()- Specified by:
isTemporaryin interfaceFLayer
-
setTemporary
public void setTemporary(boolean temporary) - Specified by:
setTemporaryin interfaceFLayer
-
getDefaultTolerance
public int getDefaultTolerance()Description copied from interface:FLayerReturns layer tolerance in pixels- Specified by:
getDefaultTolerancein interfaceFLayer- Returns:
- layer tolerance
-
invalidate
public void invalidate()- Specified by:
invalidatein interfaceFLayer
-