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 Nikhil Dinesh <ni...@seas.upenn.edu> on 2004/06/22 17:58:29 UTC

JSVGScrollPane question

Hi,

I was trying to use the JSVGScrollPane and it kept throwing
NullPointerExceptions. After tracing the execution I found that it seems
to check the viewBox before setting it. I hacked around this doing the
following:

public class MySVGScrollPane extends JSVGScrollPane{

 public MySVGScrollPane(JSVGCanvas canvas){
     super(canvas);
     super.viewBox = new java.awt.geom.Rectangle2D.Float(0,0,10000,10000);
     super.ignoreScrollChange = false;
 }
}

This keeps the scrollbars constant which is again weird it be resizing
according to changes in the document, right?


The code which uses the scroll pane is something like:

JPanel panel = new JPanel(layout...)
JSVGCanvas myCanvas = new JSVGCanvas();
myCanvas.setDocumentState(JSVGCanvas.ALWAYS_STATIC) [other options produce
the same results]

panel.add(new JVGScrollPane(myCanvas));

.....(the document is set by some user initiated action)


Am I using this the wrong way?

Thanks,
-Nikhil


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


Re: JSVGScrollPane question

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Nikhil,

Nikhil Dinesh wrote:

> Ive managed to fix resizing on the scrollpane by setting the viewBox on
> a GVTTreeRenderingCompleted event notification. But I have to do it
> explicitly.

   To use the JSVGScrollPane your SVG document should have a viewBox
attribute on the outermost svg element.  This is how it determines
what the extents of the scroll bars should be.  If you want you
can load the SVG document yourself and add the viewBox attribute
before giving the document to the canvas.

   This should be documented and there should be better checking
along with a better error message when the check fails (or it could
default to the final 'computed' bounds of the SVG - although this
can often be 'wrong'.  Contributions are always welcome.

> 
> 
> On Tue, 22 Jun 2004, Nikhil Dinesh wrote:
> 
> 
>>Hi,
>>
>>I was trying to use the JSVGScrollPane and it kept throwing
>>NullPointerExceptions. After tracing the execution I found that it seems
>>to check the viewBox before setting it. I hacked around this doing the
>>following:
>>
>>public class MySVGScrollPane extends JSVGScrollPane{
>>
>> public MySVGScrollPane(JSVGCanvas canvas){
>>     super(canvas);
>>     super.viewBox = new java.awt.geom.Rectangle2D.Float(0,0,10000,10000);
>>     super.ignoreScrollChange = false;
>> }
>>}
>>
>>This keeps the scrollbars constant which is again weird it be resizing
>>according to changes in the document, right?
>>
>>
>>The code which uses the scroll pane is something like:
>>
>>JPanel panel = new JPanel(layout...)
>>JSVGCanvas myCanvas = new JSVGCanvas();
>>myCanvas.setDocumentState(JSVGCanvas.ALWAYS_STATIC) [other options produce
>>the same results]
>>
>>panel.add(new JVGScrollPane(myCanvas));
>>
>>.....(the document is set by some user initiated action)
>>
>>
>>Am I using this the wrong way?
>>
>>Thanks,
>>-Nikhil
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org


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


Re: JSVGScrollPane question

Posted by Nikhil Dinesh <ni...@seas.upenn.edu>.
<snip>

Ive managed to fix resizing on the scrollpane by setting the viewBox on
a GVTTreeRenderingCompleted event notification. But I have to do it
explicitly.


On Tue, 22 Jun 2004, Nikhil Dinesh wrote:

> Hi,
>
> I was trying to use the JSVGScrollPane and it kept throwing
> NullPointerExceptions. After tracing the execution I found that it seems
> to check the viewBox before setting it. I hacked around this doing the
> following:
>
> public class MySVGScrollPane extends JSVGScrollPane{
>
>  public MySVGScrollPane(JSVGCanvas canvas){
>      super(canvas);
>      super.viewBox = new java.awt.geom.Rectangle2D.Float(0,0,10000,10000);
>      super.ignoreScrollChange = false;
>  }
> }
>
> This keeps the scrollbars constant which is again weird it be resizing
> according to changes in the document, right?
>
>
> The code which uses the scroll pane is something like:
>
> JPanel panel = new JPanel(layout...)
> JSVGCanvas myCanvas = new JSVGCanvas();
> myCanvas.setDocumentState(JSVGCanvas.ALWAYS_STATIC) [other options produce
> the same results]
>
> panel.add(new JVGScrollPane(myCanvas));
>
> .....(the document is set by some user initiated action)
>
>
> Am I using this the wrong way?
>
> Thanks,
> -Nikhil
>
>

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


Re: JSVGScrollPane question

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,


> I was trying to use the JSVGScrollPane and it kept throwing
> NullPointerExceptions. After tracing the execution I found that it seems
> to check the viewBox before setting it. 

I am not sure where the problem is. However you could try to set the
JSVGCanvas with loaded SVG Document before put it into JSVGScrollPane.
I check the JSVGScrollPane code, it call checkAndSetViewBoxRect (as you
said), therefore I think the svgCanvas must already loaded with
SVGDocument. 

Best Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com



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