I've searched for this, I really have.
How (in Swing) would one implement a really complex
display area. I'm thinking of something like Adobe
Illustrator, or a CAD package.
Incremental paint (AKA update() in AWT) is not useful
in Swing.
The only way I can see is to perform ALL painting
to an application side Image, keeping track of rectangles,
and then use repaint() to force paintComponent to
push the updated offscreen Image to the screen.
I would welcome tips, FAQs, pointers to tutorials etc
on this topic.
BugBear
Thomas Weidenfeller - 10 Feb 2004 11:59 GMT
> I've searched for this, I really have.
>
> How (in Swing) would one implement a really complex
> display area. I'm thinking of something like Adobe
> Illustrator, or a CAD package.
Hmm, changing to an OpenGL binding or an optimized Java 3D, on a machine
with a rendering pipeline in hardware? :-)
> The only way I can see is to perform ALL painting
> to an application side Image, keeping track of rectangles,
> and then use repaint() to force paintComponent to
> push the updated offscreen Image to the screen.
Only if you are mainly dealing with "bitmap" graphics (images, etc.).
And then I would of course pay attention to the clipping region inside
paintComponent(), to make sure you only copy the minimal area necessary.
I would also consider turning off Swing's own buffering.
If you are mainly dealing with vector graphics or shapes, I would
organize the shapes in a data structure which allows for easy 2D spacial
separation (maybe 2.5D (layer) support, too). Inside paintComponent() I
would again use the clipping region to perform the selection of the
potentially affected shapes and paint them directly to the Graphics2D
object in paintComponent().
Changing of the drawing would be done by first changing the information
in the data structure, and then calling repaint for the affected region.
/Thomas
Andrew Chase - 10 Feb 2004 18:17 GMT
The best resource I've found for really getting into Java2D painting is this
mailing list archive:
http://archives.java.sun.com/cgi-bin/wa?A0=JAVA2D-INTEREST
Spend some time reading through it and you'll be a lot better off.
-Andrew
> I've searched for this, I really have.
>
[quoted text clipped - 14 lines]
>
> BugBear
bugbear - 12 Feb 2004 12:04 GMT
> The best resource I've found for really getting into Java2D painting is this
> mailing list archive:
> http://archives.java.sun.com/cgi-bin/wa?A0=JAVA2D-INTEREST
> Spend some time reading through it and you'll be a lot better off.
Thank for the pointer. Lots of good stuff there.
BugBear