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 java.util.List;
022: import javax.xml.namespace.QName;
023: import org.geotools.filter.Expression;
024: import org.geotools.styling.ExternalGraphic;
025: import org.geotools.styling.Graphic;
026: import org.geotools.styling.Mark;
027: import org.geotools.styling.StyleFactory;
028: import org.geotools.xml.*;
029:
030: /**
031: * Binding object for the element http://www.opengis.net/sld:Graphic.
032: *
033: * <p>
034: * <pre>
035: * <code>
036: * <xsd:element name="Graphic">
037: * <xsd:annotation>
038: * <xsd:documentation> A "Graphic" specifies or
039: * refers to a "graphic symbol" with inherent
040: * shape, size, and coloring. </xsd:documentation>
041: * </xsd:annotation>
042: * <xsd:complexType>
043: * <xsd:sequence>
044: * <xsd:choice minOccurs="0" maxOccurs="unbounded">
045: * <xsd:element ref="sld:ExternalGraphic"/>
046: * <xsd:element ref="sld:Mark"/>
047: * </xsd:choice>
048: * <xsd:sequence>
049: * <xsd:element ref="sld:Opacity" minOccurs="0"/>
050: * <xsd:element ref="sld:Size" minOccurs="0"/>
051: * <xsd:element ref="sld:Rotation" minOccurs="0"/>
052: * </xsd:sequence>
053: * </xsd:sequence>
054: * </xsd:complexType>
055: * </xsd:element>
056: *
057: * </code>
058: * </pre>
059: * </p>
060: *
061: * @generated
062: */
063: public class SLDGraphicBinding extends AbstractComplexBinding {
064: StyleFactory styleFactory;
065:
066: public SLDGraphicBinding(StyleFactory styleFactory) {
067: this .styleFactory = styleFactory;
068: }
069:
070: /**
071: * @generated
072: */
073: public QName getTarget() {
074: return SLD.GRAPHIC;
075: }
076:
077: /**
078: * <!-- begin-user-doc -->
079: * <!-- end-user-doc -->
080: *
081: * @generated modifiable
082: */
083: public int getExecutionMode() {
084: return AFTER;
085: }
086:
087: /**
088: * <!-- begin-user-doc -->
089: * <!-- end-user-doc -->
090: *
091: * @generated modifiable
092: */
093: public Class getType() {
094: return Graphic.class;
095: }
096:
097: /**
098: * <!-- begin-user-doc -->
099: * <!-- end-user-doc -->
100: *
101: * @generated modifiable
102: */
103: public void initialize(ElementInstance instance, Node node,
104: MutablePicoContainer context) {
105: }
106:
107: /**
108: * <!-- begin-user-doc -->
109: * <!-- end-user-doc -->
110: *
111: * @generated modifiable
112: */
113: public Object parse(ElementInstance instance, Node node,
114: Object value) throws Exception {
115: Mark[] marks = null;
116: ExternalGraphic[] graphics = null;
117:
118: if (node.getChild("Mark") != null) {
119: List l = node.getChildValues("Mark");
120: marks = (Mark[]) l.toArray(new Mark[l.size()]);
121: } else {
122: List l = node.getChildValues("ExternalGraphic");
123: graphics = (ExternalGraphic[]) l
124: .toArray(new ExternalGraphic[l.size()]);
125: }
126:
127: Expression opacity = (Expression) node.getChildValue("Opacity");
128: Expression size = (Expression) node.getChildValue("Size");
129: Expression rotation = (Expression) node
130: .getChildValue("Rotation");
131:
132: return styleFactory.createGraphic(graphics, marks, null,
133: opacity, size, rotation);
134: }
135: }
|