You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Cameron McCormack <cl...@csse.monash.edu.au> on 2003/04/24 07:00:06 UTC

Getting CSS values

Hi everyone.

I'm new to the list.

How do you manipulate the CSS of SVG Elements?  I have a reference to a
org.w3c.dom.Element in an document and I want to see if this element's
computed "display" CSS property is "none" or some other value.  I also
want to set this property.

I'm not very familiar with how CSS works with the DOM.  I tried

  elt.getDisplay()

to get the element's current "display" value, but it seems the Element
interface doesn't have these CSS methods.  Do I need to cast my Element
to something else?

Thanks,

Cameron

-- 
Cameron McCormack
  // clm@csse.monash.edu.au
  // http://www.csse.monash.edu.au/~clm/
  // icq 26955922

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


Re: Getting CSS values

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "CM" == Cameron McCormack <cl...@csse.monash.edu.au> writes:

CM> Cameron McCormack:
>> How do you manipulate the CSS of SVG Elements?

CM> OK, I have come to the conclusion that I use the getComputedStyle
CM> method of the ViewCSS interface to get the current style of an
CM> object.  I ran into the same problems, though, as described in
CM> this post from the archive:

CM>
CM> http://koala.ilog.fr/batik/mlists/batik-users/archives/msg02176.html

CM> This says that "You get a NullPointerException because you do not
CM> initialize the CSSEngine.  In Batik this is done in
CM> org.apache.batik.bridge.BridgeContext."

CM> So how do I initialise the CSSEngine for my SVGDocument?  Do I
CM> need to create a BridgeContext which will do this for me?  Can I
CM> initialise the CSSEngine myself?

    You should be able to initialize the CSSEngine yourself without
the bridge context (just follow the code in the bridge context as an
example - I think you need to provide some sort of UserAgent
interface), but depending on what you are planning on doing you may
still want to use the Bridge.  

    In particular by using the bridge to build the rendering tree you
can use all the nice SVG DOM methods to query geometry etc.  However,
if you have no need for the rendering tree just initializing the
CSSEngine should be faster and use less memory.


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


Re: Getting CSS values

Posted by Cameron McCormack <cl...@csse.monash.edu.au>.
Cameron McCormack:
> How do you manipulate the CSS of SVG Elements?

OK, I have come to the conclusion that I use the getComputedStyle method
of the ViewCSS interface to get the current style of an object.  I ran
into the same problems, though, as described in this post from the
archive:

  http://koala.ilog.fr/batik/mlists/batik-users/archives/msg02176.html

This says that "You get a NullPointerException because you do not
initialize the CSSEngine.  In Batik this is done in
org.apache.batik.bridge.BridgeContext."

So how do I initialise the CSSEngine for my SVGDocument?  Do I need to
create a BridgeContext which will do this for me?  Can I initialise the
CSSEngine myself?

Thanks,

Cameron

-- 
Cameron McCormack
  // clm@csse.monash.edu.au
  // http://www.csse.monash.edu.au/~clm/
  // icq 26955922

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