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

Last change on this file since 1102 was 1102, checked in by davidb, 6 years ago

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File size: 2.3 KB
Line 
1/**
2 * DisplayComet.java
3 * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package org.expeditee.agents;
20
21import java.util.Collection;
22import java.util.HashSet;
23import java.util.Stack;
24
25import org.expeditee.gui.DisplayController;
26import org.expeditee.gui.Frame;
27import org.expeditee.gui.FrameIO;
28import org.expeditee.gui.MessageBay;
29import org.expeditee.items.Item;
30import org.expeditee.items.ItemUtils;
31
32public class DisplayComet extends DefaultAgent {
33 private Stack<Frame> _frameList = new Stack<Frame>();
34
35 public DisplayComet(String delay) {
36 super(delay);
37 }
38
39 public DisplayComet() {
40 super();
41 }
42
43 @Override
44 protected Frame process(Frame frame) {
45 Collection<String> seen = new HashSet<String>();
46
47 DisplayController.addToBack(frame);
48
49 // Goto the end of the comet
50 Item old = null;
51 Frame oldFrame = frame;
52 while (oldFrame != null) {
53 if (_stop)
54 return null;
55 seen.add(oldFrame.getName().toLowerCase());
56 _frameList.push(oldFrame);
57 old = ItemUtils.FindExactTag(oldFrame.getItems(), ItemUtils
58 .GetTag(ItemUtils.TAG_BACKUP));
59 oldFrame = null;
60 if (old != null) {
61 String link = old.getAbsoluteLink();
62
63 if (link != null) {
64 String linkLowerCase = link.toLowerCase();
65 if (!seen.contains(linkLowerCase)) {
66 oldFrame = FrameIO.LoadFrame(linkLowerCase);
67 MessageBay.overwriteMessage("Loading frames: " + link);
68 }
69 }
70 }
71 }
72 // Back out one frame at a time
73 while (!_frameList.empty()) {
74 if (_stop)
75 return null;
76 DisplayController.setCurrentFrame(_frameList.pop(), true);
77 _frameCount++;
78 pause(_delay);
79 }
80
81 return _start;
82 }
83
84}
Note: See TracBrowser for help on using the repository browser.