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.ListValue; 22 import org.apache.batik.css.engine.value.StringValue; 23 import org.apache.batik.css.engine.value.Value; 24 import org.w3c.dom.DOMException ; 25 import org.w3c.dom.css.CSSPrimitiveValue; 26 import org.w3c.dom.css.CSSValue; 27 import org.w3c.dom.css.CSSValueList; 28 import org.w3c.dom.css.Counter; 29 import org.w3c.dom.css.RGBColor; 30 import org.w3c.dom.css.Rect; 31 32 40 public class CSSOMValue 41 implements CSSPrimitiveValue, 42 CSSValueList, 43 Counter, 44 Rect, 45 RGBColor { 46 47 50 protected ValueProvider valueProvider; 51 52 55 protected ModificationHandler handler; 56 57 60 protected LeftComponent leftComponent; 61 62 65 protected RightComponent rightComponent; 66 67 70 protected BottomComponent bottomComponent; 71 72 75 protected TopComponent topComponent; 76 77 80 protected RedComponent redComponent; 81 82 85 protected GreenComponent greenComponent; 86 87 90 protected BlueComponent blueComponent; 91 92 95 protected CSSValue[] items; 96 97 100 public CSSOMValue(ValueProvider vp) { 101 valueProvider = vp; 102 } 103 104 107 public void setModificationHandler(ModificationHandler h) { 108 handler = h; 109 } 110 111 114 public String getCssText() { 115 return valueProvider.getValue().getCssText(); 116 } 117 118 122 public void setCssText(String cssText) throws DOMException { 123 if (handler == null) { 124 throw new DOMException 125 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 126 } else { 127 handler.textChanged(cssText); 128 } 129 } 130 131 135 public short getCssValueType() { 136 return valueProvider.getValue().getCssValueType(); 137 } 138 139 143 public short getPrimitiveType() { 144 return valueProvider.getValue().getPrimitiveType(); 145 } 146 147 151 public void setFloatValue(short unitType, float floatValue) 152 throws DOMException { 153 if (handler == null) { 154 throw new DOMException 155 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 156 } else { 157 handler.floatValueChanged(unitType, floatValue); 158 } 159 } 160 161 165 public float getFloatValue(short unitType) throws DOMException { 166 return convertFloatValue(unitType, valueProvider.getValue()); 167 } 168 169 172 public static float convertFloatValue(short unitType, Value value) { 173 switch (unitType) { 174 case CSSPrimitiveValue.CSS_NUMBER: 175 case CSSPrimitiveValue.CSS_PERCENTAGE: 176 case CSSPrimitiveValue.CSS_EMS: 177 case CSSPrimitiveValue.CSS_EXS: 178 case CSSPrimitiveValue.CSS_DIMENSION: 179 case CSSPrimitiveValue.CSS_PX: 180 if (value.getPrimitiveType() == unitType) { 181 return value.getFloatValue(); 182 } 183 break; 184 case CSSPrimitiveValue.CSS_CM: 185 return toCentimeters(value); 186 case CSSPrimitiveValue.CSS_MM: 187 return toMillimeters(value); 188 case CSSPrimitiveValue.CSS_IN: 189 return toInches(value); 190 case CSSPrimitiveValue.CSS_PT: 191 return toPoints(value); 192 case CSSPrimitiveValue.CSS_PC: 193 return toPicas(value); 194 case CSSPrimitiveValue.CSS_DEG: 195 return toDegrees(value); 196 case CSSPrimitiveValue.CSS_RAD: 197 return toRadians(value); 198 case CSSPrimitiveValue.CSS_GRAD: 199 return toGradians(value); 200 case CSSPrimitiveValue.CSS_MS: 201 return toMilliseconds(value); 202 case CSSPrimitiveValue.CSS_S: 203 return toSeconds(value); 204 case CSSPrimitiveValue.CSS_HZ: 205 return toHertz(value); 206 case CSSPrimitiveValue.CSS_KHZ: 207 return tokHertz(value); 208 } 209 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 210 } 211 212 215 protected static float toCentimeters(Value value) { 216 switch (value.getPrimitiveType()) { 217 case CSSPrimitiveValue.CSS_CM: 218 return value.getFloatValue(); 219 case CSSPrimitiveValue.CSS_MM: 220 return (value.getFloatValue() / 10); 221 case CSSPrimitiveValue.CSS_IN: 222 return (value.getFloatValue() * 2.54f); 223 case CSSPrimitiveValue.CSS_PT: 224 return (value.getFloatValue() * 2.54f / 72); 225 case CSSPrimitiveValue.CSS_PC: 226 return (value.getFloatValue() * 2.54f / 6); 227 default: 228 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 229 } 230 } 231 232 235 protected static float toInches(Value value) { 236 switch (value.getPrimitiveType()) { 237 case CSSPrimitiveValue.CSS_CM: 238 return (value.getFloatValue() / 2.54f); 239 case CSSPrimitiveValue.CSS_MM: 240 return (value.getFloatValue() / 25.4f); 241 case CSSPrimitiveValue.CSS_IN: 242 return value.getFloatValue(); 243 case CSSPrimitiveValue.CSS_PT: 244 return (value.getFloatValue() / 72); 245 case CSSPrimitiveValue.CSS_PC: 246 return (value.getFloatValue() / 6); 247 default: 248 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 249 } 250 } 251 252 255 protected static float toMillimeters(Value value) { 256 switch (value.getPrimitiveType()) { 257 case CSSPrimitiveValue.CSS_CM: 258 return (value.getFloatValue() * 10); 259 case CSSPrimitiveValue.CSS_MM: 260 return value.getFloatValue(); 261 case CSSPrimitiveValue.CSS_IN: 262 return (value.getFloatValue() * 25.4f); 263 case CSSPrimitiveValue.CSS_PT: 264 return (value.getFloatValue() * 25.4f / 72); 265 case CSSPrimitiveValue.CSS_PC: 266 return (value.getFloatValue() * 25.4f / 6); 267 default: 268 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 269 } 270 } 271 272 275 protected static float toPoints(Value value) { 276 switch (value.getPrimitiveType()) { 277 case CSSPrimitiveValue.CSS_CM: 278 return (value.getFloatValue() * 72 / 2.54f); 279 case CSSPrimitiveValue.CSS_MM: 280 return (value.getFloatValue() * 72 / 25.4f); 281 case CSSPrimitiveValue.CSS_IN: 282 return (value.getFloatValue() * 72); 283 case CSSPrimitiveValue.CSS_PT: 284 return value.getFloatValue(); 285 case CSSPrimitiveValue.CSS_PC: 286 return (value.getFloatValue() * 12); 287 default: 288 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 289 } 290 } 291 292 295 protected static float toPicas(Value value) { 296 switch (value.getPrimitiveType()) { 297 case CSSPrimitiveValue.CSS_CM: 298 return (value.getFloatValue() * 6 / 2.54f); 299 case CSSPrimitiveValue.CSS_MM: 300 return (value.getFloatValue() * 6 / 25.4f); 301 case CSSPrimitiveValue.CSS_IN: 302 return (value.getFloatValue() * 6); 303 case CSSPrimitiveValue.CSS_PT: 304 return (value.getFloatValue() / 12); 305 case CSSPrimitiveValue.CSS_PC: 306 return value.getFloatValue(); 307 default: 308 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 309 } 310 } 311 312 315 protected static float toDegrees(Value value) { 316 switch (value.getPrimitiveType()) { 317 case CSSPrimitiveValue.CSS_DEG: 318 return value.getFloatValue(); 319 case CSSPrimitiveValue.CSS_RAD: 320 return (float)(value.getFloatValue() * 180 / Math.PI); 321 case CSSPrimitiveValue.CSS_GRAD: 322 return (value.getFloatValue() * 9 / 5); 323 default: 324 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 325 } 326 } 327 328 331 protected static float toRadians(Value value) { 332 switch (value.getPrimitiveType()) { 333 case CSSPrimitiveValue.CSS_DEG: 334 return (value.getFloatValue() * 5 / 9); 335 case CSSPrimitiveValue.CSS_RAD: 336 return value.getFloatValue(); 337 case CSSPrimitiveValue.CSS_GRAD: 338 return (float)(value.getFloatValue() * 100 / Math.PI); 339 default: 340 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 341 } 342 } 343 344 347 protected static float toGradians(Value value) { 348 switch (value.getPrimitiveType()) { 349 case CSSPrimitiveValue.CSS_DEG: 350 return (float)(value.getFloatValue() * Math.PI / 180); 351 case CSSPrimitiveValue.CSS_RAD: 352 return (float)(value.getFloatValue() * Math.PI / 100); 353 case CSSPrimitiveValue.CSS_GRAD: 354 return value.getFloatValue(); 355 default: 356 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 357 } 358 } 359 360 363 protected static float toMilliseconds(Value value) { 364 switch (value.getPrimitiveType()) { 365 case CSSPrimitiveValue.CSS_MS: 366 return value.getFloatValue(); 367 case CSSPrimitiveValue.CSS_S: 368 return (value.getFloatValue() * 1000); 369 default: 370 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 371 } 372 } 373 374 377 protected static float toSeconds(Value value) { 378 switch (value.getPrimitiveType()) { 379 case CSSPrimitiveValue.CSS_MS: 380 return (value.getFloatValue() / 1000); 381 case CSSPrimitiveValue.CSS_S: 382 return value.getFloatValue(); 383 default: 384 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 385 } 386 } 387 388 391 protected static float toHertz(Value value) { 392 switch (value.getPrimitiveType()) { 393 case CSSPrimitiveValue.CSS_HZ: 394 return value.getFloatValue(); 395 case CSSPrimitiveValue.CSS_KHZ: 396 return (value.getFloatValue() / 1000); 397 default: 398 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 399 } 400 } 401 402 405 protected static float tokHertz(Value value) { 406 switch (value.getPrimitiveType()) { 407 case CSSPrimitiveValue.CSS_HZ: 408 return (value.getFloatValue() * 1000); 409 case CSSPrimitiveValue.CSS_KHZ: 410 return value.getFloatValue(); 411 default: 412 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 413 } 414 } 415 416 420 public void setStringValue(short stringType, String stringValue) 421 throws DOMException { 422 if (handler == null) { 423 throw new DOMException 424 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 425 } else { 426 handler.stringValueChanged(stringType, stringValue); 427 } 428 } 429 430 434 public String getStringValue() throws DOMException { 435 return valueProvider.getValue().getStringValue(); 436 } 437 438 442 public Counter getCounterValue() throws DOMException { 443 return this; 444 } 445 446 450 public Rect getRectValue() throws DOMException { 451 return this; 452 } 453 454 458 public RGBColor getRGBColorValue() throws DOMException { 459 return this; 460 } 461 462 464 467 public int getLength() { 468 return valueProvider.getValue().getLength(); 469 } 470 471 474 public CSSValue item(int index) { 475 int len = valueProvider.getValue().getLength(); 476 if (index < 0 || index >= len) { 477 return null; 478 } 479 if (items == null) { 480 items = new CSSValue[valueProvider.getValue().getLength()]; 481 } else if (items.length < len) { 482 CSSValue[] nitems = new CSSValue[len]; 483 for (int i = 0; i < items.length; i++) { 484 nitems[i] = items[i]; 485 } 486 items = nitems; 487 } 488 CSSValue result = items[index]; 489 if (result == null) { 490 items[index] = result = new ListComponent(index); 491 } 492 return result; 493 } 494 495 497 500 public String getIdentifier() { 501 return valueProvider.getValue().getIdentifier(); 502 } 503 504 507 public String getListStyle() { 508 return valueProvider.getValue().getListStyle(); 509 } 510 511 514 public String getSeparator() { 515 return valueProvider.getValue().getSeparator(); 516 } 517 518 520 523 public CSSPrimitiveValue getTop() { 524 valueProvider.getValue().getTop(); 525 if (topComponent == null) { 526 topComponent = new TopComponent(); 527 } 528 return topComponent; 529 } 530 531 534 public CSSPrimitiveValue getRight() { 535 valueProvider.getValue().getRight(); 536 if (rightComponent == null) { 537 rightComponent = new RightComponent(); 538 } 539 return rightComponent; 540 } 541 542 545 public CSSPrimitiveValue getBottom() { 546 valueProvider.getValue().getBottom(); 547 if (bottomComponent == null) { 548 bottomComponent = new BottomComponent(); 549 } 550 return bottomComponent; 551 } 552 553 556 public CSSPrimitiveValue getLeft() { 557 valueProvider.getValue().getLeft(); 558 if (leftComponent == null) { 559 leftComponent = new LeftComponent(); 560 } 561 return leftComponent; 562 } 563 564 566 569 public CSSPrimitiveValue getRed() { 570 valueProvider.getValue().getRed(); 571 if (redComponent == null) { 572 redComponent = new RedComponent(); 573 } 574 return redComponent; 575 } 576 577 580 public CSSPrimitiveValue getGreen() { 581 valueProvider.getValue().getGreen(); 582 if (greenComponent == null) { 583 greenComponent = new GreenComponent(); 584 } 585 return greenComponent; 586 } 587 588 589 592 public CSSPrimitiveValue getBlue() { 593 valueProvider.getValue().getBlue(); 594 if (blueComponent == null) { 595 blueComponent = new BlueComponent(); 596 } 597 return blueComponent; 598 } 599 600 603 public interface ValueProvider { 604 605 608 Value getValue(); 609 } 610 611 614 public interface ModificationHandler { 615 616 619 void textChanged(String text) throws DOMException ; 620 621 624 void floatValueChanged(short unit, float value) throws DOMException ; 625 626 629 void stringValueChanged(short type, String value) throws DOMException ; 630 631 634 void leftTextChanged(String text) throws DOMException ; 635 636 639 void leftFloatValueChanged(short unit, float value) 640 throws DOMException ; 641 642 645 void topTextChanged(String text) throws DOMException ; 646 647 650 void topFloatValueChanged(short unit, float value) 651 throws DOMException ; 652 653 656 void rightTextChanged(String text) throws DOMException ; 657 658 661 void rightFloatValueChanged(short unit, float value) 662 throws DOMException ; 663 664 667 void bottomTextChanged(String text) throws DOMException ; 668 669 672 void bottomFloatValueChanged(short unit, float value) 673 throws DOMException ; 674 675 678 void redTextChanged(String text) throws DOMException ; 679 680 683 void redFloatValueChanged(short unit, float value) 684 throws DOMException ; 685 686 689 void greenTextChanged(String text) throws DOMException ; 690 691 694 void greenFloatValueChanged(short unit, float value) 695 throws DOMException ; 696 697 700 void blueTextChanged(String text) throws DOMException ; 701 702 705 void blueFloatValueChanged(short unit, float value) 706 throws DOMException ; 707 708 711 void listTextChanged(int idx, String text) throws DOMException ; 712 713 716 void listFloatValueChanged(int idx, short unit, float value) 717 throws DOMException ; 718 719 722 void listStringValueChanged(int idx, short unit, String value) 723 throws DOMException ; 724 725 } 726 727 730 public abstract class AbstractModificationHandler 731 implements ModificationHandler { 732 733 736 protected abstract Value getValue(); 737 738 741 public void floatValueChanged(short unit, float value) 742 throws DOMException { 743 textChanged(FloatValue.getCssText(unit, value)); 744 } 745 746 749 public void stringValueChanged(short type, String value) 750 throws DOMException { 751 textChanged(StringValue.getCssText(type, value)); 752 } 753 754 757 public void leftTextChanged(String text) throws DOMException { 758 text = "rect(" + 759 getValue().getTop().getCssText() + ", " + 760 getValue().getRight().getCssText() + ", " + 761 getValue().getBottom().getCssText() + ", " + 762 text + ")"; 763 textChanged(text); 764 } 765 766 769 public void leftFloatValueChanged(short unit, float value) 770 throws DOMException { 771 String text = "rect(" + 772 getValue().getTop().getCssText() + ", " + 773 getValue().getRight().getCssText() + ", " + 774 getValue().getBottom().getCssText() + ", " + 775 FloatValue.getCssText(unit, value) + ")"; 776 textChanged(text); 777 } 778 779 782 public void topTextChanged(String text) throws DOMException { 783 text = "rect(" + 784 text + ", " + 785 getValue().getRight().getCssText() + ", " + 786 getValue().getBottom().getCssText() + ", " + 787 getValue().getLeft().getCssText() + ")"; 788 textChanged(text); 789 } 790 791 794 public void topFloatValueChanged(short unit, float value) 795 throws DOMException { 796 String text = "rect(" + 797 FloatValue.getCssText(unit, value) + ", " + 798 getValue().getRight().getCssText() + ", " + 799 getValue().getBottom().getCssText() + ", " + 800 getValue().getLeft().getCssText() + ")"; 801 textChanged(text); 802 } 803 804 807 public void rightTextChanged(String text) throws DOMException { 808 text = "rect(" + 809 getValue().getTop().getCssText() + ", " + 810 text + ", " + 811 getValue().getBottom().getCssText() + ", " + 812 getValue().getLeft().getCssText() + ")"; 813 textChanged(text); 814 } 815 816 819 public void rightFloatValueChanged(short unit, float value) 820 throws DOMException { 821 String text = "rect(" + 822 getValue().getTop().getCssText() + ", " + 823 FloatValue.getCssText(unit, value) + ", " + 824 getValue().getBottom().getCssText() + ", " + 825 getValue().getLeft().getCssText() + ")"; 826 textChanged(text); 827 } 828 829 832 public void bottomTextChanged(String text) throws DOMException { 833 text = "rect(" + 834 getValue().getTop().getCssText() + ", " + 835 getValue().getRight().getCssText() + ", " + 836 text + ", " + 837 getValue().getLeft().getCssText() + ")"; 838 textChanged(text); 839 } 840 841 844 public void bottomFloatValueChanged(short unit, float value) 845 throws DOMException { 846 String text = "rect(" + 847 getValue().getTop().getCssText() + ", " + 848 getValue().getRight().getCssText() + ", " + 849 FloatValue.getCssText(unit, value) + ", " + 850 getValue().getLeft().getCssText() + ")"; 851 textChanged(text); 852 } 853 854 857 public void redTextChanged(String text) throws DOMException { 858 text = "rgb(" + 859 text + ", " + 860 getValue().getGreen().getCssText() + ", " + 861 getValue().getBlue().getCssText() + ")"; 862 textChanged(text); 863 } 864 865 868 public void redFloatValueChanged(short unit, float value) 869 throws DOMException { 870 String text = "rgb(" + 871 FloatValue.getCssText(unit, value) + ", " + 872 getValue().getGreen().getCssText() + ", " + 873 getValue().getBlue().getCssText() + ")"; 874 textChanged(text); 875 } 876 877 880 public void greenTextChanged(String text) throws DOMException { 881 text = "rgb(" + 882 getValue().getRed().getCssText() + ", " + 883 text + ", " + 884 getValue().getBlue().getCssText() + ")"; 885 textChanged(text); 886 } 887 888 891 public void greenFloatValueChanged(short unit, float value) 892 throws DOMException { 893 String text = "rgb(" + 894 getValue().getRed().getCssText() + ", " + 895 FloatValue.getCssText(unit, value) + ", " + 896 getValue().getBlue().getCssText() + ")"; 897 textChanged(text); 898 } 899 900 903 public void blueTextChanged(String text) throws DOMException { 904 text = "rgb(" + 905 getValue().getRed().getCssText() + ", " + 906 getValue().getGreen().getCssText() + ", " + 907 text + ")"; 908 textChanged(text); 909 } 910 911 914 public void blueFloatValueChanged(short unit, float value) 915 throws DOMException { 916 String text = "rgb(" + 917 getValue().getRed().getCssText() + ", " + 918 getValue().getGreen().getCssText() + ", " + 919 FloatValue.getCssText(unit, value) + ")"; 920 textChanged(text); 921 } 922 923 926 public void listTextChanged(int idx, String text) throws DOMException { 927 ListValue lv = (ListValue)getValue(); 928 StringBuffer sb = new StringBuffer (); 929 for (int i = 0; i < idx; i++) { 930 sb.append(lv.item(i).getCssText()); 931 sb.append(lv.getSeparatorChar()); 932 } 933 sb.append(text); 934 int len = lv.getLength(); 935 for (int i = idx + 1; i < len; i++) { 936 sb.append(lv.getSeparatorChar()); 937 sb.append(lv.item(i).getCssText()); 938 } 939 text = sb.toString(); 940 textChanged(text); 941 } 942 943 946 public void listFloatValueChanged(int idx, short unit, float value) 947 throws DOMException { 948 ListValue lv = (ListValue)getValue(); 949 StringBuffer sb = new StringBuffer (); 950 for (int i = 0; i < idx; i++) { 951 sb.append(lv.item(i).getCssText()); 952 sb.append(lv.getSeparatorChar()); 953 } 954 sb.append(FloatValue.getCssText(unit, value)); 955 int len = lv.getLength(); 956 for (int i = idx + 1; i < len; i++) { 957 sb.append(lv.getSeparatorChar()); 958 sb.append(lv.item(i).getCssText()); 959 } 960 textChanged(sb.toString()); 961 } 962 963 966 public void listStringValueChanged(int idx, short unit, String value) 967 throws DOMException { 968 ListValue lv = (ListValue)getValue(); 969 StringBuffer sb = new StringBuffer (); 970 for (int i = 0; i < idx; i++) { 971 sb.append(lv.item(i).getCssText()); 972 sb.append(lv.getSeparatorChar()); 973 } 974 sb.append(StringValue.getCssText(unit, value)); 975 int len = lv.getLength(); 976 for (int i = idx + 1; i < len; i++) { 977 sb.append(lv.getSeparatorChar()); 978 sb.append(lv.item(i).getCssText()); 979 } 980 textChanged(sb.toString()); 981 } 982 } 983 984 987 protected abstract class AbstractComponent implements CSSPrimitiveValue { 988 989 992 protected abstract Value getValue(); 993 994 998 public String getCssText() { 999 return getValue().getCssText(); 1000 } 1001 1002 1006 public short getCssValueType() { 1007 return getValue().getCssValueType(); 1008 } 1009 1010 1014 public short getPrimitiveType() { 1015 return getValue().getPrimitiveType(); 1016 } 1017 1018 1022 public float getFloatValue(short unitType) throws DOMException { 1023 return convertFloatValue(unitType, getValue()); 1024 } 1025 1026 1030 public String getStringValue() throws DOMException { 1031 return valueProvider.getValue().getStringValue(); 1032 } 1033 1034 1038 public Counter getCounterValue() throws DOMException { 1039 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 1040 } 1041 1042 1046 public Rect getRectValue() throws DOMException { 1047 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 1048 } 1049 1050 1054 public RGBColor getRGBColorValue() throws DOMException { 1055 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 1056 } 1057 1058 1060 1064 public int getLength() { 1065 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 1066 } 1067 1068 1072 public CSSValue item(int index) { 1073 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 1074 } 1075 } 1076 1077 1080 protected abstract class FloatComponent extends AbstractComponent { 1081 1082 1086 public void setStringValue(short stringType, String stringValue) 1087 throws DOMException { 1088 throw new DOMException (DOMException.INVALID_ACCESS_ERR, ""); 1089 } 1090 } 1091 1092 1095 protected class LeftComponent extends FloatComponent { 1096 1097 1100 protected Value getValue() { 1101 return valueProvider.getValue().getLeft(); 1102 } 1103 1104 1108 public void setCssText(String cssText) throws DOMException { 1109 if (handler == null) { 1110 throw new DOMException 1111 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1112 } else { 1113 getValue(); 1114 handler.leftTextChanged(cssText); 1115 } 1116 } 1117 1118 1122 public void setFloatValue(short unitType, float floatValue) 1123 throws DOMException { 1124 if (handler == null) { 1125 throw new DOMException 1126 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1127 } else { 1128 getValue(); 1129 handler.leftFloatValueChanged(unitType, floatValue); 1130 } 1131 } 1132 1133 } 1134 1135 1138 protected class TopComponent extends FloatComponent { 1139 1140 1143 protected Value getValue() { 1144 return valueProvider.getValue().getTop(); 1145 } 1146 1147 1151 public void setCssText(String cssText) throws DOMException { 1152 if (handler == null) { 1153 throw new DOMException 1154 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1155 } else { 1156 getValue(); 1157 handler.topTextChanged(cssText); 1158 } 1159 } 1160 1161 1165 public void setFloatValue(short unitType, float floatValue) 1166 throws DOMException { 1167 if (handler == null) { 1168 throw new DOMException 1169 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1170 } else { 1171 getValue(); 1172 handler.topFloatValueChanged(unitType, floatValue); 1173 } 1174 } 1175 1176 } 1177 1178 1181 protected class RightComponent extends FloatComponent { 1182 1183 1186 protected Value getValue() { 1187 return valueProvider.getValue().getRight(); 1188 } 1189 1190 1194 public void setCssText(String cssText) throws DOMException { 1195 if (handler == null) { 1196 throw new DOMException 1197 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1198 } else { 1199 getValue(); 1200 handler.rightTextChanged(cssText); 1201 } 1202 } 1203 1204 1208 public void setFloatValue(short unitType, float floatValue) 1209 throws DOMException { 1210 if (handler == null) { 1211 throw new DOMException 1212 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1213 } else { 1214 getValue(); 1215 handler.rightFloatValueChanged(unitType, floatValue); 1216 } 1217 } 1218 1219 } 1220 1221 1222 1225 protected class BottomComponent extends FloatComponent { 1226 1227 1230 protected Value getValue() { 1231 return valueProvider.getValue().getBottom(); 1232 } 1233 1234 1238 public void setCssText(String cssText) throws DOMException { 1239 if (handler == null) { 1240 throw new DOMException 1241 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1242 } else { 1243 getValue(); 1244 handler.bottomTextChanged(cssText); 1245 } 1246 } 1247 1248 1252 public void setFloatValue(short unitType, float floatValue) 1253 throws DOMException { 1254 if (handler == null) { 1255 throw new DOMException 1256 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1257 } else { 1258 getValue(); 1259 handler.bottomFloatValueChanged(unitType, floatValue); 1260 } 1261 } 1262 1263 } 1264 1265 1266 1269 protected class RedComponent extends FloatComponent { 1270 1271 1274 protected Value getValue() { 1275 return valueProvider.getValue().getRed(); 1276 } 1277 1278 1282 public void setCssText(String cssText) throws DOMException { 1283 if (handler == null) { 1284 throw new DOMException 1285 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1286 } else { 1287 getValue(); 1288 handler.redTextChanged(cssText); 1289 } 1290 } 1291 1292 1296 public void setFloatValue(short unitType, float floatValue) 1297 throws DOMException { 1298 if (handler == null) { 1299 throw new DOMException 1300 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1301 } else { 1302 getValue(); 1303 handler.redFloatValueChanged(unitType, floatValue); 1304 } 1305 } 1306 1307 } 1308 1309 1310 1313 protected class GreenComponent extends FloatComponent { 1314 1315 1318 protected Value getValue() { 1319 return valueProvider.getValue().getGreen(); 1320 } 1321 1322 1326 public void setCssText(String cssText) throws DOMException { 1327 if (handler == null) { 1328 throw new DOMException 1329 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1330 } else { 1331 getValue(); 1332 handler.greenTextChanged(cssText); 1333 } 1334 } 1335 1336 1340 public void setFloatValue(short unitType, float floatValue) 1341 throws DOMException { 1342 if (handler == null) { 1343 throw new DOMException 1344 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1345 } else { 1346 getValue(); 1347 handler.greenFloatValueChanged(unitType, floatValue); 1348 } 1349 } 1350 1351 } 1352 1353 1356 protected class BlueComponent extends FloatComponent { 1357 1358 1361 protected Value getValue() { 1362 return valueProvider.getValue().getBlue(); 1363 } 1364 1365 1369 public void setCssText(String cssText) throws DOMException { 1370 if (handler == null) { 1371 throw new DOMException 1372 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1373 } else { 1374 getValue(); 1375 handler.blueTextChanged(cssText); 1376 } 1377 } 1378 1379 1383 public void setFloatValue(short unitType, float floatValue) 1384 throws DOMException { 1385 if (handler == null) { 1386 throw new DOMException 1387 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1388 } else { 1389 getValue(); 1390 handler.blueFloatValueChanged(unitType, floatValue); 1391 } 1392 } 1393 1394 } 1395 1396 1399 protected class ListComponent extends AbstractComponent { 1400 1401 1404 protected int index; 1405 1406 1409 public ListComponent(int idx) { 1410 index = idx; 1411 } 1412 1413 1416 protected Value getValue() { 1417 if (index >= valueProvider.getValue().getLength()) { 1418 throw new DOMException 1419 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1420 } 1421 return valueProvider.getValue().item(index); 1422 } 1423 1424 1428 public void setCssText(String cssText) throws DOMException { 1429 if (handler == null) { 1430 throw new DOMException 1431 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1432 } else { 1433 getValue(); 1434 handler.listTextChanged(index, cssText); 1435 } 1436 } 1437 1438 1442 public void setFloatValue(short unitType, float floatValue) 1443 throws DOMException { 1444 if (handler == null) { 1445 throw new DOMException 1446 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1447 } else { 1448 getValue(); 1449 handler.listFloatValueChanged(index, unitType, floatValue); 1450 } 1451 } 1452 1453 1457 public void setStringValue(short stringType, String stringValue) 1458 throws DOMException { 1459 if (handler == null) { 1460 throw new DOMException 1461 (DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); 1462 } else { 1463 getValue(); 1464 handler.listStringValueChanged(index, stringType, stringValue); 1465 } 1466 } 1467 } 1468 1469} 1470 | Popular Tags |