Sunday, February 13, 2011

Animated Visual Effects in an SWT Table

For the project I am currently working on, we have a view that contains a large table.  When an item in that table is selected, it drives what data shows up in the other views inside the perspective.  We needed a way to notify the user of what the context of his selection was, even if he changed focus to another view.  I wanted something with a little visual flair, rather than just the normal, mundane icon.  What I came up with was a "pulsing" background color that fades in at out slowly (keyword: slowly).  It draws the user's attention if the user is looking for his selection, but does not distract away from other views.

This approach presented two main challenges: first, I wanted to develop a clean algorithm for fading between any two colors so that the speed of the pulsing would be consistent regardless of colors, and 2nd, all the heavy duty work would need to be done in a separate thread from the GUI thread so I wouldn't freeze up the interface.

The following code creates a listener that, upon being notified of a Table Mouse double click event, starts a new thread that controls a pulsing background that fades between two colors:



No comments:

Post a Comment