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.styling;
017:
018: /**
019: * A simple visitor whose purpose is to extract the set of attributes used by a
020: * Style, that is, those that the Style expects to find in order to work
021: * properly
022: *
023: * This is very similiar to StyleAttributeExtractor, but with these differences:
024: * a) it doesnt the count the <PropertyName> tag in the <Geometry>
025: * b) it doesnt count anything in the <TextSymbolizer>'s <Priority> tag
026: * c) it doesnt count anything in the <TextSymbolizer>'s <Label> tag
027: *
028: * The reasons for this are because these fields are ALWAYS taken directly from the
029: * feature, not from the style.
030: *
031: * So, for making queries (knowing any property that might be possibily be used in the SLD), use
032: * StyleAttributeExtractor. If you want to know what a symbolizer actually needs to cache, then
033: * use this (StyleAttributeExtractorTruncated).
034: *
035: * @author dblasby
036: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/styling/StyleAttributeExtractorTruncated.java $
037: */
038: public class StyleAttributeExtractorTruncated extends
039: StyleAttributeExtractor implements StyleVisitor {
040:
041: int defaultGeometryUsed;
042:
043: public void visit(RasterSymbolizer rs) {
044: if (rs.getImageOutline() != null) {
045: rs.getImageOutline().accept(this );
046: }
047:
048: if (rs.getOpacity() != null) {
049: rs.getOpacity().accept(this , null);
050: }
051: }
052:
053: /**
054: * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PointSymbolizer)
055: */
056: public void visit(PointSymbolizer ps) {
057:
058: if (ps.getGraphic() != null) {
059: ps.getGraphic().accept(this );
060: }
061:
062: }
063:
064: /**
065: * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.LineSymbolizer)
066: */
067: public void visit(LineSymbolizer line) {
068:
069: if (line.getStroke() != null) {
070: line.getStroke().accept(this );
071: }
072: }
073:
074: /**
075: * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PolygonSymbolizer)
076: */
077: public void visit(PolygonSymbolizer poly) {
078:
079: if (poly.getStroke() != null) {
080: poly.getStroke().accept(this );
081: }
082:
083: if (poly.getFill() != null) {
084: poly.getFill().accept(this );
085: }
086: }
087:
088: /**
089: * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.TextSymbolizer)
090: */
091: public void visit(TextSymbolizer text) {
092:
093: if (text instanceof TextSymbolizer2) {
094: if (((TextSymbolizer2) text).getGraphic() != null)
095: ((TextSymbolizer2) text).getGraphic().accept(this );
096: }
097:
098: if (text.getFill() != null) {
099: text.getFill().accept(this );
100: }
101:
102: if (text.getHalo() != null) {
103: text.getHalo().accept(this );
104: }
105:
106: if (text.getFonts() != null) {
107: Font[] fonts = text.getFonts();
108:
109: for (int i = 0; i < fonts.length; i++) {
110: Font font = fonts[i];
111:
112: if (font.getFontFamily() != null) {
113: font.getFontFamily().accept(this, null);
114: }
115:
116: if (font.getFontSize() != null) {
117: font.getFontSize().accept(this, null);
118: }
119:
120: if (font.getFontStyle() != null) {
121: font.getFontStyle().accept(this, null);
122: }
123:
124: if (font.getFontWeight() != null) {
125: font.getFontWeight().accept(this, null);
126: }
127: }
128: }
129:
130: if (text.getHalo() != null) {
131: text.getHalo().accept(this);
132: }
133:
134: if (text.getPlacement() != null) {
135: text.getPlacement().accept(this);
136: }
137:
138: }
139:
140: }
|