source: trunk/src/org/expeditee/agents/SwitchyardTree.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
RevLine 
[4]1package org.expeditee.agents;
2
3import java.awt.Color;
[108]4import java.awt.geom.Point2D;
[4]5
6import org.expeditee.gui.Frame;
7import org.expeditee.gui.FrameIO;
8import org.expeditee.items.Text;
9
10public class SwitchyardTree extends DefaultAgent {
11
12 @Override
13 protected Frame process(Frame frame) {
[121]14 //MessageBay.displayMessage("Running switchyard tree...");
[4]15
[19]16 for (Text textItem : frame.getBodyTextItems(false)) {
[4]17 // Delete all non-annotations with more that one letter
[108]18 if (textItem.getText().length() > 1){
[4]19 frame.removeItem(textItem);
[108]20 if(_stop)
21 return null;
22 }else {
[4]23 // goto child frame of any linked 1 letter items
24 String link = textItem.getAbsoluteLink();
25 if (link != null) {
26 Frame childFrame = FrameIO.LoadFrame(link);
27 if (childFrame != null) {
[108]28 Point2D.Float lastItemEnd = textItem.getEndParagraphPosition();
[19]29 for (Text childItem : childFrame.getBodyTextItems(false)) {
[4]30 // look for red items
31 if (childItem.getColor().equals(Color.RED)) {
32 // make a copy and add to parent frame
33 Text itemCopy = childItem.copy();
34 // add to the right of parent item
[108]35 lastItemEnd.setLocation(lastItemEnd.x + 20, lastItemEnd.y);
36 itemCopy.setPosition(lastItemEnd.x, lastItemEnd.y);
[4]37 lastItemEnd = itemCopy
38 .getEndParagraphPosition();
39 frame.addItem(itemCopy);
40 }
[45]41 _itemCount++;
[108]42 if(_stop)
43 return null;
[4]44 }
45 }
46 }
47 }
48 }
[45]49 _frameCount++;
[4]50 return null;
51 }
52}
Note: See TracBrowser for help on using the repository browser.