batik
What is the purpose of CSSEngine class in batik css parser
I am evaluating batik css parser to integrate it with our product. TO use it best i want to understand what all its class represent. I can not understand the purpose org.apache.batik.css.engine.CSSEngine class. For what is this class used.
CSSEngine class has a function parseStyleSheet which returns a StyleSheet object. This StyleSheet object is actually a dom representation of the css. StyleSheet ss = cssEngine.parseStyleSheet(new ParsedURL("file:///"+filename),"max-width: 800px"); You can create your own cssengine by extending CSSEngine class. public class MyCSSEngine extends CSSEngine{ public MyCSSEngine (ExtendedParser parser) { super(null, null, parser, MY_VALUE_MANAGERS, SVGCSSEngine.SVG_SHORTHAND_MANAGERS, null, null, "style", null, "class", true, null, new MyCSSContext()); // TODO Auto-generated constructor stub } } create MyCSSContext by extending org.apache.batik.css.engine.CSSContext. Coming to MY_VALUE_MANAGERS which is important. Value manger can be like public static final ValueManager[] MY_VALUE_MANAGERS = { new AlignmentBaselineManager(), new BaselineShiftManager(), new ClipManager(), new ClipPathManager(), new ClipRuleManager(), new ColorManager(), new ColorInterpolationManager(), new ColorInterpolationFiltersManager(), new ColorProfileManager(), new ColorRenderingManager() } It basically register the property you are interested in while parsing.(Its much more than that). You can also use org.apache.batik.css.engine.SVGCSSEngine.SVG_VALUE_MANAGERS but implementing own value manager gives you power to handle your own custom css property like -my-own-color:mufunc(10,23,45)
Related Links
Is it possible to set the id for SVG elements drawn with SVGGraphics2D
What is the purpose of CSSEngine class in batik css parser
how to find package org.w3c.dom.svg?
Javascript will not execute with PNGEncoder