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.styling.Fill;
024: import org.geotools.styling.PolygonSymbolizer;
025: import org.geotools.styling.Stroke;
026: import org.geotools.styling.StyleFactory;
027: import org.geotools.xml.*;
028:
029: /**
030: * Binding object for the element http://www.opengis.net/sld:PolygonSymbolizer.
031: *
032: * <p>
033: * <pre>
034: * <code>
035: * <xsd:element name="PolygonSymbolizer" substitutionGroup="sld:Symbolizer">
036: * <xsd:annotation>
037: * <xsd:documentation> A "PolygonSymbolizer"
038: * specifies the rendering of a polygon or area
039: * geometry, including its interior fill and border stroke. </xsd:documentation>
040: * </xsd:annotation>
041: * <xsd:complexType>
042: * <xsd:complexContent>
043: * <xsd:extension base="sld:SymbolizerType">
044: * <xsd:sequence>
045: * <xsd:element ref="sld:Geometry" minOccurs="0"/>
046: * <xsd:element ref="sld:Fill" minOccurs="0"/>
047: * <xsd:element ref="sld:Stroke" minOccurs="0"/>
048: * </xsd:sequence>
049: * </xsd:extension>
050: * </xsd:complexContent>
051: * </xsd:complexType>
052: * </xsd:element>
053: *
054: * </code>
055: * </pre>
056: * </p>
057: *
058: * @generated
059: */
060: public class SLDPolygonSymbolizerBinding extends AbstractComplexBinding {
061: StyleFactory styleFactory;
062:
063: public SLDPolygonSymbolizerBinding(StyleFactory styleFactory) {
064: this .styleFactory = styleFactory;
065: }
066:
067: /**
068: * @generated
069: */
070: public QName getTarget() {
071: return SLD.POLYGONSYMBOLIZER;
072: }
073:
074: /**
075: * <!-- begin-user-doc -->
076: * <!-- end-user-doc -->
077: *
078: * @generated modifiable
079: */
080: public int getExecutionMode() {
081: return AFTER;
082: }
083:
084: /**
085: * <!-- begin-user-doc -->
086: * <!-- end-user-doc -->
087: *
088: * @generated modifiable
089: */
090: public Class getType() {
091: return PolygonSymbolizer.class;
092: }
093:
094: /**
095: * <!-- begin-user-doc -->
096: * <!-- end-user-doc -->
097: *
098: * @generated modifiable
099: */
100: public void initialize(ElementInstance instance, Node node,
101: MutablePicoContainer context) {
102: }
103:
104: /**
105: * <!-- begin-user-doc -->
106: * <!-- end-user-doc -->
107: *
108: * @generated modifiable
109: */
110: public Object parse(ElementInstance instance, Node node,
111: Object value) throws Exception {
112: PolygonSymbolizer ps = styleFactory.createPolygonSymbolizer();
113:
114: //<xsd:element ref="sld:Geometry" minOccurs="0"/>
115: if (node.hasChild(PropertyName.class)) {
116: PropertyName propertyName = (PropertyName) node
117: .getChildValue(PropertyName.class);
118: ps.setGeometryPropertyName(propertyName.getPropertyName());
119: }
120:
121: //<xsd:element ref="sld:Fill" minOccurs="0"/>
122: if (node.hasChild(Fill.class)) {
123: ps.setFill((Fill) node.getChildValue(Fill.class));
124: }
125:
126: //<xsd:element ref="sld:Stroke" minOccurs="0"/>
127: if (node.hasChild(Stroke.class)) {
128: ps.setStroke((Stroke) node.getChildValue(Stroke.class));
129: }
130:
131: return ps;
132: }
133: }
|