Source Code Cross Referenced for Rule.java in  » GIS » deegree » org » deegree » graphics » sld » 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 » deegree » org.deegree.graphics.sld 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/graphics/sld/Rule.java $
002:        /*----------------    FILE HEADER  ------------------------------------------
003:
004:         This file is part of deegree.
005:         Copyright (C) 2001-2008 by:
006:         EXSE, Department of Geography, University of Bonn
007:         http://www.giub.uni-bonn.de/deegree/
008:         lat/lon GmbH
009:         http://www.lat-lon.de
010:
011:         This library is free software; you can redistribute it and/or
012:         modify it under the terms of the GNU Lesser General Public
013:         License as published by the Free Software Foundation; either
014:         version 2.1 of the License, or (at your option) any later version.
015:
016:         This library is distributed in the hope that it will be useful,
017:         but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:         Lesser General Public License for more details.
020:
021:         You should have received a copy of the GNU Lesser General Public
022:         License along with this library; if not, write to the Free Software
023:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:
025:         Contact:
026:
027:         Andreas Poth
028:         lat/lon GmbH
029:         Aennchenstr. 19
030:         53115 Bonn
031:         Germany
032:         E-Mail: poth@lat-lon.de
033:
034:         Prof. Dr. Klaus Greve
035:         Department of Geography
036:         University of Bonn
037:         Meckenheimer Allee 166
038:         53115 Bonn
039:         Germany
040:         E-Mail: greve@giub.uni-bonn.de
041:
042:        
043:         ---------------------------------------------------------------------------*/
044:        package org.deegree.graphics.sld;
045:
046:        import java.util.ArrayList;
047:        import java.util.List;
048:
049:        import org.deegree.framework.xml.Marshallable;
050:        import org.deegree.model.filterencoding.Filter;
051:
052:        /**
053:         * A rule is used to attach a condition to and group the individual symbolizers used for rendering.
054:         * The Title and Abstract describe the rule and may be used to generate a legend, as may the
055:         * LegendGraphic. The Filter, ElseFilter, MinScale, and MaxScale elements allow the selection of
056:         * features and rendering scales for a rule. The scale selection works as follows. When a map is to
057:         * be rendered, the scale denominator is computed and all rules in all UserStyles that have a scale
058:         * outside of the request range are dropped. (This also includes Rules that have an ElseFilter.) An
059:         * ElseFilter is simply an ELSE condition to the conditions (Filters) of all other rules in the same
060:         * UserStyle. The exact meaning of the ElseFilter is determined after Rules have been eliminated for
061:         * not fitting the rendering scale. This definition of the behaviour of ElseFilters may seem a
062:         * little strange, but it allows for scale- dependent and scale-independent ELSE conditions. For the
063:         * Filter, only SqlExpression is available for specification, but this is a hack and should be
064:         * replaced with Filter as defined in WFS. A missing Filter element means "always true". If a set of
065:         * Rules has no ElseFilters, then some features may not be rendered (which is presumably the desired
066:         * behavior). The Scales are actually scale denominators (as double floats), so "10e6" would be
067:         * interpreted as 1:10M. A missing MinScale means there is no lower bound to the scale- denominator
068:         * range (lim[x->0+](x)), and a missing MaxScale means there is no upper bound (infinity). 0.28mm
069:         * 
070:         * 
071:         * @author <a href="mailto:k.lupp@web.de">Katharina Lupp </a>
072:         * @author last edited by: $Author: apoth $
073:         * @version $Revision: 9340 $ $Date: 2007-12-27 04:32:12 -0800 (Thu, 27 Dec 2007) $
074:         */
075:
076:        public class Rule implements  Marshallable {
077:
078:            private List<Symbolizer> symbolizers = null;
079:
080:            /**
081:             * 
082:             */
083:            private Filter filter = null;
084:
085:            /**
086:             * 
087:             */
088:            private LegendGraphic legendGraphic = null;
089:
090:            private String abstract_ = null;
091:
092:            private String name = null;
093:
094:            private String title = null;
095:
096:            private boolean elseFilter = false;
097:
098:            private double maxScaleDenominator = 0;
099:
100:            private double minScaleDenominator = 0;
101:
102:            /**
103:             * default constructor
104:             */
105:            Rule() {
106:                symbolizers = new ArrayList<Symbolizer>();
107:            }
108:
109:            /**
110:             * constructor initializing the class with the <Rule>
111:             */
112:            Rule(Symbolizer[] symbolizers, String name, String title,
113:                    String abstract_, LegendGraphic legendGraphic,
114:                    Filter filter, boolean elseFilter,
115:                    double minScaleDenominator, double maxScaleDenominator) {
116:                this ();
117:                setSymbolizers(symbolizers);
118:                setName(name);
119:                setTitle(title);
120:                setAbstract(abstract_);
121:                setLegendGraphic(legendGraphic);
122:                setFilter(filter);
123:                setElseFilter(elseFilter);
124:                setMinScaleDenominator(minScaleDenominator);
125:                setMaxScaleDenominator(maxScaleDenominator);
126:            }
127:
128:            /**
129:             * returns the name of the rule. this for machine interpreting.
130:             * 
131:             * @return the name of the rule
132:             * 
133:             */
134:            public String getName() {
135:                return name;
136:            }
137:
138:            /**
139:             * sets the name of the rule. this for machine interpreting.
140:             * 
141:             * @param name
142:             *            the name of the rule
143:             * 
144:             */
145:            public void setName(String name) {
146:                this .name = name;
147:            }
148:
149:            /**
150:             * returns the human readable title of the rule
151:             * 
152:             * @return the title of the rule
153:             * 
154:             */
155:            public String getTitle() {
156:                return title;
157:            }
158:
159:            /**
160:             * sets the human readable title of the rule
161:             * 
162:             * @param title
163:             *            the title of the rule
164:             * 
165:             */
166:            public void setTitle(String title) {
167:                this .title = title;
168:            }
169:
170:            /**
171:             * returns the human readable abstract of the rule
172:             * 
173:             * @return the abstract of the rule
174:             */
175:            public String getAbstract() {
176:                return abstract_;
177:            }
178:
179:            /**
180:             * sets the human readable abstract of the rule
181:             * 
182:             * @param abstract_
183:             *            the abstract of the rule
184:             */
185:            public void setAbstract(String abstract_) {
186:                this .abstract_ = abstract_;
187:            }
188:
189:            /**
190:             * The LegendGraphic element gives an optional explicit Graphic symbol to be displayed in a
191:             * legend for this rule.
192:             * 
193:             * @return the legendGraphic of the rule
194:             * 
195:             */
196:            public LegendGraphic getLegendGraphic() {
197:                return legendGraphic;
198:            }
199:
200:            /**
201:             * sets the LegendGraphic element
202:             * 
203:             * @param legendGraphic
204:             *            the legendGraphic of the rule
205:             * 
206:             */
207:            public void setLegendGraphic(LegendGraphic legendGraphic) {
208:                this .legendGraphic = legendGraphic;
209:            }
210:
211:            /**
212:             * The Filter element has a relatively straightforward meaning. The syntax of the Filter element
213:             * is defined in the WFS specification and allows both attribute (property) and spatial
214:             * filtering.
215:             * 
216:             * @return the filter element
217:             * 
218:             */
219:            public Filter getFilter() {
220:                return filter;
221:            }
222:
223:            /**
224:             * sets the <Filter>
225:             * 
226:             * @param filter
227:             *            the filter element
228:             * 
229:             */
230:            public void setFilter(Filter filter) {
231:                this .filter = filter;
232:            }
233:
234:            /**
235:             * The ElseFilter allows rules to be specified that are activated for features are not selected
236:             * by any other rule in a feature-type style.
237:             * 
238:             * @return true if the rule has an elseFilter
239:             */
240:            public boolean hasElseFilter() {
241:                return elseFilter;
242:            }
243:
244:            /**
245:             * sets the <ElseFilter>
246:             * 
247:             * @param elseFilter
248:             *            an elseFilter
249:             * 
250:             */
251:            public void setElseFilter(boolean elseFilter) {
252:                this .elseFilter = elseFilter;
253:            }
254:
255:            /**
256:             * The MinScaleDenominator and MaxScaleDenominator elements of a Rule define the range of
257:             * map-rendering scales for which the rule should be applied. The MinScaleDenominator and
258:             * MaxScaleDenominator elements, as their names suggest, are simply the minimum and maximum
259:             * ranges of scale (denominators) of maps for which a rule should apply.
260:             * 
261:             * @return the MinScaleDenominator for the rule
262:             * 
263:             */
264:            public double getMinScaleDenominator() {
265:                return minScaleDenominator;
266:            }
267:
268:            /**
269:             * sets the <MinScaleDenominator>
270:             * 
271:             * @param minScaleDenominator
272:             *            the MinScaleDenominator for the rule
273:             * 
274:             */
275:            public void setMinScaleDenominator(double minScaleDenominator) {
276:                this .minScaleDenominator = minScaleDenominator;
277:            }
278:
279:            /**
280:             * The MinScaleDenominator and MaxScaleDenominator elements of a Rule define the range of
281:             * map-rendering scales for which the rule should be applied. The MinScaleDenominator and
282:             * MaxScaleDenominator elements, as their names suggest, are simply the minimum and maximum
283:             * ranges of scale (denominators) of maps for which a rule should apply.
284:             * 
285:             * @return the MaxScaleDenominator for the rule
286:             * 
287:             */
288:            public double getMaxScaleDenominator() {
289:                return maxScaleDenominator;
290:            }
291:
292:            /**
293:             * sets the <MaxScaleDenominator>
294:             * 
295:             * @param maxScaleDenominator
296:             *            the MaxScaleDenominator for the rule
297:             * 
298:             */
299:            public void setMaxScaleDenominator(double maxScaleDenominator) {
300:                this .maxScaleDenominator = maxScaleDenominator;
301:            }
302:
303:            /**
304:             * Embedded inside of Rules, which group conditions for styling features, are Symbolizers. A
305:             * symbolizer describes how a feature is to appear on a map. The symbolizer describes not just
306:             * the shape that should appear but also such graphical properties as color and opacity. A
307:             * symbol is obtained by specifying one of a small number of different types of symbolizer and
308:             * then supplying parameters to override its default behaviour. Currently, five types of
309:             * symbolizers are defined.
310:             * <p>
311:             * </p>
312:             * The Symbolizers will be returned in the sequece of their occurence with in the rule
313:             * definition. Its the users function to determine what type of Symbolizer(s) are returned. This
314:             * can be done for example by using the <tt>instanceof</tt> operator of Java.
315:             * 
316:             * @return the Symbolizer for the rule
317:             * 
318:             */
319:            public Symbolizer[] getSymbolizers() {
320:                return symbolizers.toArray(new Symbolizer[symbolizers.size()]);
321:            }
322:
323:            /**
324:             * sets the <Symbolizer>
325:             * 
326:             * @param symbolizers
327:             *            symbolizers for the rule
328:             */
329:            public void setSymbolizers(Symbolizer[] symbolizers) {
330:                this .symbolizers.clear();
331:
332:                if (symbolizers != null) {
333:                    for (int i = 0; i < symbolizers.length; i++) {
334:                        this .symbolizers.add(symbolizers[i]);
335:                    }
336:                }
337:            }
338:
339:            /**
340:             * adds a <Symbolizer>
341:             * 
342:             * @param symbolizer
343:             *            symbolizer to add
344:             */
345:            public void addSymbolizer(Symbolizer symbolizer) {
346:                symbolizers.add(symbolizer);
347:            }
348:
349:            /**
350:             * Removes a <Symbolizer>from a set of Symbolizers.
351:             * 
352:             * @param symbolizer
353:             *            symbolizer to remove
354:             */
355:            public void removeSymbolizer(Symbolizer symbolizer) {
356:                if (symbolizers.indexOf(symbolizer) != -1) {
357:                    symbolizers.remove(symbolizers.indexOf(symbolizer));
358:                }
359:            }
360:
361:            /**
362:             * exports the content of the Rule as XML formated String
363:             * 
364:             * @return xml representation of the Rule
365:             */
366:            public String exportAsXML() {
367:
368:                StringBuffer sb = new StringBuffer(1000);
369:                sb.append("<Rule>");
370:                if (name != null && !name.equals("")) {
371:                    sb.append("<Name>").append(name).append("</Name>");
372:                }
373:                if (title != null && !title.equals("")) {
374:                    sb.append("<Title>").append(title).append("</Title>");
375:                }
376:                if (abstract_ != null && !abstract_.equals("")) {
377:                    sb.append("<Abstract>").append(abstract_).append(
378:                            "</Abstract>");
379:                }
380:                if (legendGraphic != null) {
381:                    sb.append("<LegendGraphic>").append(
382:                            ((Marshallable) legendGraphic).exportAsXML())
383:                            .append("</LegendGraphic>");
384:                }
385:                if (filter != null) {
386:                    sb.append(filter.toXML());
387:                }
388:                if (elseFilter) {
389:                    sb.append("<ElseFilter/>");
390:                }
391:                sb.append("<MinScaleDenominator>").append(minScaleDenominator);
392:                sb.append("</MinScaleDenominator>");
393:                sb.append("<MaxScaleDenominator>").append(maxScaleDenominator);
394:                sb.append("</MaxScaleDenominator>");
395:                for (int i = 0; i < symbolizers.size(); i++) {
396:                    sb
397:                            .append(((Marshallable) symbolizers.get(i))
398:                                    .exportAsXML());
399:                }
400:                sb.append("</Rule>");
401:
402:                return sb.toString();
403:            }
404:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.