es.prodevelop.gvsig.mobile.fmap.driver.raster.wms
Class WMSLayerDescription

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.fmap.driver.raster.wms.WMSLayerDescription

public class WMSLayerDescription
extends java.lang.Object

This class keeps information about a single WMS layer. It is used after a getCapabilities request, to manage capabilities data in a tree-like data model.

Author:
jldominguez
See Also:
WMSProtocolHandler, WmsRasterDriver

Constructor Summary
WMSLayerDescription(int lvl, WMSLayerDescription p)
          Constructor
 
Method Summary
 void addChild(WMSLayerDescription c)
          Adds a child to this layer description (used while the capabilities response is being parsed)
 void addCRS(java.lang.String srs, java.awt.geom.Rectangle2D ext)
          Adds a new SRS, indicating that this layer is also available in that SRS
 java.lang.String appendUseful(java.lang.String str)
          Recursively adds useful ID to the provided string.
 void clearSRS()
          Clears the list of available SRS
 void delete()
          This method recursively calls to the same method of the node's children.
 java.lang.String[] getAvailableSRS()
           
 WMSLayerDescription getChild(int i)
          Gets child description by index
 int getChildrenCount()
           
 java.awt.geom.Rectangle2D getExtentForSRS(java.lang.String srs)
          Gets the extent of this layer for the given SRS
 java.lang.String getLayerId()
           
 java.lang.String getLayerName()
           
 int getLevel()
           
 void increaseExtentForSRS(java.lang.String srs, java.awt.geom.Rectangle2D ext)
          Increase the extent of this layer to include the provided rectangle.
 boolean isInfoable()
           
 boolean isSelected()
           
 void parse(org.kxml2.io.KXmlParser parser, boolean layer_found)
          This method recursively parses the layers section of the capabilities response.
 int parseAsRoot(org.kxml2.io.KXmlParser parser)
          Starts the parsing process assuming that this object represents the root layer.
 void setInfoable(boolean b)
          Sets whether or not this layer is infoable (according to the response received after a get capabilities request.
 void setLayerId(java.lang.String i)
          Set the layer ID
 void setLayerName(java.lang.String n)
          Sets the layer name
 void setSelected(boolean s, boolean tell_children)
          Set the associated checkbox to a value, possibly acting recursively on children nodes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WMSLayerDescription

public WMSLayerDescription(int lvl,
                           WMSLayerDescription p)
Constructor

Parameters:
lvl - depth level of this layer
p - parent layer (parent node in the tree)
Method Detail

delete

public void delete()
This method recursively calls to the same method of the node's children. It is used to prevent memory leaks caused by non-destryoed objects, after the WMS dialog has been closed.


appendUseful

public java.lang.String appendUseful(java.lang.String str)
Recursively adds useful ID to the provided string. Some layers do not have an ID, meaning that they are just the parent of other layers.

Parameters:
str - the string to append useful IDS to.
Returns:
a new string that is the result of rescursively appending useful IDs to the provided string.

isSelected

public boolean isSelected()
Returns:
whether the checkbox associated with the layer described hehe is checked or not.

setSelected

public void setSelected(boolean s,
                        boolean tell_children)
Set the associated checkbox to a value, possibly acting recursively on children nodes.

Parameters:
s - the new value for the check box.
tell_children - whether the children nodes have to be reset or not.

getLevel

public int getLevel()
Returns:
the depth of this layer in the tree that describes the available layers.

setInfoable

public void setInfoable(boolean b)
Sets whether or not this layer is infoable (according to the response received after a get capabilities request.

Parameters:
b - whether or not this layer is infoable

isInfoable

public boolean isInfoable()
Returns:
whether or not this layer is infoable

getLayerName

public java.lang.String getLayerName()
Returns:
layer name (not to be confused with layer ID)

setLayerName

public void setLayerName(java.lang.String n)
Sets the layer name

Parameters:
n - the layer name (not to be confused with layer ID)

getLayerId

public java.lang.String getLayerId()
Returns:
layer ID (not to be confused with layer name)

setLayerId

public void setLayerId(java.lang.String i)
Set the layer ID

Parameters:
i - the layer ID

getAvailableSRS

public java.lang.String[] getAvailableSRS()
Returns:
the SRS abbreviations in which this layer is available

getExtentForSRS

public java.awt.geom.Rectangle2D getExtentForSRS(java.lang.String srs)
Gets the extent of this layer for the given SRS

Parameters:
srs - the abbreviation of the SRS of interest
Returns:
the extent of this layer for the given SRS

addChild

public void addChild(WMSLayerDescription c)
Adds a child to this layer description (used while the capabilities response is being parsed)

Parameters:
c - the new child to be added

addCRS

public void addCRS(java.lang.String srs,
                   java.awt.geom.Rectangle2D ext)
Adds a new SRS, indicating that this layer is also available in that SRS

Parameters:
srs - the new SRS to be added
ext - the extent of the layer in the provided SRS

increaseExtentForSRS

public void increaseExtentForSRS(java.lang.String srs,
                                 java.awt.geom.Rectangle2D ext)
Increase the extent of this layer to include the provided rectangle.

Parameters:
srs - the SRS that the extent refers to
ext - the new rectangle to be included in the extent associated with the provided SRS

clearSRS

public void clearSRS()
Clears the list of available SRS


parse

public void parse(org.kxml2.io.KXmlParser parser,
                  boolean layer_found)
           throws java.io.IOException,
                  org.xmlpull.v1.XmlPullParserException
This method recursively parses the layers section of the capabilities response. Data is stored in the same object that performs the parsing.

Parameters:
parser - the parser
layer_found - whether a layer description is right ahead of the current position of the parser
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

parseAsRoot

public int parseAsRoot(org.kxml2.io.KXmlParser parser)
                throws java.io.IOException,
                       org.xmlpull.v1.XmlPullParserException
Starts the parsing process assuming that this object represents the root layer. Its name will be "[WMS]" and it will have no ID. It's simply a convenience node because sometimes the server does not explicitly define a root node.

Parameters:
parser - the parser
Returns:
the code of the tag after the parsing ends. Tghis is useful to perform coherent parsings.
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

getChildrenCount

public int getChildrenCount()
Returns:
number of children of this layer description in the tree-like structure

getChild

public WMSLayerDescription getChild(int i)
Gets child description by index

Parameters:
i - the idnex of the child of interest
Returns:
child description by index