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 "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> on 2005/12/22 19:51:14 UTC

Seemingly simple question...

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.

 

Michael Bishop


Re: Seemingly simple question...

Posted by Andrew Plotkin <er...@eblong.com>.
On Thu, 22 Dec 2005, Bishop, Michael W. CONTR J9C880 wrote:

> Is there any way to turn "off" an element?  Like show/hide?

Give it visibility="visible" or "hidden"?

--Z

"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*
I'm still thinking about what to put in this space.

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


Re: Seemingly simple question...

Posted by th...@kodak.com.
Hi Michael,

"Bishop, Michael W. CONTR J9C880" <Mi...@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.