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.geotools.filter.Expression;
023: import org.geotools.filter.FilterFactory;
024: import org.geotools.styling.ShadedRelief;
025: import org.geotools.styling.StyleFactory;
026: import org.geotools.xml.*;
027:
028: /**
029: * Binding object for the element http://www.opengis.net/sld:ShadedRelief.
030: *
031: * <p>
032: * <pre>
033: * <code>
034: * <xsd:element name="ShadedRelief">
035: * <xsd:annotation>
036: * <xsd:documentation> "ShadedRelief" specifies
037: * the application of relief shading (or "hill
038: * shading") to a DEM raster to give it somewhat of a
039: * three-dimensional effect and to make elevation changes more
040: * visible. </xsd:documentation>
041: * </xsd:annotation>
042: * <xsd:complexType>
043: * <xsd:sequence>
044: * <xsd:element ref="sld:BrightnessOnly" minOccurs="0"/>
045: * <xsd:element ref="sld:ReliefFactor" minOccurs="0"/>
046: * </xsd:sequence>
047: * </xsd:complexType>
048: * </xsd:element>
049: *
050: * </code>
051: * </pre>
052: * </p>
053: *
054: * @generated
055: */
056: public class SLDShadedReliefBinding extends AbstractComplexBinding {
057: StyleFactory styleFactory;
058: FilterFactory filterFactory;
059:
060: public SLDShadedReliefBinding(StyleFactory styleFactory,
061: FilterFactory filterFactory) {
062: this .styleFactory = styleFactory;
063: this .filterFactory = filterFactory;
064: }
065:
066: /**
067: * @generated
068: */
069: public QName getTarget() {
070: return SLD.SHADEDRELIEF;
071: }
072:
073: /**
074: * <!-- begin-user-doc -->
075: * <!-- end-user-doc -->
076: *
077: * @generated modifiable
078: */
079: public int getExecutionMode() {
080: return AFTER;
081: }
082:
083: /**
084: * <!-- begin-user-doc -->
085: * <!-- end-user-doc -->
086: *
087: * @generated modifiable
088: */
089: public Class getType() {
090: return ShadedRelief.class;
091: }
092:
093: /**
094: * <!-- begin-user-doc -->
095: * <!-- end-user-doc -->
096: *
097: * @generated modifiable
098: */
099: public void initialize(ElementInstance instance, Node node,
100: MutablePicoContainer context) {
101: }
102:
103: /**
104: * <!-- begin-user-doc -->
105: * <!-- end-user-doc -->
106: *
107: * @generated modifiable
108: */
109: public Object parse(ElementInstance instance, Node node,
110: Object value) throws Exception {
111: Expression reliefFactor = null;
112:
113: if (node.hasChild("ReliefFactor")) {
114: Double d = (Double) node.getChildValue("ReliefFactor");
115: reliefFactor = (Expression) filterFactory.literal(d
116: .doubleValue());
117: }
118:
119: ShadedRelief shadedRelief = styleFactory
120: .createShadedRelief(reliefFactor);
121:
122: if (node.hasChild("BrightnessOnly")) {
123: Boolean b = (Boolean) node.getChildValue("BrightnessOnly");
124: shadedRelief.setBrightnessOnly(b.booleanValue());
125: }
126:
127: return shadedRelief;
128: }
129: }
|