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


0001:        /*
0002:
0003:           Licensed to the Apache Software Foundation (ASF) under one or more
0004:           contributor license agreements.  See the NOTICE file distributed with
0005:           this work for additional information regarding copyright ownership.
0006:           The ASF licenses this file to You under the Apache License, Version 2.0
0007:           (the "License"); you may not use this file except in compliance with
0008:           the License.  You may obtain a copy of the License at
0009:
0010:               http://www.apache.org/licenses/LICENSE-2.0
0011:
0012:           Unless required by applicable law or agreed to in writing, software
0013:           distributed under the License is distributed on an "AS IS" BASIS,
0014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0015:           See the License for the specific language governing permissions and
0016:           limitations under the License.
0017:
0018:         */
0019:        package org.apache.batik.css.dom;
0020:
0021:        import org.apache.batik.css.engine.value.FloatValue;
0022:        import org.apache.batik.css.engine.value.ListValue;
0023:        import org.apache.batik.css.engine.value.StringValue;
0024:        import org.apache.batik.css.engine.value.Value;
0025:        import org.w3c.dom.DOMException;
0026:        import org.w3c.dom.css.CSSPrimitiveValue;
0027:        import org.w3c.dom.css.CSSValue;
0028:        import org.w3c.dom.css.CSSValueList;
0029:        import org.w3c.dom.css.Counter;
0030:        import org.w3c.dom.css.RGBColor;
0031:        import org.w3c.dom.css.Rect;
0032:
0033:        /**
0034:         * This class implements the {@link org.w3c.dom.css.CSSValue},
0035:         * {@link org.w3c.dom.css.CSSPrimitiveValue},
0036:         * {@link org.w3c.dom.css.CSSValueList} interfaces.
0037:         *
0038:         * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
0039:         * @version $Id: CSSOMValue.java 504107 2007-02-06 12:32:18Z dvholten $
0040:         */
0041:        public class CSSOMValue implements  CSSPrimitiveValue, CSSValueList,
0042:                Counter, Rect, RGBColor {
0043:
0044:            /**
0045:             * The associated value.
0046:             */
0047:            protected ValueProvider valueProvider;
0048:
0049:            /**
0050:             * The modifications handler.
0051:             */
0052:            protected ModificationHandler handler;
0053:
0054:            /**
0055:             * The left component, if this value is a Rect.
0056:             */
0057:            protected LeftComponent leftComponent;
0058:
0059:            /**
0060:             * The right component, if this value is a Rect.
0061:             */
0062:            protected RightComponent rightComponent;
0063:
0064:            /**
0065:             * The bottom component, if this value is a Rect.
0066:             */
0067:            protected BottomComponent bottomComponent;
0068:
0069:            /**
0070:             * The top component, if this value is a Rect.
0071:             */
0072:            protected TopComponent topComponent;
0073:
0074:            /**
0075:             * The red component, if this value is a RGBColor.
0076:             */
0077:            protected RedComponent redComponent;
0078:
0079:            /**
0080:             * The green component, if this value is a RGBColor.
0081:             */
0082:            protected GreenComponent greenComponent;
0083:
0084:            /**
0085:             * The blue component, if this value is a RGBColor.
0086:             */
0087:            protected BlueComponent blueComponent;
0088:
0089:            /**
0090:             * The list items.
0091:             */
0092:            protected CSSValue[] items;
0093:
0094:            /**
0095:             * Creates a new CSSOMValue.
0096:             */
0097:            public CSSOMValue(ValueProvider vp) {
0098:                valueProvider = vp;
0099:            }
0100:
0101:            /**
0102:             * Sets the modification handler of this value.
0103:             */
0104:            public void setModificationHandler(ModificationHandler h) {
0105:                handler = h;
0106:            }
0107:
0108:            /**
0109:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.CSSValue#getCssText()}.
0110:             */
0111:            public String getCssText() {
0112:                return valueProvider.getValue().getCssText();
0113:            }
0114:
0115:            /**
0116:             * <b>DOM</b>: Implements {@link
0117:             * org.w3c.dom.css.CSSValue#setCssText(String)}.
0118:             */
0119:            public void setCssText(String cssText) throws DOMException {
0120:                if (handler == null) {
0121:                    throw new DOMException(
0122:                            DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
0123:                } else {
0124:                    handler.textChanged(cssText);
0125:                }
0126:            }
0127:
0128:            /**
0129:             * <b>DOM</b>: Implements {@link
0130:             * org.w3c.dom.css.CSSValue#getCssValueType()}.
0131:             */
0132:            public short getCssValueType() {
0133:                return valueProvider.getValue().getCssValueType();
0134:            }
0135:
0136:            /**
0137:             * <b>DOM</b>: Implements {@link
0138:             * org.w3c.dom.css.CSSPrimitiveValue#getPrimitiveType()}.
0139:             */
0140:            public short getPrimitiveType() {
0141:                return valueProvider.getValue().getPrimitiveType();
0142:            }
0143:
0144:            /**
0145:             * <b>DOM</b>: Implements {@link
0146:             * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
0147:             */
0148:            public void setFloatValue(short unitType, float floatValue)
0149:                    throws DOMException {
0150:                if (handler == null) {
0151:                    throw new DOMException(
0152:                            DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
0153:                } else {
0154:                    handler.floatValueChanged(unitType, floatValue);
0155:                }
0156:            }
0157:
0158:            /**
0159:             * <b>DOM</b>: Implements {@link
0160:             * org.w3c.dom.css.CSSPrimitiveValue#getFloatValue(short)}.
0161:             */
0162:            public float getFloatValue(short unitType) throws DOMException {
0163:                return convertFloatValue(unitType, valueProvider.getValue());
0164:            }
0165:
0166:            /**
0167:             * Converts the actual float value to the given unit type.
0168:             */
0169:            public static float convertFloatValue(short unitType, Value value) {
0170:                switch (unitType) {
0171:                case CSSPrimitiveValue.CSS_NUMBER:
0172:                case CSSPrimitiveValue.CSS_PERCENTAGE:
0173:                case CSSPrimitiveValue.CSS_EMS:
0174:                case CSSPrimitiveValue.CSS_EXS:
0175:                case CSSPrimitiveValue.CSS_DIMENSION:
0176:                case CSSPrimitiveValue.CSS_PX:
0177:                    if (value.getPrimitiveType() == unitType) {
0178:                        return value.getFloatValue();
0179:                    }
0180:                    break;
0181:                case CSSPrimitiveValue.CSS_CM:
0182:                    return toCentimeters(value);
0183:                case CSSPrimitiveValue.CSS_MM:
0184:                    return toMillimeters(value);
0185:                case CSSPrimitiveValue.CSS_IN:
0186:                    return toInches(value);
0187:                case CSSPrimitiveValue.CSS_PT:
0188:                    return toPoints(value);
0189:                case CSSPrimitiveValue.CSS_PC:
0190:                    return toPicas(value);
0191:                case CSSPrimitiveValue.CSS_DEG:
0192:                    return toDegrees(value);
0193:                case CSSPrimitiveValue.CSS_RAD:
0194:                    return toRadians(value);
0195:                case CSSPrimitiveValue.CSS_GRAD:
0196:                    return toGradians(value);
0197:                case CSSPrimitiveValue.CSS_MS:
0198:                    return toMilliseconds(value);
0199:                case CSSPrimitiveValue.CSS_S:
0200:                    return toSeconds(value);
0201:                case CSSPrimitiveValue.CSS_HZ:
0202:                    return toHertz(value);
0203:                case CSSPrimitiveValue.CSS_KHZ:
0204:                    return tokHertz(value);
0205:                }
0206:                throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0207:            }
0208:
0209:            /**
0210:             * Converts the current value into centimeters.
0211:             */
0212:            protected static float toCentimeters(Value value) {
0213:                switch (value.getPrimitiveType()) {
0214:                case CSSPrimitiveValue.CSS_CM:
0215:                    return value.getFloatValue();
0216:                case CSSPrimitiveValue.CSS_MM:
0217:                    return (value.getFloatValue() / 10);
0218:                case CSSPrimitiveValue.CSS_IN:
0219:                    return (value.getFloatValue() * 2.54f);
0220:                case CSSPrimitiveValue.CSS_PT:
0221:                    return (value.getFloatValue() * 2.54f / 72);
0222:                case CSSPrimitiveValue.CSS_PC:
0223:                    return (value.getFloatValue() * 2.54f / 6);
0224:                default:
0225:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0226:                }
0227:            }
0228:
0229:            /**
0230:             * Converts the current value into inches.
0231:             */
0232:            protected static float toInches(Value value) {
0233:                switch (value.getPrimitiveType()) {
0234:                case CSSPrimitiveValue.CSS_CM:
0235:                    return (value.getFloatValue() / 2.54f);
0236:                case CSSPrimitiveValue.CSS_MM:
0237:                    return (value.getFloatValue() / 25.4f);
0238:                case CSSPrimitiveValue.CSS_IN:
0239:                    return value.getFloatValue();
0240:                case CSSPrimitiveValue.CSS_PT:
0241:                    return (value.getFloatValue() / 72);
0242:                case CSSPrimitiveValue.CSS_PC:
0243:                    return (value.getFloatValue() / 6);
0244:                default:
0245:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0246:                }
0247:            }
0248:
0249:            /**
0250:             * Converts the current value into millimeters.
0251:             */
0252:            protected static float toMillimeters(Value value) {
0253:                switch (value.getPrimitiveType()) {
0254:                case CSSPrimitiveValue.CSS_CM:
0255:                    return (value.getFloatValue() * 10);
0256:                case CSSPrimitiveValue.CSS_MM:
0257:                    return value.getFloatValue();
0258:                case CSSPrimitiveValue.CSS_IN:
0259:                    return (value.getFloatValue() * 25.4f);
0260:                case CSSPrimitiveValue.CSS_PT:
0261:                    return (value.getFloatValue() * 25.4f / 72);
0262:                case CSSPrimitiveValue.CSS_PC:
0263:                    return (value.getFloatValue() * 25.4f / 6);
0264:                default:
0265:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0266:                }
0267:            }
0268:
0269:            /**
0270:             * Converts the current value into points.
0271:             */
0272:            protected static float toPoints(Value value) {
0273:                switch (value.getPrimitiveType()) {
0274:                case CSSPrimitiveValue.CSS_CM:
0275:                    return (value.getFloatValue() * 72 / 2.54f);
0276:                case CSSPrimitiveValue.CSS_MM:
0277:                    return (value.getFloatValue() * 72 / 25.4f);
0278:                case CSSPrimitiveValue.CSS_IN:
0279:                    return (value.getFloatValue() * 72);
0280:                case CSSPrimitiveValue.CSS_PT:
0281:                    return value.getFloatValue();
0282:                case CSSPrimitiveValue.CSS_PC:
0283:                    return (value.getFloatValue() * 12);
0284:                default:
0285:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0286:                }
0287:            }
0288:
0289:            /**
0290:             * Converts the current value into picas.
0291:             */
0292:            protected static float toPicas(Value value) {
0293:                switch (value.getPrimitiveType()) {
0294:                case CSSPrimitiveValue.CSS_CM:
0295:                    return (value.getFloatValue() * 6 / 2.54f);
0296:                case CSSPrimitiveValue.CSS_MM:
0297:                    return (value.getFloatValue() * 6 / 25.4f);
0298:                case CSSPrimitiveValue.CSS_IN:
0299:                    return (value.getFloatValue() * 6);
0300:                case CSSPrimitiveValue.CSS_PT:
0301:                    return (value.getFloatValue() / 12);
0302:                case CSSPrimitiveValue.CSS_PC:
0303:                    return value.getFloatValue();
0304:                default:
0305:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0306:                }
0307:            }
0308:
0309:            /**
0310:             * Converts the current value into degrees.
0311:             */
0312:            protected static float toDegrees(Value value) {
0313:                switch (value.getPrimitiveType()) {
0314:                case CSSPrimitiveValue.CSS_DEG:
0315:                    return value.getFloatValue();
0316:                case CSSPrimitiveValue.CSS_RAD:
0317:                    return (float) Math.toDegrees(value.getFloatValue());
0318:                case CSSPrimitiveValue.CSS_GRAD:
0319:                    return (value.getFloatValue() * 9 / 5);
0320:                default:
0321:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0322:                }
0323:            }
0324:
0325:            /**
0326:             * Converts the current value into radians.
0327:             */
0328:            protected static float toRadians(Value value) {
0329:                switch (value.getPrimitiveType()) {
0330:                case CSSPrimitiveValue.CSS_DEG:
0331:                    return (value.getFloatValue() * 5 / 9); // todo ??
0332:                case CSSPrimitiveValue.CSS_RAD:
0333:                    return value.getFloatValue();
0334:                case CSSPrimitiveValue.CSS_GRAD:
0335:                    return (float) (value.getFloatValue() * 100 / Math.PI);
0336:                default:
0337:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0338:                }
0339:            }
0340:
0341:            /**
0342:             * Converts the current value into gradians.
0343:             */
0344:            protected static float toGradians(Value value) {
0345:                switch (value.getPrimitiveType()) {
0346:                case CSSPrimitiveValue.CSS_DEG:
0347:                    return (float) (value.getFloatValue() * Math.PI / 180); // todo ????
0348:                case CSSPrimitiveValue.CSS_RAD:
0349:                    return (float) (value.getFloatValue() * Math.PI / 100);
0350:                case CSSPrimitiveValue.CSS_GRAD:
0351:                    return value.getFloatValue();
0352:                default:
0353:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0354:                }
0355:            }
0356:
0357:            /**
0358:             * Converts the current value into milliseconds.
0359:             */
0360:            protected static float toMilliseconds(Value value) {
0361:                switch (value.getPrimitiveType()) {
0362:                case CSSPrimitiveValue.CSS_MS:
0363:                    return value.getFloatValue();
0364:                case CSSPrimitiveValue.CSS_S:
0365:                    return (value.getFloatValue() * 1000);
0366:                default:
0367:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0368:                }
0369:            }
0370:
0371:            /**
0372:             * Converts the current value into seconds.
0373:             */
0374:            protected static float toSeconds(Value value) {
0375:                switch (value.getPrimitiveType()) {
0376:                case CSSPrimitiveValue.CSS_MS:
0377:                    return (value.getFloatValue() / 1000);
0378:                case CSSPrimitiveValue.CSS_S:
0379:                    return value.getFloatValue();
0380:                default:
0381:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0382:                }
0383:            }
0384:
0385:            /**
0386:             * Converts the current value into Hertz.
0387:             */
0388:            protected static float toHertz(Value value) {
0389:                switch (value.getPrimitiveType()) {
0390:                case CSSPrimitiveValue.CSS_HZ:
0391:                    return value.getFloatValue();
0392:                case CSSPrimitiveValue.CSS_KHZ:
0393:                    return (value.getFloatValue() / 1000);
0394:                default:
0395:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0396:                }
0397:            }
0398:
0399:            /**
0400:             * Converts the current value into kHertz.
0401:             */
0402:            protected static float tokHertz(Value value) {
0403:                switch (value.getPrimitiveType()) {
0404:                case CSSPrimitiveValue.CSS_HZ:
0405:                    return (value.getFloatValue() * 1000);
0406:                case CSSPrimitiveValue.CSS_KHZ:
0407:                    return value.getFloatValue();
0408:                default:
0409:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
0410:                }
0411:            }
0412:
0413:            /**
0414:             * <b>DOM</b>: Implements {@link
0415:             * org.w3c.dom.css.CSSPrimitiveValue#setStringValue(short,String)}.
0416:             */
0417:            public void setStringValue(short stringType, String stringValue)
0418:                    throws DOMException {
0419:                if (handler == null) {
0420:                    throw new DOMException(
0421:                            DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
0422:                } else {
0423:                    handler.stringValueChanged(stringType, stringValue);
0424:                }
0425:            }
0426:
0427:            /**
0428:             * <b>DOM</b>: Implements {@link
0429:             * org.w3c.dom.css.CSSPrimitiveValue#getStringValue()}.
0430:             */
0431:            public String getStringValue() throws DOMException {
0432:                return valueProvider.getValue().getStringValue();
0433:            }
0434:
0435:            /**
0436:             * <b>DOM</b>: Implements {@link
0437:             * org.w3c.dom.css.CSSPrimitiveValue#getCounterValue()}.
0438:             */
0439:            public Counter getCounterValue() throws DOMException {
0440:                return this ;
0441:            }
0442:
0443:            /**
0444:             * <b>DOM</b>: Implements {@link
0445:             * org.w3c.dom.css.CSSPrimitiveValue#getRectValue()}.
0446:             */
0447:            public Rect getRectValue() throws DOMException {
0448:                return this ;
0449:            }
0450:
0451:            /**
0452:             * <b>DOM</b>: Implements {@link
0453:             * org.w3c.dom.css.CSSPrimitiveValue#getRGBColorValue()}.
0454:             */
0455:            public RGBColor getRGBColorValue() throws DOMException {
0456:                return this ;
0457:            }
0458:
0459:            // CSSValueList ///////////////////////////////////////////////////////
0460:
0461:            /**
0462:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.CSSValueList#getLength()}.
0463:             */
0464:            public int getLength() {
0465:                return valueProvider.getValue().getLength();
0466:            }
0467:
0468:            /**
0469:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.CSSValueList#item(int)}.
0470:             */
0471:            public CSSValue item(int index) {
0472:                int len = valueProvider.getValue().getLength();
0473:                if (index < 0 || index >= len) {
0474:                    return null;
0475:                }
0476:                if (items == null) {
0477:                    items = new CSSValue[valueProvider.getValue().getLength()];
0478:                } else if (items.length < len) {
0479:                    CSSValue[] nitems = new CSSValue[len];
0480:                    System.arraycopy(items, 0, nitems, 0, items.length);
0481:                    items = nitems;
0482:                }
0483:                CSSValue result = items[index];
0484:                if (result == null) {
0485:                    items[index] = result = new ListComponent(index);
0486:                }
0487:                return result;
0488:            }
0489:
0490:            // Counter /////////////////////////////////////////////////////////////
0491:
0492:            /**
0493:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.Counter#getIdentifier()}.
0494:             */
0495:            public String getIdentifier() {
0496:                return valueProvider.getValue().getIdentifier();
0497:            }
0498:
0499:            /**
0500:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.Counter#getListStyle()}.
0501:             */
0502:            public String getListStyle() {
0503:                return valueProvider.getValue().getListStyle();
0504:            }
0505:
0506:            /**
0507:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.Counter#getSeparator()}.
0508:             */
0509:            public String getSeparator() {
0510:                return valueProvider.getValue().getSeparator();
0511:            }
0512:
0513:            // Rect ///////////////////////////////////////////////////////////////
0514:
0515:            /**
0516:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.Rect#getTop()}.
0517:             */
0518:            public CSSPrimitiveValue getTop() {
0519:                valueProvider.getValue().getTop();
0520:                if (topComponent == null) {
0521:                    topComponent = new TopComponent();
0522:                }
0523:                return topComponent;
0524:            }
0525:
0526:            /**
0527:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.Rect#getRight()}.
0528:             */
0529:            public CSSPrimitiveValue getRight() {
0530:                valueProvider.getValue().getRight();
0531:                if (rightComponent == null) {
0532:                    rightComponent = new RightComponent();
0533:                }
0534:                return rightComponent;
0535:            }
0536:
0537:            /**
0538:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.Rect#getBottom()}.
0539:             */
0540:            public CSSPrimitiveValue getBottom() {
0541:                valueProvider.getValue().getBottom();
0542:                if (bottomComponent == null) {
0543:                    bottomComponent = new BottomComponent();
0544:                }
0545:                return bottomComponent;
0546:            }
0547:
0548:            /**
0549:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.Rect#getLeft()}.
0550:             */
0551:            public CSSPrimitiveValue getLeft() {
0552:                valueProvider.getValue().getLeft();
0553:                if (leftComponent == null) {
0554:                    leftComponent = new LeftComponent();
0555:                }
0556:                return leftComponent;
0557:            }
0558:
0559:            // RGBColor ///////////////////////////////////////////////////
0560:
0561:            /**
0562:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.RGBColor#getRed()}.
0563:             */
0564:            public CSSPrimitiveValue getRed() {
0565:                valueProvider.getValue().getRed();
0566:                if (redComponent == null) {
0567:                    redComponent = new RedComponent();
0568:                }
0569:                return redComponent;
0570:            }
0571:
0572:            /**
0573:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.RGBColor#getGreen()}.
0574:             */
0575:            public CSSPrimitiveValue getGreen() {
0576:                valueProvider.getValue().getGreen();
0577:                if (greenComponent == null) {
0578:                    greenComponent = new GreenComponent();
0579:                }
0580:                return greenComponent;
0581:            }
0582:
0583:            /**
0584:             * <b>DOM</b>: Implements {@link org.w3c.dom.css.RGBColor#getBlue()}.
0585:             */
0586:            public CSSPrimitiveValue getBlue() {
0587:                valueProvider.getValue().getBlue();
0588:                if (blueComponent == null) {
0589:                    blueComponent = new BlueComponent();
0590:                }
0591:                return blueComponent;
0592:            }
0593:
0594:            /**
0595:             * To provides the actual value.
0596:             */
0597:            public interface ValueProvider {
0598:
0599:                /**
0600:                 * Returns the current value associated with this object.
0601:                 */
0602:                Value getValue();
0603:            }
0604:
0605:            /**
0606:             * To manage the modifications on a CSS value.
0607:             */
0608:            public interface ModificationHandler {
0609:
0610:                /**
0611:                 * Called when the value text has changed.
0612:                 */
0613:                void textChanged(String text) throws DOMException;
0614:
0615:                /**
0616:                 * Called when the float value has changed.
0617:                 */
0618:                void floatValueChanged(short unit, float value)
0619:                        throws DOMException;
0620:
0621:                /**
0622:                 * Called when the string value has changed.
0623:                 */
0624:                void stringValueChanged(short type, String value)
0625:                        throws DOMException;
0626:
0627:                /**
0628:                 * Called when the left value text has changed.
0629:                 */
0630:                void leftTextChanged(String text) throws DOMException;
0631:
0632:                /**
0633:                 * Called when the left float value has changed.
0634:                 */
0635:                void leftFloatValueChanged(short unit, float value)
0636:                        throws DOMException;
0637:
0638:                /**
0639:                 * Called when the top value text has changed.
0640:                 */
0641:                void topTextChanged(String text) throws DOMException;
0642:
0643:                /**
0644:                 * Called when the top float value has changed.
0645:                 */
0646:                void topFloatValueChanged(short unit, float value)
0647:                        throws DOMException;
0648:
0649:                /**
0650:                 * Called when the right value text has changed.
0651:                 */
0652:                void rightTextChanged(String text) throws DOMException;
0653:
0654:                /**
0655:                 * Called when the right float value has changed.
0656:                 */
0657:                void rightFloatValueChanged(short unit, float value)
0658:                        throws DOMException;
0659:
0660:                /**
0661:                 * Called when the bottom value text has changed.
0662:                 */
0663:                void bottomTextChanged(String text) throws DOMException;
0664:
0665:                /**
0666:                 * Called when the bottom float value has changed.
0667:                 */
0668:                void bottomFloatValueChanged(short unit, float value)
0669:                        throws DOMException;
0670:
0671:                /**
0672:                 * Called when the red value text has changed.
0673:                 */
0674:                void redTextChanged(String text) throws DOMException;
0675:
0676:                /**
0677:                 * Called when the red float value has changed.
0678:                 */
0679:                void redFloatValueChanged(short unit, float value)
0680:                        throws DOMException;
0681:
0682:                /**
0683:                 * Called when the green value text has changed.
0684:                 */
0685:                void greenTextChanged(String text) throws DOMException;
0686:
0687:                /**
0688:                 * Called when the green float value has changed.
0689:                 */
0690:                void greenFloatValueChanged(short unit, float value)
0691:                        throws DOMException;
0692:
0693:                /**
0694:                 * Called when the blue value text has changed.
0695:                 */
0696:                void blueTextChanged(String text) throws DOMException;
0697:
0698:                /**
0699:                 * Called when the blue float value has changed.
0700:                 */
0701:                void blueFloatValueChanged(short unit, float value)
0702:                        throws DOMException;
0703:
0704:                /**
0705:                 * Called when the list value text has changed.
0706:                 */
0707:                void listTextChanged(int idx, String text) throws DOMException;
0708:
0709:                /**
0710:                 * Called when the list float value has changed.
0711:                 */
0712:                void listFloatValueChanged(int idx, short unit, float value)
0713:                        throws DOMException;
0714:
0715:                /**
0716:                 * Called when the list string value has changed.
0717:                 */
0718:                void listStringValueChanged(int idx, short unit, String value)
0719:                        throws DOMException;
0720:
0721:            }
0722:
0723:            /**
0724:             * This class provides an abstract implementation of a ModificationHandler.
0725:             */
0726:            public abstract class AbstractModificationHandler implements 
0727:                    ModificationHandler {
0728:
0729:                /**
0730:                 * Returns the associated value.
0731:                 */
0732:                protected abstract Value getValue();
0733:
0734:                /**
0735:                 * Called when the float value has changed.
0736:                 */
0737:                public void floatValueChanged(short unit, float value)
0738:                        throws DOMException {
0739:                    textChanged(FloatValue.getCssText(unit, value));
0740:                }
0741:
0742:                /**
0743:                 * Called when the string value has changed.
0744:                 */
0745:                public void stringValueChanged(short type, String value)
0746:                        throws DOMException {
0747:                    textChanged(StringValue.getCssText(type, value));
0748:                }
0749:
0750:                /**
0751:                 * Called when the left value text has changed.
0752:                 */
0753:                public void leftTextChanged(String text) throws DOMException {
0754:                    final Value val = getValue();
0755:                    text = "rect(" + val.getTop().getCssText() + ", "
0756:                            + val.getRight().getCssText() + ", "
0757:                            + val.getBottom().getCssText() + ", " + text + ')';
0758:                    textChanged(text);
0759:                }
0760:
0761:                /**
0762:                 * Called when the left float value has changed.
0763:                 */
0764:                public void leftFloatValueChanged(short unit, float value)
0765:                        throws DOMException {
0766:                    final Value val = getValue();
0767:                    String text = "rect(" + val.getTop().getCssText() + ", "
0768:                            + val.getRight().getCssText() + ", "
0769:                            + val.getBottom().getCssText() + ", "
0770:                            + FloatValue.getCssText(unit, value) + ')';
0771:                    textChanged(text);
0772:                }
0773:
0774:                /**
0775:                 * Called when the top value text has changed.
0776:                 */
0777:                public void topTextChanged(String text) throws DOMException {
0778:                    final Value val = getValue();
0779:                    text = "rect(" + text + ", " + val.getRight().getCssText()
0780:                            + ", " + val.getBottom().getCssText() + ", "
0781:                            + val.getLeft().getCssText() + ')';
0782:                    textChanged(text);
0783:                }
0784:
0785:                /**
0786:                 * Called when the top float value has changed.
0787:                 */
0788:                public void topFloatValueChanged(short unit, float value)
0789:                        throws DOMException {
0790:                    final Value val = getValue();
0791:                    String text = "rect(" + FloatValue.getCssText(unit, value)
0792:                            + ", " + val.getRight().getCssText() + ", "
0793:                            + val.getBottom().getCssText() + ", "
0794:                            + val.getLeft().getCssText() + ')';
0795:                    textChanged(text);
0796:                }
0797:
0798:                /**
0799:                 * Called when the right value text has changed.
0800:                 */
0801:                public void rightTextChanged(String text) throws DOMException {
0802:                    final Value val = getValue();
0803:                    text = "rect(" + val.getTop().getCssText() + ", " + text
0804:                            + ", " + val.getBottom().getCssText() + ", "
0805:                            + val.getLeft().getCssText() + ')';
0806:                    textChanged(text);
0807:                }
0808:
0809:                /**
0810:                 * Called when the right float value has changed.
0811:                 */
0812:                public void rightFloatValueChanged(short unit, float value)
0813:                        throws DOMException {
0814:                    final Value val = getValue();
0815:                    String text = "rect(" + val.getTop().getCssText() + ", "
0816:                            + FloatValue.getCssText(unit, value) + ", "
0817:                            + val.getBottom().getCssText() + ", "
0818:                            + val.getLeft().getCssText() + ')';
0819:                    textChanged(text);
0820:                }
0821:
0822:                /**
0823:                 * Called when the bottom value text has changed.
0824:                 */
0825:                public void bottomTextChanged(String text) throws DOMException {
0826:                    final Value val = getValue();
0827:                    text = "rect(" + val.getTop().getCssText() + ", "
0828:                            + val.getRight().getCssText() + ", " + text + ", "
0829:                            + val.getLeft().getCssText() + ')';
0830:                    textChanged(text);
0831:                }
0832:
0833:                /**
0834:                 * Called when the bottom float value has changed.
0835:                 */
0836:                public void bottomFloatValueChanged(short unit, float value)
0837:                        throws DOMException {
0838:                    final Value val = getValue();
0839:                    String text = "rect(" + val.getTop().getCssText() + ", "
0840:                            + val.getRight().getCssText() + ", "
0841:                            + FloatValue.getCssText(unit, value) + ", "
0842:                            + val.getLeft().getCssText() + ')';
0843:                    textChanged(text);
0844:                }
0845:
0846:                /**
0847:                 * Called when the red value text has changed.
0848:                 */
0849:                public void redTextChanged(String text) throws DOMException {
0850:                    final Value val = getValue();
0851:                    text = "rgb(" + text + ", " + val.getGreen().getCssText()
0852:                            + ", " + val.getBlue().getCssText() + ')';
0853:                    textChanged(text);
0854:                }
0855:
0856:                /**
0857:                 * Called when the red float value has changed.
0858:                 */
0859:                public void redFloatValueChanged(short unit, float value)
0860:                        throws DOMException {
0861:                    final Value val = getValue();
0862:                    String text = "rgb(" + FloatValue.getCssText(unit, value)
0863:                            + ", " + val.getGreen().getCssText() + ", "
0864:                            + val.getBlue().getCssText() + ')';
0865:                    textChanged(text);
0866:                }
0867:
0868:                /**
0869:                 * Called when the green value text has changed.
0870:                 */
0871:                public void greenTextChanged(String text) throws DOMException {
0872:                    final Value val = getValue();
0873:                    text = "rgb(" + val.getRed().getCssText() + ", " + text
0874:                            + ", " + val.getBlue().getCssText() + ')';
0875:                    textChanged(text);
0876:                }
0877:
0878:                /**
0879:                 * Called when the green float value has changed.
0880:                 */
0881:                public void greenFloatValueChanged(short unit, float value)
0882:                        throws DOMException {
0883:                    final Value val = getValue();
0884:                    String text = "rgb(" + val.getRed().getCssText() + ", "
0885:                            + FloatValue.getCssText(unit, value) + ", "
0886:                            + val.getBlue().getCssText() + ')';
0887:                    textChanged(text);
0888:                }
0889:
0890:                /**
0891:                 * Called when the blue value text has changed.
0892:                 */
0893:                public void blueTextChanged(String text) throws DOMException {
0894:                    final Value val = getValue();
0895:                    text = "rgb(" + val.getRed().getCssText() + ", "
0896:                            + val.getGreen().getCssText() + ", " + text + ')';
0897:                    textChanged(text);
0898:                }
0899:
0900:                /**
0901:                 * Called when the blue float value has changed.
0902:                 */
0903:                public void blueFloatValueChanged(short unit, float value)
0904:                        throws DOMException {
0905:                    final Value val = getValue();
0906:                    String text = "rgb(" + val.getRed().getCssText() + ", "
0907:                            + val.getGreen().getCssText() + ", "
0908:                            + FloatValue.getCssText(unit, value) + ')';
0909:                    textChanged(text);
0910:                }
0911:
0912:                /**
0913:                 * Called when the list value text has changed.
0914:                 */
0915:                public void listTextChanged(int idx, String text)
0916:                        throws DOMException {
0917:                    ListValue lv = (ListValue) getValue();
0918:                    int len = lv.getLength();
0919:                    StringBuffer sb = new StringBuffer(len * 8);
0920:                    for (int i = 0; i < idx; i++) {
0921:                        sb.append(lv.item(i).getCssText());
0922:                        sb.append(lv.getSeparatorChar());
0923:                    }
0924:                    sb.append(text);
0925:                    for (int i = idx + 1; i < len; i++) {
0926:                        sb.append(lv.getSeparatorChar());
0927:                        sb.append(lv.item(i).getCssText());
0928:                    }
0929:                    text = sb.toString();
0930:                    textChanged(text);
0931:                }
0932:
0933:                /**
0934:                 * Called when the list float value has changed.
0935:                 */
0936:                public void listFloatValueChanged(int idx, short unit,
0937:                        float value) throws DOMException {
0938:                    ListValue lv = (ListValue) getValue();
0939:                    int len = lv.getLength();
0940:                    StringBuffer sb = new StringBuffer(len * 8);
0941:                    for (int i = 0; i < idx; i++) {
0942:                        sb.append(lv.item(i).getCssText());
0943:                        sb.append(lv.getSeparatorChar());
0944:                    }
0945:                    sb.append(FloatValue.getCssText(unit, value));
0946:                    for (int i = idx + 1; i < len; i++) {
0947:                        sb.append(lv.getSeparatorChar());
0948:                        sb.append(lv.item(i).getCssText());
0949:                    }
0950:                    textChanged(sb.toString());
0951:                }
0952:
0953:                /**
0954:                 * Called when the list string value has changed.
0955:                 */
0956:                public void listStringValueChanged(int idx, short unit,
0957:                        String value) throws DOMException {
0958:                    ListValue lv = (ListValue) getValue();
0959:                    int len = lv.getLength();
0960:                    StringBuffer sb = new StringBuffer(len * 8);
0961:                    for (int i = 0; i < idx; i++) {
0962:                        sb.append(lv.item(i).getCssText());
0963:                        sb.append(lv.getSeparatorChar());
0964:                    }
0965:                    sb.append(StringValue.getCssText(unit, value));
0966:                    for (int i = idx + 1; i < len; i++) {
0967:                        sb.append(lv.getSeparatorChar());
0968:                        sb.append(lv.item(i).getCssText());
0969:                    }
0970:                    textChanged(sb.toString());
0971:                }
0972:            }
0973:
0974:            /**
0975:             * To store a component.
0976:             */
0977:            protected abstract class AbstractComponent implements 
0978:                    CSSPrimitiveValue {
0979:
0980:                /**
0981:                 * The returns the actual value of this component.
0982:                 */
0983:                protected abstract Value getValue();
0984:
0985:                /**
0986:                 * <b>DOM</b>: Implements {@link
0987:                 * org.w3c.dom.css.CSSValue#getCssText()}.
0988:                 */
0989:                public String getCssText() {
0990:                    return getValue().getCssText();
0991:                }
0992:
0993:                /**
0994:                 * <b>DOM</b>: Implements {@link
0995:                 * org.w3c.dom.css.CSSValue#getCssValueType()}.
0996:                 */
0997:                public short getCssValueType() {
0998:                    return getValue().getCssValueType();
0999:                }
1000:
1001:                /**
1002:                 * <b>DOM</b>: Implements {@link
1003:                 * org.w3c.dom.css.CSSPrimitiveValue#getPrimitiveType()}.
1004:                 */
1005:                public short getPrimitiveType() {
1006:                    return getValue().getPrimitiveType();
1007:                }
1008:
1009:                /**
1010:                 * <b>DOM</b>: Implements {@link
1011:                 * org.w3c.dom.css.CSSPrimitiveValue#getFloatValue(short)}.
1012:                 */
1013:                public float getFloatValue(short unitType) throws DOMException {
1014:                    return convertFloatValue(unitType, getValue());
1015:                }
1016:
1017:                /**
1018:                 * <b>DOM</b>: Implements {@link
1019:                 * org.w3c.dom.css.CSSPrimitiveValue#getStringValue()}.
1020:                 */
1021:                public String getStringValue() throws DOMException {
1022:                    return valueProvider.getValue().getStringValue();
1023:                }
1024:
1025:                /**
1026:                 * <b>DOM</b>: Implements {@link
1027:                 * org.w3c.dom.css.CSSPrimitiveValue#getCounterValue()}.
1028:                 */
1029:                public Counter getCounterValue() throws DOMException {
1030:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
1031:                }
1032:
1033:                /**
1034:                 * <b>DOM</b>: Implements {@link
1035:                 * org.w3c.dom.css.CSSPrimitiveValue#getRectValue()}.
1036:                 */
1037:                public Rect getRectValue() throws DOMException {
1038:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
1039:                }
1040:
1041:                /**
1042:                 * <b>DOM</b>: Implements {@link
1043:                 * org.w3c.dom.css.CSSPrimitiveValue#getRGBColorValue()}.
1044:                 */
1045:                public RGBColor getRGBColorValue() throws DOMException {
1046:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
1047:                }
1048:
1049:                // CSSValueList ///////////////////////////////////////////////////////
1050:
1051:                /**
1052:                 * <b>DOM</b>: Implements {@link
1053:                 * org.w3c.dom.css.CSSValueList#getLength()}.
1054:                 */
1055:                public int getLength() {
1056:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
1057:                }
1058:
1059:                /**
1060:                 * <b>DOM</b>: Implements {@link
1061:                 * org.w3c.dom.css.CSSValueList#item(int)}.
1062:                 */
1063:                public CSSValue item(int index) {
1064:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
1065:                }
1066:            }
1067:
1068:            /**
1069:             * To store a Float component.
1070:             */
1071:            protected abstract class FloatComponent extends AbstractComponent {
1072:
1073:                /**
1074:                 * <b>DOM</b>: Implements {@link
1075:                 * org.w3c.dom.css.CSSPrimitiveValue#setStringValue(short,String)}.
1076:                 */
1077:                public void setStringValue(short stringType, String stringValue)
1078:                        throws DOMException {
1079:                    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
1080:                }
1081:            }
1082:
1083:            /**
1084:             * To represents a left component.
1085:             */
1086:            protected class LeftComponent extends FloatComponent {
1087:
1088:                /**
1089:                 * The returns the actual value of this component.
1090:                 */
1091:                protected Value getValue() {
1092:                    return valueProvider.getValue().getLeft();
1093:                }
1094:
1095:                /**
1096:                 * <b>DOM</b>: Implements {@link
1097:                 * org.w3c.dom.css.CSSValue#setCssText(String)}.
1098:                 */
1099:                public void setCssText(String cssText) throws DOMException {
1100:                    if (handler == null) {
1101:                        throw new DOMException(
1102:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1103:                    } else {
1104:                        getValue();
1105:                        handler.leftTextChanged(cssText);
1106:                    }
1107:                }
1108:
1109:                /**
1110:                 * <b>DOM</b>: Implements {@link
1111:                 * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
1112:                 */
1113:                public void setFloatValue(short unitType, float floatValue)
1114:                        throws DOMException {
1115:                    if (handler == null) {
1116:                        throw new DOMException(
1117:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1118:                    } else {
1119:                        getValue();
1120:                        handler.leftFloatValueChanged(unitType, floatValue);
1121:                    }
1122:                }
1123:
1124:            }
1125:
1126:            /**
1127:             * To represents a top component.
1128:             */
1129:            protected class TopComponent extends FloatComponent {
1130:
1131:                /**
1132:                 * The returns the actual value of this component.
1133:                 */
1134:                protected Value getValue() {
1135:                    return valueProvider.getValue().getTop();
1136:                }
1137:
1138:                /**
1139:                 * <b>DOM</b>: Implements {@link
1140:                 * org.w3c.dom.css.CSSValue#setCssText(String)}.
1141:                 */
1142:                public void setCssText(String cssText) throws DOMException {
1143:                    if (handler == null) {
1144:                        throw new DOMException(
1145:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1146:                    } else {
1147:                        getValue();
1148:                        handler.topTextChanged(cssText);
1149:                    }
1150:                }
1151:
1152:                /**
1153:                 * <b>DOM</b>: Implements {@link
1154:                 * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
1155:                 */
1156:                public void setFloatValue(short unitType, float floatValue)
1157:                        throws DOMException {
1158:                    if (handler == null) {
1159:                        throw new DOMException(
1160:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1161:                    } else {
1162:                        getValue();
1163:                        handler.topFloatValueChanged(unitType, floatValue);
1164:                    }
1165:                }
1166:
1167:            }
1168:
1169:            /**
1170:             * To represents a right component.
1171:             */
1172:            protected class RightComponent extends FloatComponent {
1173:
1174:                /**
1175:                 * The returns the actual value of this component.
1176:                 */
1177:                protected Value getValue() {
1178:                    return valueProvider.getValue().getRight();
1179:                }
1180:
1181:                /**
1182:                 * <b>DOM</b>: Implements {@link
1183:                 * org.w3c.dom.css.CSSValue#setCssText(String)}.
1184:                 */
1185:                public void setCssText(String cssText) throws DOMException {
1186:                    if (handler == null) {
1187:                        throw new DOMException(
1188:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1189:                    } else {
1190:                        getValue();
1191:                        handler.rightTextChanged(cssText);
1192:                    }
1193:                }
1194:
1195:                /**
1196:                 * <b>DOM</b>: Implements {@link
1197:                 * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
1198:                 */
1199:                public void setFloatValue(short unitType, float floatValue)
1200:                        throws DOMException {
1201:                    if (handler == null) {
1202:                        throw new DOMException(
1203:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1204:                    } else {
1205:                        getValue();
1206:                        handler.rightFloatValueChanged(unitType, floatValue);
1207:                    }
1208:                }
1209:
1210:            }
1211:
1212:            /**
1213:             * To represents a bottom component.
1214:             */
1215:            protected class BottomComponent extends FloatComponent {
1216:
1217:                /**
1218:                 * The returns the actual value of this component.
1219:                 */
1220:                protected Value getValue() {
1221:                    return valueProvider.getValue().getBottom();
1222:                }
1223:
1224:                /**
1225:                 * <b>DOM</b>: Implements {@link
1226:                 * org.w3c.dom.css.CSSValue#setCssText(String)}.
1227:                 */
1228:                public void setCssText(String cssText) throws DOMException {
1229:                    if (handler == null) {
1230:                        throw new DOMException(
1231:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1232:                    } else {
1233:                        getValue();
1234:                        handler.bottomTextChanged(cssText);
1235:                    }
1236:                }
1237:
1238:                /**
1239:                 * <b>DOM</b>: Implements {@link
1240:                 * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
1241:                 */
1242:                public void setFloatValue(short unitType, float floatValue)
1243:                        throws DOMException {
1244:                    if (handler == null) {
1245:                        throw new DOMException(
1246:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1247:                    } else {
1248:                        getValue();
1249:                        handler.bottomFloatValueChanged(unitType, floatValue);
1250:                    }
1251:                }
1252:
1253:            }
1254:
1255:            /**
1256:             * To represents a red component.
1257:             */
1258:            protected class RedComponent extends FloatComponent {
1259:
1260:                /**
1261:                 * The returns the actual value of this component.
1262:                 */
1263:                protected Value getValue() {
1264:                    return valueProvider.getValue().getRed();
1265:                }
1266:
1267:                /**
1268:                 * <b>DOM</b>: Implements {@link
1269:                 * org.w3c.dom.css.CSSValue#setCssText(String)}.
1270:                 */
1271:                public void setCssText(String cssText) throws DOMException {
1272:                    if (handler == null) {
1273:                        throw new DOMException(
1274:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1275:                    } else {
1276:                        getValue();
1277:                        handler.redTextChanged(cssText);
1278:                    }
1279:                }
1280:
1281:                /**
1282:                 * <b>DOM</b>: Implements {@link
1283:                 * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
1284:                 */
1285:                public void setFloatValue(short unitType, float floatValue)
1286:                        throws DOMException {
1287:                    if (handler == null) {
1288:                        throw new DOMException(
1289:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1290:                    } else {
1291:                        getValue();
1292:                        handler.redFloatValueChanged(unitType, floatValue);
1293:                    }
1294:                }
1295:
1296:            }
1297:
1298:            /**
1299:             * To represents a green component.
1300:             */
1301:            protected class GreenComponent extends FloatComponent {
1302:
1303:                /**
1304:                 * The returns the actual value of this component.
1305:                 */
1306:                protected Value getValue() {
1307:                    return valueProvider.getValue().getGreen();
1308:                }
1309:
1310:                /**
1311:                 * <b>DOM</b>: Implements {@link
1312:                 * org.w3c.dom.css.CSSValue#setCssText(String)}.
1313:                 */
1314:                public void setCssText(String cssText) throws DOMException {
1315:                    if (handler == null) {
1316:                        throw new DOMException(
1317:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1318:                    } else {
1319:                        getValue();
1320:                        handler.greenTextChanged(cssText);
1321:                    }
1322:                }
1323:
1324:                /**
1325:                 * <b>DOM</b>: Implements {@link
1326:                 * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
1327:                 */
1328:                public void setFloatValue(short unitType, float floatValue)
1329:                        throws DOMException {
1330:                    if (handler == null) {
1331:                        throw new DOMException(
1332:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1333:                    } else {
1334:                        getValue();
1335:                        handler.greenFloatValueChanged(unitType, floatValue);
1336:                    }
1337:                }
1338:
1339:            }
1340:
1341:            /**
1342:             * To represents a blue component.
1343:             */
1344:            protected class BlueComponent extends FloatComponent {
1345:
1346:                /**
1347:                 * The returns the actual value of this component.
1348:                 */
1349:                protected Value getValue() {
1350:                    return valueProvider.getValue().getBlue();
1351:                }
1352:
1353:                /**
1354:                 * <b>DOM</b>: Implements {@link
1355:                 * org.w3c.dom.css.CSSValue#setCssText(String)}.
1356:                 */
1357:                public void setCssText(String cssText) throws DOMException {
1358:                    if (handler == null) {
1359:                        throw new DOMException(
1360:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1361:                    } else {
1362:                        getValue();
1363:                        handler.blueTextChanged(cssText);
1364:                    }
1365:                }
1366:
1367:                /**
1368:                 * <b>DOM</b>: Implements {@link
1369:                 * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
1370:                 */
1371:                public void setFloatValue(short unitType, float floatValue)
1372:                        throws DOMException {
1373:                    if (handler == null) {
1374:                        throw new DOMException(
1375:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1376:                    } else {
1377:                        getValue();
1378:                        handler.blueFloatValueChanged(unitType, floatValue);
1379:                    }
1380:                }
1381:
1382:            }
1383:
1384:            /**
1385:             * To represents a List component.
1386:             */
1387:            protected class ListComponent extends AbstractComponent {
1388:
1389:                /**
1390:                 * The index of this component.
1391:                 */
1392:                protected int index;
1393:
1394:                /**
1395:                 * Creates a new ListComponent.
1396:                 */
1397:                public ListComponent(int idx) {
1398:                    index = idx;
1399:                }
1400:
1401:                /**
1402:                 * The returns the actual value of this component.
1403:                 */
1404:                protected Value getValue() {
1405:                    if (index >= valueProvider.getValue().getLength()) {
1406:                        throw new DOMException(
1407:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1408:                    }
1409:                    return valueProvider.getValue().item(index);
1410:                }
1411:
1412:                /**
1413:                 * <b>DOM</b>: Implements {@link
1414:                 * org.w3c.dom.css.CSSValue#setCssText(String)}.
1415:                 */
1416:                public void setCssText(String cssText) throws DOMException {
1417:                    if (handler == null) {
1418:                        throw new DOMException(
1419:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1420:                    } else {
1421:                        getValue();
1422:                        handler.listTextChanged(index, cssText);
1423:                    }
1424:                }
1425:
1426:                /**
1427:                 * <b>DOM</b>: Implements {@link
1428:                 * org.w3c.dom.css.CSSPrimitiveValue#setFloatValue(short,float)}.
1429:                 */
1430:                public void setFloatValue(short unitType, float floatValue)
1431:                        throws DOMException {
1432:                    if (handler == null) {
1433:                        throw new DOMException(
1434:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1435:                    } else {
1436:                        getValue();
1437:                        handler.listFloatValueChanged(index, unitType,
1438:                                floatValue);
1439:                    }
1440:                }
1441:
1442:                /**
1443:                 * <b>DOM</b>: Implements {@link
1444:                 * org.w3c.dom.css.CSSPrimitiveValue#setStringValue(short,String)}.
1445:                 */
1446:                public void setStringValue(short stringType, String stringValue)
1447:                        throws DOMException {
1448:                    if (handler == null) {
1449:                        throw new DOMException(
1450:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
1451:                    } else {
1452:                        getValue();
1453:                        handler.listStringValueChanged(index, stringType,
1454:                                stringValue);
1455:                    }
1456:                }
1457:            }
1458:
1459:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.