Hi Jan,

The short answer to the fillRect vs. drawLine question is for the
developers to always use the simplest API call that matches their
needs.

Rectangles are, well, a box of pixels (unless you are transformed in
which case it might be a tilted box of pixels).

Lines are complicated little pieces of geometry that have slopes and
widths and dashing and potentially custom styles specified by the Stroke
interface.

When you want to draw something simple like a box of pixels (even if
that box is only 1 pixel big), it makes sense to use the simplest
specification of what you want.  When you do this with a fillRect,
it is very easy for our software to determine that you just want
that dot on the screen to be turned on.  When you do this with a
drawLine, we have a lot of options (and potentially some user-defined
Java code to run) to consider to figure out that really all that
math boils down to "just turn this pixel on".

So, the best way to do something simple, like "turn this box of pixels
on" is to use the simplest method that lets you do that - i.e. fillRect.

While it might be true that we could put some more tests in the drawLine
code to detect that it all boils down to just a box of pixels on the
screen, such a test requires a lot more math than in the fillRect code
and is of questionable value when developers can just as easily (some
could argue - more easily) use the fillRect method for those cases we
would be trying to detect.  Thus, such code would be slowing down anyone
who really wants to draw a diagonal, dashed, wide, rounded-end line of
pixels and only benefitting developers who have a better choice of method
call to use in the first place - not necessarily a win-win tradeoff.

                                ...jim

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to