Hi Micahel, "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote on 10/29/2008 03:12:17 PM:
> In short, my event comes before that happens and I don't know why. > Of course, eliminating calls to setDocument and replacing them to > setRenderingTransform(identity) might fix the problem entirely. BTW this is effectively what resetRenderingTransform does. It sets the renderingTransform to 'initalTransform' which is currently always the identity transform. > Long shot, but do you (or anyone) have resources or links for > correcting aspect ratios? I've got a miscalculation somewhere. I > want to take the parallelogram in document/user space (represented > by three points; upper-left, upper-right, and lower-left) and > calculate how to properly fit them into the target window, To do this properly you need to know what aspect ratio in the source canvas the three points represent. This can be a single float or two 'rational' integers (width and height). float srcAR = srcWidth/srcHeight; float dstAR = dstWidth/dstHeight; int hInset = 0, vInset = 0; if (dstAR > srcAR) // new window is 'wider' than old { // so calculate how big the bars on either side should be. int scaledSrcW = srcAR*dstHeight. hInset = (dstWidth-scaledSrcW)/2 } else // new window is taller than old so calculate { // the size of the bars on top and bottom. int scaleSrcH = dstWidth/srcAR; vInset = (dstHeight-scaledSrcH); } Point2D p00 = new Point(hInset, vInset); Point2D p10 = new Point(dstWidth-hInset, vInset); Point2D P01 = new Point(hInset, dstHeight-vInset); > regardless of size and aspect-ratio. This is kind of outside the > realm of Batik, but I can't even find any resources that remotely > cover this topic. Once I fix the bug with "refresh" (more like > reset as you've pointed out), I'm going to be tackling fixing that. > > Michael > > ________________________________ > > From: Dan Slater [mailto:[EMAIL PROTECTED] > Sent: Wed 10/29/2008 11:24 AM > To: batik-users@xmlgraphics.apache.org > Subject: RE: Rendering transform on refresh? > > > Hi, Michael, > > I don't think setting the rendering transform refreshes the > document, it only changes the screen position. > > Assuming you knew your points in screen space, couldn't you use > getScreenCTM() to translate to common 'document' coords? (I think > your document coords are what I call user coords, after all SVG > attribute transforms leading to the root are applied to the local > element's x,y)? You and Thomas might have covered this in your > recent exchanges, I didn't completely follow it. > > If I understand you correcly, I would register GVT event listeners > and check for transforms at various steps (maybe you've done this). > It sounds like you need to communicate a transform after some > rendering step is completed. You can use the method I mentioned to > set/get transforms after any point. > > For example, I use a GVT listener to set the viewbox to always be > 10% larger in each dimension than the doc's bounding box, available > via a GVTTreeBuilderListener, GVTBuildStarted. > > Hopefully I'm not leading you astray... > > Dan > > PS On my next refactor I'm probably going to overload setDocument to > include a transform parameter, eliminating the need for a separate > call to setLastRender. > > Also, more errata below: I don't override the listener, I register it. > > > > -------- Original Message -------- > Subject: RE: Rendering transform on refresh? > From: "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> > Date: Wed, October 29, 2008 8:21 am > To: <batik-users@xmlgraphics.apache.org> > > Hi Dan, > > I think you indirectly answered my question and also gave me an > idea to keep in mind. I never thought about preserving the "last" > render/transform. What I want to do with setDocument() is have it > communicate the "default" transform. > > For some reason, if I call setDocument(), then fire my event, I'm > still getting the "old" transform. I want what I think you described > as the identity transform. > > I need to communicate three points in my event; the upper-left, > upper-right, and lower-left of the JSVGCanvas window *in document > coordinates* after the "refresh" has occurred. > > You're describing preserving changes BEFORE setDocument(), I'm > trying to capture the state AFTER setDocument() and can't figure out > what I need to wait for to get points after the document has refreshed. > > It sounds like I *could* eliminate the call to setDocument() > entirely and simply set the rendering transform to the identity > transform (thus refreshing the document), then fire my event? > > Michael > > ________________________________ > > From: Dan Slater [mailto:[EMAIL PROTECTED] <http://email. > secureserver.net/pcompose.php#Compose> ] > Sent: Tue 10/28/2008 6:32 PM > To: batik-users@xmlgraphics.apache.org > Subject: RE: Rendering transform on refresh? > > > > Please forgive the multiple posts...for some reason a follow-up posted > before this original (now w/minor edit), and I haven't yet received the > original :( . I think with plain text I'll have better success... > > Hi, Michael, > > I think I might have the answer. I use a crude undo function to reset > the document, but found the render to reset each time. Here's what > worked for me: > > In your extended JSVGCanvas, place an instance field to store the last > render transform, and create getter/setter. In the constructor, set the > identity transform since this is the default when the canvas is first > booted. Then override svgLoadEventDispatchCompleted with a call to > setRenderingTransform, which in turn you've already overridden per > recent threads. > > When this is all prepared, call > svgCanvas.setLastRender(svgcanvas.getrenderingtransform) (or use > whatever transform you wish) and the canvas render should automatically > reset after you call setSVGDocument. > > I can't tell you how much time it took to test the rendering transform > in all the event listeners...it's instructive but it would have been > extremely helpful to have a concise reference for the complete > JSVGCanvas event sequence. Hope this helps some others out there...if > anybody knows how to set a listener on the canvas for when the rendering > transform changes (I tried and gave up), or has a better way, I'd love > to hear about it. > > public class JSVGCanvasX extends JSVGCanvas { > private AffineTransform lastRender = new AffineTransform(); > public JSVGCanvasX() { > lastRender.setToIdentity(); > this.addSVGLoadEventDispatcherListener(new > SVGLoadEventDispatcherAdapter() { > > public void > svgLoadEventDispatchCompleted(SVGLoadEventDispatcherEvent e){ > //set the rendering transform here, after > SVGDocument is loaded but before rendering occurs > //canvas transform resets to identity before this > event is fired > setRenderingTransform(getLastRender()); > } > } > ...etc. > } > > Dan Slater > > -------- Original Message -------- > Subject: Rendering transform on refresh? > From: "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> > Date: Tue, October 28, 2008 3:41 pm > To: <batik-users@xmlgraphics.apache.org> > > I have a refresh function in my application that simply calls > setDocument() on the JSVGCanvas with the document already there, > basically causing it to reset to its default state without > zoom/pan/rotate. > > I'm also tracking changes to my rendering transform, but keying off > setRenderingTransform() doesn't seem to work; it seems to be called > before the "final" transform is achieved. > > What can I wait for to determine when the rendering transform is "done" > and ready to be communicated? Maybe computeRenderingTransform? I've > tried waiting for the GVT tree to render and for the SVG "onLoad" event, > but both seem to be too early and not communicating any change. > > Michael > > --------------------------------------------------------------------- > 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] > org 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]