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 zhan hai <ha...@gmail.com> on 2010/05/23 08:03:57 UTC

Show newly added elements beyonds initial bbox

Hi,
  I use JSVGScrollPane to show svg. When  document is loaded, i changed
the viewbox to root node's bbox value. It works fine and i can view the
whole svg content by scrolling.
  If new elements are added to position out of the initial bbox, the canvas
won't show these elements. So I want to change viewbox again to make viewbox
contains the newly added element and i expect scroll pane can resize it's
scroll bar to map the extended viewbox. But after calling
'setAttributeNS(null,SVGConstants.SVG_VIEW_BOX_ATTRIBUTE,'xxxx'), all things
in canvas disappeard .
Any suggestions?

thx
colin

Re: Show newly added elements beyonds initial bbox

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

zhan hai <ha...@gmail.com> wrote on 05/26/2010 05:40:40 AM:

>   I debugged batik's source code and found there existed a  'render 
> rect' used to clip . Initially the 'render rect' will be set the 
> same as viewport if no 'viewbox' attribute were set.

        Right, unless you set overflow="visible" all SVG elements
establish a clipping rectangle that corresponds to the view port.
The fact that you didn't include a viewBox simply means that there is
no transform created to fit your viewBox to the available view port.

> When scroll bar is moved/dragged, the scroll pane will call 
> 'setRenderingTransform' to show other parts of svg image, but since 
> the 'render rect' is not changed and remained as the original viewport 
> position(0,0) , so new content won't be showed since it will be 
> clipped by the 'rendering rect'.

        Right, that is the purpose of a clip rect.  To keep you from
seeing things that are outside of the clipping rectangle.


> Then I adjusted 'render rect' each time scroll bar is moved, it works.
>   'Render rect' including 'bounds' of document's root node, 'bounds'
> and 'clip' of canvas node.
>   This way maybe somewhat of 'hacker' since people have to fall into
> batik implementation deeply. Any other normal solutions?

        The normal solution would be to disable the clipping if you don't
want it, by adding 'overflow="visible"' to the SVG element...

> 2010/5/25 <th...@kodak.com>
> Hi Colin, 
> 
> zhan hai <ha...@gmail.com> wrote on 05/23/2010 02:03:57 AM: 
> 
> 
> >   If new elements are added to position out of the initial bbox, the
> > canvas won't show these elements. So I want to change viewbox again 
> > to make viewbox contains the newly added element and i expect scroll
> > pane can resize it's scroll bar to map the extended viewbox. 
> 
> 
>         Well the simplest thing is to set 'overflow="visible"' on 
> the root SVG element. 
> 
> > But after calling 'setAttributeNS
> > (null,SVGConstants.SVG_VIEW_BOX_ATTRIBUTE,'xxxx'), all things in 
> > canvas disappeard . 
> > Any suggestions? 

>         I've tested this before and it has worked.  Are you sure your 
> 'xxxx' is a valid viewBox specification?  I should also say that 
> setting the viewBox is a very expensive operation as we have to 
> rebuild the entire graphics tree because any attributes that use 
> percentages are likely to have changed.  

Re: Show newly added elements beyonds initial bbox

Posted by zhan hai <ha...@gmail.com>.
Hi thomas,
  Thanks for ur opinion about 'viewbox'.  I decided to solve the problem in
another way and it seems I succeeded.
  I debugged batik's source code and found there existed a  'render rect'
used to clip . Initially the 'render rect' will be set the same as viewport
if no 'viewbox' attribute were set. When scroll bar is moved/dragged, the
scroll pane will call 'setRenderingTransform' to show other parts of svg
image, but since the 'render rect' is not changed and remained as the
original viewport position(0,0) , so new content won't be showed since it
will be clipped by the 'rendering rect'.  Then I adjusted 'render rect' each
time scroll bar is moved , it works .
  'Render rect' including 'bounds' of document's root node, 'bounds' and
'clip' of canvas node.
  This way maybe somewhat of 'hacker' since people have to fall into batik
implementation deeply. Any other normal solutions?




2010/5/25 <th...@kodak.com>

> Hi Colin,
>
> zhan hai <ha...@gmail.com> wrote on 05/23/2010 02:03:57 AM:
>
>
> >   If new elements are added to position out of the initial bbox, the
> > canvas won't show these elements. So I want to change viewbox again
> > to make viewbox contains the newly added element and i expect scroll
> > pane can resize it's scroll bar to map the extended viewbox.
>
>
>         Well the simplest thing is to set 'overflow="visible"' on
> the root SVG element.
>
> > But after calling 'setAttributeNS
> > (null,SVGConstants.SVG_VIEW_BOX_ATTRIBUTE,'xxxx'), all things in
> > canvas disappeard .
> > Any suggestions?
>
>         I've tested this before and it has worked.  Are you sure your
> 'xxxx' is a valid viewBox specification?  I should also say that
> setting the viewBox is a very expensive operation as we have to
> rebuild the entire graphics tree because any attributes that use
> percentages are likely to have changed.
>

Re: Show newly added elements beyonds initial bbox

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

zhan hai <ha...@gmail.com> wrote on 05/23/2010 02:03:57 AM:

>   If new elements are added to position out of the initial bbox, the
> canvas won't show these elements. So I want to change viewbox again 
> to make viewbox contains the newly added element and i expect scroll
> pane can resize it's scroll bar to map the extended viewbox. 

        Well the simplest thing is to set 'overflow="visible"' on
the root SVG element.

> But after calling 'setAttributeNS
> (null,SVGConstants.SVG_VIEW_BOX_ATTRIBUTE,'xxxx'), all things in 
> canvas disappeard .
> Any suggestions?

        I've tested this before and it has worked.  Are you sure your
'xxxx' is a valid viewBox specification?  I should also say that
setting the viewBox is a very expensive operation as we have to 
rebuild the entire graphics tree because any attributes that use
percentages are likely to have changed.