Posted by dodger
on May 23, 2006 at 10:06 AM PDT
1. I don't understand why Java 2D classes such as Rectangle2D have float and double constructors, and not integer constructors? I thought these values represented pixel coordinates? Are these values rounded, or what? (I know I'm missing something huge here, so this is an embarrassing question to ask)
2. Should methods in the Graphics class, such as drawRect, ever be used? (i.e., should you always cast the Graphics object to Graphics2D, and call draw(myShape2D)?)
3. What is the best way of filling a rounded rectangle with 2 gradients, as shown here: http://ld.hostrocket.com/images/rr_grad.png
I believe the LinearGradientPaint in Mustang will make this a lot easier, but I'd like it to at least run on Tiger (I think).
What I did was set the clip to a rounded rectangle, and then fill two separate rectangles using a GradientPaint. I then 'reset' the clip, and drew the rounded rectangle border. (The corners of the border seemed to be cut off if I didn't remove the clip -- I probably did something wrong) Anyway, is this an acceptable solution? Is there a better way to do it?
Any other Java 2D tips are welcome. :)