Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2004

Tip: Looking for answers? Try searching our database.

optimising *really* complex painting in Swing?

Thread view: 
bugbear - 10 Feb 2004 10:02 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.

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.