Home » Eclipse Projects » GEF » scaledgraphics
scaledgraphics [message #88580] |
Fri, 25 July 2003 16:43  |
Eclipse User |
|
|
|
Originally posted by: ian.ianbull.com
I assume we can also post Draw2D questions to this newsgroup? If not, let
me know where they should be posted.
I have embedded a zoomable canvas on another zoomable canvas. On this inner
canvas I put a 300,300 rectangle. (it is really 75, 75, since each zoom
ratio is set to 50%.) I then added a mouse drag listener and started
dragging the innermost box around. As it moves, it gets cropped in the
width and height. At first I figured it was my code, but I pulled away all
but the essential code and it was still giving problems. I tracked it down
to this.
ScaledGraphics.java:
private Rectangle zoomClipRect(Rectangle r) {
TEMP.x = (int)(Math.ceil(r.x * zoom + fractionalX));
TEMP.y = (int)(Math.ceil(r.y * zoom + fractionalY));
TEMP.width = (int) (r.width * zoom + fractionalX);
TEMP.height = (int) (r.height * zoom + fractionalY);
/*
TEMP.width = (int)(Math.ceil(((r.x + r.width) * zoom + fractionalX))) -
TEMP.x;
TEMP.height = (int)(Math.ceil(((r.y + r.height) * zoom + fractionalY))) -
TEMP.y;
*/
return TEMP;
}
It seems that the width and height are being calculated based on the zoom
ratio as a function of the top left corner. This would explain why as I
moved it to the left, it got thinner. I the width and height calculation to
be simply a function of the original width & height and the zoom ratio (plus
the fractionalX ???), and now it seems to work.
I don't know if this was a bug, or I wasn't doing some else wrong.
Any thoughts? Has anyone else nested zoomable canvases before?
P.S. I am using the zoomable canvas found in the zoom example.
Cheers,
Ian
--
Ian Bull - IBM Centre for Advanced Studies
University of Victoria
|
|
|
Re: scaledgraphics [message #88597 is a reply to message #88580] |
Fri, 25 July 2003 18:33   |
Eclipse User |
|
|
|
Originally posted by: ian.ianbull.com
I did some more investigation into this problem (because I was wondering why
it only happened when I had nested scalable graphics) and because both our
calculations reduce to the same value. It seems the TEMP value is actually
the problem. It is a static field, and because the way graphics are nested,
the TEMP value gets assigned the same object as the clipRect
(ScaledGraphics: clipRect(Rectangle r)).
If you step through this with a debugger TEMP == r (the clip rect) once you
nest a scalable graphic. This means that TEMP.x (calculated on the first
line of zoomClipRect) is equal to r.x. My early solution just masked this
problem (because I didn't used r.x to calculate TEMP.width).
Is there a reason TEMP is static?
Cheers,
Ian
--
Ian Bull - IBM Centre for Advanced Studies
University of Victoria
"ian" <ian@ianbull.com> wrote in message news:bfs4pk$llt$1@eclipse.org...
> I assume we can also post Draw2D questions to this newsgroup? If not, let
> me know where they should be posted.
>
> I have embedded a zoomable canvas on another zoomable canvas. On this
inner
> canvas I put a 300,300 rectangle. (it is really 75, 75, since each zoom
> ratio is set to 50%.) I then added a mouse drag listener and started
> dragging the innermost box around. As it moves, it gets cropped in the
> width and height. At first I figured it was my code, but I pulled away
all
> but the essential code and it was still giving problems. I tracked it
down
> to this.
>
> ScaledGraphics.java:
>
> private Rectangle zoomClipRect(Rectangle r) {
> TEMP.x = (int)(Math.ceil(r.x * zoom + fractionalX));
> TEMP.y = (int)(Math.ceil(r.y * zoom + fractionalY));
>
> TEMP.width = (int) (r.width * zoom + fractionalX);
> TEMP.height = (int) (r.height * zoom + fractionalY);
> /*
> TEMP.width = (int)(Math.ceil(((r.x + r.width) * zoom + fractionalX))) -
> TEMP.x;
> TEMP.height = (int)(Math.ceil(((r.y + r.height) * zoom + fractionalY))) -
> TEMP.y;
> */
> return TEMP;
> }
>
> It seems that the width and height are being calculated based on the zoom
> ratio as a function of the top left corner. This would explain why as I
> moved it to the left, it got thinner. I the width and height calculation
to
> be simply a function of the original width & height and the zoom ratio
(plus
> the fractionalX ???), and now it seems to work.
>
> I don't know if this was a bug, or I wasn't doing some else wrong.
>
> Any thoughts? Has anyone else nested zoomable canvases before?
>
> P.S. I am using the zoomable canvas found in the zoom example.
>
> Cheers,
> Ian
>
> --
> Ian Bull - IBM Centre for Advanced Studies
> University of Victoria
>
>
|
|
|
Re: scaledgraphics [message #89094 is a reply to message #88597] |
Tue, 29 July 2003 13:29   |
Eclipse User |
|
|
|
Originally posted by: ian.ianbull.com
Is it better that I open a bug report on the GEF website (with the proposed
solution), or should I post the code that is causing the problem to the news
group?
Cheers,
Ian
"ian" <ian@ianbull.com> wrote in message news:bfsb8c$s49$1@eclipse.org...
> I did some more investigation into this problem (because I was wondering
why
> it only happened when I had nested scalable graphics) and because both our
> calculations reduce to the same value. It seems the TEMP value is
actually
> the problem. It is a static field, and because the way graphics are
nested,
> the TEMP value gets assigned the same object as the clipRect
> (ScaledGraphics: clipRect(Rectangle r)).
>
> If you step through this with a debugger TEMP == r (the clip rect) once
you
> nest a scalable graphic. This means that TEMP.x (calculated on the first
> line of zoomClipRect) is equal to r.x. My early solution just masked this
> problem (because I didn't used r.x to calculate TEMP.width).
>
> Is there a reason TEMP is static?
>
> Cheers,
> Ian
>
> --
> Ian Bull - IBM Centre for Advanced Studies
> University of Victoria
> "ian" <ian@ianbull.com> wrote in message news:bfs4pk$llt$1@eclipse.org...
> > I assume we can also post Draw2D questions to this newsgroup? If not,
let
> > me know where they should be posted.
> >
> > I have embedded a zoomable canvas on another zoomable canvas. On this
> inner
> > canvas I put a 300,300 rectangle. (it is really 75, 75, since each zoom
> > ratio is set to 50%.) I then added a mouse drag listener and started
> > dragging the innermost box around. As it moves, it gets cropped in the
> > width and height. At first I figured it was my code, but I pulled away
> all
> > but the essential code and it was still giving problems. I tracked it
> down
> > to this.
> >
> > ScaledGraphics.java:
> >
> > private Rectangle zoomClipRect(Rectangle r) {
> > TEMP.x = (int)(Math.ceil(r.x * zoom + fractionalX));
> > TEMP.y = (int)(Math.ceil(r.y * zoom + fractionalY));
> >
> > TEMP.width = (int) (r.width * zoom + fractionalX);
> > TEMP.height = (int) (r.height * zoom + fractionalY);
> > /*
> > TEMP.width = (int)(Math.ceil(((r.x + r.width) * zoom + fractionalX))) -
> > TEMP.x;
> > TEMP.height = (int)(Math.ceil(((r.y + r.height) * zoom +
fractionalY))) -
> > TEMP.y;
> > */
> > return TEMP;
> > }
> >
> > It seems that the width and height are being calculated based on the
zoom
> > ratio as a function of the top left corner. This would explain why as I
> > moved it to the left, it got thinner. I the width and height
calculation
> to
> > be simply a function of the original width & height and the zoom ratio
> (plus
> > the fractionalX ???), and now it seems to work.
> >
> > I don't know if this was a bug, or I wasn't doing some else wrong.
> >
> > Any thoughts? Has anyone else nested zoomable canvases before?
> >
> > P.S. I am using the zoomable canvas found in the zoom example.
> >
> > Cheers,
> > Ian
> >
> > --
> > Ian Bull - IBM Centre for Advanced Studies
> > University of Victoria
> >
> >
>
>
|
|
|
Re: scaledgraphics [message #89122 is a reply to message #88597] |
Tue, 29 July 2003 14:55  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
The anticipated usage was that once you wrappered a Graphics with a
ScaledGraphics, you wouldn't do so again. If you continue to wrap and wrap,
you will pay rounding penalties multiple times. So, a workaround, which is
arguably better, is to check if the Graphics is an instance of
ScaledGraphics, and reuse it if so.
Open a bugzilla for the TEMP rectangle problem. We can fix this in the next
service release.
"ian" <ian@ianbull.com> wrote in message news:bfsb8c$s49$1@eclipse.org...
> I did some more investigation into this problem (because I was wondering
why
> it only happened when I had nested scalable graphics) and because both our
> calculations reduce to the same value. It seems the TEMP value is
actually
> the problem. It is a static field, and because the way graphics are
nested,
> the TEMP value gets assigned the same object as the clipRect
> (ScaledGraphics: clipRect(Rectangle r)).
>
> If you step through this with a debugger TEMP == r (the clip rect) once
you
> nest a scalable graphic. This means that TEMP.x (calculated on the first
> line of zoomClipRect) is equal to r.x. My early solution just masked this
> problem (because I didn't used r.x to calculate TEMP.width).
>
> Is there a reason TEMP is static?
>
> Cheers,
> Ian
>
> --
> Ian Bull - IBM Centre for Advanced Studies
> University of Victoria
> "ian" <ian@ianbull.com> wrote in message news:bfs4pk$llt$1@eclipse.org...
> > I assume we can also post Draw2D questions to this newsgroup? If not,
let
> > me know where they should be posted.
> >
> > I have embedded a zoomable canvas on another zoomable canvas. On this
> inner
> > canvas I put a 300,300 rectangle. (it is really 75, 75, since each zoom
> > ratio is set to 50%.) I then added a mouse drag listener and started
> > dragging the innermost box around. As it moves, it gets cropped in the
> > width and height. At first I figured it was my code, but I pulled away
> all
> > but the essential code and it was still giving problems. I tracked it
> down
> > to this.
> >
> > ScaledGraphics.java:
> >
> > private Rectangle zoomClipRect(Rectangle r) {
> > TEMP.x = (int)(Math.ceil(r.x * zoom + fractionalX));
> > TEMP.y = (int)(Math.ceil(r.y * zoom + fractionalY));
> >
> > TEMP.width = (int) (r.width * zoom + fractionalX);
> > TEMP.height = (int) (r.height * zoom + fractionalY);
> > /*
> > TEMP.width = (int)(Math.ceil(((r.x + r.width) * zoom + fractionalX))) -
> > TEMP.x;
> > TEMP.height = (int)(Math.ceil(((r.y + r.height) * zoom +
fractionalY))) -
> > TEMP.y;
> > */
> > return TEMP;
> > }
> >
> > It seems that the width and height are being calculated based on the
zoom
> > ratio as a function of the top left corner. This would explain why as I
> > moved it to the left, it got thinner. I the width and height
calculation
> to
> > be simply a function of the original width & height and the zoom ratio
> (plus
> > the fractionalX ???), and now it seems to work.
> >
> > I don't know if this was a bug, or I wasn't doing some else wrong.
> >
> > Any thoughts? Has anyone else nested zoomable canvases before?
> >
> > P.S. I am using the zoomable canvas found in the zoom example.
> >
> > Cheers,
> > Ian
> >
> > --
> > Ian Bull - IBM Centre for Advanced Studies
> > University of Victoria
> >
> >
>
>
|
|
|
Goto Forum:
Current Time: Mon Jun 09 03:47:22 EDT 2025
Powered by FUDForum. Page generated in 0.03692 seconds
|