source: trunk/src/org/expeditee/agents/TreeProcessor.java@ 1415

Last change on this file since 1415 was 1415, checked in by bln4, 5 years ago

Renamed Frame.getItems() to Frame.getSortedItems() to better represent its functionality.

-> org.apollo.ApolloGestureActions
-> org.apollo.ApolloSystem
-> org.expeditee.actions.Actions
-> org.expeditee.actions.Debug
-> org.expeditee.actions.ExploratorySearchActions
-> org.expeditee.actions.JfxBrowserActions
-> org.expeditee.actions.Misc
-> org.expeditee.actions.Navigation
-> org.expeditee.actions.ScriptBase
-> org.expeditee.actions.Simple
-> org.expeditee.agents.ComputeTree
-> org.expeditee.agents.CopyTree
-> org.expeditee.agents.DisplayComet
-> org.expeditee.agents.DisplayTree
-> org.expeditee.agents.DisplayTreeLeaves
-> org.expeditee.agents.GraphFramesetLinks
-> org.expeditee.agents.TreeProcessor
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gui.DisplayController
-> org.expeditee.gui.FrameCreator
-> org.expeditee.gui.FrameIO
-> org.expeditee.io.DefaultTreeWriter
-> org.expeditee.io.JavaWriter
-> org.expeditee.io.PDF2Writer
-> org.expeditee.io.TXTWriter
-> org.expeditee.io.WebParser
-> org.expeditee.io.flowlayout.XGroupItem
-> org.expeditee.items.Dot
-> org.expeditee.items.Item
-> org.expeditee.items.ItemUtils
-> org.expeditee.network.FrameShare
-> org.expeditee.stats.TreeStats


Created ItemsList class to wrap ArrayList<Item>. Frames now use this new class to store its body list (used for display) as well as its primaryBody and surrogateBody.

-> org.expeditee.agents.Format
-> org.expeditee.agents.HFormat
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gui.Frame
-> org.expeditee.gui.FrameUtils


Refactorted Frame.setResort(bool) to Frame.invalidateSorted() to better function how it is intended to with a more accurate name.

-> org.expeditee.agents.Sort


When writing out .exp files and getting attributes to respond to LEFT + RIGHT click, boolean items are by default true. This has always been the case. An ammendment to this is that defaults can now be established.
Also added 'EnterClick' functionality. If cursored over a item with this property and you press enter, it acts as if you have clicked on it instead.

-> org.expeditee.assets.resources-public.framesets.authentication.1.exp to 6.exp
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gio.input.KBMInputEvent
-> org.expeditee.gio.javafx.JavaFXConversions
-> org.expeditee.gio.swing.SwingConversions
-> org.expeditee.gui.AttributeUtils
-> org.expeditee.io.Conversion
-> org.expeditee.io.DefaultFrameWriter
-> org.expeditee.items.Item


Fixed a bug caused by calling Math.abs on Integer.MIN_VALUE returning unexpected result. Due to zero being a thing, you cannot represent Math.abs(Integer.MIN_VALUE) in a Integer object. The solution is to use Integer.MIN_VALUE + 1 instead of Integer.MIN_VALUE.

-> org.expeditee.core.bounds.CombinationBounds
-> org.expeditee.io.flowlayout.DimensionExtent


Recoded the contains function in EllipticalBounds so that intersection tests containing circles work correctly.

-> org.expeditee.core.bounds.EllipticalBounds


Added toString() to PolygonBounds to allow for useful printing during debugging.

-> org.expeditee.core.bounds.PolygonBounds

Implemented Surrogate Mode!

-> org.expeditee.encryption.io.EncryptedExpReader
-> org.expeditee.encryption.io.EncryptedExpWriter
-> org.expeditee.encryption.items.surrogates.EncryptionDetail
-> org.expeditee.encryption.items.surrogates.Label
-> org.expeditee.gui.FrameUtils
-> org.expeditee.gui.ItemsList
-> org.expeditee.items.Item
-> org.expeditee.items.Text


???? Use Integer.MAX_VALUE cast to a float instead of Float.MAX_VALUE. This fixed some bug which I cannot remember.

-> org.expeditee.gio.TextLayoutManager
-> org.expeditee.gio.swing.SwingTextLayoutManager


Improved solution for dealing with the F10 key taking focus away from Expeditee due to it being a assessibility key.

-> org.expeditee.gio.swing.SwingInputManager


Renamed variable visibleItems in FrameGraphics.paintFrame to itemsToPaintCanditates to better represent functional intent.

-> org.expeditee.gui.FrameGraphics


Improved checking for if personal resources exist before recreating them

-> org.expeditee.gui.FrameIO


Repeated messages to message bay now have a visual feedback instead of just a beep. This visual feedback is in the form of a count of the amount of times it has repeated.

-> org.expeditee.gui.MessageBay


Updated comment on the Vector class to explain what vectors are.

-> org.expeditee.gui.Vector


Added constants to represent all of the property keys in DefaultFrameReader and DefaultFrameWriter.

-> org.expeditee.io.DefaultFrameReader
-> org.expeditee.io.DefaultFrameWriter


Updated the KeyList setting to be more heirarcial with how users will store their Secrets.

-> org.expeditee.settings.identity.secrets.KeyList

File size: 3.8 KB
Line 
1/**
2 * TreeProcessor.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.List;
22import java.util.Stack;
23
24import org.expeditee.gui.Frame;
25import org.expeditee.gui.FrameIO;
26import org.expeditee.items.Item;
27
28/**
29 * This class provides some generic methods that process a tree of Frames.
30 * Subclasses that only use text items can simply implement
31 * processTextItem(Text, int)
32 */
33public abstract class TreeProcessor extends DefaultAgent {
34
35 // the list of frames currently being processed
36 private Stack<FrameCounter> _frames = new Stack<FrameCounter>();
37
38 public TreeProcessor(String delay) {
39 super(delay);
40 }
41
42 public TreeProcessor() {
43 super();
44 }
45
46 /**
47 * Processes the Frame by calling processItem() for each unlinked item
48 * encountered. Linked items call processStartLinkItem(), then load the
49 * linked frame and process it recursively, upon returning
50 * processEndLinkItem() is called.
51 */
52 protected Frame process(Frame toProcess) {
53 if (_stop)
54 return null;
55
56 if (toProcess == null)
57 return null;
58
59 _frames.push(new FrameCounter(toProcess.getName(), -1));
60
61 // process the entire tree of frames in depth-first order
62 while (_frames.size() > 0) {
63 if (_stop)
64 return null;
65
66 FrameCounter cur = _frames.pop();
67
68 Frame next = FrameIO.LoadFrame(cur.frame);
69 if (next == null) {
70 message("There is no " + cur.frame + " Frame to display");
71 return null;
72 }
73
74 if (cur.index < 0) {
75 if (next != null)
76 overwriteMessage("Processing: " + next.getName());
77 processFrame(next);
78 }
79
80 // the items on the frame currently being processed.
81 List<Item> items = next.getSortedItems();
82
83 // resume from the next item in the list
84 for (int i = cur.index + 1; i < items.size(); i++) {
85 Item item = items.get(i);
86
87 // ignore annotation and framenames
88 if (!item.isAnnotation() && item.getID() >= 0) {
89 if (item.getLink() != null) {
90 cur.index = i;
91 _frames.push(cur);
92
93 Frame linked = FrameIO.LoadFrame(item.getAbsoluteLink());
94
95 // if the linked frame was found, then display it next
96 if (linked != null) {
97 FrameCounter fc = new FrameCounter(linked
98 .getName(), -1);
99 if (!_frames.contains(fc)) {
100 // remember what frame we are on before
101 // processing it
102 _frames.push(fc);
103
104 // processFrame(linked);
105
106 // process the loaded frame immediately
107 // (depth-first)
108 break;
109 }
110 }
111 }
112 }
113 }
114 }
115
116 return null;
117 }
118
119 protected abstract void processFrame(Frame toProcess);
120
121 /**
122 * Inner class used to keep track of what frames have been seen, as well as
123 * what Item in the Frame the processing was up to. Only Frame names are
124 * stored to keep memory usage down.
125 */
126 private class FrameCounter {
127 public int index;
128
129 public String frame;
130
131 public FrameCounter(String f, int i) {
132 frame = f.toLowerCase();
133 index = i;
134 }
135
136 @Override
137 public boolean equals(Object o) {
138 if (o instanceof FrameCounter)
139 return (((FrameCounter) o).frame.equals(frame));// && fc.index
140 // == index);
141
142 return false;
143 }
144 }
145
146}
Note: See TracBrowser for help on using the repository browser.