I am thinking to use two Timers (one to fade towards a color, then one to fade right back to the original color) to create a fading effect on a Graphic. The graphic is built as follows:
SimpleMarkerSymbol pointSymbol = SimpleMarkerSymbol.create();
DojoColor color = DojoColor.fromRGB(125, 125, 255);
pointSymbol = (SimpleMarkerSymbol) pointSymbol.setColor(color);
pointSymbol = (SimpleMarkerSymbol) pointSymbol.setSize(6);
SimpleLineSymbol outline = SimpleLineSymbol.create();
color = DojoColor.fromRGB(0, 0, 0);
outline.setColor(color);
pointSymbol.setOutline(outline);
I have the following code so far for my fade timers:
Timer fadeInTimer = new Timer() {
int r = 125;
int g = 125;
int b = 255;
@Override
public void run() {
for(int i = 0; i<5;i++) {
r++;
g++;
b--;
}
DojoColor color = DojoColor.fromRGB(r, g, b);
}
};
Timer fadeOutTimer = new Timer() {
int r = 125;
int g = 125;
int b = 255;
@Override
public void run() {
for(int i = 0; i<5;i++) {
r--;
g--;
b++;
}
DojoColor color = DojoColor.fromRGB(r, g, b);
}
};
The idea here being that I will call the fadeInTimer x amount of times to change the color significantly (lets say x=25). Then I will call fadeOutTimer x amount of times to return it to the original color. I see that I can schedule a timer for a single occurence via a delay or I can schedule a repeating timer, however I need a repeating timer that will stop running after a given amount of time and I need my fadeOutTimer to wait for the fadeInTimer to complete. I am not sure how to accomplish this. Help is much appreciated.