1 18 package org.apache.batik.css.engine.value.css2; 19 20 import org.apache.batik.css.engine.CSSEngine; 21 import org.apache.batik.css.engine.CSSStylableElement; 22 import org.apache.batik.css.engine.StyleMap; 23 import org.apache.batik.css.engine.value.IdentifierManager; 24 import org.apache.batik.css.engine.value.StringMap; 25 import org.apache.batik.css.engine.value.Value; 26 import org.apache.batik.css.engine.value.ValueConstants; 27 import org.apache.batik.css.engine.value.ValueManager; 28 import org.apache.batik.util.CSSConstants; 29 30 36 public class FontStretchManager extends IdentifierManager { 37 38 41 protected final static StringMap values = new StringMap(); 42 static { 43 values.put(CSSConstants.CSS_ALL_VALUE, 44 ValueConstants.ALL_VALUE); 45 values.put(CSSConstants.CSS_CONDENSED_VALUE, 46 ValueConstants.CONDENSED_VALUE); 47 values.put(CSSConstants.CSS_EXPANDED_VALUE, 48 ValueConstants.EXPANDED_VALUE); 49 values.put(CSSConstants.CSS_EXTRA_CONDENSED_VALUE, 50 ValueConstants.EXTRA_CONDENSED_VALUE); 51 values.put(CSSConstants.CSS_EXTRA_EXPANDED_VALUE, 52 ValueConstants.EXTRA_EXPANDED_VALUE); 53 values.put(CSSConstants.CSS_NARROWER_VALUE, 54 ValueConstants.NARROWER_VALUE); 55 values.put(CSSConstants.CSS_NORMAL_VALUE, 56 ValueConstants.NORMAL_VALUE); 57 values.put(CSSConstants.CSS_SEMI_CONDENSED_VALUE, 58 ValueConstants.SEMI_CONDENSED_VALUE); 59 values.put(CSSConstants.CSS_SEMI_EXPANDED_VALUE, 60 ValueConstants.SEMI_EXPANDED_VALUE); 61 values.put(CSSConstants.CSS_ULTRA_CONDENSED_VALUE, 62 ValueConstants.ULTRA_CONDENSED_VALUE); 63 values.put(CSSConstants.CSS_ULTRA_EXPANDED_VALUE, 64 ValueConstants.ULTRA_EXPANDED_VALUE); 65 values.put(CSSConstants.CSS_WIDER_VALUE, 66 ValueConstants.WIDER_VALUE); 67 } 68 69 73 public boolean isInheritedProperty() { 74 return true; 75 } 76 77 81 public String getPropertyName() { 82 return CSSConstants.CSS_FONT_STRETCH_PROPERTY; 83 } 84 85 89 public Value getDefaultValue() { 90 return ValueConstants.NORMAL_VALUE; 91 } 92 93 97 public Value computeValue(CSSStylableElement elt, 98 String pseudo, 99 CSSEngine engine, 100 int idx, 101 StyleMap sm, 102 Value value) { 103 if (value == ValueConstants.NARROWER_VALUE) { 104 sm.putParentRelative(idx, true); 105 106 CSSStylableElement p = CSSEngine.getParentCSSStylableElement(elt); 107 if (p == null) { 108 return ValueConstants.SEMI_CONDENSED_VALUE; 109 } 110 Value v = engine.getComputedStyle(p, pseudo, idx); 111 if (v == ValueConstants.NORMAL_VALUE) { 112 return ValueConstants.SEMI_CONDENSED_VALUE; 113 } 114 if (v == ValueConstants.CONDENSED_VALUE) { 115 return ValueConstants.EXTRA_CONDENSED_VALUE; 116 } 117 if (v == ValueConstants.EXPANDED_VALUE) { 118 return ValueConstants.SEMI_EXPANDED_VALUE; 119 } 120 if (v == ValueConstants.SEMI_EXPANDED_VALUE) { 121 return ValueConstants.NORMAL_VALUE; 122 } 123 if (v == ValueConstants.SEMI_CONDENSED_VALUE) { 124 return ValueConstants.CONDENSED_VALUE; 125 } 126 if (v == ValueConstants.EXTRA_CONDENSED_VALUE) { 127 return ValueConstants.ULTRA_CONDENSED_VALUE; 128 } 129 if (v == ValueConstants.EXTRA_EXPANDED_VALUE) { 130 return ValueConstants.EXPANDED_VALUE; 131 } 132 if (v == ValueConstants.ULTRA_CONDENSED_VALUE) { 133 return ValueConstants.ULTRA_CONDENSED_VALUE; 134 } 135 return ValueConstants.EXTRA_EXPANDED_VALUE; 136 } else if (value == ValueConstants.WIDER_VALUE) { 137 sm.putParentRelative(idx, true); 138 139 CSSStylableElement p = CSSEngine.getParentCSSStylableElement(elt); 140 if (p == null) { 141 return ValueConstants.SEMI_CONDENSED_VALUE; 142 } 143 Value v = engine.getComputedStyle(p, pseudo, idx); 144 if (v == ValueConstants.NORMAL_VALUE) { 145 return ValueConstants.SEMI_EXPANDED_VALUE; 146 } 147 if (v == ValueConstants.CONDENSED_VALUE) { 148 return ValueConstants.SEMI_CONDENSED_VALUE; 149 } 150 if (v == ValueConstants.EXPANDED_VALUE) { 151 return ValueConstants.EXTRA_EXPANDED_VALUE; 152 } 153 if (v == ValueConstants.SEMI_EXPANDED_VALUE) { 154 return ValueConstants.EXPANDED_VALUE; 155 } 156 if (v == ValueConstants.SEMI_CONDENSED_VALUE) { 157 return ValueConstants.NORMAL_VALUE; 158 } 159 if (v == ValueConstants.EXTRA_CONDENSED_VALUE) { 160 return ValueConstants.CONDENSED_VALUE; 161 } 162 if (v == ValueConstants.EXTRA_EXPANDED_VALUE) { 163 return ValueConstants.ULTRA_EXPANDED_VALUE; 164 } 165 if (v == ValueConstants.ULTRA_CONDENSED_VALUE) { 166 return ValueConstants.EXTRA_CONDENSED_VALUE; 167 } 168 return ValueConstants.ULTRA_EXPANDED_VALUE; 169 } 170 return value; 171 } 172 173 176 public StringMap getIdentifiers() { 177 return values; 178 } 179 } 180 | Popular Tags |