Source Code Cross Referenced for StyleMap.java in  » Graphic-Library » batik » org » apache » batik » css » engine » 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 » Graphic Library » batik » org.apache.batik.css.engine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:        package org.apache.batik.css.engine;
020:
021:        import org.apache.batik.css.engine.value.Value;
022:
023:        /**
024:         * This class represents objects which contains property/value mappings.
025:         *
026:         * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
027:         * @version $Id: StyleMap.java 498515 2007-01-22 03:19:02Z cam $
028:         */
029:        public class StyleMap {
030:
031:            //
032:            // The masks, still have 2 free bits: 0x0800, & 0x1000, could also
033:            // go to int if needed.
034:            //
035:            public static final short IMPORTANT_MASK = 0x0001;
036:            public static final short COMPUTED_MASK = 0x0002;
037:            public static final short NULL_CASCADED_MASK = 0x0004;
038:            public static final short INHERITED_MASK = 0x0008;
039:
040:            public static final short LINE_HEIGHT_RELATIVE_MASK = 0x0010;
041:            public static final short FONT_SIZE_RELATIVE_MASK = 0x0020;
042:            public static final short COLOR_RELATIVE_MASK = 0x0040;
043:            public static final short PARENT_RELATIVE_MASK = 0x0080;
044:            public static final short BLOCK_WIDTH_RELATIVE_MASK = 0x0100;
045:            public static final short BLOCK_HEIGHT_RELATIVE_MASK = 0x0200;
046:            public static final short BOX_RELATIVE_MASK = 0x0400;
047:
048:            public static final short ORIGIN_MASK = (short) 0xE000; // 3 last bits
049:
050:            //
051:            // The origin values.
052:            //
053:            public static final short USER_AGENT_ORIGIN = 0;
054:            public static final short USER_ORIGIN = 0x2000; // 0010
055:            public static final short NON_CSS_ORIGIN = 0x4000; // 0100
056:            public static final short AUTHOR_ORIGIN = 0x6000; // 0110
057:            public static final short INLINE_AUTHOR_ORIGIN = (short) 0x8000; // 1000
058:            public static final short OVERRIDE_ORIGIN = (short) 0xA000; // 1010
059:
060:            /**
061:             * The values.
062:             */
063:            protected Value[] values;
064:
065:            /**
066:             * To store the value masks.
067:             */
068:            protected short[] masks;
069:
070:            /**
071:             * Whether the values of this map cannot be re-cascaded.
072:             */
073:            protected boolean fixedCascadedValues;
074:
075:            /**
076:             * Creates a new StyleMap.
077:             */
078:            public StyleMap(int size) {
079:                values = new Value[size];
080:                masks = new short[size];
081:            }
082:
083:            /**
084:             * Whether this map has fixed cascaded value.
085:             */
086:            public boolean hasFixedCascadedValues() {
087:                return fixedCascadedValues;
088:            }
089:
090:            /**
091:             * Sets the fixedCascadedValues property.
092:             */
093:            public void setFixedCascadedStyle(boolean b) {
094:                fixedCascadedValues = b;
095:            }
096:
097:            /**
098:             * Returns the value at the given index, null if unspecified.
099:             */
100:            public Value getValue(int i) {
101:                return values[i];
102:            }
103:
104:            /**
105:             * Returns the mask of the given property value.
106:             */
107:            public short getMask(int i) {
108:                return masks[i];
109:            }
110:
111:            /**
112:             * Tells whether the given property value is important.
113:             */
114:            public boolean isImportant(int i) {
115:                return (masks[i] & IMPORTANT_MASK) != 0;
116:            }
117:
118:            /**
119:             * Tells whether the given property value is computed.
120:             */
121:            public boolean isComputed(int i) {
122:                return (masks[i] & COMPUTED_MASK) != 0;
123:            }
124:
125:            /**
126:             * Tells whether the given cascaded property value is null.
127:             */
128:            public boolean isNullCascaded(int i) {
129:                return (masks[i] & NULL_CASCADED_MASK) != 0;
130:            }
131:
132:            /**
133:             * Tells whether the given cascaded property value was
134:             * inherited from it's parent or set locally.
135:             */
136:            public boolean isInherited(int i) {
137:                return (masks[i] & INHERITED_MASK) != 0;
138:            }
139:
140:            /**
141:             * Returns the origin value.
142:             */
143:            public short getOrigin(int i) {
144:                return (short) (masks[i] & ORIGIN_MASK);
145:            }
146:
147:            /**
148:             * Tells whether the given property value is relative to 'color'.
149:             */
150:            public boolean isColorRelative(int i) {
151:                return (masks[i] & COLOR_RELATIVE_MASK) != 0;
152:            }
153:
154:            /**
155:             * Tells whether the given property value is relative to the parent's
156:             * property value.
157:             */
158:            public boolean isParentRelative(int i) {
159:                return (masks[i] & PARENT_RELATIVE_MASK) != 0;
160:            }
161:
162:            /**
163:             * Tells whether the given property value is relative to 'line-height'.
164:             */
165:            public boolean isLineHeightRelative(int i) {
166:                return (masks[i] & LINE_HEIGHT_RELATIVE_MASK) != 0;
167:            }
168:
169:            /**
170:             * Tells whether the given property value is relative to 'font-size'.
171:             */
172:            public boolean isFontSizeRelative(int i) {
173:                return (masks[i] & FONT_SIZE_RELATIVE_MASK) != 0;
174:            }
175:
176:            /**
177:             * Tells whether the given property value is relative to the
178:             * width of the containing block.
179:             */
180:            public boolean isBlockWidthRelative(int i) {
181:                return (masks[i] & BLOCK_WIDTH_RELATIVE_MASK) != 0;
182:            }
183:
184:            /**
185:             * Tells whether the given property value is relative to the
186:             * height of the containing block.
187:             */
188:            public boolean isBlockHeightRelative(int i) {
189:                return (masks[i] & BLOCK_HEIGHT_RELATIVE_MASK) != 0;
190:            }
191:
192:            /**
193:             * Puts a property value, given the property index.
194:             * @param i The property index.
195:             * @param v The property value.
196:             */
197:            public void putValue(int i, Value v) {
198:                values[i] = v;
199:            }
200:
201:            /**
202:             * Puts a property mask, given the property index.
203:             * @param i The property index.
204:             * @param m The property mask.
205:             */
206:            public void putMask(int i, short m) {
207:                masks[i] = m;
208:            }
209:
210:            /**
211:             * Sets the priority of a property value.
212:             */
213:            public void putImportant(int i, boolean b) {
214:                if (b)
215:                    masks[i] |= IMPORTANT_MASK;
216:                else
217:                    masks[i] &= ~IMPORTANT_MASK;
218:            }
219:
220:            /**
221:             * Sets the origin of the given value.
222:             */
223:            public void putOrigin(int i, short val) {
224:                masks[i] &= ~ORIGIN_MASK;
225:                masks[i] |= (short) (val & ORIGIN_MASK);
226:            }
227:
228:            /**
229:             * Sets the computed flag of a property value.
230:             */
231:            public void putComputed(int i, boolean b) {
232:                if (b)
233:                    masks[i] |= COMPUTED_MASK;
234:                else
235:                    masks[i] &= ~COMPUTED_MASK;
236:            }
237:
238:            /**
239:             * Sets the null-cascaded flag of a property value.
240:             */
241:            public void putNullCascaded(int i, boolean b) {
242:                if (b)
243:                    masks[i] |= NULL_CASCADED_MASK;
244:                else
245:                    masks[i] &= ~NULL_CASCADED_MASK;
246:            }
247:
248:            /**
249:             * Sets the inherited flag of a property value.
250:             * If true this computed value was inherited from it's parent.
251:             */
252:            public void putInherited(int i, boolean b) {
253:                if (b)
254:                    masks[i] |= INHERITED_MASK;
255:                else
256:                    masks[i] &= ~INHERITED_MASK;
257:            }
258:
259:            /**
260:             * Sets the color-relative flag of a property value.
261:             */
262:            public void putColorRelative(int i, boolean b) {
263:                if (b)
264:                    masks[i] |= COLOR_RELATIVE_MASK;
265:                else
266:                    masks[i] &= ~COLOR_RELATIVE_MASK;
267:            }
268:
269:            /**
270:             * Sets the parent-relative flag of a property value.
271:             */
272:            public void putParentRelative(int i, boolean b) {
273:                if (b)
274:                    masks[i] |= PARENT_RELATIVE_MASK;
275:                else
276:                    masks[i] &= ~PARENT_RELATIVE_MASK;
277:            }
278:
279:            /**
280:             * Sets the line-height-relative flag of a property value.
281:             */
282:            public void putLineHeightRelative(int i, boolean b) {
283:                if (b)
284:                    masks[i] |= LINE_HEIGHT_RELATIVE_MASK;
285:                else
286:                    masks[i] &= ~LINE_HEIGHT_RELATIVE_MASK;
287:            }
288:
289:            /**
290:             * Sets the font-size-relative flag of a property value.
291:             */
292:            public void putFontSizeRelative(int i, boolean b) {
293:                if (b)
294:                    masks[i] |= FONT_SIZE_RELATIVE_MASK;
295:                else
296:                    masks[i] &= ~FONT_SIZE_RELATIVE_MASK;
297:            }
298:
299:            /**
300:             * Sets the block-width-relative flag of a property value.
301:             */
302:            public void putBlockWidthRelative(int i, boolean b) {
303:                if (b)
304:                    masks[i] |= BLOCK_WIDTH_RELATIVE_MASK;
305:                else
306:                    masks[i] &= ~BLOCK_WIDTH_RELATIVE_MASK;
307:            }
308:
309:            /**
310:             * Sets the block-height-relative flag of a property value.
311:             */
312:            public void putBlockHeightRelative(int i, boolean b) {
313:                if (b)
314:                    masks[i] |= BLOCK_HEIGHT_RELATIVE_MASK;
315:                else
316:                    masks[i] &= ~BLOCK_HEIGHT_RELATIVE_MASK;
317:            }
318:
319:            /**
320:             * Returns a printable representation of this style map.
321:             */
322:            public String toString(CSSEngine eng) {
323:                // Note that values.length should always be equal to
324:                // eng.getNumberOfProperties() for StyleMaps that were created
325:                // by that CSSEngine.
326:                int nSlots = values.length;
327:                StringBuffer sb = new StringBuffer(nSlots * 8);
328:                for (int i = 0; i < nSlots; i++) {
329:                    Value v = values[i];
330:                    if (v == null)
331:                        continue;
332:
333:                    sb.append(eng.getPropertyName(i));
334:                    sb.append(": ");
335:                    sb.append(v);
336:                    if (isImportant(i))
337:                        sb.append(" !important");
338:                    sb.append(";\n");
339:                }
340:                return sb.toString();
341:            }
342:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.