Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » ScaledGraphics
ScaledGraphics [message #196496] Thu, 22 September 2005 10:49 Go to next message
J F is currently offline J FFriend
Messages: 256
Registered: July 2009
Senior Member
GEF is great, however I'm having some difficulty understanding why
ScaledGraphics does some things the way it does.

zoomFillRect in ScaledGraphics is implemented
so that the zoomed rectangle's size takes into account the origin of the
rectangle.

private Rectangle zoomFillRect(int x, int y, int w, int h) {
TEMP.x = (int)(Math.floor((x * zoom + fractionalX)));
TEMP.y = (int)(Math.floor((y * zoom + fractionalY)));

//width is not w * zoom + fractionalX
TEMP.width = (int)(Math.floor(((x + w - 1) * zoom + fractionalX))) -
TEMP.x + 1;
TEMP.height = (int)(Math.floor(((y + h - 1) * zoom + fractionalY))) -
TEMP.y + 1;
return TEMP;
}

Please can someone spare a minute and tell me why this is. Its a long time
since I did any graphics work.

ScaledGraphics does not set the scale of the underlying graphics context,
it seems to do the calcualtion itself, so its not because its taking that
into account ?

Also if I draw a cross inside the same fill rectangle, topLeft to
bottomRight, bottomLeft to topRight its centered elsewhere.
Re: ScaledGraphics [message #196504 is a reply to message #196496] Thu, 22 September 2005 14:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

We had to decide what to do when two rectangles are drawn such that they
share a common edge. When zoom occurs, the common edge should still overlap
and not separate.

Our version of scaling existed before SWT supported it. We have plans to
allow clients to chose which version they want. You can easily override the
behavior of ScalableLayeredPane to just use hte SWTGraphics#scale method

"J Francis" <jfrancis@his.co.uk> wrote in message
news:486a4dfb4746f81f91a28ccdd096a7ff$1@www.eclipse.org...
> GEF is great, however I'm having some difficulty understanding why
> ScaledGraphics does some things the way it does.
>
> zoomFillRect in ScaledGraphics is implemented so that the zoomed
> rectangle's size takes into account the origin of the rectangle.
>
> private Rectangle zoomFillRect(int x, int y, int w, int h) {
> TEMP.x = (int)(Math.floor((x * zoom + fractionalX)));
> TEMP.y = (int)(Math.floor((y * zoom + fractionalY)));
>
> //width is not w * zoom + fractionalX
> TEMP.width = (int)(Math.floor(((x + w - 1) * zoom + fractionalX))) -
> TEMP.x + 1;
> TEMP.height = (int)(Math.floor(((y + h - 1) * zoom + fractionalY))) -
> TEMP.y + 1;
> return TEMP;
> }
>
> Please can someone spare a minute and tell me why this is. Its a long time
> since I did any graphics work.
>
> ScaledGraphics does not set the scale of the underlying graphics context,
> it seems to do the calcualtion itself, so its not because its taking that
> into account ?
>
> Also if I draw a cross inside the same fill rectangle, topLeft to
> bottomRight, bottomLeft to topRight its centered elsewhere.
>
Re: ScaledGraphics [message #196524 is a reply to message #196504] Thu, 22 September 2005 15:09 Go to previous message
J F is currently offline J FFriend
Messages: 256
Registered: July 2009
Senior Member
Thanks
Previous Topic:Open new GraphicalEditors for a single resource.
Next Topic:Newbie Q: multiple state machine editor in GEF
Goto Forum:
  


Current Time: Sat Jan 18 07:55:46 GMT 2025

Powered by FUDForum. Page generated in 0.03341 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top