net.refractions.udig.project
Interface ILayer

All Superinterfaces:
java.lang.Comparable<ILayer>

public interface ILayer
extends java.lang.Comparable<ILayer>

TODO Purpose of net.refractions.udig.project

Since:
1.0.0
Author:
Jesse

Field Summary
static int DONE
          DONE rendering process completed normally
static int ERROR
          ERROR render process was unable to complete normally
static int MISSING
          MISSING cannot locate a GeoResource for this layer
static int UNCONFIGURED
          UNCONFIGURED associated GeoResource is unconfigured, or is unavailable
static CoordinateReferenceSystem UNKNOWN_CRS
          Indicates the crs that will be used if the layer does not declare a crs.
static int WAIT
          WAIT layer is waiting for information.
static int WARNING
          WARNING render process has produced warning(s) in the log.
static int WORKING
          WORKING rendering process is underway.
 
Method Summary
 void addListener(ILayerListener listener)
          Listen to changes on this layer.
 Filter createBBoxFilter(Envelope boundingBox, IProgressMonitor monitor)
          Creates A geometry filter for the layer.
<T> IGeoResource
findGeoResource(java.lang.Class<T> clazz)
          Locate the first IGeoResource that canResolve the provided resource type.
 IBlackboard getBlackboard()
          Temporary layer properties, used for lightweight collaboration.
 ReferencedEnvelope getBounds(IProgressMonitor monitor, CoordinateReferenceSystem crs)
          Returns the bounds of the layer as best estimated.
 CoordinateReferenceSystem getCRS()
          Gets the CRS for the layer.
 CoordinateReferenceSystem getCRS(IProgressMonitor monitor)
          Deprecated.  
 Filter getFilter()
          Filter indicating the selected features.
 IGeoResource getGeoResource()
          Resource the user associates with this layer.
<T> IGeoResource
getGeoResource(java.lang.Class<T> clazz)
          Deprecated.  
 java.util.List<IGeoResource> getGeoResources()
          Access to resources that hold data for this layer.
 ImageDescriptor getGlyph()
          ImageDescriptor for this Layer.
 java.net.URL getID()
          Gets the unique id, unique within a context model
 IMap getMap()
          The Map that "owns" or "contains" the current layer.
 java.lang.String getName()
          Gets the name from the associated metadata.
 IBlackboard getProperties()
          Deprecated.  
 Query getQuery(boolean selection)
          Query that selects all the features for the layer.
<E> E
getResource(java.lang.Class<E> resourceType, IProgressMonitor monitor)
          Returns a real resource that one of the GeoResources can resolved to.
 FeatureType getSchema()
          Retrieve a schema description of this Layer.
 int getStatus()
          Indication of Layer status.
 java.lang.String getStatusMessage()
          A message to provide the user with additional feed back about the current rendering status.
 IStyleBlackboard getStyleBlackboard()
          StyleBlackboard used for collaboration with the rendering process.
 int getZorder()
          Returns the ZOrder of the Layer.
<T> boolean
hasResource(java.lang.Class<T> resourceType)
          Check if a IGeoResource exists that canResolve to the provided resource type.
 boolean isApplicable(java.lang.String toolCategoryId)
          Check toolset applicability.
<T> boolean
isType(java.lang.Class<T> resourceType)
          Deprecated. use hasResource(Class)
 boolean isVisible()
          Returns whether this layer is currently visible
 MathTransform layerToMapTransform()
          Returns the Mathtransform from this layers CRS to the map's CRS (modelled as part of the viewport model).
 MathTransform mapToLayerTransform()
          Returns the Mathtransform from the map's CRS (modeled as part of the viewport model) to this layers CRS .
 void refresh(Envelope bounds)
          Triggers the layer to rerender if it is currently displayed.
 void removeListener(ILayerListener listener)
          remove LayerListener
 void setStatus(int status)
          Sets the current status of the Layer.
 void setStatusMessage(java.lang.String string)
          Sets the current status message
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

UNKNOWN_CRS

static final CoordinateReferenceSystem UNKNOWN_CRS
Indicates the crs that will be used if the layer does not declare a crs. This crs is wgs84 crs with the name: Messages.LayerImpl_unknown (unkown in english)


UNCONFIGURED

static final int UNCONFIGURED
UNCONFIGURED associated GeoResource is unconfigured, or is unavailable

See Also:
Constant Field Values

MISSING

static final int MISSING
MISSING cannot locate a GeoResource for this layer

See Also:
Constant Field Values

DONE

static final int DONE
DONE rendering process completed normally

See Also:
Constant Field Values

WAIT

static final int WAIT
WAIT layer is waiting for information.

See Also:
Constant Field Values

ERROR

static final int ERROR
ERROR render process was unable to complete normally

See Also:
Constant Field Values

WARNING

static final int WARNING
WARNING render process has produced warning(s) in the log.

See Also:
Constant Field Values

WORKING

static final int WORKING
WORKING rendering process is underway.

Note the default Label decorator makes use of a WORKING_HINT layer property. The rendering process will clear this HINT when starting work, subsequence calls to setState( WORKING ) will cycle the to update the clock.

See Also:
Constant Field Values
Method Detail

addListener

void addListener(ILayerListener listener)
Listen to changes on this layer. Each listener can only be added once


removeListener

void removeListener(ILayerListener listener)
remove LayerListener


getGeoResource

IGeoResource getGeoResource()
Resource the user associates with this layer. This is not the same as getGeoResource(Class clazz).

Returns:
Resource the user associates with this layer.

getGeoResource

<T> IGeoResource getGeoResource(java.lang.Class<T> clazz)
Deprecated. 

Returns the first found geoResource that can resolve to clazz.

Parameters:
clazz - the clazz that the returned georesource can resolve to.
Returns:
the first found geoResource that can resolve to clazz.

findGeoResource

<T> IGeoResource findGeoResource(java.lang.Class<T> clazz)
Locate the first IGeoResource that canResolve the provided resource type.

Example implementation:


 for( IGeoResource resource : getGeoResources() ) {
     if (resource.canResolve(FeatureSource.class)) {
         return resource;
     }
 }
 return null;
 

Parameters:
clazz - class of the resource that the IGeoResource claims it can adapt to.
Returns:
true if a IGeoResource exists that canResolve to resourceType.

getStyleBlackboard

IStyleBlackboard getStyleBlackboard()
StyleBlackboard used for collaboration with the rendering process.

This Blackboard is persisted, any modications made to the blackboard will result refresh of the effected layers.

Returns:
Blackboard used for renderer collaboration.

hasResource

<T> boolean hasResource(java.lang.Class<T> resourceType)
Check if a IGeoResource exists that canResolve to the provided resource type.

Example:


 if (layer.hasResource(FeatureSource.class)) {
     return handle.getResource(FeatureSource.class, monitor);
 }
 

The blocking getResource(Class, IProgressMonitor) method allow the object to be obtained.

Parameters:
resourceType - the type of resource calleer is interested in.
Returns:
true if a IGeoResource exists that canResolve to resourceType.

isType

<T> boolean isType(java.lang.Class<T> resourceType)
Deprecated. use hasResource(Class)

See Also:
hasResource(Class)

getResource

<E> E getResource(java.lang.Class<E> resourceType,
                  IProgressMonitor monitor)
              throws java.io.IOException
Returns a real resource that one of the GeoResources can resolved to.

Note: examples of resources are: FeatureSource, WebMapServer, etc... GeoResources are handles for real resources.

Example implementation:


 for( IGeoResource resource : getGeoResources() ) {
     if (resource.canResolve(FeatureSource.class)) {
         return resource;
     }
 }
 return null;
 

IMPORTANT: unlike using IGeoResource#resolve(Class, IProgressMonitor) getResource(Class, IProgressMonitor) returns the same instance of the resource. The IGeoResource#resolve(Class, IProgressMonitor) method returns a new instance each time and therefore should NOT be used as a replacement for getResource(Class, IProgressMonitor).

Parameters:
resourceType -
Returns:
true if a IGeoResource exists that canResolve to resourceType.
Throws:
java.io.IOException

getFilter

Filter getFilter()
Filter indicating the selected features.

In order for this value to be useful the layer should be selectable, often a single fid filter during user edit opperations.

Note: Filter.ALL indicates no selected Features. (All features are filtered out)

A tool may wish to record the previous Filter, before replacing (or adding to) this value.

Will never return null.

Returns:
Filter indicating the selected features. Filter.ALL indicates no selected Features.

getZorder

int getZorder()
Returns the ZOrder of the Layer. The Z-Order dictates the order in which the Layer is rendered Low z-orders are rendered first and higher z-orders are rendered on top.

Returns:
the ZOrder of the Layer.

getStatus

int getStatus()
Indication of Layer status.

This is used to provide feedback for a Layers rendering status.

Future versions will return an enum.

Returns:

getStatusMessage

java.lang.String getStatusMessage()
A message to provide the user with additional feed back about the current rendering status.

This is used to provide feedback for a Layers rendering status.

Returns:
message to provide the user with additional feed back about the current rendering status.

isApplicable

boolean isApplicable(java.lang.String toolCategoryId)
Check toolset applicability.

Note: some layers may not ever be applicable for certaint toolsets. Sometimes this is can be determined quickly from a layer property like "selectable" for the selection toolset. Other toolsets may need to perform a more detailed examination.

Parameters:
toolCategoryId -
Returns:
See Also:
isSelectable

getName

java.lang.String getName()
Gets the name from the associated metadata.

Returns:
the name from the associated metadata

getID

java.net.URL getID()
Gets the unique id, unique within a context model

Returns:
the id of the layerRef

isVisible

boolean isVisible()
Returns whether this layer is currently visible

Returns:
whether this layer is currently visible

getGeoResources

java.util.List<IGeoResource> getGeoResources()
Access to resources that hold data for this layer.

Returns:
IGeoResources that can used to obtain layer data

getGlyph

ImageDescriptor getGlyph()
ImageDescriptor for this Layer.

Note we need to do the decorator exention on Layer to reflect status.

Returns:
Custom glyph - or null if none available.

getQuery

Query getQuery(boolean selection)
Query that selects all the features for the layer.

The selected flag is used with respect to getFilter():

Convenience method

Parameters:
layer - The layer the Query is associated with.
selection - true will return a query for the selected features.
Returns:
If selection if false then the features that are not selected are returned, otherwise a query that selects all the selected features is returned.

getSchema

FeatureType getSchema()
Retrieve a schema description of this Layer.

This schema can be used to determine the available attributes for use in Style Rule construction. That is we will need to construct an "answer" for this query even if we just have a WMS layer.

This is similar to the following check:


  
   data = getResource();
   <b>return</b> data != null ? data.getSchema() : null;
   
 

Returns:
Schema information if available, otherwise null.

getCRS

CoordinateReferenceSystem getCRS(IProgressMonitor monitor)
Deprecated. 

Gets the CRS for the layer. NOTE: THIS METHOD MAY BLOCK!!!

Parameters:
monitor - may be null.
Returns:
the CoordinateReferenceSystem of the layer or if the CRS cannot be determined. the current map's CRS will be returned, or if this fails the CRS will be WGS84.

getCRS

CoordinateReferenceSystem getCRS()
Gets the CRS for the layer. NOTE: THIS METHOD MAY BLOCK!!!

Returns:
the CoordinateReferenceSystem of the layer or if the CRS cannot be determined. the current map's CRS will be returned, or if this fails the CRS will be WGS84.

refresh

void refresh(Envelope bounds)
Triggers the layer to rerender if it is currently displayed.

Parameters:
bounds - The area to render or the entire viewport if null.

layerToMapTransform

MathTransform layerToMapTransform()
                                  throws java.io.IOException
Returns the Mathtransform from this layers CRS to the map's CRS (modelled as part of the viewport model).

getMap().getViewportModel() will return the ViewportModel.

Throws:
java.io.IOException
See Also:
IViewportModel

mapToLayerTransform

MathTransform mapToLayerTransform()
                                  throws java.io.IOException
Returns the Mathtransform from the map's CRS (modeled as part of the viewport model) to this layers CRS .

getMap().getViewportModel() will return the ViewportModel.

Throws:
java.io.IOException
See Also:
IViewportModel

getProperties

IBlackboard getProperties()
Deprecated. 

Temporary layer properties, used for lightweight collaboration.

Note these values are not persisted, this can act as a blackboard for plugin collabaration. These properties are not saved and are reset when a map is opened.

If you need long term collaboration we can set up a persistent blackboard in the same manner as StyleBlackbord.

Note: Please don't use this to work around limitations of our object model, instead send email and we can set up a long term solution.

Returns:
Blackboard used for lightweight collaboration.

getBlackboard

IBlackboard getBlackboard()
Temporary layer properties, used for lightweight collaboration.

Note these values are not persisted, this can act as a blackboard for plugin collabaration. These properties are not saved and are reset when a map is opened.

If you need long term collaboration we can set up a persistent blackboard in the same manner as IMap.getBlackboard().

Note: Please don't use this to work around limitations of our object model, instead send email and we can set up a long term solution.

Returns:
Blackboard used for lightweight collaboration.

getBounds

ReferencedEnvelope getBounds(IProgressMonitor monitor,
                             CoordinateReferenceSystem crs)
                             throws java.io.IOException
Returns the bounds of the layer as best estimated. The bounds will be reprojected into the crs provided. If the crs parameter is null then the native envelope will be returned. If the native projection is not known or if a transformation is not possible then the native envelope will be returned.. This method may be blocking.

Parameters:
monitor -
crs - the desired CRS for the returned envelope.
Returns:
the envelope of the layer. If the native crs is not known or if a transformation is not possible then the untransformed envelope will be returned.
Throws:
java.io.IOException

createBBoxFilter

Filter createBBoxFilter(Envelope boundingBox,
                        IProgressMonitor monitor)
Creates A geometry filter for the layer.

getMap().getViewportModel() will return the ViewportModel.

Parameters:
boundingBox - in the same crs as the viewport model.
Returns:
a Geometry filter in the correct CRS or null if an exception occurs.
See Also:
IViewportModel

getMap

IMap getMap()
The Map that "owns" or "contains" the current layer.

Returns:
the containing map.

setStatus

void setStatus(int status)
Sets the current status of the Layer.

Parameters:
status - the status. Will be an enum in the future but current EMF implementation prevents this.

setStatusMessage

void setStatusMessage(java.lang.String string)
Sets the current status message

Parameters:
message - the status message