Source Code Cross Referenced for CSSOMSVGPaint.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) 


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.dom;
020:
021:        import org.apache.batik.css.engine.value.FloatValue;
022:        import org.apache.batik.css.engine.value.Value;
023:        import org.apache.batik.css.engine.value.svg.ICCColor;
024:        import org.apache.batik.util.CSSConstants;
025:
026:        import org.w3c.dom.DOMException;
027:        import org.w3c.dom.css.CSSPrimitiveValue;
028:        import org.w3c.dom.css.CSSValue;
029:        import org.w3c.dom.svg.SVGPaint;
030:
031:        /**
032:         * This class implements the {@link SVGPaint} interface.
033:         *
034:         * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
035:         * @version $Id: CSSOMSVGPaint.java 476924 2006-11-19 21:13:26Z dvholten $
036:         */
037:        public class CSSOMSVGPaint extends CSSOMSVGColor implements  SVGPaint {
038:
039:            /**
040:             * Creates a new CSSOMSVGPaint.
041:             */
042:            public CSSOMSVGPaint(ValueProvider vp) {
043:                super (vp);
044:            }
045:
046:            /**
047:             * Sets the modification handler of this value.
048:             */
049:            public void setModificationHandler(ModificationHandler h) {
050:                if (!(h instanceof  PaintModificationHandler)) {
051:                    throw new IllegalArgumentException();
052:                }
053:                super .setModificationHandler(h);
054:            }
055:
056:            /**
057:             * <b>DOM</b>: Implements {@link
058:             * org.w3c.dom.svg.SVGColor#getColorType()}.
059:             */
060:            public short getColorType() {
061:                throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
062:            }
063:
064:            /**
065:             * <b>DOM</b>: Implements {@link
066:             * org.w3c.dom.svg.SVGPaint#getPaintType()}.
067:             */
068:            public short getPaintType() {
069:                Value value = valueProvider.getValue();
070:                switch (value.getCssValueType()) {
071:                case CSSValue.CSS_PRIMITIVE_VALUE:
072:                    switch (value.getPrimitiveType()) {
073:                    case CSSPrimitiveValue.CSS_IDENT: {
074:                        String str = value.getStringValue();
075:                        if (str.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) {
076:                            return SVG_PAINTTYPE_NONE;
077:                        } else if (str
078:                                .equalsIgnoreCase(CSSConstants.CSS_CURRENTCOLOR_VALUE)) {
079:                            return SVG_PAINTTYPE_CURRENTCOLOR;
080:                        }
081:                        return SVG_PAINTTYPE_RGBCOLOR;
082:                    }
083:                    case CSSPrimitiveValue.CSS_RGBCOLOR:
084:                        return SVG_PAINTTYPE_RGBCOLOR;
085:
086:                    case CSSPrimitiveValue.CSS_URI:
087:                        return SVG_PAINTTYPE_URI;
088:                    }
089:                    break;
090:
091:                case CSSValue.CSS_VALUE_LIST:
092:                    Value v0 = value.item(0);
093:                    Value v1 = value.item(1);
094:                    switch (v0.getPrimitiveType()) {
095:                    case CSSPrimitiveValue.CSS_IDENT:
096:                        return SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR;
097:                    case CSSPrimitiveValue.CSS_URI:
098:                        if (v1.getCssValueType() == CSSValue.CSS_VALUE_LIST)
099:                            // Should probably check this more deeply...
100:                            return SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR;
101:
102:                        switch (v1.getPrimitiveType()) {
103:                        case CSSPrimitiveValue.CSS_IDENT: {
104:                            String str = v1.getStringValue();
105:                            if (str
106:                                    .equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) {
107:                                return SVG_PAINTTYPE_URI_NONE;
108:                            } else if (str
109:                                    .equalsIgnoreCase(CSSConstants.CSS_CURRENTCOLOR_VALUE)) {
110:                                return SVG_PAINTTYPE_URI_CURRENTCOLOR;
111:                            }
112:                            return SVG_PAINTTYPE_URI_RGBCOLOR;
113:                        }
114:                        case CSSPrimitiveValue.CSS_RGBCOLOR:
115:                            return SVG_PAINTTYPE_URI_RGBCOLOR;
116:                        }
117:
118:                    case CSSPrimitiveValue.CSS_RGBCOLOR:
119:                        return SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR;
120:                    }
121:                }
122:                return SVG_PAINTTYPE_UNKNOWN;
123:            }
124:
125:            /**
126:             * <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGPaint#getUri()}.
127:             */
128:            public String getUri() {
129:                switch (getPaintType()) {
130:                case SVG_PAINTTYPE_URI:
131:                    return valueProvider.getValue().getStringValue();
132:
133:                case SVG_PAINTTYPE_URI_NONE:
134:                case SVG_PAINTTYPE_URI_CURRENTCOLOR:
135:                case SVG_PAINTTYPE_URI_RGBCOLOR:
136:                case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
137:                    return valueProvider.getValue().item(0).getStringValue();
138:                }
139:                throw new InternalError();
140:            }
141:
142:            /**
143:             * <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGPaint#setUri(String)}.
144:             */
145:            public void setUri(String uri) {
146:                if (handler == null) {
147:                    throw new DOMException(
148:                            DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
149:                } else {
150:                    ((PaintModificationHandler) handler).uriChanged(uri);
151:                }
152:            }
153:
154:            /**
155:             * <b>DOM</b>: Implements {@link
156:             * org.w3c.dom.svg.SVGPaint#setPaint(short,String,String,String)}.
157:             */
158:            public void setPaint(short paintType, String uri, String rgbColor,
159:                    String iccColor) {
160:                if (handler == null) {
161:                    throw new DOMException(
162:                            DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
163:                } else {
164:                    ((PaintModificationHandler) handler).paintChanged(
165:                            paintType, uri, rgbColor, iccColor);
166:                }
167:            }
168:
169:            /**
170:             * To manage the modifications on a SVGPaint value.
171:             */
172:            public interface PaintModificationHandler extends
173:                    ModificationHandler {
174:
175:                /**
176:                 * Called when the URI has been modified.
177:                 */
178:                void uriChanged(String uri);
179:
180:                /**
181:                 * Called when the paint value has beem modified.
182:                 */
183:                void paintChanged(short type, String uri, String rgb, String icc);
184:            }
185:
186:            /**
187:             * Provides an abstract implementation of a PaintModificationHandler.
188:             */
189:            public abstract class AbstractModificationHandler implements 
190:                    PaintModificationHandler {
191:
192:                /**
193:                 * Returns the associated value.
194:                 */
195:                protected abstract Value getValue();
196:
197:                /**
198:                 * Called when the red value text has changed.
199:                 */
200:                public void redTextChanged(String text) throws DOMException {
201:                    switch (getPaintType()) {
202:                    case SVG_PAINTTYPE_RGBCOLOR:
203:                        text = "rgb(" + text + ", "
204:                                + getValue().getGreen().getCssText() + ", "
205:                                + getValue().getBlue().getCssText() + ')';
206:                        break;
207:
208:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
209:                        text = "rgb(" + text + ", "
210:                                + getValue().item(0).getGreen().getCssText()
211:                                + ", "
212:                                + getValue().item(0).getBlue().getCssText()
213:                                + ") " + getValue().item(1).getCssText();
214:                        break;
215:
216:                    case SVG_PAINTTYPE_URI_RGBCOLOR:
217:                        text = getValue().item(0) + " rgb(" + text + ", "
218:                                + getValue().item(1).getGreen().getCssText()
219:                                + ", "
220:                                + getValue().item(1).getBlue().getCssText()
221:                                + ')';
222:                        break;
223:
224:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
225:                        text = getValue().item(0) + " rgb(" + text + ", "
226:                                + getValue().item(1).getGreen().getCssText()
227:                                + ", "
228:                                + getValue().item(1).getBlue().getCssText()
229:                                + ") " + getValue().item(2).getCssText();
230:                        break;
231:
232:                    default:
233:                        throw new DOMException(
234:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
235:                    }
236:                    textChanged(text);
237:                }
238:
239:                /**
240:                 * Called when the red float value has changed.
241:                 */
242:                public void redFloatValueChanged(short unit, float value)
243:                        throws DOMException {
244:                    String text;
245:                    switch (getPaintType()) {
246:                    case SVG_PAINTTYPE_RGBCOLOR:
247:                        text = "rgb(" + FloatValue.getCssText(unit, value)
248:                                + ", " + getValue().getGreen().getCssText()
249:                                + ", " + getValue().getBlue().getCssText()
250:                                + ')';
251:                        break;
252:
253:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
254:                        text = "rgb(" + FloatValue.getCssText(unit, value)
255:                                + ", "
256:                                + getValue().item(0).getGreen().getCssText()
257:                                + ", "
258:                                + getValue().item(0).getBlue().getCssText()
259:                                + ") " + getValue().item(1).getCssText();
260:                        break;
261:
262:                    case SVG_PAINTTYPE_URI_RGBCOLOR:
263:                        text = getValue().item(0) + " rgb("
264:                                + FloatValue.getCssText(unit, value) + ", "
265:                                + getValue().item(1).getGreen().getCssText()
266:                                + ", "
267:                                + getValue().item(1).getBlue().getCssText()
268:                                + ')';
269:                        break;
270:
271:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
272:                        text = getValue().item(0) + " rgb("
273:                                + FloatValue.getCssText(unit, value) + ", "
274:                                + getValue().item(1).getGreen().getCssText()
275:                                + ", "
276:                                + getValue().item(1).getBlue().getCssText()
277:                                + ") " + getValue().item(2).getCssText();
278:                        break;
279:
280:                    default:
281:                        throw new DOMException(
282:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
283:                    }
284:                    textChanged(text);
285:                }
286:
287:                /**
288:                 * Called when the green value text has changed.
289:                 */
290:                public void greenTextChanged(String text) throws DOMException {
291:                    switch (getPaintType()) {
292:                    case SVG_PAINTTYPE_RGBCOLOR:
293:                        text = "rgb(" + getValue().getRed().getCssText() + ", "
294:                                + text + ", "
295:                                + getValue().getBlue().getCssText() + ')';
296:                        break;
297:
298:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
299:                        text = "rgb("
300:                                + getValue().item(0).getRed().getCssText()
301:                                + ", " + text + ", "
302:                                + getValue().item(0).getBlue().getCssText()
303:                                + ") " + getValue().item(1).getCssText();
304:                        break;
305:
306:                    case SVG_PAINTTYPE_URI_RGBCOLOR:
307:                        text = getValue().item(0) + " rgb("
308:                                + getValue().item(1).getRed().getCssText()
309:                                + ", " + text + ", "
310:                                + getValue().item(1).getBlue().getCssText()
311:                                + ')';
312:                        break;
313:
314:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
315:                        text = getValue().item(0) + " rgb("
316:                                + getValue().item(1).getRed().getCssText()
317:                                + ", " + text + ", "
318:                                + getValue().item(1).getBlue().getCssText()
319:                                + ") " + getValue().item(2).getCssText();
320:                        break;
321:
322:                    default:
323:                        throw new DOMException(
324:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
325:                    }
326:                    textChanged(text);
327:                }
328:
329:                /**
330:                 * Called when the green float value has changed.
331:                 */
332:                public void greenFloatValueChanged(short unit, float value)
333:                        throws DOMException {
334:                    String text;
335:                    switch (getPaintType()) {
336:                    case SVG_PAINTTYPE_RGBCOLOR:
337:                        text = "rgb(" + getValue().getRed().getCssText() + ", "
338:                                + FloatValue.getCssText(unit, value) + ", "
339:                                + getValue().getBlue().getCssText() + ')';
340:                        break;
341:
342:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
343:                        text = "rgb("
344:                                + getValue().item(0).getRed().getCssText()
345:                                + ", " + FloatValue.getCssText(unit, value)
346:                                + ", "
347:                                + getValue().item(0).getBlue().getCssText()
348:                                + ") " + getValue().item(1).getCssText();
349:                        break;
350:
351:                    case SVG_PAINTTYPE_URI_RGBCOLOR:
352:                        text = getValue().item(0) + " rgb("
353:                                + getValue().item(1).getRed().getCssText()
354:                                + ", " + FloatValue.getCssText(unit, value)
355:                                + ", "
356:                                + getValue().item(1).getBlue().getCssText()
357:                                + ')';
358:                        break;
359:
360:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
361:                        text = getValue().item(0) + " rgb("
362:                                + getValue().item(1).getRed().getCssText()
363:                                + ", " + FloatValue.getCssText(unit, value)
364:                                + ", "
365:                                + getValue().item(1).getBlue().getCssText()
366:                                + ") " + getValue().item(2).getCssText();
367:                        break;
368:
369:                    default:
370:                        throw new DOMException(
371:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
372:                    }
373:                    textChanged(text);
374:                }
375:
376:                /**
377:                 * Called when the blue value text has changed.
378:                 */
379:                public void blueTextChanged(String text) throws DOMException {
380:                    switch (getPaintType()) {
381:                    case SVG_PAINTTYPE_RGBCOLOR:
382:                        text = "rgb(" + getValue().getRed().getCssText() + ", "
383:                                + getValue().getGreen().getCssText() + ", "
384:                                + text + ')';
385:                        break;
386:
387:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
388:                        text = "rgb("
389:                                + getValue().item(0).getRed().getCssText()
390:                                + ", "
391:                                + getValue().item(0).getGreen().getCssText()
392:                                + ", " + text + ") "
393:                                + getValue().item(1).getCssText();
394:                        break;
395:
396:                    case SVG_PAINTTYPE_URI_RGBCOLOR:
397:                        text = getValue().item(0) + " rgb("
398:                                + getValue().item(1).getRed().getCssText()
399:                                + ", "
400:                                + getValue().item(1).getGreen().getCssText()
401:                                + ", " + text + ")";
402:                        break;
403:
404:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
405:                        text = getValue().item(0) + " rgb("
406:                                + getValue().item(1).getRed().getCssText()
407:                                + ", "
408:                                + getValue().item(1).getGreen().getCssText()
409:                                + ", " + text + ") "
410:                                + getValue().item(2).getCssText();
411:                        break;
412:
413:                    default:
414:                        throw new DOMException(
415:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
416:                    }
417:                    textChanged(text);
418:                }
419:
420:                /**
421:                 * Called when the blue float value has changed.
422:                 */
423:                public void blueFloatValueChanged(short unit, float value)
424:                        throws DOMException {
425:                    String text;
426:                    switch (getPaintType()) {
427:                    case SVG_PAINTTYPE_RGBCOLOR:
428:                        text = "rgb(" + getValue().getRed().getCssText() + ", "
429:                                + getValue().getGreen().getCssText() + ", "
430:                                + FloatValue.getCssText(unit, value) + ')';
431:                        break;
432:
433:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
434:                        text = "rgb("
435:                                + getValue().item(0).getRed().getCssText()
436:                                + ", "
437:                                + getValue().item(0).getGreen().getCssText()
438:                                + ", " + FloatValue.getCssText(unit, value)
439:                                + ") " + getValue().item(1).getCssText();
440:                        break;
441:
442:                    case SVG_PAINTTYPE_URI_RGBCOLOR:
443:                        text = getValue().item(0) + " rgb("
444:                                + getValue().item(1).getRed().getCssText()
445:                                + ", "
446:                                + getValue().item(1).getGreen().getCssText()
447:                                + ", " + FloatValue.getCssText(unit, value)
448:                                + ')';
449:                        break;
450:
451:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
452:                        text = getValue().item(0) + " rgb("
453:                                + getValue().item(1).getRed().getCssText()
454:                                + ", "
455:                                + getValue().item(1).getGreen().getCssText()
456:                                + ", " + FloatValue.getCssText(unit, value)
457:                                + ") " + getValue().item(2).getCssText();
458:                        break;
459:
460:                    default:
461:                        throw new DOMException(
462:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
463:                    }
464:                    textChanged(text);
465:                }
466:
467:                /**
468:                 * Called when the RGBColor text has changed.
469:                 */
470:                public void rgbColorChanged(String text) throws DOMException {
471:                    switch (getPaintType()) {
472:                    case SVG_PAINTTYPE_RGBCOLOR:
473:                        break;
474:
475:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
476:                        text += getValue().item(1).getCssText();
477:                        break;
478:
479:                    case SVG_PAINTTYPE_URI_RGBCOLOR:
480:                        text = getValue().item(0).getCssText() + ' ' + text;
481:                        break;
482:
483:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
484:                        text = getValue().item(0).getCssText() + ' ' + text
485:                                + ' ' + getValue().item(2).getCssText();
486:                        break;
487:
488:                    default:
489:                        throw new DOMException(
490:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
491:                    }
492:                    textChanged(text);
493:                }
494:
495:                /**
496:                 * Called when the RGBColor and the ICCColor text has changed.
497:                 */
498:                public void rgbColorICCColorChanged(String rgb, String icc)
499:                        throws DOMException {
500:                    switch (getPaintType()) {
501:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
502:                        textChanged(rgb + ' ' + icc);
503:                        break;
504:
505:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
506:                        textChanged(getValue().item(0).getCssText() + ' ' + rgb
507:                                + ' ' + icc);
508:                        break;
509:
510:                    default:
511:                        throw new DOMException(
512:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
513:                    }
514:                }
515:
516:                /**
517:                 * Called when the SVGColor has changed.
518:                 */
519:                public void colorChanged(short type, String rgb, String icc)
520:                        throws DOMException {
521:                    switch (type) {
522:                    case SVG_PAINTTYPE_CURRENTCOLOR:
523:                        textChanged("currentcolor");
524:                        break;
525:
526:                    case SVG_PAINTTYPE_RGBCOLOR:
527:                        textChanged(rgb);
528:                        break;
529:
530:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
531:                        textChanged(rgb + ' ' + icc);
532:                        break;
533:
534:                    default:
535:                        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
536:                                "");
537:                    }
538:                }
539:
540:                /**
541:                 * Called when the ICC color profile has changed.
542:                 */
543:                public void colorProfileChanged(String cp) throws DOMException {
544:                    switch (getPaintType()) {
545:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
546:                        StringBuffer sb = new StringBuffer(getValue().item(0)
547:                                .getCssText());
548:                        sb.append(" icc-color(");
549:                        sb.append(cp);
550:                        ICCColor iccc = (ICCColor) getValue().item(1);
551:                        for (int i = 0; i < iccc.getLength(); i++) {
552:                            sb.append(',');
553:                            sb.append(iccc.getColor(i));
554:                        }
555:                        sb.append(')');
556:                        textChanged(sb.toString());
557:                        break;
558:
559:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
560:                        sb = new StringBuffer(getValue().item(0).getCssText());
561:                        sb.append(' ');
562:                        sb.append(getValue().item(1).getCssText());
563:                        sb.append(" icc-color(");
564:                        sb.append(cp);
565:                        iccc = (ICCColor) getValue().item(1);
566:                        for (int i = 0; i < iccc.getLength(); i++) {
567:                            sb.append(',');
568:                            sb.append(iccc.getColor(i));
569:                        }
570:                        sb.append(')');
571:                        textChanged(sb.toString());
572:                        break;
573:
574:                    default:
575:                        throw new DOMException(
576:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
577:                    }
578:                }
579:
580:                /**
581:                 * Called when the ICC colors has changed.
582:                 */
583:                public void colorsCleared() throws DOMException {
584:                    switch (getPaintType()) {
585:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
586:                        StringBuffer sb = new StringBuffer(getValue().item(0)
587:                                .getCssText());
588:                        sb.append(" icc-color(");
589:                        ICCColor iccc = (ICCColor) getValue().item(1);
590:                        sb.append(iccc.getColorProfile());
591:                        sb.append(')');
592:                        textChanged(sb.toString());
593:                        break;
594:
595:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
596:                        sb = new StringBuffer(getValue().item(0).getCssText());
597:                        sb.append(' ');
598:                        sb.append(getValue().item(1).getCssText());
599:                        sb.append(" icc-color(");
600:                        iccc = (ICCColor) getValue().item(1);
601:                        sb.append(iccc.getColorProfile());
602:                        sb.append(')');
603:                        textChanged(sb.toString());
604:                        break;
605:
606:                    default:
607:                        throw new DOMException(
608:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
609:                    }
610:                }
611:
612:                /**
613:                 * Called when the ICC colors has been initialized.
614:                 */
615:                public void colorsInitialized(float f) throws DOMException {
616:                    switch (getPaintType()) {
617:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
618:                        StringBuffer sb = new StringBuffer(getValue().item(0)
619:                                .getCssText());
620:                        sb.append(" icc-color(");
621:                        ICCColor iccc = (ICCColor) getValue().item(1);
622:                        sb.append(iccc.getColorProfile());
623:                        sb.append(',');
624:                        sb.append(f);
625:                        sb.append(')');
626:                        textChanged(sb.toString());
627:                        break;
628:
629:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
630:                        sb = new StringBuffer(getValue().item(0).getCssText());
631:                        sb.append(' ');
632:                        sb.append(getValue().item(1).getCssText());
633:                        sb.append(" icc-color(");
634:                        iccc = (ICCColor) getValue().item(1);
635:                        sb.append(iccc.getColorProfile());
636:                        sb.append(',');
637:                        sb.append(f);
638:                        sb.append(')');
639:                        textChanged(sb.toString());
640:                        break;
641:
642:                    default:
643:                        throw new DOMException(
644:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
645:                    }
646:                }
647:
648:                /**
649:                 * Called when the ICC color has been inserted.
650:                 */
651:                public void colorInsertedBefore(float f, int idx)
652:                        throws DOMException {
653:                    switch (getPaintType()) {
654:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
655:                        StringBuffer sb = new StringBuffer(getValue().item(0)
656:                                .getCssText());
657:                        sb.append(" icc-color(");
658:                        ICCColor iccc = (ICCColor) getValue().item(1);
659:                        sb.append(iccc.getColorProfile());
660:                        for (int i = 0; i < idx; i++) {
661:                            sb.append(',');
662:                            sb.append(iccc.getColor(i));
663:                        }
664:                        sb.append(',');
665:                        sb.append(f);
666:                        for (int i = idx; i < iccc.getLength(); i++) {
667:                            sb.append(',');
668:                            sb.append(iccc.getColor(i));
669:                        }
670:                        sb.append(')');
671:                        textChanged(sb.toString());
672:                        break;
673:
674:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
675:                        sb = new StringBuffer(getValue().item(0).getCssText());
676:                        sb.append(' ');
677:                        sb.append(getValue().item(1).getCssText());
678:                        sb.append(" icc-color(");
679:                        iccc = (ICCColor) getValue().item(1);
680:                        sb.append(iccc.getColorProfile());
681:                        for (int i = 0; i < idx; i++) {
682:                            sb.append(',');
683:                            sb.append(iccc.getColor(i));
684:                        }
685:                        sb.append(',');
686:                        sb.append(f);
687:                        for (int i = idx; i < iccc.getLength(); i++) {
688:                            sb.append(',');
689:                            sb.append(iccc.getColor(i));
690:                        }
691:                        sb.append(')');
692:                        textChanged(sb.toString());
693:                        break;
694:
695:                    default:
696:                        throw new DOMException(
697:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
698:                    }
699:                }
700:
701:                /**
702:                 * Called when the ICC color has been replaced.
703:                 */
704:                public void colorReplaced(float f, int idx) throws DOMException {
705:                    switch (getPaintType()) {
706:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
707:                        StringBuffer sb = new StringBuffer(getValue().item(0)
708:                                .getCssText());
709:                        sb.append(" icc-color(");
710:                        ICCColor iccc = (ICCColor) getValue().item(1);
711:                        sb.append(iccc.getColorProfile());
712:                        for (int i = 0; i < idx; i++) {
713:                            sb.append(',');
714:                            sb.append(iccc.getColor(i));
715:                        }
716:                        sb.append(',');
717:                        sb.append(f);
718:                        for (int i = idx + 1; i < iccc.getLength(); i++) {
719:                            sb.append(',');
720:                            sb.append(iccc.getColor(i));
721:                        }
722:                        sb.append(')');
723:                        textChanged(sb.toString());
724:                        break;
725:
726:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
727:                        sb = new StringBuffer(getValue().item(0).getCssText());
728:                        sb.append(' ');
729:                        sb.append(getValue().item(1).getCssText());
730:                        sb.append(" icc-color(");
731:                        iccc = (ICCColor) getValue().item(1);
732:                        sb.append(iccc.getColorProfile());
733:                        for (int i = 0; i < idx; i++) {
734:                            sb.append(',');
735:                            sb.append(iccc.getColor(i));
736:                        }
737:                        sb.append(',');
738:                        sb.append(f);
739:                        for (int i = idx + 1; i < iccc.getLength(); i++) {
740:                            sb.append(',');
741:                            sb.append(iccc.getColor(i));
742:                        }
743:                        sb.append(')');
744:                        textChanged(sb.toString());
745:                        break;
746:
747:                    default:
748:                        throw new DOMException(
749:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
750:                    }
751:                }
752:
753:                /**
754:                 * Called when the ICC color has been removed.
755:                 */
756:                public void colorRemoved(int idx) throws DOMException {
757:                    switch (getPaintType()) {
758:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
759:                        StringBuffer sb = new StringBuffer(getValue().item(0)
760:                                .getCssText());
761:                        sb.append(" icc-color(");
762:                        ICCColor iccc = (ICCColor) getValue().item(1);
763:                        sb.append(iccc.getColorProfile());
764:                        for (int i = 0; i < idx; i++) {
765:                            sb.append(',');
766:                            sb.append(iccc.getColor(i));
767:                        }
768:                        for (int i = idx + 1; i < iccc.getLength(); i++) {
769:                            sb.append(',');
770:                            sb.append(iccc.getColor(i));
771:                        }
772:                        sb.append(')');
773:                        textChanged(sb.toString());
774:                        break;
775:
776:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
777:                        sb = new StringBuffer(getValue().item(0).getCssText());
778:                        sb.append(' ');
779:                        sb.append(getValue().item(1).getCssText());
780:                        sb.append(" icc-color(");
781:                        iccc = (ICCColor) getValue().item(1);
782:                        sb.append(iccc.getColorProfile());
783:                        for (int i = 0; i < idx; i++) {
784:                            sb.append(',');
785:                            sb.append(iccc.getColor(i));
786:                        }
787:                        for (int i = idx + 1; i < iccc.getLength(); i++) {
788:                            sb.append(',');
789:                            sb.append(iccc.getColor(i));
790:                        }
791:                        sb.append(')');
792:                        textChanged(sb.toString());
793:                        break;
794:
795:                    default:
796:                        throw new DOMException(
797:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
798:                    }
799:                }
800:
801:                /**
802:                 * Called when the ICC color has been append.
803:                 */
804:                public void colorAppend(float f) throws DOMException {
805:                    switch (getPaintType()) {
806:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
807:                        StringBuffer sb = new StringBuffer(getValue().item(0)
808:                                .getCssText());
809:                        sb.append(" icc-color(");
810:                        ICCColor iccc = (ICCColor) getValue().item(1);
811:                        sb.append(iccc.getColorProfile());
812:                        for (int i = 0; i < iccc.getLength(); i++) {
813:                            sb.append(',');
814:                            sb.append(iccc.getColor(i));
815:                        }
816:                        sb.append(',');
817:                        sb.append(f);
818:                        sb.append(')');
819:                        textChanged(sb.toString());
820:                        break;
821:
822:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
823:                        sb = new StringBuffer(getValue().item(0).getCssText());
824:                        sb.append(' ');
825:                        sb.append(getValue().item(1).getCssText());
826:                        sb.append(" icc-color(");
827:                        iccc = (ICCColor) getValue().item(1);
828:                        sb.append(iccc.getColorProfile());
829:                        for (int i = 0; i < iccc.getLength(); i++) {
830:                            sb.append(',');
831:                            sb.append(iccc.getColor(i));
832:                        }
833:                        sb.append(',');
834:                        sb.append(f);
835:                        sb.append(')');
836:                        textChanged(sb.toString());
837:                        break;
838:
839:                    default:
840:                        throw new DOMException(
841:                                DOMException.NO_MODIFICATION_ALLOWED_ERR, "");
842:                    }
843:                }
844:
845:                /**
846:                 * Called when the URI has been modified.
847:                 */
848:                public void uriChanged(String uri) {
849:                    textChanged("url(" + uri + ") none");
850:                }
851:
852:                /**
853:                 * Called when the paint value has beem modified.
854:                 */
855:                public void paintChanged(short type, String uri, String rgb,
856:                        String icc) {
857:                    switch (type) {
858:                    case SVG_PAINTTYPE_NONE:
859:                        textChanged("none");
860:                        break;
861:
862:                    case SVG_PAINTTYPE_CURRENTCOLOR:
863:                        textChanged("currentcolor");
864:                        break;
865:
866:                    case SVG_PAINTTYPE_RGBCOLOR:
867:                        textChanged(rgb);
868:                        break;
869:
870:                    case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
871:                        textChanged(rgb + ' ' + icc);
872:                        break;
873:
874:                    case SVG_PAINTTYPE_URI:
875:                        textChanged("url(" + uri + ')');
876:                        break;
877:
878:                    case SVG_PAINTTYPE_URI_NONE:
879:                        textChanged("url(" + uri + ") none");
880:                        break;
881:
882:                    case SVG_PAINTTYPE_URI_CURRENTCOLOR:
883:                        textChanged("url(" + uri + ") currentcolor");
884:                        break;
885:
886:                    case SVG_PAINTTYPE_URI_RGBCOLOR:
887:                        textChanged("url(" + uri + ") " + rgb);
888:                        break;
889:
890:                    case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
891:                        textChanged("url(" + uri + ") " + rgb + ' ' + icc);
892:                    }
893:                }
894:            }
895:
896:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.