Trivial question on BufferedGraphicsSource.getGraphics() [message #163690] |
Wed, 12 January 2005 14:17 |
Rob Grzywinski Messages: 29 Registered: July 2009 |
Junior Member |
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0016_01C4F87F.3431CAF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
BufferedGraphicsSource.getGraphics() does the following
...
org.eclipse.swt.graphics.Point ptSWT =3D control.getSize();
inUse =3D new Rectangle(0, 0, ptSWT.x, ptSWT.y);
inUse.intersect(region);
...
graphics.setClip(region);
graphics.clipRect(new Rectangle(0, 0, ptSWT.x, ptSWT.y));
...
where SWTGraphics.clipRect() is:
relativeClip.intersect(rect);
...
It seems to me that BufferedGraphicsSource.getGraphics() could be =
simplified to:
...
org.eclipse.swt.graphics.Point ptSWT =3D control.getSize();
inUse =3D new Rectangle(0, 0, ptSWT.x, ptSWT.y);
inUse.intersect(region);
...
graphics.setClip(inUse);
...
I'm trying to understand if there are any cases in which the above =
simplication would *not* work as desired (e.g. ScaledGraphics).
(I should point out that this exemplifies the case of where "code should =
be descriptive enough that comments are not necessary" is false. I have =
to guess if the code is an oversight or "crafy programming".)
Thanks!
--
Rob Grzywinski
------=_NextPart_000_0016_01C4F87F.3431CAF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2><FONT=20
face=3D"Courier New">BufferedGraphicsSource.getGraphics()</FONT> does =
the=20
following</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2> org.eclipse.swt.graphics.Point ptSWT =3D=20
control.getSize();<BR> inUse =3D new Rectangle(0, 0, =
ptSWT.x,=20
ptSWT.y);<BR> inUse.intersect(region);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
graphics.setClip(region);<BR> graphics.clipRect(new=20
Rectangle(0, 0, ptSWT.x, ptSWT.y));</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>where <FONT=20
face=3D"Courier New">SWTGraphics.clipRect()</FONT><FONT face=3DArial>=20
is:</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Courier New"> =20
relativeClip.intersect(rect);<BR> =
....<BR></FONT></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>It seems to me that <FONT=20
face=3D"Courier New">BufferedGraphicsSource.getGraphics() </FONT>could =
be=20
simplified to:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2> org.eclipse.swt.graphics.Point ptSWT =3D=20
control.getSize();<BR> inUse =3D new Rectangle(0, 0, =
ptSWT.x,=20
ptSWT.y);<BR> inUse.intersect(region);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
graphics.setClip(inUse);<BR></FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =
....</FONT></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I'm trying to understand if there are =
any cases in=20
which the above simplication would *not* work as desired (e.g. <FONT=20
face=3D"Courier New">ScaledGraphics</FONT><FONT =
face=3DArial>).</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>(I should point out that this =
exemplifies the case=20
of where "code should be descriptive enough that comments are not =
necessary" is=20
false. I have to guess if the code is an oversight or "crafy=20
programming".)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>--</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Rob Grzywinski</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT=20
face=3D"Courier New"></FONT> </DIV></FONT></BODY></HTML>
------=_NextPart_000_0016_01C4F87F.3431CAF0--
|
|
|
Re: Trivial question on BufferedGraphicsSource.getGraphics() [message #163720 is a reply to message #163690] |
Wed, 12 January 2005 18:35 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
This is a multi-part message in MIME format.
------=_NextPart_000_005A_01C4F8AB.9FE46CE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Perhaps long ago the intersection was not occuring at the top of the =
method, so it was done at the end. Then the code got changed.
"Rob Grzywinski" <rgrzywinski@realityinteractive.com> wrote in message =
news:cs3bic$s49$1@www.eclipse.org...
BufferedGraphicsSource.getGraphics() does the following
...
org.eclipse.swt.graphics.Point ptSWT =3D control.getSize();
inUse =3D new Rectangle(0, 0, ptSWT.x, ptSWT.y);
inUse.intersect(region);
...
graphics.setClip(region);
graphics.clipRect(new Rectangle(0, 0, ptSWT.x, ptSWT.y));
...
where SWTGraphics.clipRect() is:
relativeClip.intersect(rect);
...
It seems to me that BufferedGraphicsSource.getGraphics() could be =
simplified to:
...
org.eclipse.swt.graphics.Point ptSWT =3D control.getSize();
inUse =3D new Rectangle(0, 0, ptSWT.x, ptSWT.y);
inUse.intersect(region);
...
graphics.setClip(inUse);
...
I'm trying to understand if there are any cases in which the above =
simplication would *not* work as desired (e.g. ScaledGraphics).
(I should point out that this exemplifies the case of where "code =
should be descriptive enough that comments are not necessary" is false. =
I have to guess if the code is an oversight or "crafy programming".)
Thanks!
--
Rob Grzywinski
------=_NextPart_000_005A_01C4F8AB.9FE46CE0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Perhaps long ago the intersection was =
not occuring=20
at the top of the method, so it was done at the end. Then the code =
got=20
changed.</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Rob Grzywinski" <<A=20
=
href=3D"mailto:rgrzywinski@realityinteractive.com">rgrzywinski@realityint=
eractive.com</A>>=20
wrote in message <A=20
=
href=3D"news:cs3bic$s49$1@www.eclipse.org">news:cs3bic$s49$1@www.eclipse.=
org</A>...</DIV>
<DIV><FONT face=3DArial size=3D2><FONT=20
face=3D"Courier New">BufferedGraphicsSource.getGraphics()</FONT> does =
the=20
following</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2> org.eclipse.swt.graphics.Point ptSWT =3D=20
control.getSize();<BR> inUse =3D new Rectangle(0, 0, =
ptSWT.x,=20
ptSWT.y);<BR> inUse.intersect(region);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
graphics.setClip(region);<BR> graphics.clipRect(new=20
Rectangle(0, 0, ptSWT.x, ptSWT.y));</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>where <FONT=20
face=3D"Courier New">SWTGraphics.clipRect()</FONT><FONT face=3DArial>=20
is:</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Courier New"> =20
relativeClip.intersect(rect);<BR> =20
....<BR></FONT></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>It seems to me that <FONT=20
face=3D"Courier New">BufferedGraphicsSource.getGraphics() </FONT>could =
be=20
simplified to:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2> org.eclipse.swt.graphics.Point ptSWT =3D=20
control.getSize();<BR> inUse =3D new Rectangle(0, 0, =
ptSWT.x,=20
ptSWT.y);<BR> inUse.intersect(region);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> ...</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
graphics.setClip(inUse);<BR></FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =20
....</FONT></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I'm trying to understand if there are =
any cases=20
in which the above simplication would *not* work as desired (e.g. =
<FONT=20
face=3D"Courier New">ScaledGraphics</FONT><FONT=20
face=3DArial>).</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>(I should point out that this =
exemplifies the=20
case of where "code should be descriptive enough that comments are not =
necessary" is false. I have to guess if the code is an oversight =
or=20
"crafy programming".)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>--</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Rob Grzywinski</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT=20
face=3D"Courier =
New"></FONT> </DIV></BLOCKQUOTE></FONT></BODY ></HTML>
------=_NextPart_000_005A_01C4F8AB.9FE46CE0--
|
|
|
Powered by
FUDForum. Page generated in 0.02899 seconds