001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.sld.bindings;
017:
018: import org.picocontainer.MutablePicoContainer;
019: import org.w3c.dom.Document;
020: import org.w3c.dom.Element;
021: import javax.xml.namespace.QName;
022: import org.opengis.filter.expression.PropertyName;
023: import org.geotools.filter.Expression;
024: import org.geotools.styling.ChannelSelection;
025: import org.geotools.styling.ColorMap;
026: import org.geotools.styling.ContrastEnhancement;
027: import org.geotools.styling.ImageOutline;
028: import org.geotools.styling.OverlapBehavior;
029: import org.geotools.styling.RasterSymbolizer;
030: import org.geotools.styling.ShadedRelief;
031: import org.geotools.styling.StyleFactory;
032: import org.geotools.xml.*;
033:
034: /**
035: * Binding object for the element http://www.opengis.net/sld:RasterSymbolizer.
036: *
037: * <p>
038: * <pre>
039: * <code>
040: * <xsd:element name="RasterSymbolizer" substitutionGroup="sld:Symbolizer">
041: * <xsd:annotation>
042: * <xsd:documentation> A "RasterSymbolizer" is
043: * used to specify the rendering of raster/
044: * matrix-coverage data (e.g., satellite images, DEMs). </xsd:documentation>
045: * </xsd:annotation>
046: * <xsd:complexType>
047: * <xsd:complexContent>
048: * <xsd:extension base="sld:SymbolizerType">
049: * <xsd:sequence>
050: * <xsd:element ref="sld:Geometry" minOccurs="0"/>
051: * <xsd:element ref="sld:Opacity" minOccurs="0"/>
052: * <xsd:element ref="sld:ChannelSelection" minOccurs="0"/>
053: * <xsd:element ref="sld:OverlapBehavior" minOccurs="0"/>
054: * <xsd:element ref="sld:ColorMap" minOccurs="0"/>
055: * <xsd:element ref="sld:ContrastEnhancement" minOccurs="0"/>
056: * <xsd:element ref="sld:ShadedRelief" minOccurs="0"/>
057: * <xsd:element ref="sld:ImageOutline" minOccurs="0"/>
058: * </xsd:sequence>
059: * </xsd:extension>
060: * </xsd:complexContent>
061: * </xsd:complexType>
062: * </xsd:element>
063: *
064: * </code>
065: * </pre>
066: * </p>
067: *
068: * @generated
069: */
070: public class SLDRasterSymbolizerBinding extends AbstractComplexBinding {
071: StyleFactory styleFactory;
072:
073: public SLDRasterSymbolizerBinding(StyleFactory styleFactory) {
074: this .styleFactory = styleFactory;
075: }
076:
077: /**
078: * @generated
079: */
080: public QName getTarget() {
081: return SLD.RASTERSYMBOLIZER;
082: }
083:
084: /**
085: * <!-- begin-user-doc -->
086: * <!-- end-user-doc -->
087: *
088: * @generated modifiable
089: */
090: public int getExecutionMode() {
091: return AFTER;
092: }
093:
094: /**
095: * <!-- begin-user-doc -->
096: * <!-- end-user-doc -->
097: *
098: * @generated modifiable
099: */
100: public Class getType() {
101: return RasterSymbolizer.class;
102: }
103:
104: /**
105: * <!-- begin-user-doc -->
106: * <!-- end-user-doc -->
107: *
108: * @generated modifiable
109: */
110: public void initialize(ElementInstance instance, Node node,
111: MutablePicoContainer context) {
112: }
113:
114: /**
115: * <!-- begin-user-doc -->
116: * <!-- end-user-doc -->
117: *
118: * @generated modifiable
119: */
120: public Object parse(ElementInstance instance, Node node,
121: Object value) throws Exception {
122: RasterSymbolizer rs = styleFactory.createRasterSymbolizer();
123:
124: //<xsd:element ref="sld:Geometry" minOccurs="0"/>
125: if (node.hasChild("Geometry")) {
126: PropertyName propertyName = (PropertyName) node
127: .getChildValue("Geometry");
128: rs.setGeometryPropertyName(propertyName.getPropertyName());
129: }
130:
131: //<xsd:element ref="sld:Opacity" minOccurs="0"/>
132: if (node.hasChild("Opacity")) {
133: rs.setOpacity((Expression) node.getChildValue("Opacity"));
134: }
135:
136: //<xsd:element ref="sld:ChannelSelection" minOccurs="0"/>
137: if (node.hasChild("ChannelSelection")) {
138: rs.setChannelSelection((ChannelSelection) node
139: .getChildValue("ChannelSelection"));
140: }
141:
142: //<xsd:element ref="sld:OverlapBehavior" minOccurs="0"/>
143: if (node.hasChild("OverlapBehavior")) {
144: rs.setOverlap((OverlapBehavior) node
145: .getChildValue("OverlapBehavior"));
146: }
147:
148: //<xsd:element ref="sld:ColorMap" minOccurs="0"/>
149: if (node.hasChild("ColorMap")) {
150: rs.setColorMap((ColorMap) node.getChildValue("ColorMap"));
151: }
152:
153: //<xsd:element ref="sld:ContrastEnhancement" minOccurs="0"/>
154: if (node.hasChild("ConstrastEnhancement")) {
155: rs.setContrastEnhancement((ContrastEnhancement) node
156: .getChildValue("ContrastEnhancement"));
157: }
158:
159: //<xsd:element ref="sld:ShadedRelief" minOccurs="0"/>
160: if (node.hasChild("ShadedRelief")) {
161: rs.setShadedRelief((ShadedRelief) node
162: .getChildValue("ShadedRelief"));
163: }
164:
165: //<xsd:element ref="sld:ImageOutline" minOccurs="0"/>
166: if (node.hasChild("ImageOutline")) {
167: ImageOutline imageOutput = (ImageOutline) node
168: .getChildValue("ImageOutline");
169: rs.setImageOutline(imageOutput.getSymbolizer());
170: }
171:
172: return rs;
173: }
174: }
|