001: package net.refractions.udig.core;
002:
003: import org.geotools.filter.FilterFactory;
004: import org.geotools.filter.FilterFactoryFinder;
005: import org.geotools.styling.AnchorPoint;
006: import org.geotools.styling.ColorMap;
007: import org.geotools.styling.ColorMapEntry;
008: import org.geotools.styling.Displacement;
009: import org.geotools.styling.ExternalGraphic;
010: import org.geotools.styling.FeatureTypeConstraint;
011: import org.geotools.styling.FeatureTypeStyle;
012: import org.geotools.styling.Fill;
013: import org.geotools.styling.Graphic;
014: import org.geotools.styling.Halo;
015: import org.geotools.styling.LinePlacement;
016: import org.geotools.styling.LineSymbolizer;
017: import org.geotools.styling.Mark;
018: import org.geotools.styling.NamedLayer;
019: import org.geotools.styling.PointPlacement;
020: import org.geotools.styling.PointSymbolizer;
021: import org.geotools.styling.PolygonSymbolizer;
022: import org.geotools.styling.RasterSymbolizer;
023: import org.geotools.styling.Rule;
024: import org.geotools.styling.Stroke;
025: import org.geotools.styling.Style;
026: import org.geotools.styling.StyleVisitor;
027: import org.geotools.styling.StyledLayerDescriptor;
028: import org.geotools.styling.Symbolizer;
029: import org.geotools.styling.TextSymbolizer;
030: import org.geotools.styling.UserLayer;
031:
032: /**
033: * Removes the transparency from a style.
034: *
035: * @author Jesse
036: */
037: public class TransparencyRemovingVisitor implements StyleVisitor {
038:
039: public void visit(StyledLayerDescriptor arg0) {
040: // nothing
041: }
042:
043: public void visit(NamedLayer arg0) {
044: // nothing
045: }
046:
047: public void visit(UserLayer arg0) {
048: // nothing
049: }
050:
051: public void visit(FeatureTypeConstraint arg0) {
052: // nothing
053: }
054:
055: public void visit(Style arg0) {
056: for (FeatureTypeStyle fts : arg0.getFeatureTypeStyles()) {
057: fts.accept(this );
058: }
059: }
060:
061: public void visit(Rule arg0) {
062: for (Symbolizer s : arg0.getSymbolizers()) {
063: s.accept(this );
064: }
065: }
066:
067: public void visit(FeatureTypeStyle arg0) {
068: for (Rule s : arg0.getRules()) {
069: s.accept(this );
070: }
071: }
072:
073: FilterFactory fac = FilterFactoryFinder.createFilterFactory();
074:
075: public void visit(Fill arg0) {
076: arg0.setOpacity(fac.createLiteralExpression(1.0));
077: }
078:
079: public void visit(Stroke arg0) {
080: arg0.setOpacity(fac.createLiteralExpression(1.0));
081: }
082:
083: public void visit(Symbolizer arg0) {
084: if (arg0 instanceof PointSymbolizer) {
085: PointSymbolizer ps = (PointSymbolizer) arg0;
086: ps.accept(this );
087: }
088: if (arg0 instanceof PolygonSymbolizer) {
089: PolygonSymbolizer ps = (PolygonSymbolizer) arg0;
090: ps.accept(this );
091: }
092: if (arg0 instanceof LineSymbolizer) {
093: LineSymbolizer ps = (LineSymbolizer) arg0;
094: ps.accept(this );
095: }
096: if (arg0 instanceof TextSymbolizer) {
097: TextSymbolizer ps = (TextSymbolizer) arg0;
098: ps.accept(this );
099: }
100: if (arg0 instanceof RasterSymbolizer) {
101: RasterSymbolizer ps = (RasterSymbolizer) arg0;
102: ps.accept(this );
103: }
104: }
105:
106: public void visit(PointSymbolizer arg0) {
107: arg0.getGraphic().accept(this );
108: }
109:
110: public void visit(LineSymbolizer arg0) {
111: Stroke stroke = arg0.getStroke();
112: if (stroke != null)
113: stroke.accept(this );
114: }
115:
116: public void visit(PolygonSymbolizer arg0) {
117: Fill fill = arg0.getFill();
118: if (fill != null)
119: fill.accept(this );
120: Stroke stroke = arg0.getStroke();
121: if (stroke != null)
122: stroke.accept(this );
123: }
124:
125: public void visit(TextSymbolizer arg0) {
126: Fill fill = arg0.getFill();
127: if (fill != null)
128: fill.accept(this );
129: }
130:
131: public void visit(RasterSymbolizer arg0) {
132: arg0.setOpacity(fac.createLiteralExpression(1.0));
133: }
134:
135: public void visit(Graphic arg0) {
136: arg0.setOpacity(fac.createLiteralExpression(1.0));
137: }
138:
139: public void visit(Mark arg0) {
140: Fill fill = arg0.getFill();
141: if (fill != null)
142: fill.accept(this );
143:
144: Stroke stroke = arg0.getStroke();
145: if (stroke != null)
146: stroke.accept(this );
147: }
148:
149: public void visit(ExternalGraphic arg0) {
150: // nothing
151: }
152:
153: public void visit(PointPlacement arg0) {
154: // nothing
155:
156: }
157:
158: public void visit(AnchorPoint arg0) {
159: // nothing
160: }
161:
162: public void visit(Displacement arg0) {
163: // nothing
164: }
165:
166: public void visit(LinePlacement arg0) {
167: // nothing
168: }
169:
170: public void visit(Halo arg0) {
171: Fill fill = arg0.getFill();
172: if (fill != null)
173: fill.accept(this );
174: }
175:
176: public void visit(ColorMap colorMap) {
177: // nothing
178: }
179:
180: public void visit(ColorMapEntry colorMapEntry) {
181: // nothing
182: }
183:
184: }
|