1 18 package org.apache.batik.css.engine; 19 20 import java.net.URL ; 21 22 import org.apache.batik.css.engine.value.ShorthandManager; 23 import org.apache.batik.css.engine.value.ValueConstants; 24 import org.apache.batik.css.engine.value.ValueManager; 25 import org.apache.batik.css.engine.value.css2.ClipManager; 26 import org.apache.batik.css.engine.value.css2.CursorManager; 27 import org.apache.batik.css.engine.value.css2.DirectionManager; 28 import org.apache.batik.css.engine.value.css2.DisplayManager; 29 import org.apache.batik.css.engine.value.css2.FontFamilyManager; 30 import org.apache.batik.css.engine.value.css2.FontShorthandManager; 31 import org.apache.batik.css.engine.value.css2.FontSizeAdjustManager; 32 import org.apache.batik.css.engine.value.css2.FontSizeManager; 33 import org.apache.batik.css.engine.value.css2.FontStretchManager; 34 import org.apache.batik.css.engine.value.css2.FontStyleManager; 35 import org.apache.batik.css.engine.value.css2.FontVariantManager; 36 import org.apache.batik.css.engine.value.css2.FontWeightManager; 37 import org.apache.batik.css.engine.value.css2.OverflowManager; 38 import org.apache.batik.css.engine.value.css2.SrcManager; 39 import org.apache.batik.css.engine.value.css2.TextDecorationManager; 40 import org.apache.batik.css.engine.value.css2.UnicodeBidiManager; 41 import org.apache.batik.css.engine.value.css2.VisibilityManager; 42 import org.apache.batik.css.engine.value.svg.AlignmentBaselineManager; 43 import org.apache.batik.css.engine.value.svg.BaselineShiftManager; 44 import org.apache.batik.css.engine.value.svg.ClipPathManager; 45 import org.apache.batik.css.engine.value.svg.ClipRuleManager; 46 import org.apache.batik.css.engine.value.svg.ColorInterpolationFiltersManager; 47 import org.apache.batik.css.engine.value.svg.ColorInterpolationManager; 48 import org.apache.batik.css.engine.value.svg.ColorManager; 49 import org.apache.batik.css.engine.value.svg.ColorProfileManager; 50 import org.apache.batik.css.engine.value.svg.ColorRenderingManager; 51 import org.apache.batik.css.engine.value.svg.DominantBaselineManager; 52 import org.apache.batik.css.engine.value.svg.EnableBackgroundManager; 53 import org.apache.batik.css.engine.value.svg.FillRuleManager; 54 import org.apache.batik.css.engine.value.svg.FilterManager; 55 import org.apache.batik.css.engine.value.svg.GlyphOrientationHorizontalManager; 56 import org.apache.batik.css.engine.value.svg.GlyphOrientationVerticalManager; 57 import org.apache.batik.css.engine.value.svg.ImageRenderingManager; 58 import org.apache.batik.css.engine.value.svg.KerningManager; 59 import org.apache.batik.css.engine.value.svg.MarkerManager; 60 import org.apache.batik.css.engine.value.svg.MarkerShorthandManager; 61 import org.apache.batik.css.engine.value.svg.MaskManager; 62 import org.apache.batik.css.engine.value.svg.OpacityManager; 63 import org.apache.batik.css.engine.value.svg.PointerEventsManager; 64 import org.apache.batik.css.engine.value.svg.SVGColorManager; 65 import org.apache.batik.css.engine.value.svg.SVGPaintManager; 66 import org.apache.batik.css.engine.value.svg.ShapeRenderingManager; 67 import org.apache.batik.css.engine.value.svg.SpacingManager; 68 import org.apache.batik.css.engine.value.svg.StrokeDasharrayManager; 69 import org.apache.batik.css.engine.value.svg.StrokeDashoffsetManager; 70 import org.apache.batik.css.engine.value.svg.StrokeLinecapManager; 71 import org.apache.batik.css.engine.value.svg.StrokeLinejoinManager; 72 import org.apache.batik.css.engine.value.svg.StrokeMiterlimitManager; 73 import org.apache.batik.css.engine.value.svg.StrokeWidthManager; 74 import org.apache.batik.css.engine.value.svg.TextAnchorManager; 75 import org.apache.batik.css.engine.value.svg.TextRenderingManager; 76 import org.apache.batik.css.engine.value.svg.WritingModeManager; 77 import org.apache.batik.css.parser.ExtendedParser; 78 import org.apache.batik.util.CSSConstants; 79 import org.w3c.dom.Document ; 80 81 87 public class SVGCSSEngine extends CSSEngine { 88 89 96 public SVGCSSEngine(Document doc, 97 URL uri, 98 ExtendedParser p, 99 CSSContext ctx) { 100 super(doc, uri, p, 101 SVG_VALUE_MANAGERS, 102 SVG_SHORTHAND_MANAGERS, 103 null, 104 null, 105 "style", 106 null, 107 "class", 108 true, 109 null, 110 ctx); 111 lineHeightIndex = fontSizeIndex; 113 } 114 115 124 public SVGCSSEngine(Document doc, 125 URL uri, 126 ExtendedParser p, 127 ValueManager[] vms, 128 ShorthandManager[] sms, 129 CSSContext ctx) { 130 super(doc, uri, p, 131 mergeArrays(SVG_VALUE_MANAGERS, vms), 132 mergeArrays(SVG_SHORTHAND_MANAGERS, sms), 133 null, 134 null, 135 "style", 136 null, 137 "class", 138 true, 139 null, 140 ctx); 141 lineHeightIndex = fontSizeIndex; 143 } 144 145 protected SVGCSSEngine(Document doc, 146 URL uri, 147 ExtendedParser p, 148 ValueManager[] vms, 149 ShorthandManager[] sms, 150 String [] pe, 151 String sns, 152 String sln, 153 String cns, 154 String cln, 155 boolean hints, 156 String hintsNS, 157 CSSContext ctx) { 158 super(doc, uri, p, 159 mergeArrays(SVG_VALUE_MANAGERS, vms), 160 mergeArrays(SVG_SHORTHAND_MANAGERS, sms), 161 pe, sns, sln, cns, cln, hints, hintsNS, ctx); 162 lineHeightIndex = fontSizeIndex; 164 } 165 166 167 170 protected static ValueManager[] mergeArrays(ValueManager[] a1, 171 ValueManager[] a2) { 172 ValueManager[] result = new ValueManager[a1.length + a2.length]; 173 System.arraycopy(a1, 0, result, 0, a1.length); 174 System.arraycopy(a2, 0, result, a1.length, a2.length); 175 return result; 176 } 177 178 181 protected static ShorthandManager[] mergeArrays(ShorthandManager[] a1, 182 ShorthandManager[] a2) { 183 ShorthandManager[] result = 184 new ShorthandManager[a1.length + a2.length]; 185 System.arraycopy(a1, 0, result, 0, a1.length); 186 System.arraycopy(a2, 0, result, a1.length, a2.length); 187 return result; 188 } 189 190 193 public final static ValueManager[] SVG_VALUE_MANAGERS = { 194 new AlignmentBaselineManager(), 195 new BaselineShiftManager(), 196 new ClipManager(), 197 new ClipPathManager(), 198 new ClipRuleManager(), 199 200 new ColorManager(), 201 new ColorInterpolationManager(), 202 new ColorInterpolationFiltersManager(), 203 new ColorProfileManager(), 204 new ColorRenderingManager(), 205 206 new CursorManager(), 207 new DirectionManager(), 208 new DisplayManager(), 209 new DominantBaselineManager(), 210 new EnableBackgroundManager(), 211 212 new SVGPaintManager(CSSConstants.CSS_FILL_PROPERTY), 213 new OpacityManager(CSSConstants.CSS_FILL_OPACITY_PROPERTY, true), 214 new FillRuleManager(), 215 new FilterManager(), 216 new SVGColorManager(CSSConstants.CSS_FLOOD_COLOR_PROPERTY), 217 218 new OpacityManager(CSSConstants.CSS_FLOOD_OPACITY_PROPERTY, false), 219 new FontFamilyManager(), 220 new FontSizeManager(), 221 new FontSizeAdjustManager(), 222 new FontStretchManager(), 223 224 new FontStyleManager(), 225 new FontVariantManager(), 226 new FontWeightManager(), 227 new GlyphOrientationHorizontalManager(), 228 new GlyphOrientationVerticalManager(), 229 230 new ImageRenderingManager(), 231 new KerningManager(), 232 new SpacingManager(CSSConstants.CSS_LETTER_SPACING_PROPERTY), 233 new SVGColorManager(CSSConstants.CSS_LIGHTING_COLOR_PROPERTY, 234 ValueConstants.WHITE_RGB_VALUE), 235 new MarkerManager(CSSConstants.CSS_MARKER_END_PROPERTY), 236 237 new MarkerManager(CSSConstants.CSS_MARKER_MID_PROPERTY), 238 new MarkerManager(CSSConstants.CSS_MARKER_START_PROPERTY), 239 new MaskManager(), 240 new OpacityManager(CSSConstants.CSS_OPACITY_PROPERTY, false), 241 new OverflowManager(), 242 243 new PointerEventsManager(), 244 new SrcManager(), 245 new ShapeRenderingManager(), 246 new SVGColorManager(CSSConstants.CSS_STOP_COLOR_PROPERTY), 247 new OpacityManager(CSSConstants.CSS_STOP_OPACITY_PROPERTY, false), 248 new SVGPaintManager(CSSConstants.CSS_STROKE_PROPERTY, 249 ValueConstants.NONE_VALUE), 250 251 new StrokeDasharrayManager(), 252 new StrokeDashoffsetManager(), 253 new StrokeLinecapManager(), 254 new StrokeLinejoinManager(), 255 new StrokeMiterlimitManager(), 256 257 new OpacityManager(CSSConstants.CSS_STROKE_OPACITY_PROPERTY, true), 258 new StrokeWidthManager(), 259 new TextAnchorManager(), 260 new TextDecorationManager(), 261 new TextRenderingManager(), 262 263 new UnicodeBidiManager(), 264 new VisibilityManager(), 265 new SpacingManager(CSSConstants.CSS_WORD_SPACING_PROPERTY), 266 new WritingModeManager(), 267 }; 268 269 272 public final static ShorthandManager[] SVG_SHORTHAND_MANAGERS = { 273 new FontShorthandManager(), 274 new MarkerShorthandManager(), 275 }; 276 277 public final static int ALIGNMENT_BASELINE_INDEX = 0; 281 public final static int BASELINE_SHIFT_INDEX = 282 ALIGNMENT_BASELINE_INDEX + 1; 283 public final static int CLIP_INDEX = BASELINE_SHIFT_INDEX + 1; 284 public final static int CLIP_PATH_INDEX = CLIP_INDEX +1; 285 public final static int CLIP_RULE_INDEX = CLIP_PATH_INDEX + 1; 286 287 288 public final static int COLOR_INDEX = CLIP_RULE_INDEX + 1; 289 public final static int COLOR_INTERPOLATION_INDEX = COLOR_INDEX + 1; 290 public final static int COLOR_INTERPOLATION_FILTERS_INDEX = 291 COLOR_INTERPOLATION_INDEX + 1; 292 public final static int COLOR_PROFILE_INDEX = 293 COLOR_INTERPOLATION_FILTERS_INDEX + 1; 294 public final static int COLOR_RENDERING_INDEX = COLOR_PROFILE_INDEX + 1; 295 296 297 public final static int CURSOR_INDEX = COLOR_RENDERING_INDEX + 1; 298 public final static int DIRECTION_INDEX = CURSOR_INDEX + 1; 299 public final static int DISPLAY_INDEX = DIRECTION_INDEX + 1; 300 public final static int DOMINANT_BASELINE_INDEX = DISPLAY_INDEX + 1; 301 public final static int ENABLE_BACKGROUND_INDEX = 302 DOMINANT_BASELINE_INDEX + 1; 303 304 305 public final static int FILL_INDEX = ENABLE_BACKGROUND_INDEX + 1; 306 public final static int FILL_OPACITY_INDEX = FILL_INDEX + 1; 307 public final static int FILL_RULE_INDEX = FILL_OPACITY_INDEX + 1; 308 public final static int FILTER_INDEX = FILL_RULE_INDEX + 1; 309 public final static int FLOOD_COLOR_INDEX = FILTER_INDEX + 1; 310 311 public final static int FLOOD_OPACITY_INDEX = FLOOD_COLOR_INDEX + 1; 312 public final static int FONT_FAMILY_INDEX = FLOOD_OPACITY_INDEX + 1; 313 public final static int FONT_SIZE_INDEX = FONT_FAMILY_INDEX + 1; 314 public final static int FONT_SIZE_ADJUST_INDEX = FONT_SIZE_INDEX + 1; 315 public final static int FONT_STRETCH_INDEX = FONT_SIZE_ADJUST_INDEX + 1; 316 317 public final static int FONT_STYLE_INDEX = FONT_STRETCH_INDEX + 1; 318 public final static int FONT_VARIANT_INDEX = FONT_STYLE_INDEX + 1; 319 public final static int FONT_WEIGHT_INDEX = FONT_VARIANT_INDEX + 1; 320 public final static int GLYPH_ORIENTATION_HORIZONTAL_INDEX = 321 FONT_WEIGHT_INDEX + 1; 322 public final static int GLYPH_ORIENTATION_VERTICAL_INDEX = 323 GLYPH_ORIENTATION_HORIZONTAL_INDEX + 1; 324 325 326 public final static int IMAGE_RENDERING_INDEX = 327 GLYPH_ORIENTATION_VERTICAL_INDEX + 1; 328 public final static int KERNING_INDEX = IMAGE_RENDERING_INDEX + 1; 329 public final static int LETTER_SPACING_INDEX = KERNING_INDEX + 1; 330 public final static int LIGHTING_COLOR_INDEX = LETTER_SPACING_INDEX + 1; 331 public final static int MARKER_END_INDEX = LIGHTING_COLOR_INDEX + 1; 332 333 334 public final static int MARKER_MID_INDEX = MARKER_END_INDEX + 1; 335 public final static int MARKER_START_INDEX = MARKER_MID_INDEX + 1; 336 public final static int MASK_INDEX = MARKER_START_INDEX + 1; 337 public final static int OPACITY_INDEX = MASK_INDEX + 1; 338 public final static int OVERFLOW_INDEX = OPACITY_INDEX + 1; 339 340 341 public final static int POINTER_EVENTS_INDEX = OVERFLOW_INDEX + 1; 342 public final static int SRC_INDEX = POINTER_EVENTS_INDEX + 1; 343 public final static int SHAPE_RENDERING_INDEX = SRC_INDEX + 1; 344 public final static int STOP_COLOR_INDEX = SHAPE_RENDERING_INDEX + 1; 345 public final static int STOP_OPACITY_INDEX = STOP_COLOR_INDEX + 1; 346 public final static int STROKE_INDEX = STOP_OPACITY_INDEX + 1; 347 348 349 public final static int STROKE_DASHARRAY_INDEX = STROKE_INDEX + 1; 350 public final static int STROKE_DASHOFFSET_INDEX = 351 STROKE_DASHARRAY_INDEX + 1; 352 public final static int STROKE_LINECAP_INDEX = STROKE_DASHOFFSET_INDEX + 1; 353 public final static int STROKE_LINEJOIN_INDEX = STROKE_LINECAP_INDEX + 1; 354 public final static int STROKE_MITERLIMIT_INDEX = 355 STROKE_LINEJOIN_INDEX + 1; 356 357 358 public final static int STROKE_OPACITY_INDEX = STROKE_MITERLIMIT_INDEX + 1; 359 public final static int STROKE_WIDTH_INDEX = STROKE_OPACITY_INDEX + 1; 360 public final static int TEXT_ANCHOR_INDEX = STROKE_WIDTH_INDEX + 1; 361 public final static int TEXT_DECORATION_INDEX = TEXT_ANCHOR_INDEX + 1; 362 public final static int TEXT_RENDERING_INDEX = TEXT_DECORATION_INDEX + 1; 363 364 365 public final static int UNICODE_BIDI_INDEX = TEXT_RENDERING_INDEX + 1; 366 public final static int VISIBILITY_INDEX = UNICODE_BIDI_INDEX + 1; 367 public final static int WORD_SPACING_INDEX = VISIBILITY_INDEX + 1; 368 public final static int WRITING_MODE_INDEX = WORD_SPACING_INDEX + 1; 369 public final static int FINAL_INDEX = WRITING_MODE_INDEX; 370 371 } 372 | Popular Tags |