Re: "fading" graphics using Graphics2D
- From: "visionset" <spam@xxxxxxxxxxxx>
- Date: Thu, 24 May 2007 22:34:42 GMT
"Brandon McCombs" <none@xxxxxxxx> wrote in message
news:46552116$0$4719$4c368faf@xxxxxxxxxxxxxxxxx
Hello everyone,
I started a small Java program just as something fun to do. It simulates a
sonar, like on a submarine. Right now I'm at the point where I have
multiple objects moving independently around the sonar screen with a
rotating needle. I keep track of the speed/location/etc. of each object
which extends Thread. The needle rotates around the screen in a way that
lights up the part it just touched and the glow gradually fades away using
a gradient that I created. The objects on the screen only change location
when the needle intersects them (using the intersects() method of
java.awt.geom.Line2D.Double).
...
I think you are on the right track with the transparency overlay.
I would paint a rectangle of eg new Color(1.0,1.0,1.0,alpha) over the icon.
also use a Swing Timer that starts when the icon is first created (needle
pass over).
Then every actionPerformed will increase decrease the alpha.
You are going to need to repaint regularly perhaps by another timer purely
for repainting.
If your app does other intensive stuff you will likely need to make some
drawing optimisations
such as calling repaint(x,y,w,h) to only repaint the areas necessary, eg
icons with attendent rectangles that are not fully opaque. You would union
together the rectangles to obtain the reapaint area.
Cache everything that is going to be painted.
Just some ideas,
HTH,
--
Mike W
.
- Follow-Ups:
- Re: "fading" graphics using Graphics2D
- From: Brandon McCombs
- Re: "fading" graphics using Graphics2D
- References:
- "fading" graphics using Graphics2D
- From: Brandon McCombs
- "fading" graphics using Graphics2D
- Prev by Date: Re: JTable Editing not take effect until hit Enter
- Next by Date: Detecting Focus In A Tabbed Pane
- Previous by thread: "fading" graphics using Graphics2D
- Next by thread: Re: "fading" graphics using Graphics2D
- Index(es):