1 18 package org.apache.batik.css.dom; 19 20 import org.apache.batik.css.engine.CSSEngine; 21 import org.apache.batik.css.engine.CSSStylableElement; 22 import org.apache.batik.css.engine.SVGCSSEngine; 23 import org.apache.batik.css.engine.value.Value; 24 import org.apache.batik.css.engine.value.svg.SVGColorManager; 25 import org.apache.batik.css.engine.value.svg.SVGPaintManager; 26 import org.w3c.dom.css.CSSValue; 27 28 34 public class CSSOMSVGComputedStyle extends CSSOMComputedStyle { 35 36 39 public CSSOMSVGComputedStyle(CSSEngine e, 40 CSSStylableElement elt, 41 String pseudoElt) { 42 super(e, elt, pseudoElt); 43 } 44 45 48 protected CSSValue createCSSValue(int idx) { 49 if (idx > SVGCSSEngine.FINAL_INDEX) { 50 if (cssEngine.getValueManagers()[idx] instanceof SVGPaintManager) { 51 return new ComputedCSSPaintValue(idx); 52 } 53 if (cssEngine.getValueManagers()[idx] instanceof SVGColorManager) { 54 return new ComputedCSSColorValue(idx); 55 } 56 } else { 57 switch (idx) { 58 case SVGCSSEngine.FILL_INDEX: 59 case SVGCSSEngine.STROKE_INDEX: 60 return new ComputedCSSPaintValue(idx); 61 62 case SVGCSSEngine.FLOOD_COLOR_INDEX: 63 case SVGCSSEngine.LIGHTING_COLOR_INDEX: 64 case SVGCSSEngine.STOP_COLOR_INDEX: 65 return new ComputedCSSColorValue(idx); 66 } 67 } 68 return super.createCSSValue(idx); 69 } 70 71 74 protected class ComputedCSSColorValue 75 extends CSSOMSVGColor 76 implements CSSOMSVGColor.ValueProvider { 77 78 81 protected int index; 82 83 86 public ComputedCSSColorValue(int idx) { 87 super(null); 88 valueProvider = this; 89 index = idx; 90 } 91 92 95 public Value getValue() { 96 return cssEngine.getComputedStyle(element, pseudoElement, index); 97 } 98 } 99 100 103 public class ComputedCSSPaintValue 104 extends CSSOMSVGPaint 105 implements CSSOMSVGPaint.ValueProvider { 106 107 110 protected int index; 111 112 115 public ComputedCSSPaintValue(int idx) { 116 super(null); 117 valueProvider = this; 118 index = idx; 119 } 120 121 124 public Value getValue() { 125 return cssEngine.getComputedStyle(element, pseudoElement, index); 126 } 127 } 128 } 129 | Popular Tags |