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.FilterFactory;
023: import org.geotools.styling.ContrastEnhancement;
024: import org.geotools.styling.StyleFactory;
025: import org.geotools.xml.AbstractComplexBinding;
026: import org.geotools.xml.ElementInstance;
027: import org.geotools.xml.Node;
028:
029: /**
030: * Binding object for the element http://www.opengis.net/sld:ContrastEnhancement.
031: *
032: * <p>
033: * <pre>
034: * <code>
035: * <xsd:element name="ContrastEnhancement">
036: * <xsd:annotation>
037: * <xsd:documentation> "ContrastEnhancement"
038: * defines the 'stretching' of contrast for a
039: * channel of a false-color image or for a whole grey/color
040: * image. Contrast enhancement is used to make ground
041: * features in images more visible. </xsd:documentation>
042: * </xsd:annotation>
043: * <xsd:complexType>
044: * <xsd:sequence>
045: * <xsd:choice minOccurs="0">
046: * <xsd:element ref="sld:Normalize"/>
047: * <xsd:element ref="sld:Histogram"/>
048: * </xsd:choice>
049: * <xsd:element ref="sld:GammaValue" minOccurs="0"/>
050: * </xsd:sequence>
051: * </xsd:complexType>
052: * </xsd:element>
053: *
054: * </code>
055: * </pre>
056: * </p>
057: *
058: * @generated
059: */
060: public class SLDContrastEnhancementBinding extends
061: AbstractComplexBinding {
062: StyleFactory styleFactory;
063: FilterFactory filterFactory;
064:
065: public SLDContrastEnhancementBinding(StyleFactory styleFactory,
066: FilterFactory filterFactory) {
067: this .styleFactory = styleFactory;
068: this .filterFactory = filterFactory;
069: }
070:
071: /**
072: * @generated
073: */
074: public QName getTarget() {
075: return SLD.CONTRASTENHANCEMENT;
076: }
077:
078: /**
079: * <!-- begin-user-doc -->
080: * <!-- end-user-doc -->
081: *
082: * @generated modifiable
083: */
084: public int getExecutionMode() {
085: return AFTER;
086: }
087:
088: /**
089: * <!-- begin-user-doc -->
090: * <!-- end-user-doc -->
091: *
092: * @generated modifiable
093: */
094: public Class getType() {
095: return ContrastEnhancement.class;
096: }
097:
098: /**
099: * <!-- begin-user-doc -->
100: * <!-- end-user-doc -->
101: *
102: * @generated modifiable
103: */
104: public void initialize(ElementInstance instance, Node node,
105: MutablePicoContainer context) {
106: }
107:
108: /**
109: * <!-- begin-user-doc -->
110: * <!-- end-user-doc -->
111: *
112: * @generated modifiable
113: */
114: public Object parse(ElementInstance instance, Node node,
115: Object value) throws Exception {
116: ContrastEnhancement ce = styleFactory
117: .createContrastEnhancement();
118:
119: if (node.getChildValue("GammaValue") != null) {
120: Double gamma = (Double) node.getChildValue("GammaValue");
121: ce.setGammaValue(filterFactory
122: .createLiteralExpression(gamma.doubleValue()));
123: }
124:
125: if (node.getChild("Normalize") != null) {
126: ce.setNormalize();
127: } else {
128: if (node.getChild("Histogram") != null) {
129: ce.setHistogram();
130: }
131: }
132:
133: return ce;
134: }
135: }
|