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

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

Made a few minor changes...

Also

For interactive widgets the border will not be selected if the user is inside the enclosed area

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 //MessageBay.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.getParagraphEndPosition();
29 for (Text childItem : childFrame.getBodyTextItems(false)) {
30 // look for red items (remember get color may be null
31 if (Color.RED.equals(childItem.getPaintColor())) {
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 .getParagraphEndPosition();
39 itemCopy.setID(frame.getNextItemID());
40 frame.addItem(itemCopy);
41 }
42 _itemCount++;
43 if(_stop)
44 return null;
45 }
46 }
47 }
48 }
49 }
50 _frameCount++;
51 return null;
52 }
53}
Note: See TracBrowser for help on using the repository browser.