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 "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> on 2006/11/09 23:18:14 UTC
RE: Overlay?
OK, using overlays is providing the desired effect, but my bounding
boxes I draw can still get misaligned.
Consider the case where the SVG document or the JSVGCanvas gets resized.
If I end up with "non document" space between the document and the left
edge of the JSVGCanvas, the bounding boxes get shifted to the right by
that same amount.
I'm applying the view box transform of the JSVGCanvas to the Graphics
object I use to draw the overlay.
What I need is to draw bounding boxes around whatever I see, be it
zoomed, resized, scrolled, etc. I thought the overlay would be the
object to solve this issue.
Michael Bishop
-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: Friday, October 06, 2006 8:28 PM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: Overlay?
Hi Michael,
"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on
10/06/2006 09:46:30 AM:
> JSVGCanvas.getOverlays().add(...) is the only way I can come up with
to
> add an Overlay to the object.
This is it (a bit odd I agree but I didn't write it and it does
work).
> -----Original Message-----
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> Sent: Friday, October 06, 2006 6:55 AM
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xmlgraphics.apache.org
> Subject: Re: Overlay?
>
> Hi Michael,
>
> "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote
on
>
> 10/04/2006 12:57:27 PM:
>
> > Can I get some more information about the overlay in Batik?
>
> There really isn't much to tell. Basically an overlay is
> an object who's 'paint' method is called after the main canvas has
> drawn it's stuff. The 'paint' transform has been applied to the
> Graphics2D but not the 'viewing' transform.
>
> > I want to replace my "glass pane" for outline drawing of bounding
> > boxes, "ghosting" of a shape before I render one to the actual
> > document, etc. I've been using a glass pane and aligning it with
> > the document has been problematic. The JSVGScrollPane, resizing
> > of the canvas, etc., has been throwing off my glass pane and I think
> > the overlay can solve my problem.
>
> This sounds like exactly the sort of thing the Overlay objects are
> intended for.
>
> > Is there a brief on what this can/can't do for me and if I should
> > use it to solve this problem?
>
> As I said an Overlay is pretty simple it just has one 'paint'
> method that get's called after the canvas has drawn it's stuff.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: Overlay?
Posted by "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil>.
Ah, I see. The code I'm using is left over from my glass pane that was simply a JComponent acting as the glass pane to a JRootPane that held the JSVGCanvas.
So now it looks like I can do something like this:
SVGRect boundingBox = svgLocatable.getBBox();
SVGMatrix matrix = svgLocatable.getTransformToElement(rootElement);
// I don't know of a better way to get from matrix -> AffineTransform.
AffineTransform shapeTransform = new AffineTransform(matrix.getA(), matrix.getB(), matrix.getC(), matrix.getD(),
matrix.getE(), matrix.getF());
// Create the bounding box with the specified "padding" amount around the edges.
Rectangle2D rectangle2D =
new Rectangle2D.Double(
boundingBox.getX() - padding, boundingBox.getY() - padding,
boundingBox.getWidth() + (2 * padding),
boundingBox.getHeight() + (2 * padding));
// Transform and render the shape to the overlay.
Shape transformedBox = shapeTransform.createTransformedShape(rectangle2D);
graphics.draw(transformedShape);
Michael Bishop
________________________________
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: Fri 11/10/2006 6:54 AM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: Overlay?
Hi Michael,
I would suggest using either 'getScreenCTM' or
'getTransformToElement(rootSVGElem)' to
transform the results of 'getBBox' to your overlay. You are likely to
encounter problems if you
try and 'simulate' the behavior of these methods.
"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on
11/09/2006 05:18:14 PM:
> OK, using overlays is providing the desired effect, but my bounding
> boxes I draw can still get misaligned.
>
> Consider the case where the SVG document or the JSVGCanvas gets resized.
> If I end up with "non document" space between the document and the left
> edge of the JSVGCanvas, the bounding boxes get shifted to the right by
> that same amount.
>
> I'm applying the view box transform of the JSVGCanvas to the Graphics
> object I use to draw the overlay.
>
> What I need is to draw bounding boxes around whatever I see, be it
> zoomed, resized, scrolled, etc. I thought the overlay would be the
> object to solve this issue.
>
> Michael Bishop
>
> -----Original Message-----
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> Sent: Friday, October 06, 2006 8:28 PM
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xmlgraphics.apache.org
> Subject: RE: Overlay?
>
> Hi Michael,
>
> "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on
>
> 10/06/2006 09:46:30 AM:
>
> > JSVGCanvas.getOverlays().add(...) is the only way I can come up with
> to
> > add an Overlay to the object.
>
> This is it (a bit odd I agree but I didn't write it and it does
> work).
>
> > -----Original Message-----
> > From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> > Sent: Friday, October 06, 2006 6:55 AM
> > To: batik-users@xmlgraphics.apache.org
> > Cc: batik-users@xmlgraphics.apache.org
> > Subject: Re: Overlay?
> >
> > Hi Michael,
> >
> > "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote
> on
> >
> > 10/04/2006 12:57:27 PM:
> >
> > > Can I get some more information about the overlay in Batik?
> >
> > There really isn't much to tell. Basically an overlay is
> > an object who's 'paint' method is called after the main canvas has
> > drawn it's stuff. The 'paint' transform has been applied to the
> > Graphics2D but not the 'viewing' transform.
> >
> > > I want to replace my "glass pane" for outline drawing of bounding
> > > boxes, "ghosting" of a shape before I render one to the actual
> > > document, etc. I've been using a glass pane and aligning it with
> > > the document has been problematic. The JSVGScrollPane, resizing
> > > of the canvas, etc., has been throwing off my glass pane and I think
>
> > > the overlay can solve my problem.
> >
> > This sounds like exactly the sort of thing the Overlay objects are
> > intended for.
> >
> > > Is there a brief on what this can/can't do for me and if I should
> > > use it to solve this problem?
> >
> > As I said an Overlay is pretty simple it just has one 'paint'
> > method that get's called after the canvas has drawn it's stuff.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
> batik-users-help@xmlgraphics.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
> batik-users-help@xmlgraphics.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: Overlay?
Posted by th...@kodak.com.
Hi Michael,
I would suggest using either 'getScreenCTM' or
'getTransformToElement(rootSVGElem)' to
transform the results of 'getBBox' to your overlay. You are likely to
encounter problems if you
try and 'simulate' the behavior of these methods.
"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on
11/09/2006 05:18:14 PM:
> OK, using overlays is providing the desired effect, but my bounding
> boxes I draw can still get misaligned.
>
> Consider the case where the SVG document or the JSVGCanvas gets resized.
> If I end up with "non document" space between the document and the left
> edge of the JSVGCanvas, the bounding boxes get shifted to the right by
> that same amount.
>
> I'm applying the view box transform of the JSVGCanvas to the Graphics
> object I use to draw the overlay.
>
> What I need is to draw bounding boxes around whatever I see, be it
> zoomed, resized, scrolled, etc. I thought the overlay would be the
> object to solve this issue.
>
> Michael Bishop
>
> -----Original Message-----
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> Sent: Friday, October 06, 2006 8:28 PM
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xmlgraphics.apache.org
> Subject: RE: Overlay?
>
> Hi Michael,
>
> "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on
>
> 10/06/2006 09:46:30 AM:
>
> > JSVGCanvas.getOverlays().add(...) is the only way I can come up with
> to
> > add an Overlay to the object.
>
> This is it (a bit odd I agree but I didn't write it and it does
> work).
>
> > -----Original Message-----
> > From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> > Sent: Friday, October 06, 2006 6:55 AM
> > To: batik-users@xmlgraphics.apache.org
> > Cc: batik-users@xmlgraphics.apache.org
> > Subject: Re: Overlay?
> >
> > Hi Michael,
> >
> > "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote
> on
> >
> > 10/04/2006 12:57:27 PM:
> >
> > > Can I get some more information about the overlay in Batik?
> >
> > There really isn't much to tell. Basically an overlay is
> > an object who's 'paint' method is called after the main canvas has
> > drawn it's stuff. The 'paint' transform has been applied to the
> > Graphics2D but not the 'viewing' transform.
> >
> > > I want to replace my "glass pane" for outline drawing of bounding
> > > boxes, "ghosting" of a shape before I render one to the actual
> > > document, etc. I've been using a glass pane and aligning it with
> > > the document has been problematic. The JSVGScrollPane, resizing
> > > of the canvas, etc., has been throwing off my glass pane and I think
>
> > > the overlay can solve my problem.
> >
> > This sounds like exactly the sort of thing the Overlay objects are
> > intended for.
> >
> > > Is there a brief on what this can/can't do for me and if I should
> > > use it to solve this problem?
> >
> > As I said an Overlay is pretty simple it just has one 'paint'
> > method that get's called after the canvas has drawn it's stuff.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
> batik-users-help@xmlgraphics.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
> batik-users-help@xmlgraphics.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org