Hi all,
I have a question. I am using the CSSEngine, loaded with the stylesheet from my document (if any) to determine the property values that need to be set on each element in my model. My code goes something like this:
public void setElementStyles (final StylableShape shape, final SVGStylableElement se)
{
StyleMap styles = this.cssEngine.getCascadedStyleMap( se, null );
final int nProps = this.cssEngine.getNumberOfProperties(); for (int i = 0; i < nProps; i++) { final String pName = this.cssEngine.getPropertyName( i ); final Value value = styles.getValue( i ); if (value != null) { short flags = styles.getMask( i ); Value cv = this.cssEngine.getComputedStyle( se, null, i ); if (cv instanceof ComputedValue) { // if the value is a computed value, get the computed // part and ignore the cascaded part (which gives // the value as supplied by the user) cv = ((ComputedValue) cv).getComputedValue(); }
shape.applyCssProperty( pName, cv ); } } }
This seems to work OK, except that I can't determine the origin of each style. The 'flags' variable should (it appears) contain StyleMap.AUTHOR_ORIGIN only if the styles don't come from the user agent stylesheet or user stylesheet. I set both these stylesheets null in my CSSEngine, expecting there to be no default styles therefore. But it seems I still get some default styles. I don't understand where these come from.
For example, with this SVG...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="tiny" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360">
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="red" stroke="#000000"/>
</svg>
...I expect to see no CSS styles on the rect. The rectangle should be filled red and with black stroke, based only on the presentation attributes. But in fact I get
fill: rgb(85, 85, 85)
fill-rule: evenodd
stroke: #000
stroke-opacity: 0.5
stroke-width: 10pt (computed value 3.5277777)
I've probably done something daft. Can you help me by pointing out what I might have done wrong?
TIA, Rick
--
Visit our website at www.roke.co.uk
Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.
The information contained in this e-mail and any attachments is confidential to Roke Manor Research Ltd and must not be passed to any third party without permission. This communication is for information only and shall not create or change any contractual relationship.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]