org.geotools.renderer.lite.gridcoverage2d
Class BaseCoverageProcessingNode

java.lang.Object
  extended by org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode
All Implemented Interfaces:
CoverageProcessingNode

public abstract class BaseCoverageProcessingNode
extends java.lang.Object
implements CoverageProcessingNode

Base implementation of a CoverageProcessingNode .

This implementation provides convenient methods for managing sinks and source for a CoverageProcessingNode . The getOutput() is used to get the output of this CoverageProcessingNode (a CoverageProcessingException is thrown in case something bad happens while processing

Implementors must implement the abstract method execute() which is guaranteed to run in a critical section where the sources and sinks for this CoverageProcessingNode will not be touched.

Author:
Simone Giannecchini, GeoSolutions.

Constructor Summary
BaseCoverageProcessingNode(org.opengis.util.InternationalString name, org.opengis.util.InternationalString description)
          Default constructor
BaseCoverageProcessingNode(int maxSources, Hints hints, org.opengis.util.InternationalString name, org.opengis.util.InternationalString description)
          Default constructor that gives users the possibility
BaseCoverageProcessingNode(int maxSources, org.opengis.util.InternationalString name, org.opengis.util.InternationalString description)
          Default constructor that gives users the possibility
 
Method Summary
 void addSink(CoverageProcessingNode sink)
          Adds a sink CoverageProcessingNode to the list of sinks for this CoverageProcessingNode.
 boolean addSource(CoverageProcessingNode source)
          Adds a source CoverageProcessingNode to the list of sources for this CoverageProcessingNode.
 void dispose(boolean force)
          Disposes this CoverageProcessingNode along with all the resources it might have allocated
protected static void ensureNotNull(java.lang.Object source, java.lang.String name)
          Checks whether the provided object is null or not.
protected static void ensureSourceNotNull(java.lang.Object source, java.lang.String name)
          Checks whether the provided source object is null or not.
protected abstract  org.opengis.coverage.grid.GridCoverage execute()
          Subclasses MUST override this method in order to do the actual processing.
 GridCoverageFactory getCoverageFactory()
          The GridCoverageFactory we will internally use for build intermediate and output GridCoverage2D .
 org.opengis.util.InternationalString getDescription()
          Retrieves the description for this CoverageProcessingNode
 Hints getHints()
          Getter for Hints .
 int getMaximumNumberOfSources()
          retrieves the maximum number of sources we are allowed to set for this CoverageProcessingNode
 org.opengis.util.InternationalString getName()
          Retrieves the name for this CoverageProcessingNode
 int getNumberOfSinks()
          Returns the number of sinks for this CoverageProcessingNode.
 int getNumberOfSources()
          Returns the number of sources for this CoverageProcessingNode.
 GridCoverage2D getOutput()
          This method is responsible for triggering the execution of this CoverageProcessingNode and also of all its sources.
 CoverageProcessingNode getSink(int index)
          Retrieves the sink located at index index in the List of sinks for this CoverageProcessingNode.
 java.util.List<CoverageProcessingNode> getSinks()
          Retrieves the List of sinks for this CoverageProcessingNode.
 CoverageProcessingNode getSource(int index)
          Retrieves the source located at index index in the List of sources for this CoverageProcessingNode.
 java.util.List<CoverageProcessingNode> getSources()
          Retrieves the List of source for this CoverageProcessingNode.
 boolean isDisposed()
          Tells me whether or not the node has been already disposed.
 boolean isExecuted()
          Tells me whether or not the node has been already executed.
 boolean removeSink(CoverageProcessingNode sink)
          Removes a sink CoverageProcessingNode from the list of sinks for this CoverageProcessingNode.
 CoverageProcessingNode removeSink(int index)
          Removes a sink CoverageProcessingNode from the list of sinks for this CoverageProcessingNode.
 boolean removeSource(CoverageProcessingNode source)
          Removes a source CoverageProcessingNode to the list of sources for this CoverageProcessingNode.
 CoverageProcessingNode removeSource(int index)
          Removes a source CoverageProcessingNode to the list of sources for this CoverageProcessingNode.
 java.lang.String toString()
          Provides a descriptive description for this CoverageProcessingNode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseCoverageProcessingNode

public BaseCoverageProcessingNode(org.opengis.util.InternationalString name,
                                  org.opengis.util.InternationalString description)
Default constructor


BaseCoverageProcessingNode

public BaseCoverageProcessingNode(int maxSources,
                                  org.opengis.util.InternationalString name,
                                  org.opengis.util.InternationalString description)
Default constructor that gives users the possibility

Parameters:
maxSources - maximum number of sources allowed for this node.
description -
name -

BaseCoverageProcessingNode

public BaseCoverageProcessingNode(int maxSources,
                                  Hints hints,
                                  org.opengis.util.InternationalString name,
                                  org.opengis.util.InternationalString description)
Default constructor that gives users the possibility

Parameters:
maxSources - maximum number of sources allowed for this node.
hints - instance of Hints class to control creation of internal factories. It can be null.
description -
name -
Method Detail

execute

protected abstract org.opengis.coverage.grid.GridCoverage execute()
Subclasses MUST override this method in order to do the actual processing.

Note that this method is invoked through this framework hence it is run within a critical section. Be careful with what you do within this method since it is essentially an "alien" method running within a synch section, hence all sort of bad things can happen.

Returns:
a GridCoverage2D which is the result of the processing.

dispose

public void dispose(boolean force)
Disposes this CoverageProcessingNode along with all the resources it might have allocated

The result for this CoverageProcessingNode is also disposed.

Specified by:
dispose in interface CoverageProcessingNode
Parameters:
force - force the disposition of this node.

getOutput

public GridCoverage2D getOutput()
                         throws CoverageProcessingException
This method is responsible for triggering the execution of this CoverageProcessingNode and also of all its sources.

In case something bad happens a CoverageProcessingException is thrown.

Specified by:
getOutput in interface CoverageProcessingNode
Returns:
the Coverage which represents the output for this CoverageProcessingNode.
Throws:
CoverageProcessingException

addSink

public void addSink(CoverageProcessingNode sink)
Description copied from interface: CoverageProcessingNode
Adds a sink CoverageProcessingNode to the list of sinks for this CoverageProcessingNode.

Specified by:
addSink in interface CoverageProcessingNode

addSource

public boolean addSource(CoverageProcessingNode source)
Description copied from interface: CoverageProcessingNode
Adds a source CoverageProcessingNode to the list of sources for this CoverageProcessingNode.

Specified by:
addSource in interface CoverageProcessingNode
Parameters:
source - the CoverageProcessingNode to add to the List of sources for this CoverageProcessingNode.
Returns:
true if everything goes fine, false otherwise.

getSink

public CoverageProcessingNode getSink(int index)
Description copied from interface: CoverageProcessingNode
Retrieves the sink located at index index in the List of sinks for this CoverageProcessingNode.

Specified by:
getSink in interface CoverageProcessingNode
Parameters:
index - is the zero-based index for the source we want to access.
Returns:
the CoverageProcessingNode which represents the source at index index for this CoverageProcessingNode.

getSinks

public java.util.List<CoverageProcessingNode> getSinks()
Description copied from interface: CoverageProcessingNode
Retrieves the List of sinks for this CoverageProcessingNode. Each sink MUST be a CoverageProcessingNode.

Specified by:
getSinks in interface CoverageProcessingNode
Returns:

getSource

public CoverageProcessingNode getSource(int index)
Description copied from interface: CoverageProcessingNode
Retrieves the source located at index index in the List of sources for this CoverageProcessingNode.

Specified by:
getSource in interface CoverageProcessingNode
Parameters:
index - is the zero-based index for the sink we want to get.
Returns:
the CoverageProcessingNode which represents the sink at index index for this CoverageProcessingNode.

getSources

public java.util.List<CoverageProcessingNode> getSources()
Description copied from interface: CoverageProcessingNode
Retrieves the List of source for this CoverageProcessingNode. Each source MUST be a CoverageProcessingNode.

Specified by:
getSources in interface CoverageProcessingNode
Returns:

removeSink

public boolean removeSink(CoverageProcessingNode sink)
Description copied from interface: CoverageProcessingNode
Removes a sink CoverageProcessingNode from the list of sinks for this CoverageProcessingNode.

Specified by:
removeSink in interface CoverageProcessingNode
Parameters:
sink - the CoverageProcessingNode to remove from the List of sinks for this CoverageProcessingNode.
Returns:
true in case we remove something, false otherwise.

removeSink

public CoverageProcessingNode removeSink(int index)
Description copied from interface: CoverageProcessingNode
Removes a sink CoverageProcessingNode from the list of sinks for this CoverageProcessingNode.

Specified by:
removeSink in interface CoverageProcessingNode
Parameters:
index - the index at which we want to remove a sink from the List of sinks for this CoverageProcessingNode.
Returns:
the CoverageProcessingNode we actually remove from the sinks list.

removeSource

public boolean removeSource(CoverageProcessingNode source)
Description copied from interface: CoverageProcessingNode
Removes a source CoverageProcessingNode to the list of sources for this CoverageProcessingNode.

Specified by:
removeSource in interface CoverageProcessingNode
Returns:
true in case we remove something, false otherwise.

getHints

public Hints getHints()
Getter for Hints .

Specified by:
getHints in interface CoverageProcessingNode
Returns:
Hints provided at construction time to control GridCoverageFactory creation.

getMaximumNumberOfSources

public int getMaximumNumberOfSources()
retrieves the maximum number of sources we are allowed to set for this CoverageProcessingNode

Returns:
the maximum number of sources we are allowed to set for this CoverageProcessingNode

getCoverageFactory

public GridCoverageFactory getCoverageFactory()
The GridCoverageFactory we will internally use for build intermediate and output GridCoverage2D .

Specified by:
getCoverageFactory in interface CoverageProcessingNode
Returns:
a GridCoverageFactory we will internally use for build intermediate and output GridCoverage2D .

getNumberOfSinks

public int getNumberOfSinks()
Description copied from interface: CoverageProcessingNode
Returns the number of sinks for this CoverageProcessingNode.

Specified by:
getNumberOfSinks in interface CoverageProcessingNode
Returns:
the number of sinks for this CoverageProcessingNode.

getNumberOfSources

public int getNumberOfSources()
Description copied from interface: CoverageProcessingNode
Returns the number of sources for this CoverageProcessingNode.

Specified by:
getNumberOfSources in interface CoverageProcessingNode
Returns:
the number of sources for this CoverageProcessingNode.

getDescription

public org.opengis.util.InternationalString getDescription()
Description copied from interface: CoverageProcessingNode
Retrieves the description for this CoverageProcessingNode

Specified by:
getDescription in interface CoverageProcessingNode
Returns:

getName

public org.opengis.util.InternationalString getName()
Description copied from interface: CoverageProcessingNode
Retrieves the name for this CoverageProcessingNode

Specified by:
getName in interface CoverageProcessingNode
Returns:

ensureSourceNotNull

protected static void ensureSourceNotNull(java.lang.Object source,
                                          java.lang.String name)
Checks whether the provided source object is null or not. If it is null it throws an IllegalArgumentException exception.

Parameters:
source - the object to check.
node - the operation we are trying to run.

ensureNotNull

protected static void ensureNotNull(java.lang.Object source,
                                    java.lang.String name)
Checks whether the provided object is null or not. If it is null it throws an IllegalArgumentException exception.

Parameters:
source - the object to check.
node - the operation we are trying to run.

removeSource

public CoverageProcessingNode removeSource(int index)
                                    throws java.lang.IndexOutOfBoundsException
Description copied from interface: CoverageProcessingNode
Removes a source CoverageProcessingNode to the list of sources for this CoverageProcessingNode.

Specified by:
removeSource in interface CoverageProcessingNode
Parameters:
index - the index at which we want to remove a source from the List of sources for this CoverageProcessingNode.
Returns:
the CoverageProcessingNode we actually remove from the sources list.
Throws:
java.lang.IndexOutOfBoundsException

toString

public java.lang.String toString()
Description copied from interface: CoverageProcessingNode
Provides a descriptive description for this CoverageProcessingNode.

Specified by:
toString in interface CoverageProcessingNode
Overrides:
toString in class java.lang.Object
Returns:
a descriptive description for this CoverageProcessingNode

isDisposed

public boolean isDisposed()
Tells me whether or not the node has been already disposed.

Returns:
true if the node has been already disposed, false otherwise.

isExecuted

public boolean isExecuted()
Tells me whether or not the node has been already executed.

Returns:
true if the node has been already executed, false otherwise.


Copyright © 1996-2010 Geotools. All Rights Reserved.