public interface FLayer
extends org.cresques.geo.Projected, org.gvsig.tools.persistence.Persistent, org.gvsig.metadata.Metadata, org.gvsig.tools.dispose.Disposable
Definition of the basic functionality that all kind of FMap layers should implement.
This kind of layers store their data, are drawable, projectable (with a projection), can be a node of a tree of layers, and could be editable and have a cache with previous draws. They also can be visible or not, and active or not.
A layer can also store information about errors produced working with it, and have a name (kind of layer) and a brief summary explaining what's for.
Each particular implementation can add new properties, and limit or expand the functionality.
Projected
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
METADATA_CRS |
static java.lang.String |
METADATA_DEFINITION_DESCRIPTION |
static java.lang.String |
METADATA_DEFINITION_NAME |
static java.lang.String |
METADATA_NAME |
Modifier and Type | Method and Description |
---|---|
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. |
boolean |
allowLinks()
Returns information about if the layer allows HyperLink or not
|
FLayer |
cloneLayer()
This method can be used to have a fast cloned layer.
|
void |
draw(java.awt.image.BufferedImage image,
java.awt.Graphics2D g,
ViewPort viewPort,
org.gvsig.tools.task.Cancellable cancel,
double scale)
Draws the layer using a buffer.
|
org.cresques.cts.ICoordTrans |
getCoordTrans()
Returns the transformation coordinates.
|
long |
getDrawVersion() |
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.
|
org.gvsig.fmap.geom.primitive.Envelope |
getFullEnvelope()
Returns the full extension of the layer node.
|
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.
|
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. |
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.
|
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.
|
ComposedLayer |
newComposedLayer()
Returns a new instance of
ComposedLayer . |
void |
print(java.awt.Graphics2D g,
ViewPort viewPort,
org.gvsig.tools.task.Cancellable cancel,
double scale,
org.gvsig.compat.print.PrintAttributes properties)
Prints this layer according to some properties requested.
|
void |
reload()
Tries recover a layer of a possible error.
|
boolean |
removeLayerListener(LayerListener o)
Removes the
LayerListener argument from this layer. |
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)
Inserts the transformation coordinates.
|
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 obj)
Insets an object as a property to this layer.
|
void |
setVisible(boolean visibility)
Changes the status of this layer to visible or not.
|
boolean |
visibleRequired()
Returns
true if this layer has the visible status enabled. |
getMetadataChildren, getMetadataID, getMetadataName
static final java.lang.String METADATA_CRS
static final java.lang.String METADATA_DEFINITION_DESCRIPTION
static final java.lang.String METADATA_DEFINITION_NAME
static final java.lang.String METADATA_NAME
void addError(org.gvsig.tools.exception.BaseException exception)
error
- a BaseException
with the information of the errorgetNumErrors()
,
getError(int)
,
getErrors()
boolean addLayerListener(LayerListener o)
LayerListener
to the listener list.o
- a layer listenertrue
if hasn't been any problem during the insertion of the listenergetLayerListeners()
,
removeLayerListener(LayerListener)
boolean allowLinks()
FLayer cloneLayer() throws java.lang.Exception
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.
java.lang.Exception
- any exception produced during the cloning of this layer.void draw(java.awt.image.BufferedImage image, java.awt.Graphics2D g, ViewPort viewPort, org.gvsig.tools.task.Cancellable cancel, double scale) throws org.gvsig.fmap.dal.exception.ReadException
image
- an image used to accelerate the screen drawg
- for rendering 2-dimensional shapes, text and images on the Java(tm) platformviewPort
- information for drawing this layercancel
- an object thread that implements the Cancellable
interface, and will allow to cancel the drawscale
- value that represents the scaleorg.gvsig.fmap.dal.exception.ReadException
- if fails the driver used in this method.print(Graphics2D, ViewPort, Cancellable, double, PrintAttributes)
org.cresques.cts.ICoordTrans getCoordTrans()
setCoordTrans(ICoordTrans)
long getDrawVersion()
org.gvsig.tools.exception.BaseException getError(int i)
i
- index of the error >= 0 && < getNumErrors
getNumErrors()
,
getErrors()
java.util.List getErrors()
ArrayList
with the errorsgetError(int)
,
getNumErrors()
java.util.Map getExtendedProperties()
getProperty(Object)
,
setProperty(Object, Object)
FLayerStatus getFLayerStatus()
FLayerStatus
objectsetFLayerStatus(FLayerStatus)
org.gvsig.fmap.geom.primitive.Envelope getFullEnvelope() throws org.gvsig.fmap.dal.exception.ReadException
org.gvsig.fmap.dal.exception.ReadException
- if fails the driver used in this method.java.lang.String getInfoString()
LayerListener[] getLayerListeners()
LayerListener
s of this layer as an array.addLayerListener(LayerListener)
,
removeLayerListener(LayerListener)
java.net.URI[] getLink(java.awt.geom.Point2D point, double tolerance) throws org.gvsig.fmap.dal.exception.ReadException
layer,
- the layerpoint,
- the point to check that is contained or not in the geometries in the layertolerance,
- the tolerance allowed. Allowed margin of error to detect if the point
is contained in some geometries of the layerorg.gvsig.fmap.dal.exception.ReadException
BehaviorException
org.gvsig.fmap.mapcontext.layers.AbstractLinkProperties getLinkProperties()
MapContext getMapContext()
Returns a reference to the model of this layer, or null if this layer has no model.
double getMaxScale()
setMaxScale(double)
double getMinScale()
setMinScale(double)
java.lang.String getName()
setName(String)
int getNumErrors()
getError(int)
,
getErrors()
FLayers getParentLayer()
FLayers
node of this layer.null
if hasn't parentsetParentLayer(FLayers)
java.lang.Object getProperty(java.lang.Object key)
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.
key
- the key associated to the propertynull
if key is not foundgetExtendedProperties()
,
setProperty(Object, Object)
java.lang.String getTocImageIcon()
null
if there isn't anyjava.awt.Image getTocStatusImage()
boolean isActive()
Returns if this layer is active or not in TOC.
One layer is active if is selected in TOC.
true
if this layer is active; false
otherwisesetActive(boolean)
boolean isAvailable()
Returns the status of availability of this layer.
One layer is available if the source of data is on-line.
true
if the source of data is on-line; false
otherwisesetAvailable(boolean)
,
isVisible()
boolean isEditing()
Returns if this layer is editable.
One layer is editable if user can modify its information with graphical tools.
true
if this layer is editable; false
otherwisesetEditing(boolean)
boolean isInTOC()
Returns if this layer appears in the TOC.
If doesn't appears, remains in the view and in the project.
true
if this layer appears in the TOC; false
otherwiseboolean isOk()
Returns if this layer hasn't got errors.
true
if this layer hasn't got errors; false
otherwiseboolean isVisible()
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.
true
if this layer is visible and available; false
otherwiseisAvailable()
,
setAvailable(boolean)
,
visibleRequired()
boolean isWithinScale(double scale)
Returns if the value of scale
argument
is within the maximum and minimum scale of this layer.
scale
- the scale > 0true
if the scale
argument is within the range of scales of this layer; false
otherwisesetMinScale(double)
,
setMaxScale(double)
boolean isWritable()
Returns the writing status of this layer.
One layer is writable if there is a writing driver for this layer.
true
if there is a writing driver for this layer; false
otherwisevoid load() throws LoadLayerException
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.
org.gvsig.fmap.drivers.reading.DriverIOException
- if fails loading the layer.LoadLayerException
reload()
ComposedLayer newComposedLayer()
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.
null
if not supportedComposedLayer
void print(java.awt.Graphics2D g, ViewPort viewPort, org.gvsig.tools.task.Cancellable cancel, double scale, org.gvsig.compat.print.PrintAttributes properties) throws org.gvsig.fmap.dal.exception.ReadException
g
- for rendering 2-dimensional shapes, text and images on the Java(tm) platformviewPort
- the information for drawing the layerscancel
- an object thread that implements the Cancellable
interface, and will allow to cancel the drawscale
- the scale of the view. Must be between getMinScale() and getMaxScale().properties
- a set with the settings to be applied to a whole print job and to all the docs in the print joborg.gvsig.fmap.dal.exception.ReadException
- if fails the driver used in this method.draw(BufferedImage, Graphics2D, ViewPort, Cancellable, double)
void reload() throws ReloadLayerException
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.
ReloadLayerException
- if it's thrown a ReadException
or an
IOException
during the load of this layer.load()
boolean removeLayerListener(LayerListener o)
LayerListener
argument from this layer.o
- a layer listenertrue
if hasn't been any problem doing this processaddLayerListener(LayerListener)
,
getLayerListeners()
void setActive(boolean selected)
Changes the status of this layer to active or inactive.
One layer is active if is selected in TOC.
selected
- the boolean to be setisActive()
void setAvailable(boolean available)
Changes the status of availability of this layer.
One layer is available if the source of data is on-line.
the
- boolean to be setisAvailable()
void setCoordTrans(org.cresques.cts.ICoordTrans ct)
ct
- transformation coordinatesgetCoordTrans()
void setFLayerStatus(FLayerStatus status)
status
- information of the status for this layergetFLayerStatus()
void setInTOC(boolean b)
Sets that this layer appears or not in the TOC.
b
- true
if appears in the TOC; false
otherwisevoid setMaxScale(double maxScale)
maxScale
- the scale > 0, -1 if not definedgetMaxScale()
void setMinScale(double minScale)
minScale
- the scale > 0, -1 if not definedgetMinScale()
void setName(java.lang.String name)
name
- the string that is to be this layer's namegetName()
void setParentLayer(FLayers root)
FLayers
node of the layer.root
- a FLayers
objectgetParentLayer()
void setProjection(org.cresques.cts.IProjection proj)
Inserts the projection to this layer.
proj
- information about the new projectionvoid setProperty(java.lang.Object key, java.lang.Object obj)
key
- the key associated to the propertyobj
- the propertygetProperty(Object)
,
getExtendedProperties()
void setVisible(boolean visibility)
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
.
visibility
- the boolean to be setisVisible()
,
visibleRequired()
,
isAvailable()
boolean visibleRequired()
true
if this layer has the visible status enabled.true
if visible this layer has the visible status enabled, otherwise false
isVisible()
,
setVisible(boolean)
Copyright © 2013 gvSIG Association. All rights reserved.