xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Kane <dk...@money.buser.net>
Subject Error in style handling
Date Thu, 23 Aug 2001 15:38:01 GMT
Folks,

I'm working on some code the change an SVG document programatically.  I
think I have encountered a pair of errors in how Batik handles style
attributes.  In my code, I'd like to add a fill color attribute.  I have
the following code:

    Element  theNodeIWantToAlter = theDoc.getElementById(id);
    SVGStylableSupport styles = new SVGStylableSupport();
    CSSStyleDeclaration svgStyle = styles.getStyle(theNodeIWantToAlter);
    svgStyle.setProperty("fill", "green", "");
    theNodeIWantToAlter.setAttribute("style",svgStyle.getCssText());

So, before this code is executed, the style attribute appears as:

fill-rule:evenodd;clip-rule:evenodd;stroke:none;
font-family:'Times-Italic';

After the code is executed, the style attribute appears (using
getCssText()) as:
    font-family: "Times-Italic";
    fill-rule: evenodd;
    clip-rule: evenodd;
    stroke: none;
    font-size: 24.0;
    fill: rgb(0.0, 128.0, 0.0);

The document won't display when these attributes are set.  If I edit
my SVG document to include these properties, the document will not
dislay.  If I edit these properties in the SVG document, to replace
the " with ', and delete the .0's, then it will dislay.  I have been
unable to change the style attribute within my program however, and
still get the new properties to display.  [I am aware of the
non-support for dynamic SVG behavior, but I'm redrawing the canvas,
and my code will correctly change the position attributes.] There appears
to be two problems with the resulting style attribute.

* The format of the color does not appear to comply with the spec.  The
CSS spec (http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-color)
which is referenced in the SVG spec
(http://www.w3.org/TR/2001/PR-SVG-20010719/painting.html#SpecifyingPaint)
offers several RGB color representations.:

EM { color: #f00 }              /* #rgb */
EM { color: #ff0000 }           /* #rrggbb */
EM { color: rgb(255,0,0) }      /* integer range 0 - 255 */
EM { color: rgb(100%, 0%, 0%) } /* float range 0.0% - 100.0% */

It looks like batik is trying a combination of the 3rd and 4th, using
values between 0 and 255, but doing do with a float, instead of an integer
format.

* The second problem is the quotaton marks around the font-family style
attribute.  Because the style attribute itself is written with quotes, the
attribute is no longer well formed.



I've been able to replicate this behavior with both Batik 1.0 and the 1.1
release candidate.

Is my interpretation incorrect, or are these bugs?

Sincerely,
David Kane

---------------------------------------------------------
 David Kane                     david_kane@houseofyin.com
"What's Life?"                  http://www.houseofyin.com
                                http://www.vraps.com



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message