>> Hello everyone,
>>
[quoted text clipped - 13 lines]
> also use a Swing Timer that starts when the icon is first created (needle
> pass over).
Actually I already have a Timer that runs the entire time the program
runs. It fires every 6 ms and does all the repainting by calling
repaint() in actionPerformed(). Shortly after posting this I ended up
fixing the problem in the code where the object wasn't disappearing when
it moved out of range and I inadvertently laid the groundwork for fixing
the fading of the objects. I had the revelation for fixing the fading
while laying in bed later that night and tried it first thing Friday
morning and got it working.
I had setup multiple "if" conditions for drawing or not drawing the
objects. As my last condition, which is encountered when the object is
in range but isn't being intersected by the needle, I ended up
creating/calling a variation of each object's display() method which
draws the object with increasing transparency, in effect making it fade
away. With each object tracking its own transparency I was able to make
them all fade properly based on their distance from the needle. The
first condition, when the object is both in range and intersected by the
needle, calls the primary variation of the object's display() method
which will redraw the object and its label with 0 transparency thus
making it appear again (as I timed the fading of each object so that the
object totally disappears right before the needle rotates back around to
intersect it again).
> Then every actionPerformed will increase decrease the alpha.
> You are going to need to repaint regularly perhaps by another timer purely
> for repainting.
See above. I already had that in place. I have 1 timer that repaints
everything in varying layers. The moving vehicles that are tracked on
the sonar are in the top-most layer.
> 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.
Since I'm increasingly using more transparencies I'm going to have to
think of ways to optimize it because it is using more and more CPU to
run the program (mainly to repaint I believe). I'll look into your idea
to see if I can get repainting only certain areas to work.
> Cache everything that is going to be painted.
>
> Just some ideas,
> HTH,
thanks for your help Mike.