xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Seemingly simple question...
Date Thu, 22 Dec 2005 21:08:18 GMT
Hi Michael,

"Bishop, Michael W. CONTR J9C880" <Michael.Bishop@je.jfcom.mil> wrote on 
12/22/2005 01:51:14 PM:

> Is there any way to turn “off” an element?  Like show/hide?  I want to 
apply a
> show/hide functionality to a g tag.  I don’t see anything in my book or 
the 
> spec on it, save the CSS property.  I don’t want to hassle with CSS; in 
order 
> to use it, I’d have to check for the style tag, see if there’s a display 
tag, 
> add one if it’s not there, and preserve the other attributes.

   There are two CSS properties which provide slightly different versions
of this functionality: 'display', and 'visibility'.  There are a number
of ways to control them, the simplest is to use the 'presentation 
attributes'
these are normal xml attributes that are "reflected" in the CSS cascade.

   So assuming nothing else in CSS land is modifying the property on the
element you can just do:

        e.setAttributeNS(null, "display", "none");

   This will not win however if there is 'style="display: inline"' for 
example.
So the 'correct' way to do this is with the SAC (Simple API for CSS). This
introduces a 'style' member to the element which you can use to get and 
set
properties on the element:

        e.getStyle().setProperty("display", "none", "");

   The third argument can be "!important" which boosts it's priority.

   Of the two if the element is likely to become visible again later it
is best to use 'visibility', there are some issues since visibility can
be 'overridden' further down in the tree.  Also when visibility is hidden
it still takes up memory in the rendering tree.

Mime
View raw message