Source Code Cross Referenced for StyleAttributeExtractor.java in  » GIS » GeoTools-2.4.1 » org » geotools » styling » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.styling 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        import org.geotools.filter.FilterAttributeExtractor;
019:        import org.opengis.filter.Filter;
020:        import org.opengis.filter.expression.ExpressionVisitor;
021:
022:        /**
023:         * A simple visitor whose purpose is to extract the set of attributes used by a
024:         * Style, that is, those that the Style expects to find in order to work
025:         * properly
026:         *
027:         * @author wolf
028:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/styling/StyleAttributeExtractor.java $
029:         */
030:
031:        /**
032:         * ===========================================================================
033:         * if you're modifying this, you probably should also take a look at StyleAttributeExtractorTruncated
034:         * ===========================================================================
035:         *
036:         */
037:
038:        public class StyleAttributeExtractor extends FilterAttributeExtractor
039:                implements  StyleVisitor {
040:
041:            /**
042:             *   if the default geometry is used, this will be true.  See GEOS-469
043:             */
044:            boolean defaultGeometryUsed = false;
045:
046:            /**
047:             * reads the read-only-property.
048:             * See GEOS-469
049:             *
050:             * @return true if any of the symbolizers visted use the default geometry.
051:             */
052:            public boolean getDefaultGeometryUsed() {
053:                return defaultGeometryUsed;
054:            }
055:
056:            /**
057:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Style)
058:             */
059:            public void visit(Style style) {
060:                FeatureTypeStyle[] ftStyles = style.getFeatureTypeStyles();
061:
062:                for (int i = 0; i < ftStyles.length; i++) {
063:                    ftStyles[i].accept(this );
064:                }
065:            }
066:
067:            /**
068:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Rule)
069:             */
070:            public void visit(Rule rule) {
071:                Filter filter = rule.getFilter();
072:
073:                if (filter != null) {
074:                    filter.accept(this , null);
075:                }
076:
077:                Symbolizer[] symbolizers = rule.getSymbolizers();
078:
079:                if (symbolizers != null) {
080:                    for (int i = 0; i < symbolizers.length; i++) {
081:                        Symbolizer symbolizer = symbolizers[i];
082:                        symbolizer.accept(this );
083:                    }
084:                }
085:
086:                Graphic[] legendGraphics = rule.getLegendGraphic();
087:
088:                if (legendGraphics != null) {
089:                }
090:            }
091:
092:            /**
093:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.FeatureTypeStyle)
094:             */
095:            public void visit(FeatureTypeStyle fts) {
096:                Rule[] rules = fts.getRules();
097:
098:                for (int i = 0; i < rules.length; i++) {
099:                    Rule rule = rules[i];
100:                    rule.accept(this );
101:                }
102:            }
103:
104:            /**
105:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Fill)
106:             */
107:            public void visit(Fill fill) {
108:                if (fill.getBackgroundColor() != null) {
109:                    fill.getBackgroundColor().accept((ExpressionVisitor) this ,
110:                            null);
111:                }
112:
113:                if (fill.getColor() != null) {
114:                    fill.getColor().accept(this , null);
115:                }
116:
117:                if (fill.getGraphicFill() != null) {
118:                    fill.getGraphicFill().accept(this );
119:                }
120:
121:                if (fill.getOpacity() != null) {
122:                    fill.getOpacity().accept(this , null);
123:                }
124:            }
125:
126:            /**
127:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Stroke)
128:             */
129:            public void visit(Stroke stroke) {
130:                if (stroke.getColor() != null) {
131:                    stroke.getColor().accept(this , null);
132:                }
133:
134:                if (stroke.getDashOffset() != null) {
135:                    stroke.getDashOffset().accept(this , null);
136:                }
137:
138:                if (stroke.getGraphicFill() != null) {
139:                    stroke.getGraphicFill().accept(this );
140:                }
141:
142:                if (stroke.getGraphicStroke() != null) {
143:                    stroke.getGraphicStroke().accept(this );
144:                }
145:
146:                if (stroke.getLineCap() != null) {
147:                    stroke.getLineCap().accept(this , null);
148:                }
149:
150:                if (stroke.getLineJoin() != null) {
151:                    stroke.getLineJoin().accept(this , null);
152:                }
153:
154:                if (stroke.getOpacity() != null) {
155:                    stroke.getOpacity().accept(this , null);
156:                }
157:
158:                if (stroke.getWidth() != null) {
159:                    stroke.getWidth().accept(this , null);
160:                }
161:            }
162:
163:            /**
164:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Symbolizer)
165:             */
166:            public void visit(Symbolizer sym) {
167:                if (sym instanceof  PointSymbolizer) {
168:                    visit((PointSymbolizer) sym);
169:                }
170:
171:                if (sym instanceof  LineSymbolizer) {
172:                    visit((LineSymbolizer) sym);
173:                }
174:
175:                if (sym instanceof  PolygonSymbolizer) {
176:                    visit((PolygonSymbolizer) sym);
177:                }
178:
179:                if (sym instanceof  TextSymbolizer) {
180:                    visit((TextSymbolizer) sym);
181:                }
182:
183:                if (sym instanceof  RasterSymbolizer) {
184:                    visit((RasterSymbolizer) sym);
185:                }
186:            }
187:
188:            public void visit(RasterSymbolizer rs) {
189:                if (rs.getGeometryPropertyName() != null) {
190:                    attributeNames.add(rs.getGeometryPropertyName());
191:
192:                    // FIXME
193:                    // LiteRenderer2 trhwos an Exception:
194:                    //  Do not know how to deep copy org.geotools.coverage.grid.GridCoverage2D
195:                    // attributeNames.add("grid");
196:                }
197:
198:                if (rs.getImageOutline() != null) {
199:                    rs.getImageOutline().accept(this );
200:                }
201:
202:                if (rs.getOpacity() != null) {
203:                    rs.getOpacity().accept(this , null);
204:                }
205:            }
206:
207:            /**
208:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PointSymbolizer)
209:             */
210:            public void visit(PointSymbolizer ps) {
211:                if (ps.getGeometryPropertyName() != null) {
212:                    attributeNames.add(ps.getGeometryPropertyName());
213:                } else {
214:                    this .defaultGeometryUsed = true; // they want the default geometry (see GEOS-469)
215:                }
216:
217:                if (ps.getGraphic() != null) {
218:                    ps.getGraphic().accept(this );
219:                }
220:
221:            }
222:
223:            /**
224:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.LineSymbolizer)
225:             */
226:            public void visit(LineSymbolizer line) {
227:                if (line.getGeometryPropertyName() != null) {
228:                    attributeNames.add(line.getGeometryPropertyName());
229:                } else {
230:                    this .defaultGeometryUsed = true; // they want the default geometry (see GEOS-469)
231:                }
232:
233:                if (line.getStroke() != null) {
234:                    line.getStroke().accept(this );
235:                }
236:            }
237:
238:            /**
239:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PolygonSymbolizer)
240:             */
241:            public void visit(PolygonSymbolizer poly) {
242:                if (poly.getGeometryPropertyName() != null) {
243:                    attributeNames.add(poly.getGeometryPropertyName());
244:                } else {
245:                    this .defaultGeometryUsed = true; // they want the default geometry (see GEOS-469)
246:                }
247:
248:                if (poly.getStroke() != null) {
249:                    poly.getStroke().accept(this );
250:                }
251:
252:                if (poly.getFill() != null) {
253:                    poly.getFill().accept(this );
254:                }
255:            }
256:
257:            /**
258:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.TextSymbolizer)
259:             */
260:            public void visit(TextSymbolizer text) {
261:                if (text.getGeometryPropertyName() != null) {
262:                    attributeNames.add(text.getGeometryPropertyName());
263:                } else {
264:                    this .defaultGeometryUsed = true; // they want the default geometry (see GEOS-469)
265:                }
266:
267:                if (text instanceof  TextSymbolizer2) {
268:                    if (((TextSymbolizer2) text).getGraphic() != null)
269:                        ((TextSymbolizer2) text).getGraphic().accept(this );
270:                }
271:
272:                if (text.getFill() != null) {
273:                    text.getFill().accept(this );
274:                }
275:
276:                if (text.getHalo() != null) {
277:                    text.getHalo().accept(this );
278:                }
279:
280:                if (text.getFonts() != null) {
281:                    Font[] fonts = text.getFonts();
282:
283:                    for (int i = 0; i < fonts.length; i++) {
284:                        Font font = fonts[i];
285:
286:                        if (font.getFontFamily() != null) {
287:                            font.getFontFamily().accept(this , null);
288:                        }
289:
290:                        if (font.getFontSize() != null) {
291:                            font.getFontSize().accept(this , null);
292:                        }
293:
294:                        if (font.getFontStyle() != null) {
295:                            font.getFontStyle().accept(this , null);
296:                        }
297:
298:                        if (font.getFontWeight() != null) {
299:                            font.getFontWeight().accept(this , null);
300:                        }
301:                    }
302:                }
303:
304:                if (text.getHalo() != null) {
305:                    text.getHalo().accept(this );
306:                }
307:
308:                if (text.getLabel() != null) {
309:                    text.getLabel().accept(this , null);
310:                }
311:
312:                if (text.getPlacement() != null) {
313:                    text.getPlacement().accept(this );
314:                }
315:
316:                if (text.getPriority() != null) {
317:                    text.getPriority().accept(this , null);
318:                }
319:            }
320:
321:            /**
322:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Graphic)
323:             */
324:            public void visit(Graphic gr) {
325:                if (gr.getSymbols() != null) {
326:                    Symbol[] symbols = gr.getSymbols();
327:
328:                    for (int i = 0; i < symbols.length; i++) {
329:                        Symbol symbol = symbols[i];
330:                        symbol.accept(this );
331:                    }
332:                }
333:
334:                if (gr.getOpacity() != null) {
335:                    gr.getOpacity().accept(this , null);
336:                }
337:
338:                if (gr.getRotation() != null) {
339:                    gr.getRotation().accept(this , null);
340:                }
341:
342:                if (gr.getSize() != null) {
343:                    gr.getSize().accept(this , null);
344:                }
345:
346:                if (gr.getDisplacement() != null)
347:                    gr.getDisplacement().accept(this );
348:            }
349:
350:            /**
351:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Mark)
352:             */
353:            public void visit(Mark mark) {
354:                if (mark.getFill() != null) {
355:                    mark.getFill().accept(this );
356:                }
357:
358:                if (mark.getStroke() != null) {
359:                    mark.getStroke().accept(this );
360:                }
361:
362:                if (mark.getRotation() != null) {
363:                    mark.getRotation().accept(this , null);
364:                }
365:
366:                if (mark.getSize() != null) {
367:                    mark.getSize().accept(this , null);
368:                }
369:
370:                if (mark.getWellKnownName() != null)
371:                    mark.getWellKnownName().accept(this , null);
372:            }
373:
374:            /**
375:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.ExternalGraphic)
376:             */
377:            public void visit(ExternalGraphic exgr) {
378:                // nothing to do
379:            }
380:
381:            /**
382:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.PointPlacement)
383:             */
384:            public void visit(PointPlacement pp) {
385:                if (pp.getAnchorPoint() != null) {
386:                    pp.getAnchorPoint().accept(this );
387:                }
388:
389:                if (pp.getDisplacement() != null) {
390:                    pp.getDisplacement().accept(this );
391:                }
392:
393:                if (pp.getRotation() != null) {
394:                    pp.getRotation().accept(this , null);
395:                }
396:            }
397:
398:            /**
399:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.AnchorPoint)
400:             */
401:            public void visit(AnchorPoint ap) {
402:                if (ap.getAnchorPointX() != null) {
403:                    ap.getAnchorPointX().accept(this , null);
404:                }
405:
406:                if (ap.getAnchorPointY() != null) {
407:                    ap.getAnchorPointY().accept(this , null);
408:                }
409:            }
410:
411:            /**
412:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Displacement)
413:             */
414:            public void visit(Displacement dis) {
415:                if (dis.getDisplacementX() != null) {
416:                    dis.getDisplacementX().accept(this , null);
417:                }
418:
419:                if (dis.getDisplacementY() != null) {
420:                    dis.getDisplacementY().accept(this , null);
421:                }
422:            }
423:
424:            /**
425:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.LinePlacement)
426:             */
427:            public void visit(LinePlacement lp) {
428:                if (lp.getPerpendicularOffset() != null) {
429:                    lp.getPerpendicularOffset().accept(this , null);
430:                }
431:            }
432:
433:            /**
434:             * @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Halo)
435:             */
436:            public void visit(Halo halo) {
437:                if (halo.getFill() != null) {
438:                    halo.getFill().accept(this );
439:                }
440:
441:                if (halo.getRadius() != null) {
442:                    halo.getRadius().accept(this , null);
443:                }
444:            }
445:
446:            public void visit(StyledLayerDescriptor sld) {
447:                StyledLayer[] layers = sld.getStyledLayers();
448:
449:                for (int i = 0; i < layers.length; i++) {
450:                    if (layers[i] instanceof  NamedLayer) {
451:                        ((NamedLayer) layers[i]).accept(this );
452:                    } else if (layers[i] instanceof  UserLayer) {
453:                        ((UserLayer) layers[i]).accept(this );
454:                    }
455:                }
456:            }
457:
458:            public void visit(NamedLayer layer) {
459:                Style[] styles = layer.getStyles();
460:
461:                for (int i = 0; i < styles.length; i++) {
462:                    styles[i].accept(this );
463:                }
464:            }
465:
466:            public void visit(UserLayer layer) {
467:                Style[] styles = layer.getUserStyles();
468:
469:                for (int i = 0; i < styles.length; i++) {
470:                    styles[i].accept(this );
471:                }
472:            }
473:
474:            public void visit(FeatureTypeConstraint ftc) {
475:                // TODO Auto-generated method stub
476:            }
477:
478:            public void visit(ColorMap map) {
479:                ColorMapEntry[] entries = map.getColorMapEntries();
480:
481:                for (int i = 0; i < entries.length; i++) {
482:                    entries[i].accept(this );
483:                }
484:            }
485:
486:            public void visit(ColorMapEntry entry) {
487:                // TODO Auto-generated method stub
488:            }
489:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.