I have one more minor issue that affects the size of the canvas. On my root SVGDocument, I have viewBox, height, and width attributes. If someone "resizes" a page; i.e. goes from 640x480 to 800x600 by changing the height/width attribute, things get screwed up. The canvas doesn't resize, but the document does. The document goes outside the viewable area. How can I handle the changes to width/height by scaling the document appropriates? If I receive any changes to the width/height attributes, I essentially want to tell the canvas to "Fit this in your viewable area." I want the same effect that I get when I resize the window and cause the component to resize.
Michael Bishop -----Original Message----- From: Bishop, Michael W. CONTR J9C880 [mailto:[EMAIL PROTECTED] Sent: Monday, January 08, 2007 10:40 AM To: batik-users@xmlgraphics.apache.org Subject: RE: Resizing a JSVGCanvas... OK, I ran through the debugger and figured it out. Even though I wasn't using a JSVGScrollPane, I still initialized one: JSVGScrollPane scrollPane = new JSVGScrollPane(jsvgCanvas); Then later (commenting out the use of the JSVGScrollPane and adding the JSVGCanvas directly): // this.getContentPane().add(scrollPane); this.getContentPane().add(jsvgCanvas); The updateRenderingTransform() method was returning true: ... if (!recenterOnResize) return true; ... I fixed it by not even initializing the JSVGScrollPane with the JSVGCanvas and resize happens as you describe now. Michael Bishop -----Original Message----- From: Bishop, Michael W. CONTR J9C880 [mailto:[EMAIL PROTECTED] Sent: Thursday, January 04, 2007 4:31 PM To: batik-users@xmlgraphics.apache.org Subject: RE: Resizing a JSVGCanvas... > I think the only way to figure out why you aren't getting > your content resized would be to debug what is happening > in the updateRenderingTransform function. Do your > documents have a viewBox attribute on the root SVG element? Yes, I always set a viewBox in my documents. I'll have to attach the Batik source and a debugger. I don't do this often, so it'll take me a bit to figure it out. A quick test (System.out.println and super.updateRenderingTransform()) confirms that it's being called at all. The other components I have in the main frame are (floatable) toolbars and none of them seem to change size when I resize the window either. I wouldn't expect them to change size anyway; never seen a toolbar resize. Michael Bishop -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, January 04, 2007 5:51 AM To: batik-users@xmlgraphics.apache.org Cc: batik-users@xmlgraphics.apache.org Subject: RE: Resizing a JSVGCanvas... Hi Michael, "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote on 01/03/2007 10:32:23 PM: > > I wonder if your JSVGCanvas is not setup to resize with it's parent? > > The resize listener is directly on the JSVGCanvas as a > ComponentListener. Ok, then the AbstractJGVTComponents componentResized event handler should be called, which should call updateRenderingTransform. I think the only way to figure out why you aren't getting your content resized would be to debug what is happening in the updateRenderingTransform function. Do your documents have a viewBox attribute on the root SVG element? > I don't explicitly stop anything from resizing > when I resize the parent window. The layout is a little funky. > It's a BorderLayout, but each of the five components are added to > each other; the idea was that the top, right, bottom, and left > panels all have toolbars and I wanted each toolbar to dock on each > side. The center panel that contains the JSVGCanvas adds a > JRootPane that contains the JSVGCanvas. I use the JRootPane so the > mouse cursor will stay consistent. I don't have any other influence > on resizing; no other listeners or code to manually size components. > > Michael Bishop > > > ________________________________ > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Wed 1/3/2007 9:46 PM > To: batik-users@xmlgraphics.apache.org > Subject: RE: Resizing a JSVGCanvas... > > > > Hi Michael, > > "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> > wrote on 01/03/2007 04:03:10 PM: > > > > In the AbstractJSVGComponent it overrides updateRenderingTransform > > > to implement what you are talking about. > > > > Yes, this is what happens. In order to "see" the changes, I have to > > call setDocument on the JSVGCanvas class though. Is this correct? > > No. > > > Otherwise the parent frame/window just resizes without any changes to > > the JSVGCanvas. I attached a ComponentListener to my JSVGCanvas: > > I wonder if your JSVGCanvas is not setup to resize with it's parent? > I think the Canvas does a some stuff like setting it's preferred size > and invalidating it's layout that might trigger a relayout. > > > public void componentResized(ComponentEvent componentEvent) { > > jsvgCanvas.setDocument(currentDocument); > > } > > This should definitely _NOT_ be needed. Is this listener on the > canvas or on one of it's parents? > > > > I suspect that you probably want the default behavior of the > > > canvas when recenterOnResize is set to true (it's just that > > > the scrollPane turns this off). > > > > Yes. If the scrollbars are NOT visible, I want the default behavior of > > the canvas. If the scrollbars ARE visible, I want the default behavior > > of the JSVGScrollPane. I think I need extend the JSVGScrollPane class > > to accommodate this as you said. I only want the scrollbars to appear > > when I apply a zoom to the canvas. > > > > Michael Bishop > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Sent: Sunday, December 31, 2006 8:15 PM > > To: batik-users@xmlgraphics.apache.org > > Cc: batik-users@xmlgraphics.apache.org > > Subject: RE: Resizing a JSVGCanvas... > > > > > > Hi Michael, > > > > "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote on > > 12/22/2006 11:10:43 AM: > > > > > > If you want the canvas to change scale or pan position then > > > > the rendering transform needs to change. The built in > > > > updateRenderingTransform function does this in some cases but I > > > > don't think you can all of what you want by adjusting component > > sizes. > > > > > > OK, can we talk through the simplest case? Assume I have a JSVGCanvas > > > WITHOUT a JSVGScrollPane. I'm going to eliminate the scroll bars so I > > > can tackle one problem at a time. > > > > > > My JSVGCanvas is viewing an entire document and is sized at 400x400. > > > > > > I reduce the size of my window so it's now 75% of its original size. > > > > > > At this point, the JSVGCanvas should be 300x300, but should also be > > > displaying the entire document. > > > > > > To me, that sounds like I need to: > > > > > > - Change the size of the component to 300x300. > > > - Apply something like a JSVGCanvas.ZoomAction to make the document > > fit > > > inside the JSVGCanvas. > > > > What happens in this case is that when the window is resized > > a Swing 'componentResized' event is generated which is trapped > > by the AbstractJGVTComponent. This looks like: > > > > public void componentResized(ComponentEvent e) { > > if (updateRenderingTransform()) > > scheduleGVTRendering(); > > } > > > > In the AbstractJSVGComponent it overrides updateRenderingTransform > > to implement what you are talking about. The first thing it does > > is recalculate the viewing transform (which is what fits the SVG > > viewBox to the components width/height). This takes care of fitting > > the image to the new component size. The second part of the > > function (after 'if (!recenterOnResize)') is trying to keep > > what was the center of the view as the center of the view (this > > is tricky in the presence of rotation etc...). > > > > > (This is how I would want it to work with a JSVGScrollPane if the > > > scrollbars are NOT visible. > > > > I suspect that you probably want the default behavior of the > > canvas when recenterOnResize is set to true (it's just that > > the scrollPane turns this off). > > > > > I think when I reintroduce the JSVGScrollPane, I have to > > > extend the class as you've said.) > > > > > I'm going to do some experimenting, but I wanted to share my thoughts > > > and get feedback from the list in case I get stuck. > > > > > > Michael Bishop > > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, December 21, 2006 7:48 PM > > > To: batik-users@xmlgraphics.apache.org > > > Cc: batik-users@xmlgraphics.apache.org > > > Subject: RE: Resizing a JSVGCanvas... > > > > > > > > > Hi Michael, > > > > > > "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote > > on > > > 12/19/2006 10:24:32 AM: > > > > > > > Yeah, that's what I was afraid of. I was hoping for some > > > guidance > > > > on doing it fairly simply, if there is such a way: > > > > > > > > - If the scroll bars of the JSVGScrollPane aren't visible, then just > > > > size the JSVGCanvas according to the resize. Is this the default > > > > behavior of the JSVGCanvas? Even inside a JSVGScrollPane? > > > > > > Hmm, actually when it's inside a scrollPane the scroll pane > > > sets 'recenterOnResize' to false. Which means that the canvas > > > keeps the upper left the upper left and just changes size ( > > > showing more content on the right/bottom for example). > > > > > > > - If the scroll bars of the JSVGScrollPane are visible, then just > > size > > > > the JSVGScrollPane's viewable area. > > > > > > > > Any hints on where to start? > > > > > > You might consider subclassing/replacing/modifying the > > JSVGScrollPane > > > > > > so it only sets recenterOnResize to false when the scrollbars are > > > showing... > > > > > > > Would I even need to touch rendering transforms or would setting > > > > the size on these components be sufficient? > > > > > > If you want the canvas to change scale or pan position then > > > the rendering transform needs to change. The built in > > > updateRenderingTransform function does this in some cases but I > > > don't think you can all of what you want by adjusting component sizes. > > > > > > > > > I know it needs experimentation; I'm just trying to narrow down the > > > > variables I need to play with. > > > > > > > > Michael Bishop > > > > > > > > -----Original Message----- > > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > > > Sent: Friday, December 15, 2006 6:53 AM > > > > To: batik-users@xmlgraphics.apache.org > > > > Cc: batik-users@xmlgraphics.apache.org > > > > Subject: Re: Resizing a JSVGCanvas... > > > > > > > > > > > > Hi Michael, > > > > > > > > "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> > > wrote > > > on > > > > 12/14/2006 09:12:44 AM: > > > > > > > > > so there are a bunch of transforms associated with the > > > > > JSVGCanvas. Plus you define a viewBox attribute in your SVG > > > > > document. What I'd like to do is have the JSVGCanvas resize when > > I > > > > > resize my main Window/Frame. If the user has zoomed in or out, I > > > > > want to preserve that. Basically I want to take what the user > > > > > currently sees and resize it accordingly. > > > > > > > > I was under the impression that this was more or less the > > > > default behavior of the Canvas. Anyway the code that handles > > > > this is the 'updateRenderingTransform' method on the JSVGCanvas > > > > (the default implementation is in AbstractJSVGComponent). > > > > > > > > > If the user's looking at an entire document and they resize the > > > window > > > > > > > > > smaller, I want the entire document shown (smaller) in the smaller > > > > > > > JSVGCanvas. If the user is zoomed in and has scrolled to an area > > of > > > > > > > > the document (I have a JSVGScrollPane), I want that viewing area > > to > > > > > be the same when they resize. In short, I want to preserve what > > the > > > > > > > > user sees, just size it according to the window size. Can I get > > > some > > > > > pointers on how to achieve this? > > > > > > > > You can override the default implementation and do what ever you > > > > want, however I warn you it's tricker than it seems... ;) > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > > > For additional commands, e-mail: > > > [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > [attachment "winmail.dat" deleted by Thomas E. DeWeese/449433/EKC] > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]