Source Code Cross Referenced for FillImpl.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:         *    (C) 2002, Centre for Computational Geography
006:         *    
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation;
010:         *    version 2.1 of the License.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         */
017:        package org.geotools.styling;
018:
019:        // J2SE dependencies
020:        import java.util.logging.Logger;
021:
022:        import org.geotools.event.AbstractGTComponent;
023:        import org.geotools.factory.CommonFactoryFinder;
024:        import org.geotools.factory.GeoTools;
025:        import org.geotools.resources.Utilities;
026:        import org.opengis.filter.FilterFactory;
027:        import org.opengis.filter.expression.Expression;
028:        import org.opengis.util.Cloneable;
029:
030:        /**
031:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/styling/FillImpl.java $
032:         * @version $Id: FillImpl.java 27862 2007-11-12 19:51:19Z desruisseaux $
033:         * @author James Macgill, CCG
034:         */
035:        public class FillImpl extends AbstractGTComponent implements  Fill,
036:                Cloneable {
037:            /**
038:             * The logger for the default core module.
039:             */
040:            private static final Logger LOGGER = org.geotools.util.logging.Logging
041:                    .getLogger("org.geotools.core");
042:            private FilterFactory filterFactory;
043:            private Expression color = null;
044:            private Expression backgroundColor = null;
045:            private Expression opacity = null;
046:            private Graphic graphicFill = null;
047:
048:            /** Creates a new instance of DefaultFill */
049:            protected FillImpl() {
050:                this (CommonFactoryFinder.getFilterFactory(GeoTools
051:                        .getDefaultHints()));
052:            }
053:
054:            public FillImpl(FilterFactory factory) {
055:                filterFactory = factory;
056:            }
057:
058:            public void setFilterFactory(FilterFactory factory) {
059:                filterFactory = factory;
060:            }
061:
062:            /**
063:             * This parameter gives the solid color that will be used for a Fill.<br>
064:             * The color value is RGB-encoded using two hexidecimal digits per
065:             * primary-color component, in the order Red, Green, Blue, prefixed with
066:             * the hash (#) sign.
067:             * The hexidecimal digits between A and F may be in either upper
068:             * or lower case.  For example, full red is encoded as "#ff0000" (with no
069:             * quotation marks).
070:             * The default color is defined to be 50% gray ("#808080").
071:             *
072:             * Note: in CSS this parameter is just called Fill and not Color.
073:             *
074:             * @return The color of the Fill encoded as a hexidecimal RGB value.
075:             */
076:            public Expression getColor() {
077:                return color;
078:            }
079:
080:            /**
081:             * This parameter gives the solid color that will be used for a Fill.<br>
082:             * The color value is RGB-encoded using two hexidecimal digits per
083:             * primary-color component, in the order Red, Green, Blue, prefixed with
084:             * the hash (#) sign.
085:             * The hexidecimal digits between A and F may be in either upper
086:             * or lower case.  For example, full red is encoded as "#ff0000" (with no
087:             * quotation marks).
088:             *
089:             * Note: in CSS this parameter is just called Fill and not Color.
090:             *
091:             * @param rgb The color of the Fill encoded as a hexidecimal RGB value.
092:             */
093:            public void setColor(Expression rgb) {
094:                if (color == rgb)
095:                    return;
096:                Expression old = color;
097:                color = rgb;
098:                fireChildChanged("color", rgb, old);
099:            }
100:
101:            public void setColor(String rgb) {
102:                if (color.toString() == rgb)
103:                    return;
104:
105:                setColor(filterFactory.literal(rgb));
106:            }
107:
108:            /**
109:             * This parameter gives the solid color that will be used as a background for a Fill.<br>
110:             * The color value is RGB-encoded using two hexidecimal digits per
111:             * primary-color component, in the order Red, Green, Blue, prefixed with
112:             * the hash (#) sign.
113:             * The hexidecimal digits between A and F may be in either upper
114:             * or lower case.  For example, full red is encoded as "#ff0000" (with no
115:             * quotation marks).
116:             * The default color is defined to be transparent.
117:             *
118:             *
119:             * @return The color of the Fill encoded as a hexidecimal RGB value.
120:             */
121:            public Expression getBackgroundColor() {
122:                return backgroundColor;
123:            }
124:
125:            /**
126:             * This parameter gives the solid color that will be used as a background for a Fill.<br>
127:             * The color value is RGB-encoded using two hexidecimal digits per
128:             * primary-color component, in the order Red, Green, Blue, prefixed with
129:             * the hash (#) sign.
130:             * The hexidecimal digits between A and F may be in either upper
131:             * or lower case.  For example, full red is encoded as "#ff0000" (with no
132:             * quotation marks).
133:             *
134:             *
135:             *
136:             * @param rgb The color of the Fill encoded as a hexidecimal RGB value.
137:             */
138:            public void setBackgroundColor(Expression rgb) {
139:                if (this .backgroundColor == rgb)
140:                    return;
141:                Expression old = backgroundColor;
142:                backgroundColor = rgb;
143:                fireChildChanged("backgroundColor", rgb, old);
144:            }
145:
146:            public void setBackgroundColor(String rgb) {
147:                LOGGER.fine("setting bg color with " + rgb + " as a string");
148:                if (backgroundColor.toString() == rgb)
149:                    return;
150:
151:                setBackgroundColor(filterFactory.literal(rgb));
152:            }
153:
154:            /**
155:             * This specifies the level of translucency to use when rendering the fill.
156:             * <br>
157:             * The value is encoded as a floating-point value between 0.0 and 1.0
158:             * with 0.0 representing totally transparent and 1.0 representing totally
159:             * opaque, with a linear scale of translucency for intermediate values.<br>
160:             * For example, "0.65" would represent 65% opacity.
161:             * The default value is 1.0 (opaque).
162:             *
163:             * @return The opacity of the fill, where 0.0 is completely transparent
164:             *         and 1.0 is completely opaque.
165:             */
166:            public Expression getOpacity() {
167:                return opacity;
168:            }
169:
170:            /**
171:             * Setter for property opacity.
172:             * @param opacity New value of property opacity.
173:             */
174:            public void setOpacity(Expression opacity) {
175:                if (this .opacity == opacity)
176:                    return;
177:
178:                Expression old = this .opacity;
179:                this .opacity = opacity;
180:
181:                fireChildChanged("opacity", opacity, old);
182:            }
183:
184:            public void setOpacity(String opacity) {
185:                if (this .opacity.toString() == opacity)
186:                    return;
187:
188:                setOpacity(filterFactory.literal(opacity));
189:            }
190:
191:            /**
192:             * This parameter indicates that a stipple-fill repeated graphic will be
193:             * used and specifies the fill graphic to use.
194:             *
195:             * @return graphic The graphic to use as a stipple fill.
196:             *         If null then no Stipple fill should be used.
197:             */
198:            public org.geotools.styling.Graphic getGraphicFill() {
199:                return graphicFill;
200:            }
201:
202:            /**
203:             * Setter for property graphic.
204:             * @param graphicFill New value of property graphic.
205:             */
206:            public void setGraphicFill(org.geotools.styling.Graphic graphicFill) {
207:                if (this .graphicFill == graphicFill)
208:                    return;
209:                Graphic old = this .graphicFill;
210:                this .graphicFill = graphicFill;
211:                fireChildChanged("graphicFill", graphicFill, old);
212:            }
213:
214:            public void accept(StyleVisitor visitor) {
215:                visitor.visit(this );
216:            }
217:
218:            /**
219:             * Returns a clone of the FillImpl.
220:             *  
221:             * @see org.geotools.styling.Fill#clone()
222:             */
223:            public Object clone() {
224:                try {
225:                    FillImpl clone = (FillImpl) super .clone();
226:                    if (graphicFill != null) {
227:                        clone.graphicFill = (Graphic) ((Cloneable) graphicFill)
228:                                .clone();
229:                    }
230:                    return clone;
231:                } catch (CloneNotSupportedException e) {
232:                    // This will never happen
233:                    throw new RuntimeException("Failed to clone FillImpl");
234:                }
235:            }
236:
237:            /**
238:             * Generates a hashcode for the FillImpl.
239:             * 
240:             * @return The hashcode.
241:             */
242:            public int hashCode() {
243:                final int PRIME = 1000003;
244:                int result = 0;
245:                if (color != null) {
246:                    result = PRIME * result + color.hashCode();
247:                }
248:                if (backgroundColor != null) {
249:                    result = PRIME * result + backgroundColor.hashCode();
250:                }
251:                if (opacity != null) {
252:                    result = PRIME * result + opacity.hashCode();
253:                }
254:                if (graphicFill != null) {
255:                    result = PRIME * result + graphicFill.hashCode();
256:                }
257:
258:                return result;
259:            }
260:
261:            /** Compares a FillImpl with another for equality.
262:             * 
263:             *  <p>Two FillImpls are equal if they contain the same,
264:             *  color, backgroundcolor, opacity and graphicFill.
265:             *  
266:             *  @param oth The other FillImpl
267:             *  @return True if this FillImpl is equal to oth.
268:             */
269:            public boolean equals(Object oth) {
270:                if (this  == oth) {
271:                    return true;
272:                }
273:
274:                if (oth instanceof  FillImpl) {
275:                    FillImpl other = (FillImpl) oth;
276:                    return Utilities.equals(this .color, other.color)
277:                            && Utilities.equals(this .backgroundColor,
278:                                    other.backgroundColor)
279:                            && Utilities.equals(this .opacity, other.opacity)
280:                            && Utilities.equals(this .graphicFill,
281:                                    other.graphicFill);
282:                }
283:
284:                return false;
285:            }
286:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.