|
Hi Michael, for converting a Point I
do as follows: public static Float
convertPointToViewBox(SVGCanvas canvas, Point point) { try { AffineTransform
viewBoxTranfrom = canvas.getViewBoxTransform(); viewBoxTranfrom =
viewBoxTranfrom.createInverse(); return
convertPoint(point, viewBoxTranfrom); } catch
(NoninvertibleTransformException e) {
e.printStackTrace(); } return null; } private static
Point2D.Float convertPoint(Point point, AffineTransform viewBoxTranfrom) { double[] matrix = new
double[6];
viewBoxTranfrom.getMatrix(matrix); return convertPoint(point,
matrix); } public static
Point2D.Float convertPoint(Point point, double[] matrix) { Point2D.Float retP =
new Point2D.Float(); retP.x = (float)
(matrix[0] * point.x + matrix[2] * point.y + matrix[4]); retP.y = (float)
(matrix[1] * point.x + matrix[3] * point.y + matrix[5]); return retP; } I hope this helps… J Dominik Steiner Von: Bishop, Michael
W. CONTR J9C880 [mailto:[EMAIL PROTECTED] Oops, forgot Line2D falls in the Shape
category. For the text and the polyline, I really have the same problem;
the text is a single x,y coordinate and the polyline is a set of x,y
coordinates. If I can figure out how to translate those, I should be in good
shape. Michael Bishop From: Bishop,
Michael W. CONTR J9C880 [mailto:[EMAIL PROTECTED] That is precisely what I needed. I
was using JSVGCanvas.getRenderingTransform() and that didn't quite work.
That works for my boxes and ellipses, but is there a similar school of thought,
using the AffineTransform for Line2D, a set of points (later used to create a polyline)
and text?? Michael Bishop From: Steiner,
Dominik [mailto:[EMAIL PROTECTED] Hi Michael, I’m not sure if
this helps you, but I would suggest that you transform the screen coordinates
to viewbox coordinates. I first let the user draw on screen coordinates and
when he finished I do the transformation to viewbox coordinates as follows: public static
Shape scaleShapeToViewbox(Shape shape, SVGCanvas canvas) { try {
AffineTransform at = canvas.getViewBoxTransform().createInverse();
shape = at.createTransformedShape(shape); }
catch (NoninvertibleTransformException e1) {
e1.printStackTrace(); } return
shape; } So this works for my
Java2D shapes…. I hope it helps… Dominik Von: Bishop, Michael
W. CONTR J9C880 [mailto:[EMAIL PROTECTED] OK, so I have the JSVGCanvas zooming in and zooming
out. Since I have a whiteboard application, users can draw objects to the
canvas. Much like typical art programs, you get an “outline”
of what you’re going to draw before it’s placed. For a box,
you click, drag the mouse to the desired size and release. I guess they
call it “rubber-banding” or whatever. On to my question. When the canvas is zoomed
in/zoomed out, how can I get the translation correct on the glass pane?
The glass pane is currently drawing based on the coordinates of the JSVGCanvas,
but it draws as if the JSVGCanvas isn’t zoomed in or out. In short,
what the glass pane is rendering is not zoomed, but what the JSVGCanvas is rendering
is. So what you see isn’t what you get when you let go of the
mouse. How can I translate my shapes based on the zoom? If I draw
something on a canvas that is zoomed in 20%, I’d like to scale the
outline 20%...etc. That degree of scaling is what I don’t know how to
get. Michael Bishop |
- AW: Translations with zoom in and zoom out... Steiner, Dominik
- Re: AW: Translations with zoom in and... thomas . deweese
- RE: AW: Translations with zoom in and... Bishop, Michael W. CONTR J9C880
- RE: AW: Translations with zoom in... thomas . deweese
- RE: AW: Translations with zoom in and... Bishop, Michael W. CONTR J9C880
- RE: AW: Translations with zoom in... thomas . deweese
- RE: AW: Translations with zoom in and... Bishop, Michael W. CONTR J9C880
- RE: AW: Translations with zoom in... thomas . deweese
- RE: AW: Translations with zoom in and... Bishop, Michael W. CONTR J9C880
- RE: AW: Translations with zoom in and... Bishop, Michael W. CONTR J9C880
- RE: AW: Translations with zoom in... thomas . deweese
