xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Slater" <dsla...@simulsoft.com>
Subject RE: Rendering transform on refresh?
Date Wed, 29 Oct 2008 20:11:26 GMT
<html><body><span style="font-family:Verdana; color:#000000; font-size:10pt;">Hi,
Michael,<br><br>I would imagine the "old" coordinates come from the previous screenCTM,
"new" coords from the updated screenCTM.&nbsp; According to my own tests, upon rerendering
the GVTTree (), the old and new screenCTMs can be accessed between the following events:<br><br>[same
screenCTM as previous rendering finished with] <br>GVTTreeBuild Started... 0.24855052
0.0 0.0 0.24855052 393.99997 261.5<br><br>[new screenCTM]<br>GVTTreeBuild
Completed... 0.08296057 0.0 0.0 0.08296057 394.0 261.50003<br><br>This from a
GVTTreeBuildListener.<br><br>I'm afraid I don't have any info on your aspect ratio
calcs.<br><br>Dan <br><br>
<blockquote webmail="1" style="border-left: 2px solid blue; margin-left: 8px; padding-left:
8px; font-size: 10pt; color: black; font-family: verdana;">
<div   >
-------- Original Message --------<br>
Subject: RE: Rendering transform on refresh?<br>
From: "Bishop, Michael W. CONTR J9C880" &lt;michael.bishop.ctr@jfcom.mil&gt;<br>
Date: Wed, October 29, 2008 2:12 pm<br>
To: &lt;batik-users@xmlgraphics.apache.org&gt;<br>
<br>
Hi Dan,<br>
 <br>
I'm using poor terminology.  I do want to essentially reset the screen position.  I have no
(current) need to physically reload/refresh the document from disk, memory, etc.  I want a
"reset" button to bring the document back to the "default" view after zooming, panning, rotating,
etc.<br>
 <br>
And yes, I do use the screenCTM to go from window/ui coordinates to document/user coordinates.
 For some reason, on setDocument(), I get the "old" coordinates before setDocument, not the
ones after.  I've used a GVTTreeListener and an SVGOnLoad listener without success.  I'm looking
for the event where window position 0,0 can be pushed through the screenCTM to get the document/user
point visible there.<br>
 <br>
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.<br>
 <br>
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, 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.<br>
 <br>
Michael<br>
<br>
________________________________<br>
<br>
From: Dan Slater [<a onclick="return true;Popup.composeWindow('pcompose.php?sendto=dslater%40simulsoft.com');
return false;" href="http://email.secureserver.net/pcompose.php#Compose" mce_href="http://email.secureserver.net/pcompose.php#Compose">mailto:dslater<b></b>@simulsoft.com</a>]<br>
Sent: Wed 10/29/2008 11:24 AM<br>
To: batik-users@xmlgraphics.apache.org<br>
Subject: RE: Rendering transform on refresh?<br>
<br>
<br>
Hi, Michael,<br>
<br>
I don't think setting the rendering transform refreshes the document, it only changes the
screen position.<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
Hopefully I'm not leading you astray...<br>
<br>
Dan<br>
<br>
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.<br>
<br>
Also, more errata below: I don't override the listener, I register it. <br>
<br>
<br>
<br>
	-------- Original Message --------<br>
	Subject: RE: Rendering transform on refresh?<br>
	From: "Bishop, Michael W. CONTR J9C880" &lt;michael.bishop.ctr@jfcom.mil&gt;<br>
	Date: Wed, October 29, 2008 8:21 am<br>
	To: &lt;batik-users@xmlgraphics.apache.org&gt;<br>
	<br>
	Hi Dan,<br>
	<br>
	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.<br>
	<br>
	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.<br>
	<br>
	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.<br>
	<br>
	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.<br>
	<br>
	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?<br>
	<br>
	Michael<br>
	<br>
	________________________________<br>
	<br>
	From: Dan Slater [<a onclick="return true;Popup.composeWindow('pcompose.php?sendto=dslater%40simulsoft.com');
return false;" href="http://email.secureserver.net/pcompose.php#Compose" mce_href="http://email.secureserver.net/pcompose.php#Compose">mailto:dslater<b></b>@simulsoft.com</a>
&lt;<a href="http://email.secureserver.net/pcompose.php#Compose" target="_blank" mce_href="http://email.secureserver.net/pcompose.php#Compose">http://email.secureserver.net/pcompose.php#Compose</a>&gt;
]<br>
	Sent: Tue 10/28/2008 6:32 PM<br>
	To: batik-users@xmlgraphics.apache.org<br>
	Subject: RE: Rendering transform on refresh?<br>
	<br>
	<br>
	<br>
	Please forgive the multiple posts...for some reason a follow-up posted<br>
	before this original (now w/minor edit), and I haven't yet received the<br>
	original :( . I think with plain text I'll have better success...<br>
	<br>
	Hi, Michael,<br>
	<br>
	I think I might have the answer. I use a crude undo function to reset<br>
	the document, but found the render to reset each time. Here's what<br>
	worked for me:<br>
	<br>
	In your extended JSVGCanvas, place an instance field to store the last<br>
	render transform, and create getter/setter. In the constructor, set the<br>
	identity transform since this is the default when the canvas is first<br>
	booted. Then override svgLoadEventDispatchCompleted with a call to<br>
	setRenderingTransform, which in turn you've already overridden per<br>
	recent threads.<br>
	<br>
	When this is all prepared, call<br>
	svgCanvas.setLastRender(svgcanvas.getrenderingtransform) (or use<br>
	whatever transform you wish) and the canvas render should automatically<br>
	reset after you call setSVGDocument.<br>
	<br>
	I can't tell you how much time it took to test the rendering transform<br>
	in all the event listeners...it's instructive but it would have been<br>
	extremely helpful to have a concise reference for the complete<br>
	JSVGCanvas event sequence. Hope this helps some others out there...if<br>
	anybody knows how to set a listener on the canvas for when the rendering<br>
	transform changes (I tried and gave up), or has a better way, I'd love<br>
	to hear about it.<br>
	<br>
	public class JSVGCanvasX extends JSVGCanvas {<br>
	private AffineTransform lastRender = new AffineTransform();<br>
	public JSVGCanvasX() {<br>
	lastRender.setToIdentity();<br>
	this.addSVGLoadEventDispatcherListener(new<br>
	SVGLoadEventDispatcherAdapter() {<br>
	<br>
	public void<br>
	svgLoadEventDispatchCompleted(SVGLoadEventDispatcherEvent e){<br>
	//set the rendering transform here, after<br>
	SVGDocument is loaded but before rendering occurs<br>
	//canvas transform resets to identity before this<br>
	event is fired<br>
	setRenderingTransform(getLastRender());<br>
	}<br>
	}<br>
	...etc.<br>
	}<br>
	<br>
	Dan Slater<br>
	<br>
	-------- Original Message --------<br>
	Subject: Rendering transform on refresh?<br>
	From: "Bishop, Michael W. CONTR J9C880" &lt;michael.bishop.ctr@jfcom.mil&gt;<br>
	Date: Tue, October 28, 2008 3:41 pm<br>
	To: &lt;batik-users@xmlgraphics.apache.org&gt;<br>
	<br>
	I have a refresh function in my application that simply calls<br>
	setDocument() on the JSVGCanvas with the document already there,<br>
	basically causing it to reset to its default state without<br>
	zoom/pan/rotate.<br>
	<br>
	I'm also tracking changes to my rendering transform, but keying off<br>
	setRenderingTransform() doesn't seem to work; it seems to be called<br>
	before the "final" transform is achieved.<br>
	<br>
	What can I wait for to determine when the rendering transform is "done"<br>
	and ready to be communicated? Maybe computeRenderingTransform? I've<br>
	tried waiting for the GVT tree to render and for the SVG "onLoad" event,<br>
	but both seem to be too early and not communicating any change.<br>
	<br>
	Michael<br>
	<br>
	---------------------------------------------------------------------<br>
	To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org<br>
	For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org<br>
	<br>
	<br>
	---------------------------------------------------------------------<br>
	To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org<br>
	For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org<br>
	<br>
	<br>
	<br>
	<br>
________________________________<br>
<br>
	---------------------------------------------------------------------<br>
	To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org<br>
	For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org <br>
<br>
--------------------------------------------------------------------- To unsubscribe, e-mail:
batik-users-unsubscribe@xmlgraphics.apache.org For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
<br>
<hr>---------------------------------------------------------------------<br>
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org<br>
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
</div>
</blockquote></span></body></html>

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


Mime
View raw message