source: trunk/src/org/expeditee/agents/SwitchyardTree.java@ 108

Last change on this file since 108 was 108, checked in by ra33, 16 years ago

Heaps of changes!!!!
Added circles...
Better drawing of lines etc etc

File size: 1.5 KB
Line 
1package org.expeditee.agents;
2
3import java.awt.Color;
4import java.awt.geom.Point2D;
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) {
14 //FrameGraphics.DisplayMessage("Running switchyard tree...");
15
16 for (Text textItem : frame.getBodyTextItems(false)) {
17 // Delete all non-annotations with more that one letter
18 if (textItem.getText().length() > 1){
19 frame.removeItem(textItem);
20 if(_stop)
21 return null;
22 }else {
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) {
28 Point2D.Float lastItemEnd = textItem.getEndParagraphPosition();
29 for (Text childItem : childFrame.getBodyTextItems(false)) {
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
35 lastItemEnd.setLocation(lastItemEnd.x + 20, lastItemEnd.y);
36 itemCopy.setPosition(lastItemEnd.x, lastItemEnd.y);
37 lastItemEnd = itemCopy
38 .getEndParagraphPosition();
39 frame.addItem(itemCopy);
40 }
41 _itemCount++;
42 if(_stop)
43 return null;
44 }
45 }
46 }
47 }
48 }
49 _frameCount++;
50 return null;
51 }
52}
Note: See TracBrowser for help on using the repository browser.