I am evaluating batik css parser to integrate it with our product. To use it best I want to understand what all it's classes represent. I can not understand the purpose of the org.apache.batik.css.engine.CSSEngine
class. What is this class used for?
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)