[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| [udig-devel] new documentation page interceptors | 
| One of the things I have been doing is updating the documentation associated with each of the extension points;  and one of the fields I get to fill in is that of "supplied implementation" which I am pointing to a wiki page. 
 Thanks to Jim for supplying the example used on that page. 
 | 
Title: layerInterceptor
layerInterceptor
Identifier: 
net.refractions.udig.project.layerInterceptor
Since: 
[Enter the first release in which this extension point appears.]
Description: 
Layer Interceptors allow customized actions to be executed at certain points in a Layer's life cycle.  The points available are: Layer creation, Layer being added to a Map and layer being removed from a map.
Configuration Markup:
<!ELEMENT extension (layerCreated* , layerAdded* , layerRemoved*)>
<!ATTLIST extension
point CDATA #REQUIRED
id    CDATA #IMPLIED
name  CDATA #IMPLIED
>
<!ELEMENT layerCreated EMPTY>
<!ATTLIST layerCreated
id    CDATA #REQUIRED
name  CDATA #IMPLIED
class CDATA #REQUIRED
>
An interceptor that will be ran when a layer is created.  This is only ran if the layer is created by a Map's LayerFactory class.  Not ProjectPackage's createLayer() methods.
- id - an id for the extension
- name - A name for the interceptor
- class - The interceptor class.
<!ELEMENT layerAdded EMPTY>
<!ATTLIST layerAdded
id    CDATA #REQUIRED
name  CDATA #IMPLIED
class CDATA #REQUIRED
>
An interceptor that will be ran when a layer is added to a map.
- id - an id for the extension
- name - A name for the interceptor
- class - The interceptor class.
<!ELEMENT layerRemoved EMPTY>
<!ATTLIST layerRemoved
id    CDATA #REQUIRED
name  CDATA #IMPLIED
class CDATA #REQUIRED
>
An interceptor that will be ran when a layer is about to be removed from a map.  The method is called before the layer has been removed.
- id - an id for the extension
- name - A name for the interceptor
- class - The interceptor class.
Examples: 
An example use is:
<layerCreated
  class="net.refractions.udig.project.internal.impl.SetStyleInterceptor"
  id="net.refractions.udig.project.setStyleInterceptor"
  name="Set Layer Style"/>
This entry is used to advertise the SetStyleInterceptor to uDig so that it can be used to configure a layer as it is created.
A layer interceptor is free to change more then just the layer under observation; as an example a layer interceptor is used to expand or set the bounds of a map when it is added.
public class InitMapBoundsInterceptor implements LayerInterceptor {
    public void run( Layer layer ) {
        if(layer.getMap()==null ){
            return; // this check is here because we could be doing a copy            
        }
        Map map = layer.getMapInternal();
        ReferencedEnvelope bounds = map.getViewportModelInternal().getBounds();
        
        //  If first layer or if the crs has been unchanged from the original BBox
  if( map.getMapLayers().size()==1 || bounds==ViewportModel.NIL_BBOX){
            bounds = map.getBounds(ProgressManager.instance().get());
            map.getViewportModelInternal().setBounds(bounds);
        }
    }
}
API Information: 
Implementors are responsible for providing an implementation of LayerInterceptor.
Supplied Implementation: 
The developers guide has a page on 
Interceptors.