Steven Huey wrote:
I'm starting to dig into the source code to try and figure out a few things, but figured I ask here to try and save myself some time.

If I have a JSVGCanvas within a JSVGScroll pane does the document state have to be set to ALWAYS_STATIC? If I do the following:

No, not in my testing.

JPanel panel = new JPanel(new BorderLayout());
JSVGCanvas canvas = new JSVGCanvas();
JSVGScrollPane scrollPane = new JSVGScrollPane(canvas);
canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
canvas.setURI(someURI);
panel.add(scrollPane, BorderLayout.CENTER);

Nothing is drawn in the JFrame that the panel is added to, if I comment out the fourth line it is drawn and scrolls just fine. Is there a way to get ALWAYS_DYNAMIC documents to scroll within a JSVGScrollPane?

I suspect that the problem is that when you set the document the size of the JSVGCanvas is zero (it isn't parented). You should (must) have the Canvas connected (and packed?) before you set the URI. In your example I suspect that you just need to move all the swing building before the canvas manipulating.

   I'm a little surprised that it works for STATIC but the place
where the desired size of the canvas is set is a bit different
between the two.

Secondly, what is the relationship between the SVG viewport, SVG viewBox attribute, and the size of the JSVGCanvas?

Sure ask the simple questions ;)

   The requested size of the JSVGCanvas is controlled by the
width/height attributes on the outermost SVG element.

   The viewBox is used to map the actually available screen space
(the component size) to the provided userspace (or the other way around
if you prefer).  When either or both of these aren't specified there
are a bunch of "fallbacks".

How are things different (if at all) when the JSVGCanvas is placed inside a JSVGScrollPane?

Things are a little bit different in this case. I believe(?) that the canvas/scrollpane set the desired size to the width/height attributes. However when the scrollPane (and hence the canvas) is resized the userspace->devicespace is not recomputed (as it is by default when the canvas is not in a scrollpane). This is why your canvas stays 1 pixel large when it is finally reparented into the swing tree and get's a real size (I still don't know why it works for static).

   In the JSVGScrollPane the viewbox is also used to determine the
extent of scrolling allowed.

What I'd like to be able to do is load a SVG document into a JSVGCanvas within a JSVGScrollPane with the SVG document set to display at a
preset size, rather than automatically resizing to fit the size of the JSVGCanvas.

This should be easily accomplished by overriding the JSVGComponent method 'setMySize' to do nothing (it's a little unclear to me exactly how the ScrollPane get's it's size, I think it just goes with the flow with it's child/parent (i.e. default swing behaviour for a container).

I need to set the document state to ALWAYS_DYNAMIC so that I can dynamically modify the "display" attribute of several elements at runtime.

I've done a fair amount of testing of this so I'm fairly certain this works.

   Hope that makes things clearer.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to