1 18 package org.apache.batik.css.dom; 19 20 import org.apache.batik.css.engine.value.FloatValue; 21 import org.apache.batik.css.engine.value.Value; 22 import org.apache.batik.css.engine.value.svg.ICCColor; 23 import org.apache.batik.util.CSSConstants; 24 25 import org.w3c.dom.DOMException ; 26 import org.w3c.dom.css.CSSPrimitiveValue; 27 import org.w3c.dom.css.CSSValue; 28 import org.w3c.dom.svg.SVGPaint; 29 30 36 public class CSSOMSVGPaint extends CSSOMSVGColor implements SVGPaint { 37 38 41 public CSSOMSVGPaint(ValueProvider vp) { 42 super(vp); 43 } 44 45 48 public void setModificationHandler(ModificationHandler h) { 49 if (!(h instanceof PaintModificationHandler)) { 50 throw new IllegalArgumentException (); 51 } 52 super.setModificationHandler(h); 53 } 54 55 59 public short getColorType() { 60 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 61 } 62 63 67 public short getPaintType() { 68 Value value = valueProvider.getValue(); 69 switch (value.getCssValueType()) { 70 case CSSValue.CSS_PRIMITIVE_VALUE: 71 switch (value.getPrimitiveType()) { 72 case CSSPrimitiveValue.CSS_IDENT: { 73 String str = value.getStringValue(); 74 if (str.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) { 75 return SVG_PAINTTYPE_NONE; 76 } else if (str.equalsIgnoreCase 77 (CSSConstants.CSS_CURRENTCOLOR_VALUE)) { 78 return SVG_PAINTTYPE_CURRENTCOLOR; 79 } 80 return SVG_PAINTTYPE_RGBCOLOR; 81 } 82 case CSSPrimitiveValue.CSS_RGBCOLOR: 83 return SVG_PAINTTYPE_RGBCOLOR; 84 85 case CSSPrimitiveValue.CSS_URI: 86 return SVG_PAINTTYPE_URI; 87 } 88 break; 89 90 case CSSValue.CSS_VALUE_LIST: 91 Value v0 = value.item(0); 92 Value v1 = value.item(1); 93 switch (v0.getPrimitiveType()) { 94 case CSSPrimitiveValue.CSS_IDENT: 95 return SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR; 96 case CSSPrimitiveValue.CSS_URI: 97 if (v1.getCssValueType() == CSSValue.CSS_VALUE_LIST) 98 return SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR; 100 101 switch (v1.getPrimitiveType()) { 102 case CSSPrimitiveValue.CSS_IDENT: { 103 String str = v1.getStringValue(); 104 if (str.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) { 105 return SVG_PAINTTYPE_URI_NONE; 106 } else if (str.equalsIgnoreCase 107 (CSSConstants.CSS_CURRENTCOLOR_VALUE)) { 108 return SVG_PAINTTYPE_URI_CURRENTCOLOR; 109 } 110 return SVG_PAINTTYPE_URI_RGBCOLOR; 111 } 112 case CSSPrimitiveValue.CSS_RGBCOLOR: 113 return SVG_PAINTTYPE_URI_RGBCOLOR; 114 } 115 116 case CSSPrimitiveValue.CSS_RGBCOLOR: 117 return SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR; 118 } 119 } 120 return SVG_PAINTTYPE_UNKNOWN; 121 } 122 123 126 public String getUri() { 127 switch (getPaintType()) { 128 case SVG_PAINTTYPE_URI: 129 return valueProvider.getValue().getStringValue(); 130 131 case SVG_PAINTTYPE_URI_NONE: 132 case SVG_PAINTTYPE_URI_CURRENTCOLOR: 133 case SVG_PAINTTYPE_URI_RGBCOLOR: 134 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 135 return valueProvider.getValue().item(0).getStringValue(); 136 } 137 throw new InternalError (); 138 } 139 140 143 public void setUri(String uri) { 144 if (handler == null) { 145 throw new DOMException 146 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 147 } else { 148 ((PaintModificationHandler)handler).uriChanged(uri); 149 } 150 } 151 152 156 public void setPaint(short paintType, String uri, 157 String rgbColor, String iccColor) { 158 if (handler == null) { 159 throw new DOMException 160 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 161 } else { 162 ((PaintModificationHandler)handler).paintChanged 163 (paintType, uri, rgbColor, iccColor); 164 } 165 } 166 167 170 public interface PaintModificationHandler extends ModificationHandler { 171 172 175 void uriChanged(String uri); 176 177 180 void paintChanged(short type, String uri, String rgb, String icc); 181 } 182 183 186 public abstract class AbstractModificationHandler 187 implements PaintModificationHandler { 188 189 192 protected abstract Value getValue(); 193 194 197 public void redTextChanged(String text) throws DOMException { 198 switch (getPaintType()) { 199 case SVG_PAINTTYPE_RGBCOLOR: 200 text = "rgb(" + 201 text + ", " + 202 getValue().getGreen().getCssText() + ", " + 203 getValue().getBlue().getCssText() + ")"; 204 break; 205 206 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 207 text = "rgb(" + 208 text + ", " + 209 getValue().item(0).getGreen().getCssText() + ", " + 210 getValue().item(0).getBlue().getCssText() + ") " + 211 getValue().item(1).getCssText(); 212 break; 213 214 case SVG_PAINTTYPE_URI_RGBCOLOR: 215 text = getValue().item(0) + 216 " rgb(" + 217 text + ", " + 218 getValue().item(1).getGreen().getCssText() + ", " + 219 getValue().item(1).getBlue().getCssText() + ")"; 220 break; 221 222 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 223 text = getValue().item(0) + 224 " rgb(" + 225 text + ", " + 226 getValue().item(1).getGreen().getCssText() + ", " + 227 getValue().item(1).getBlue().getCssText() + ") " + 228 getValue().item(2).getCssText(); 229 break; 230 231 default: 232 throw new DOMException 233 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 234 } 235 textChanged(text); 236 } 237 238 241 public void redFloatValueChanged(short unit, float value) 242 throws DOMException { 243 String text; 244 switch (getPaintType()) { 245 case SVG_PAINTTYPE_RGBCOLOR: 246 text = "rgb(" + 247 FloatValue.getCssText(unit, value) + ", " + 248 getValue().getGreen().getCssText() + ", " + 249 getValue().getBlue().getCssText() + ")"; 250 break; 251 252 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 253 text = "rgb(" + 254 FloatValue.getCssText(unit, value) + ", " + 255 getValue().item(0).getGreen().getCssText() + ", " + 256 getValue().item(0).getBlue().getCssText() + ") " + 257 getValue().item(1).getCssText(); 258 break; 259 260 case SVG_PAINTTYPE_URI_RGBCOLOR: 261 text = getValue().item(0) + 262 " rgb(" + 263 FloatValue.getCssText(unit, value) + ", " + 264 getValue().item(1).getGreen().getCssText() + ", " + 265 getValue().item(1).getBlue().getCssText() + ")"; 266 break; 267 268 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 269 text = getValue().item(0) + 270 " rgb(" + 271 FloatValue.getCssText(unit, value) + ", " + 272 getValue().item(1).getGreen().getCssText() + ", " + 273 getValue().item(1).getBlue().getCssText() + ") " + 274 getValue().item(2).getCssText(); 275 break; 276 277 default: 278 throw new DOMException 279 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 280 } 281 textChanged(text); 282 } 283 284 287 public void greenTextChanged(String text) throws DOMException { 288 switch (getPaintType()) { 289 case SVG_PAINTTYPE_RGBCOLOR: 290 text = "rgb(" + 291 getValue().getRed().getCssText() + ", " + 292 text + ", " + 293 getValue().getBlue().getCssText() + ")"; 294 break; 295 296 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 297 text = "rgb(" + 298 getValue().item(0).getRed().getCssText() + ", " + 299 text + ", " + 300 getValue().item(0).getBlue().getCssText() + ") " + 301 getValue().item(1).getCssText(); 302 break; 303 304 case SVG_PAINTTYPE_URI_RGBCOLOR: 305 text = getValue().item(0) + 306 " rgb(" + 307 getValue().item(1).getRed().getCssText() + ", " + 308 text + ", " + 309 getValue().item(1).getBlue().getCssText() + ")"; 310 break; 311 312 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 313 text = getValue().item(0) + 314 " rgb(" + 315 getValue().item(1).getRed().getCssText() + ", " + 316 text + ", " + 317 getValue().item(1).getBlue().getCssText() + ") " + 318 getValue().item(2).getCssText(); 319 break; 320 321 default: 322 throw new DOMException 323 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 324 } 325 textChanged(text); 326 } 327 328 331 public void greenFloatValueChanged(short unit, float value) 332 throws DOMException { 333 String text; 334 switch (getPaintType()) { 335 case SVG_PAINTTYPE_RGBCOLOR: 336 text = "rgb(" + 337 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 getValue().item(0).getBlue().getCssText() + ") " + 347 getValue().item(1).getCssText(); 348 break; 349 350 case SVG_PAINTTYPE_URI_RGBCOLOR: 351 text = getValue().item(0) + 352 " rgb(" + 353 getValue().item(1).getRed().getCssText() + ", " + 354 FloatValue.getCssText(unit, value) + ", " + 355 getValue().item(1).getBlue().getCssText() + ")"; 356 break; 357 358 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 359 text = getValue().item(0) + 360 " rgb(" + 361 getValue().item(1).getRed().getCssText() + ", " + 362 FloatValue.getCssText(unit, value) + ", " + 363 getValue().item(1).getBlue().getCssText() + ") " + 364 getValue().item(2).getCssText(); 365 break; 366 367 default: 368 throw new DOMException 369 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 370 } 371 textChanged(text); 372 } 373 374 377 public void blueTextChanged(String text) throws DOMException { 378 switch (getPaintType()) { 379 case SVG_PAINTTYPE_RGBCOLOR: 380 text = "rgb(" + 381 getValue().getRed().getCssText() + ", " + 382 getValue().getGreen().getCssText() + ", " + 383 text + ")"; 384 break; 385 386 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 387 text = "rgb(" + 388 getValue().item(0).getRed().getCssText() + ", " + 389 getValue().item(0).getGreen().getCssText() + ", " + 390 text + ") " + 391 getValue().item(1).getCssText(); 392 break; 393 394 case SVG_PAINTTYPE_URI_RGBCOLOR: 395 text = getValue().item(0) + 396 " rgb(" + 397 getValue().item(1).getRed().getCssText() + ", " + 398 getValue().item(1).getGreen().getCssText() + ", " + 399 text + ")"; 400 break; 401 402 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 403 text = getValue().item(0) + 404 " rgb(" + 405 getValue().item(1).getRed().getCssText() + ", " + 406 getValue().item(1).getGreen().getCssText() + ", " + 407 text + ") " + 408 getValue().item(2).getCssText(); 409 break; 410 411 default: 412 throw new DOMException 413 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 414 } 415 textChanged(text); 416 } 417 418 421 public void blueFloatValueChanged(short unit, float value) 422 throws DOMException { 423 String text; 424 switch (getPaintType()) { 425 case SVG_PAINTTYPE_RGBCOLOR: 426 text = "rgb(" + 427 getValue().getRed().getCssText() + ", " + 428 getValue().getGreen().getCssText() + ", " + 429 FloatValue.getCssText(unit, value) + ")"; 430 break; 431 432 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 433 text = "rgb(" + 434 getValue().item(0).getRed().getCssText() + ", " + 435 getValue().item(0).getGreen().getCssText() + ", " + 436 FloatValue.getCssText(unit, value) + ") " + 437 getValue().item(1).getCssText(); 438 break; 439 440 case SVG_PAINTTYPE_URI_RGBCOLOR: 441 text = getValue().item(0) + 442 " rgb(" + 443 getValue().item(1).getRed().getCssText() + ", " + 444 getValue().item(1).getGreen().getCssText() + ", " + 445 FloatValue.getCssText(unit, value) + ")"; 446 break; 447 448 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 449 text = getValue().item(0) + 450 " rgb(" + 451 getValue().item(1).getRed().getCssText() + ", " + 452 getValue().item(1).getGreen().getCssText() + ", " + 453 FloatValue.getCssText(unit, value) + ") " + 454 getValue().item(2).getCssText(); 455 break; 456 457 default: 458 throw new DOMException 459 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 460 } 461 textChanged(text); 462 } 463 464 467 public void rgbColorChanged(String text) throws DOMException { 468 switch (getPaintType()) { 469 case SVG_PAINTTYPE_RGBCOLOR: 470 break; 471 472 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 473 text += getValue().item(1).getCssText(); 474 break; 475 476 case SVG_PAINTTYPE_URI_RGBCOLOR: 477 text = getValue().item(0).getCssText() + " " + text; 478 break; 479 480 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 481 text = getValue().item(0).getCssText() + " " + text + " " + 482 getValue().item(2).getCssText(); 483 break; 484 485 default: 486 throw new DOMException 487 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 488 } 489 textChanged(text); 490 } 491 492 495 public void rgbColorICCColorChanged(String rgb, String icc) 496 throws DOMException { 497 switch (getPaintType()) { 498 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 499 textChanged(rgb + " " + icc); 500 break; 501 502 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 503 textChanged(getValue().item(0).getCssText() + " " + 504 rgb + " " + icc); 505 break; 506 507 default: 508 throw new DOMException 509 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 510 } 511 } 512 513 516 public void colorChanged(short type, String rgb, String icc) 517 throws DOMException { 518 switch (type) { 519 case SVG_PAINTTYPE_CURRENTCOLOR: 520 textChanged("currentcolor"); 521 break; 522 523 case SVG_PAINTTYPE_RGBCOLOR: 524 textChanged(rgb); 525 break; 526 527 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 528 textChanged(rgb + " " + icc); 529 break; 530 531 default: 532 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 533 } 534 } 535 536 539 public void colorProfileChanged(String cp) throws DOMException { 540 switch (getPaintType()) { 541 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 542 StringBuffer sb = 543 new StringBuffer (getValue().item(0).getCssText()); 544 sb.append(" icc-color("); 545 sb.append(cp); 546 ICCColor iccc = (ICCColor)getValue().item(1); 547 for (int i = 0; i < iccc.getLength(); i++) { 548 sb.append(","); 549 sb.append(iccc.getColor(i)); 550 } 551 sb.append(")"); 552 textChanged(sb.toString()); 553 break; 554 555 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 556 sb = new StringBuffer (getValue().item(0).getCssText()); 557 sb.append(" "); 558 sb.append(getValue().item(1).getCssText()); 559 sb.append(" icc-color("); 560 sb.append(cp); 561 iccc = (ICCColor)getValue().item(1); 562 for (int i = 0; i < iccc.getLength(); i++) { 563 sb.append(","); 564 sb.append(iccc.getColor(i)); 565 } 566 sb.append(")"); 567 textChanged(sb.toString()); 568 break; 569 570 default: 571 throw new DOMException 572 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 573 } 574 } 575 576 579 public void colorsCleared() throws DOMException { 580 switch (getPaintType()) { 581 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 582 StringBuffer sb = 583 new StringBuffer (getValue().item(0).getCssText()); 584 sb.append(" icc-color("); 585 ICCColor iccc = (ICCColor)getValue().item(1); 586 sb.append(iccc.getColorProfile()); 587 sb.append(")"); 588 textChanged(sb.toString()); 589 break; 590 591 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 592 sb = new StringBuffer (getValue().item(0).getCssText()); 593 sb.append(" "); 594 sb.append(getValue().item(1).getCssText()); 595 sb.append(" icc-color("); 596 iccc = (ICCColor)getValue().item(1); 597 sb.append(iccc.getColorProfile()); 598 sb.append(")"); 599 textChanged(sb.toString()); 600 break; 601 602 default: 603 throw new DOMException 604 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 605 } 606 } 607 608 611 public void colorsInitialized(float f) throws DOMException { 612 switch (getPaintType()) { 613 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 614 StringBuffer sb = 615 new StringBuffer (getValue().item(0).getCssText()); 616 sb.append(" icc-color("); 617 ICCColor iccc = (ICCColor)getValue().item(1); 618 sb.append(iccc.getColorProfile()); 619 sb.append(","); 620 sb.append(f); 621 sb.append(")"); 622 textChanged(sb.toString()); 623 break; 624 625 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 626 sb = new StringBuffer (getValue().item(0).getCssText()); 627 sb.append(" "); 628 sb.append(getValue().item(1).getCssText()); 629 sb.append(" icc-color("); 630 iccc = (ICCColor)getValue().item(1); 631 sb.append(iccc.getColorProfile()); 632 sb.append(","); 633 sb.append(f); 634 sb.append(")"); 635 textChanged(sb.toString()); 636 break; 637 638 default: 639 throw new DOMException 640 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 641 } 642 } 643 644 647 public void colorInsertedBefore(float f, int idx) throws DOMException { 648 switch (getPaintType()) { 649 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 650 StringBuffer sb = 651 new StringBuffer (getValue().item(0).getCssText()); 652 sb.append(" icc-color("); 653 ICCColor iccc = (ICCColor)getValue().item(1); 654 sb.append(iccc.getColorProfile()); 655 for (int i = 0; i < idx; i++) { 656 sb.append(","); 657 sb.append(iccc.getColor(i)); 658 } 659 sb.append(","); 660 sb.append(f); 661 for (int i = idx; i < iccc.getLength(); i++) { 662 sb.append(","); 663 sb.append(iccc.getColor(i)); 664 } 665 sb.append(")"); 666 textChanged(sb.toString()); 667 break; 668 669 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 670 sb = new StringBuffer (getValue().item(0).getCssText()); 671 sb.append(" "); 672 sb.append(getValue().item(1).getCssText()); 673 sb.append(" icc-color("); 674 iccc = (ICCColor)getValue().item(1); 675 sb.append(iccc.getColorProfile()); 676 for (int i = 0; i < idx; i++) { 677 sb.append(","); 678 sb.append(iccc.getColor(i)); 679 } 680 sb.append(","); 681 sb.append(f); 682 for (int i = idx; i < iccc.getLength(); i++) { 683 sb.append(","); 684 sb.append(iccc.getColor(i)); 685 } 686 sb.append(")"); 687 textChanged(sb.toString()); 688 break; 689 690 default: 691 throw new DOMException 692 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 693 } 694 } 695 696 699 public void colorReplaced(float f, int idx) throws DOMException { 700 switch (getPaintType()) { 701 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 702 StringBuffer sb = 703 new StringBuffer (getValue().item(0).getCssText()); 704 sb.append(" icc-color("); 705 ICCColor iccc = (ICCColor)getValue().item(1); 706 sb.append(iccc.getColorProfile()); 707 for (int i = 0; i < idx; i++) { 708 sb.append(","); 709 sb.append(iccc.getColor(i)); 710 } 711 sb.append(","); 712 sb.append(f); 713 for (int i = idx + 1; i < iccc.getLength(); i++) { 714 sb.append(","); 715 sb.append(iccc.getColor(i)); 716 } 717 sb.append(")"); 718 textChanged(sb.toString()); 719 break; 720 721 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 722 sb = new StringBuffer (getValue().item(0).getCssText()); 723 sb.append(" "); 724 sb.append(getValue().item(1).getCssText()); 725 sb.append(" icc-color("); 726 iccc = (ICCColor)getValue().item(1); 727 sb.append(iccc.getColorProfile()); 728 for (int i = 0; i < idx; i++) { 729 sb.append(","); 730 sb.append(iccc.getColor(i)); 731 } 732 sb.append(","); 733 sb.append(f); 734 for (int i = idx + 1; i < iccc.getLength(); i++) { 735 sb.append(","); 736 sb.append(iccc.getColor(i)); 737 } 738 sb.append(")"); 739 textChanged(sb.toString()); 740 break; 741 742 default: 743 throw new DOMException 744 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 745 } 746 } 747 748 751 public void colorRemoved(int idx) throws DOMException { 752 switch (getPaintType()) { 753 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 754 StringBuffer sb = 755 new StringBuffer (getValue().item(0).getCssText()); 756 sb.append(" icc-color("); 757 ICCColor iccc = (ICCColor)getValue().item(1); 758 sb.append(iccc.getColorProfile()); 759 for (int i = 0; i < idx; i++) { 760 sb.append(","); 761 sb.append(iccc.getColor(i)); 762 } 763 for (int i = idx + 1; i < iccc.getLength(); i++) { 764 sb.append(","); 765 sb.append(iccc.getColor(i)); 766 } 767 sb.append(")"); 768 textChanged(sb.toString()); 769 break; 770 771 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 772 sb = new StringBuffer (getValue().item(0).getCssText()); 773 sb.append(" "); 774 sb.append(getValue().item(1).getCssText()); 775 sb.append(" icc-color("); 776 iccc = (ICCColor)getValue().item(1); 777 sb.append(iccc.getColorProfile()); 778 for (int i = 0; i < idx; i++) { 779 sb.append(","); 780 sb.append(iccc.getColor(i)); 781 } 782 for (int i = idx + 1; i < iccc.getLength(); i++) { 783 sb.append(","); 784 sb.append(iccc.getColor(i)); 785 } 786 sb.append(")"); 787 textChanged(sb.toString()); 788 break; 789 790 default: 791 throw new DOMException 792 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 793 } 794 } 795 796 799 public void colorAppend(float f) throws DOMException { 800 switch (getPaintType()) { 801 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 802 StringBuffer sb = 803 new StringBuffer (getValue().item(0).getCssText()); 804 sb.append(" icc-color("); 805 ICCColor iccc = (ICCColor)getValue().item(1); 806 sb.append(iccc.getColorProfile()); 807 for (int i = 0; i < iccc.getLength(); i++) { 808 sb.append(","); 809 sb.append(iccc.getColor(i)); 810 } 811 sb.append(","); 812 sb.append(f); 813 sb.append(")"); 814 textChanged(sb.toString()); 815 break; 816 817 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 818 sb = new StringBuffer (getValue().item(0).getCssText()); 819 sb.append(" "); 820 sb.append(getValue().item(1).getCssText()); 821 sb.append(" icc-color("); 822 iccc = (ICCColor)getValue().item(1); 823 sb.append(iccc.getColorProfile()); 824 for (int i = 0; i < iccc.getLength(); i++) { 825 sb.append(","); 826 sb.append(iccc.getColor(i)); 827 } 828 sb.append(","); 829 sb.append(f); 830 sb.append(")"); 831 textChanged(sb.toString()); 832 break; 833 834 default: 835 throw new DOMException 836 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 837 } 838 } 839 840 843 public void uriChanged(String uri) { 844 textChanged("url(" + uri + ") none"); 845 } 846 847 850 public void paintChanged(short type, String uri, 851 String rgb, String icc) { 852 switch (type) { 853 case SVG_PAINTTYPE_NONE: 854 textChanged("none"); 855 break; 856 857 case SVG_PAINTTYPE_CURRENTCOLOR: 858 textChanged("currentcolor"); 859 break; 860 861 case SVG_PAINTTYPE_RGBCOLOR: 862 textChanged(rgb); 863 break; 864 865 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 866 textChanged(rgb + " " + icc); 867 break; 868 869 case SVG_PAINTTYPE_URI: 870 textChanged("url(" + uri + ")"); 871 break; 872 873 case SVG_PAINTTYPE_URI_NONE: 874 textChanged("url(" + uri + ") none"); 875 break; 876 877 case SVG_PAINTTYPE_URI_CURRENTCOLOR: 878 textChanged("url(" + uri + ") currentcolor"); 879 break; 880 881 case SVG_PAINTTYPE_URI_RGBCOLOR: 882 textChanged("url(" + uri + ") " + rgb); 883 break; 884 885 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 886 textChanged("url(" + uri + ") " + rgb + " " + icc); 887 } 888 } 889 } 890 891 } 892 | Popular Tags |