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.Fill;
024: import org.geotools.styling.Mark;
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:Mark.
031: *
032: * <p>
033: * <pre>
034: * <code>
035: * <xsd:element name="Mark">
036: * <xsd:annotation>
037: * <xsd:documentation> A "Mark" specifies a
038: * geometric shape and applies coloring to it. </xsd:documentation>
039: * </xsd:annotation>
040: * <xsd:complexType>
041: * <xsd:sequence>
042: * <xsd:element ref="sld:WellKnownName" minOccurs="0"/>
043: * <xsd:element ref="sld:Fill" minOccurs="0"/>
044: * <xsd:element ref="sld:Stroke" minOccurs="0"/>
045: * </xsd:sequence>
046: * </xsd:complexType>
047: * </xsd:element>
048: *
049: * </code>
050: * </pre>
051: * </p>
052: *
053: * @generated
054: */
055: public class SLDMarkBinding extends AbstractComplexBinding {
056: FilterFactory filterFactory;
057: StyleFactory styleFactory;
058:
059: public SLDMarkBinding(StyleFactory styleFactory,
060: FilterFactory filterFactory) {
061: this .styleFactory = styleFactory;
062: this .filterFactory = filterFactory;
063: }
064:
065: /**
066: * @generated
067: */
068: public QName getTarget() {
069: return SLD.MARK;
070: }
071:
072: /**
073: * <!-- begin-user-doc -->
074: * <!-- end-user-doc -->
075: *
076: * @generated modifiable
077: */
078: public int getExecutionMode() {
079: return AFTER;
080: }
081:
082: /**
083: * <!-- begin-user-doc -->
084: * <!-- end-user-doc -->
085: *
086: * @generated modifiable
087: */
088: public Class getType() {
089: return Mark.class;
090: }
091:
092: /**
093: * <!-- begin-user-doc -->
094: * <!-- end-user-doc -->
095: *
096: * @generated modifiable
097: */
098: public void initialize(ElementInstance instance, Node node,
099: MutablePicoContainer context) {
100: }
101:
102: /**
103: * <!-- begin-user-doc -->
104: * <!-- end-user-doc -->
105: *
106: * @generated modifiable
107: */
108: public Object parse(ElementInstance instance, Node node,
109: Object value) throws Exception {
110: String wkName = (String) node.getChildValue("WellKnownName");
111: Stroke stroke = (Stroke) node.getChildValue("Stroke");
112: Fill fill = (Fill) node.getChildValue("Fill");
113:
114: Mark mark = styleFactory.createMark();
115:
116: if (wkName != null) {
117: mark.setWellKnownName(filterFactory
118: .createLiteralExpression(wkName));
119: }
120:
121: if (stroke != null) {
122: mark.setStroke(stroke);
123: }
124:
125: if (fill != null) {
126: mark.setFill(fill);
127: }
128:
129: return mark;
130: }
131: }
|