source: trunk/src/org/expeditee/agents/DisplayComet.java@ 121

Last change on this file since 121 was 121, checked in by bjn8, 16 years ago

Added invalidation for graphics... biiiig commit. LOts of effeciency improvements - now can animate

File size: 1.5 KB
Line 
1package org.expeditee.agents;
2
3import java.util.Collection;
4import java.util.HashSet;
5import java.util.Stack;
6
7import org.expeditee.gui.DisplayIO;
8import org.expeditee.gui.Frame;
9import org.expeditee.gui.FrameIO;
10import org.expeditee.gui.MessageBay;
11import org.expeditee.items.Item;
12import org.expeditee.items.ItemUtils;
13
14public class DisplayComet extends DefaultAgent {
15 private Stack<Frame> _frameList = new Stack<Frame>();
16
17 public DisplayComet(String delay) {
18 super(delay);
19 }
20
21 public DisplayComet() {
22 super();
23 }
24
25 @Override
26 protected Frame process(Frame frame) {
27 Collection<String> seen = new HashSet<String>();
28
29 DisplayIO.addToBack(frame);
30
31 // Goto the end of the comet
32 Item old = null;
33 Frame oldFrame = frame;
34 while (oldFrame != null) {
35 if(_stop)
36 return null;
37 seen.add(oldFrame.getName().toLowerCase());
38 _frameList.push(oldFrame);
39 old = ItemUtils.FindExactTag(oldFrame.getItems(), ItemUtils
40 .GetTag(ItemUtils.TAG_BACKUP));
41 oldFrame = null;
42 if (old != null) {
43 String link = old.getAbsoluteLink();
44 String linkLowerCase = link.toLowerCase();
45 if (link != null && !seen.contains(linkLowerCase)) {
46 oldFrame = FrameIO.LoadFrame(linkLowerCase);
47 MessageBay.overwriteMessage("Loading frames: " + link);
48 }
49 }
50 }
51 // Back out one frame at a time
52 while (!_frameList.empty()) {
53 if(_stop)
54 return null;
55 DisplayIO.setCurrentFrame(_frameList.pop());
56 _frameCount++;
57 pause(_delay);
58 }
59
60 return _start;
61 }
62
63}
Note: See TracBrowser for help on using the repository browser.