Changeset 156
- Timestamp:
- 07/25/08 09:24:45 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r154 r156 22 22 import org.expeditee.gui.FrameIO; 23 23 import org.expeditee.gui.FrameUtils; 24 import org.expeditee.gui.FreeItems; 24 25 import org.expeditee.gui.MessageBay; 25 26 import org.expeditee.io.Conversion; … … 38 39 * When adding an action to a class in the actions folder the following must be 39 40 * considered: 40 * <li> If the first parameter is of type Frame or Item they will be called with 41 * the current frame and the item used to execute the action.</li> 42 * <li> If the second item is also of type Frame or Item it will be set to the 43 * current frame or item.</li> 41 * <li> If the first parameter is of type Frame, the current frame will be 42 * passed as a parameter. 43 * <li> If the next param is of type Item the item on the end of the cursor will 44 * be passed or the item that was clicked to execute the action if nothing is on 45 * the end of the cursor. current frame or item.</li> 44 46 * <li> If there are multiple overloads for the same method they should be 45 47 * declared in order of the methods with the most parameteres to least … … 383 385 * The starting Frame that the JAG is being launched on 384 386 */ 385 private static void LaunchAgent(String name, String parameters, Frame source, Item clicked) { 387 private static void LaunchAgent(String name, String parameters, 388 Frame source, Item clicked) { 386 389 // Use the correct case version for printing error messages 387 390 String nameWithCorrectCase = name; … … 444 447 t.setPriority(Thread.MIN_PRIORITY); 445 448 449 Item itemParam = clicked; 450 if (FreeItems.textAttachedToCursor()) { 451 itemParam = FreeItems.getItemAttachedToCursor(); 452 } 453 446 454 // check for errors during initialisation 447 if (!_Agent.initialise(source, clicked)) {455 if (!_Agent.initialise(source, itemParam)) { 448 456 MessageBay.errorMessage("Error initialising agent: " 449 457 + nameWithCorrectCase); … … 521 529 Class[] paramTypes = method.getParameterTypes(); 522 530 531 int paramCount = paramTypes.length; 523 532 // if the method has no parameters 524 if (param Types.length== 0)533 if (paramCount == 0) 525 534 return new Object[0]; 526 535 527 Object[] objects = new Object[param Types.length];536 Object[] objects = new Object[paramCount]; 528 537 int ind = 0; 529 538 … … 531 540 // or launcher 532 541 // length must be at least one if we are still running 533 if (paramTypes[0] == Frame.class) { 534 objects[0] = source; 535 ind = 1; 536 } else if (Item.class.isAssignableFrom(paramTypes[0])) { 537 objects[0] = launcher; 538 ind = 1; 539 } 540 541 // if the first class was a frame or item, the second class might be the 542 // other 543 if (paramTypes.length > 1 && objects[0] != null) { 544 if (paramTypes[1] == Frame.class) { 545 objects[1] = source; 546 ind = 2; 547 } else if (Item.class.isAssignableFrom(paramTypes[1])) { 548 objects[1] = launcher; 549 ind = 2; 550 } 542 if (paramTypes[ind] == Frame.class) { 543 objects[ind] = source; 544 ind++; 545 } 546 547 if (paramCount > ind && Item.class.isAssignableFrom(paramTypes[ind])) { 548 objects[ind] = launcher; 549 ind++; 551 550 } 552 551 … … 670 669 */ 671 670 public static String getCapitalizedFontName(String fontName) { 672 // Initialize the fonts if they have not already been loaded671 // Initialize the fonts if they have not already been loaded 673 672 initFonts(); 674 673 return _Fonts.get(fontName.toLowerCase()); … … 688 687 } 689 688 } 690 691 public static HashMap<String, String> getFonts() {689 690 public static HashMap<String, String> getFonts() { 692 691 initFonts(); 693 692 return _Fonts; -
trunk/src/org/expeditee/actions/Misc.java
r154 r156 9 9 import java.io.IOException; 10 10 import java.lang.reflect.Method; 11 import java.text.NumberFormat; 11 12 import java.util.ArrayList; 12 13 import java.util.Collection; 13 14 import java.util.List; 15 import java.util.Observable; 16 import java.util.Observer; 14 17 15 18 import javax.imageio.ImageIO; 16 19 20 import org.expeditee.gui.AttributeUtils; 21 import org.expeditee.gui.AttributeValuePair; 17 22 import org.expeditee.gui.DisplayIO; 18 23 import org.expeditee.gui.Frame; … … 28 33 import org.expeditee.stats.StatsLogger; 29 34 import org.expeditee.stats.TreeStats; 35 import org.nfunk.jep.Node; 36 import org.nfunk.jep.Variable; 30 37 31 38 /** … … 88 95 action); 89 96 } 97 } else { 98 MessageBay.errorMessage("Item must be a text item."); 90 99 } 91 100 } … … 106 115 if (deletedFrameName != null) { 107 116 DisplayIO.Back(); 108 //Remove any links on the previous frame to the one being deleted 117 // Remove any links on the previous frame to the one being 118 // deleted 109 119 Frame current = DisplayIO.getCurrentFrame(); 110 120 for (Item i : current.getItems()) … … 116 126 MessageBay.displayMessage(deletedFrame + " renamed " 117 127 + deletedFrameName); 118 // FrameGraphics.Repaint();128 // FrameGraphics.Repaint(); 119 129 return; 120 130 } … … 645 655 return item; 646 656 } 657 658 public static void calculate(Frame frame, Item toCalculate) { 659 if (toCalculate instanceof Text) { 660 Text text = (Text) toCalculate; 661 org.nfunk.jep.JEP myParser = new org.nfunk.jep.JEP(); 662 myParser.addStandardFunctions(); 663 myParser.addStandardConstants(); 664 myParser.setImplicitMul(true); 665 666 Observer observer = new Observer() { 667 private String _attribute = ""; 668 public void update(Observable ob, Object o) { 669 _attribute = ((Variable)o).getName() + ": "; 670 } 671 672 @Override 673 public String toString() { 674 return _attribute; 675 } 676 }; 677 678 // Check for variables 679 for (Text t : frame.getTextItems()) { 680 AttributeValuePair avp = AttributeUtils.getPair(t.getText()); 681 if (avp != null) { 682 myParser.addVariable(avp.getAttribute(), avp 683 .getDoubleValue()); 684 } 685 } 686 687 myParser.getSymbolTable().addObserver(observer); 688 myParser.setAllowAssignment(true); 689 myParser.setAllowUndeclared(true); 690 691 // Do the calculation 692 Node node = myParser.parseExpression(text.getText()); 693 if (node == null) { 694 for (String s : myParser.getErrorInfo().split("\n")) { 695 MessageBay.errorMessage(s); 696 } 697 } else { 698 Double result = myParser.getValue(); 699 NumberFormat nf = NumberFormat.getInstance(); 700 nf.setMinimumFractionDigits(0); 701 nf.setMaximumFractionDigits(15); 702 text.setText(observer.toString() + nf.format(result)); 703 text.setPosition(FrameMouseActions.MouseX, 704 FrameMouseActions.MouseY); 705 FrameMouseActions.resetOffset(); 706 } 707 708 } 709 } 647 710 } -
trunk/src/org/expeditee/actions/Simple.java
r154 r156 24 24 import org.expeditee.agents.WriteTree; 25 25 import org.expeditee.gui.AttributeUtils; 26 import org.expeditee.gui.Browser; 26 27 import org.expeditee.gui.DisplayIO; 27 28 import org.expeditee.gui.Frame; … … 312 313 t.start(); 313 314 } else { 314 assert (testSuite.runSuite()); 315 if (!testSuite.runSuite()){ 316 throw new RuntimeException(frameset + " failed"); 317 } 315 318 } 316 319 … … 826 829 .getVariable(tokens[1]).getValue(); 827 830 boolean bFound = false; 828 for (Text itemToSearch : frameToSearch.getBodyTextItems(true, 829 true)) { 831 for (Text itemToSearch : frameToSearch.getTextItems()) { 830 832 bFound = context.searchItem(itemToSearch, context 831 833 .getPrimitives().getStringValue(tokens[2]), … … 862 864 tokens[2]); 863 865 SearchAgent searchAgent = new SearchFrameset(); 864 searchAgent.initialise( frameset, resultsFrameset,866 searchAgent.initialise(null, null, frameset, resultsFrameset, 865 867 replacementString, pattern); 866 868 _agent = searchAgent; … … 899 901 SearchAgent searchAgent = new SearchTree(); 900 902 _agent = searchAgent; 901 searchAgent.initialise( topFrameName, resultsFrameset,903 searchAgent.initialise(null, null, topFrameName, resultsFrameset, 902 904 replacementString, pattern); 903 905 searchAgent.run(); … … 962 964 Item valueItem = null; 963 965 // Begin the search 964 for (Text text : targetFrame.get BodyTextItems(true)){966 for (Text text : targetFrame.getTextItems()){ 965 967 String s = text.getText().toLowerCase(); 966 968 … … 978 980 .getParagraphEndPosition(); 979 981 980 for (Text text : targetFrame.get BodyTextItems(true)) {982 for (Text text : targetFrame.getTextItems()) { 981 983 Point startPoint = text.getPosition(); 982 984 if (Math.abs(startPoint.y - endPoint.y) < 10 … … 1196 1198 Item valueItem = null; 1197 1199 // Begin the search 1198 for (Text text : targetFrame.get BodyTextItems(true)) {1200 for (Text text : targetFrame.getTextItems()) { 1199 1201 String s = text.getText().toLowerCase(); 1200 1202 if (s.startsWith(targetAttribute)) { … … 1213 1215 .getParagraphEndPosition(); 1214 1216 1215 for (Text text : targetFrame.get BodyTextItems(true)) {1217 for (Text text : targetFrame.getTextItems()) { 1216 1218 Point startPoint = text.getPosition(); 1217 1219 if (Math.abs(startPoint.y - endPoint.y) < 10 … … 1254 1256 context.getPrimitives().setValue(frameNameVar, 1255 1257 frame.getName()); 1256 } else if (tokens[0].startsWith("getframefilepath")) { 1258 } else if (tokens[0].startsWith("getframetitle")) { 1259 String frameTitleVar = DEFAULT_ITEM; 1260 String frameVar = DEFAULT_FRAME; 1261 1262 if (tokens.length > 1) { 1263 assertExactParametreCount(tokens, 2); 1264 assertVariableType(tokens[1], 1, SPointer.framePrefix); 1265 assertVariableType(tokens[2], 2, SPointer.itemPrefix); 1266 frameTitleVar = tokens[2]; 1267 frameVar = tokens[1]; 1268 } 1269 Frame frame = (Frame) context.getPointers().getVariable( 1270 frameVar).getValue(); 1271 context.getPointers().setObject(frameTitleVar, 1272 frame.getTitleItem()); 1273 }else if (tokens[0].startsWith("getframefilepath")) { 1257 1274 assertExactParametreCount(tokens, 2); 1258 1275 String frameName = context.getPrimitives().getStringValue( … … 1371 1388 // assertPrimitiveType(tokens[2], 2); 1372 1389 String link = ((Item) context.getPointers().getVariable( 1373 tokens[1]).getValue()).get Link();1390 tokens[1]).getValue()).getAbsoluteLink(); 1374 1391 context.getPrimitives().setValue(tokens[2], 1375 1392 new SString(link)); … … 1645 1662 } else if (ifStatement.equals("ifdefined")) { 1646 1663 result = context.isDefined(tokens[1]); 1647 } else if (ifStatement.equals("ifnotdef ")) {1664 } else if (ifStatement.equals("ifnotdefined")) { 1648 1665 result = !context.isDefined(tokens[1]); 1649 1666 } else if (ifStatement.equals("ifzero")) { … … 1982 1999 } else 1983 2000 context.readFrame(frameName, frameVar, null); 1984 } else if (tokens[0].equals("readkbdcond")) { 2001 }else if (tokens[0].equals("exitexpeditee")) { 2002 Browser._theBrowser.exit(); 2003 }else if (tokens[0].equals("readkbdcond")) { 1985 2004 1986 2005 String nextCharVarName = DEFAULT_CHAR; -
trunk/src/org/expeditee/agents/ComputeTree.java
r154 r156 5 5 import org.expeditee.gui.AttributeUtils; 6 6 import org.expeditee.gui.Frame; 7 import org.expeditee.gui.FrameGraphics;8 7 import org.expeditee.gui.FrameIO; 9 8 import org.expeditee.items.Item; -
trunk/src/org/expeditee/agents/DisplayTree.java
r154 r156 3 3 import org.expeditee.gui.DisplayIO; 4 4 import org.expeditee.gui.Frame; 5 import org.expeditee.gui.FrameUtils;6 5 import org.expeditee.gui.MessageBay; 7 6 import org.expeditee.items.Item; -
trunk/src/org/expeditee/agents/Format.java
r154 r156 52 52 ArrayList<Item> columnHeads = new ArrayList<Item>(); 53 53 54 ArrayList<ArrayList< Item>> columns = new ArrayList<ArrayList<Item>>();54 ArrayList<ArrayList<Text>> columns = new ArrayList<ArrayList<Text>>(); 55 55 56 for ( Itemt : itemsToFormat) {56 for (Text t : itemsToFormat) { 57 57 int col = findColumn(columnHeads, t); 58 58 // if this is the head of a new column 59 59 if (col < 0) { 60 60 columnHeads.add(t); 61 columns.add(new ArrayList< Item>());61 columns.add(new ArrayList<Text>()); 62 62 // otherwise the column for this item has already been 63 63 // found set the column to be the one we just added... … … 92 92 93 93 // sort lists by their X axis 94 Collections.sort(columns, new Comparator<ArrayList< Item>>() {95 public int compare(ArrayList< Item> o1, ArrayList<Item> o2) {94 Collections.sort(columns, new Comparator<ArrayList<Text>>() { 95 public int compare(ArrayList<Text> o1, ArrayList<Text> o2) { 96 96 if (o2.size() == 0) 97 97 return -10; … … 112 112 113 113 for (int i = 0; i < columns.size() - 1; i++) { 114 List< Item> list = columns.get(i);114 List<Text> list = columns.get(i); 115 115 116 116 int maxX = 0; -
trunk/src/org/expeditee/agents/SearchAgent.java
r143 r156 5 5 import org.expeditee.gui.FrameGraphics; 6 6 import org.expeditee.gui.FrameIO; 7 import org.expeditee.gui.FreeItems;8 import org.expeditee.gui.MessageBay;9 7 import org.expeditee.io.Conversion; 10 8 import org.expeditee.items.Item; … … 23 21 @Override 24 22 public boolean initialise(Frame frame, Item item) { 25 if (FreeItems.getInstance().size() != 1) { 26 MessageBay 27 .displayMessage("Attach search pattern to the end of the cursor"); 28 return false; 29 } 30 Item cursorItem = Frame.getItemAttachedToCursor(); 31 if (!(cursorItem instanceof Text)) 32 return false; 33 34 String pattern = ((Text) cursorItem).getText(); 23 String pattern = item.getText(); 35 24 String resultFrameset = null; 25 26 //TODO use a results frame specified on the profile frame 36 27 if (item.getLink() == null) { 37 28 resultFrameset = frame.getFramesetName(); … … 40 31 false); 41 32 } 42 return initialise(frame .getFramesetName(), resultFrameset, null, pattern);33 return initialise(frame, item, frame.getFramesetName(), resultFrameset, null, pattern); 43 34 } 44 35 45 public boolean initialise( String startName, String resultsFrameset,36 public boolean initialise(Frame frame, Item item, String startName, String resultsFrameset, 46 37 String replacementString, String pattern) { 47 38 _pattern = pattern; … … 57 48 _end = _results.getFirstFrame(); 58 49 59 return super.initialise( null, null);50 return super.initialise(frame, item); 60 51 } 61 52 … … 86 77 if (frameToSearch == null) 87 78 return false; 88 for (Text itemToSearch : frameToSearch.get VisibleTextItems()) {79 for (Text itemToSearch : frameToSearch.getTextItems()) { 89 80 // Search for the item and add it to the results page if 90 81 // it is found -
trunk/src/org/expeditee/agents/SearchTree.java
r134 r156 42 42 overwriteMessage("Searching " + frameName); 43 43 44 for (Text itemToSearch : frameToSearch.get VisibleTextItems()) {44 for (Text itemToSearch : frameToSearch.getTextItems()) { 45 45 // Search for the item and add it to the results page if 46 46 // it is found -
trunk/src/org/expeditee/gui/AttributeUtils.java
r154 r156 95 95 _GetMethods.add(Item.class.getMethod("getLink", param)); 96 96 _GetMethods.add(Item.class.getMethod("getFillColor", param)); 97 _GetMethods.add(Item.class.getMethod("getGradientColor", param)); 97 98 _GetMethods.add(Item.class.getMethod("getFillPattern", param)); 98 99 _GetMethods.add(Item.class.getMethod("getThickness", param)); … … 709 710 return null; 710 711 } 712 713 public static AttributeValuePair getPair(String text) { 714 //TODO Make this more efficient 715 String attribute = AttributeUtils.getAttribute(text); 716 String value = AttributeUtils.getValue(text); 717 if(attribute == null || value == null) 718 return null; 719 return new AttributeValuePair(attribute, value); 720 } 711 721 } -
trunk/src/org/expeditee/gui/Browser.java
r154 r156 102 102 } 103 103 104 p ublicstatic boolean isInitComplete() {104 private static boolean isInitComplete() { 105 105 return _initComplete; 106 106 } … … 428 428 } 429 429 430 public static Browser initialize(){ 431 if (Browser._theBrowser == null) { 432 Browser.main(null); 433 try { 434 while (!isInitComplete()) { 435 Thread.sleep(10); 436 } 437 } catch (Exception e) { 438 } 439 } 440 return _theBrowser; 441 } 442 430 443 } -
trunk/src/org/expeditee/gui/DisplayIO.java
r154 r156 62 62 * The title to display in the Title bar. 63 63 */ 64 public static final String TITLE = "Exp 18Jul2008A";64 public static final String TITLE = "Exp22Jul2008A"; 65 65 66 66 private DisplayIO() { … … 207 207 FrameMouseActions.setLastRobotMove(x, y); 208 208 209 if (Fr ame.itemAttachedToCursor()) {209 if (FreeItems.itemAttachedToCursor()) { 210 210 List<Item> toMove = FreeItems.getInstance(); 211 211 for (Item move : toMove) { -
trunk/src/org/expeditee/gui/Frame.java
r154 r156 237 237 } 238 238 239 public List<Text> getVisibleTextItems() {240 List<Text> textItems = new ArrayList<Text>();241 for (Item i : getItems(true)) {242 // only add up normal body text items243 if (i instanceof Text) {244 textItems.add((Text) i);245 }246 }247 return textItems;248 }249 250 239 public List<Item> getItems() { 251 240 return getItems(false); … … 264 253 265 254 /** 266 * Gets a list of all the non annotation text items on the frame, excluding267 * the title and frame name.255 * Returns a list of all the non annotation text items on the frame which 256 * are not the title or frame name or special annotation items. 268 257 * 269 258 * @param includeAnnotations 270 * true if annotations should be included in the list 271 * @return list of text items 272 */ 273 public List<Text> getBodyTextItems(boolean includeAnnotations) { 274 return getBodyTextItems(includeAnnotations, false); 275 } 276 277 /** 278 * Returns a list of all the non annotation text items on the frame which 279 * are not the title or frame name. 280 * 259 * true if annotation items without special meaning should be 260 * included 281 261 * @param includeLineEnds 282 262 * true if text on the end of lines should be included in the … … 284 264 * @return the list of body text items. 285 265 */ 286 public List<Text> getBodyTextItems(boolean includeAnnotations, 287 boolean includeLineEnds) { 266 public List<Text> getBodyTextItems(boolean includeAnnotations) { 288 267 List<Text> bodyTextItems = new ArrayList<Text>(); 289 268 for (Item i : getItems(true)) { 290 269 // only add up normal body text items 291 270 if ((i instanceof Text) 292 && (includeAnnotations || !i.isAnnotation()) 293 && (includeLineEnds || !i.isLineEnd())) { 271 && ((includeAnnotations && !((Text) i) 272 .isSpecialAnnotation()) || !i.isAnnotation()) 273 && !i.isLineEnd()) { 294 274 bodyTextItems.add((Text) i); 295 275 } … … 617 597 public void resetDateCreated() { 618 598 setDateCreated(Logger.EasyDateFormat("ddMMMyyyy:HHmm")); 599 setActiveTime(new Time(0)); 600 setDarkTime(new Time(0)); 601 setVersion(0); 619 602 } 620 603 … … 662 645 if (item == null || item.equals(_frameName) || _body.contains(item)) 663 646 return; 647 648 // When an annotation item is anchored the annotation list must be 649 // refreshed 650 if (item.isAnnotation()) { 651 clearAnnotations(); 652 } 664 653 665 654 if (item instanceof Line) … … 706 695 if (anchorRight != null) { 707 696 i.setX(width - anchorRight); 708 if (i.hasVector()){697 if (i.hasVector()) { 709 698 bReparse = true; 710 699 } … … 712 701 if (anchorBottom != null) { 713 702 i.setY(height - anchorBottom); 714 if (i.hasVector()){703 if (i.hasVector()) { 715 704 bReparse = true; 716 705 } 717 706 } 718 707 } 719 if (bReparse){708 if (bReparse) { 720 709 FrameUtils.Parse(this, false); 721 710 } … … 725 714 726 715 public void addAllItems(Collection<Item> toAdd) { 727 for (Item i : toAdd) 716 for (Item i : toAdd) { 717 // If an annotation is being deleted clear the annotation list 718 if (i.isAnnotation()) 719 i.getParentOrCurrentFrame().clearAnnotations(); 728 720 addItem(i); 721 } 729 722 } 730 723 731 724 public void removeAllItems(Collection<Item> toRemove) { 732 for (Item i : toRemove) 725 for (Item i : toRemove) { 726 // If an annotation is being deleted clear the annotation list 727 if (i.isAnnotation()) 728 i.getParentOrCurrentFrame().clearAnnotations(); 733 729 removeItem(i); 730 } 734 731 } 735 732 736 733 public void removeItem(Item item) { 734 // If an annotation is being deleted clear the annotation list 735 if (item.isAnnotation()) 736 item.getParentOrCurrentFrame().clearAnnotations(); 737 737 738 if (_body.remove(item)) { 738 739 change(); … … 954 955 } 955 956 956 public Item getItemAbove(Item current) { 957 public Text getTextAbove(Text current) { 958 Collection<Text> currentTextItems = FrameUtils.getCurrentTextItems(); 959 List<Text> toCheck = new ArrayList<Text>(); 960 if (currentTextItems.contains(current)) { 961 toCheck.addAll(currentTextItems); 962 } else { 963 toCheck.addAll(getTextItems()); 964 } 957 965 // Make sure the items are sorted 958 Collections.sort(_body); 959 int ind = _body.indexOf(current); 966 Collections.sort(toCheck); 967 968 int ind = toCheck.indexOf(current); 960 969 if (ind == -1) 961 970 return null; … … 963 972 // loop through all items above this one, return the first match 964 973 for (int i = ind - 1; i >= 0; i--) { 965 Item check = _body.get(i);966 if ( check.isVisible() &&FrameUtils.inSameColumn(check, current))974 Text check = toCheck.get(i); 975 if (FrameUtils.inSameColumn(check, current)) 967 976 return check; 968 977 } … … 992 1001 * The Item to get the column for. 993 1002 */ 994 public List< Item> getColumn(Item from) {1003 public List<Text> getColumn(Item from) { 995 1004 // Check that this item is on the current frame 996 1005 if (!_body.contains(from)) 997 1006 return null; 998 1007 999 // Make sure the items are sorted1000 Collections.sort(_body);1001 1002 1008 if (from == null) { 1003 1009 from = getLastNonAnnotationTextItem(); … … 1007 1013 return null; 1008 1014 1009 List<Item> column = new ArrayList<Item>(); 1015 // Get the enclosedItems 1016 Collection<Text> enclosed = FrameUtils.getCurrentTextItems(); 1017 List<Text> toCheck = null; 1018 if (enclosed.contains(from)) { 1019 toCheck = new ArrayList<Text>(); 1020 toCheck.addAll(enclosed); 1021 } else { 1022 toCheck = getBodyTextItems(true); 1023 } 1024 1025 // Make sure the items are sorted 1026 Collections.sort(toCheck); 1027 1028 List<Text> column = new ArrayList<Text>(); 1010 1029 1011 1030 // Create a list of items consisting of the item 'from' and all the 1012 1031 // items below it which are also in the same column as it 1013 for (int i = _body.indexOf(from); i < _body.size(); i++) { 1014 Item item = _body.get(i); 1015 if (item.isVisible() && isNormalTextItem(item)) { 1016 if (FrameUtils.inSameColumn(from, item)) 1017 column.add(item); 1018 } 1032 for (int i = toCheck.indexOf(from); i < toCheck.size(); i++) { 1033 Text item = toCheck.get(i); 1034 if (FrameUtils.inSameColumn(from, item)) 1035 column.add(item); 1019 1036 } 1020 1037 … … 1314 1331 _body = newBody; 1315 1332 change(); 1333 1334 if (!keepAnnotations) 1335 _annotations.clear(); 1316 1336 } 1317 1337 … … 1352 1372 // Make it the width of the page 1353 1373 // t.setMaxWidth(FrameGraphics.getMaxFrameSize().width); 1354 // if (t.getWidth() <= 0) {1355 1356 // }1374 // if (t.getWidth() <= 0) { 1375 t.setRightMargin(FrameGraphics.getMaxFrameSize().width); 1376 // } 1357 1377 addItem(t); 1358 1378 return t; … … 1460 1480 && (FreeItems.getInstance().get(0) instanceof Line || FreeItems 1461 1481 .getInstance().get(1) instanceof Line); 1462 }1463 1464 public static boolean itemAttachedToCursor() {1465 return FreeItems.getInstance().size() > 0;1466 }1467 1468 public static boolean textItemAttachedToCursor() {1469 return itemAttachedToCursor()1470 && FreeItems.getInstance().get(0) instanceof Text;1471 }1472 1473 // TODO move this method to FreeItems1474 public static Item getItemAttachedToCursor() {1475 if (itemAttachedToCursor())1476 return FreeItems.getInstance().get(0);1477 1478 return null;1479 1482 } 1480 1483 … … 1548 1551 if (t.getText().equals("")) 1549 1552 DisplayIO.getCurrentFrame().removeItem(t); 1550 if (!Fr ame.itemAttachedToCursor()) {1553 if (!FreeItems.itemAttachedToCursor()) { 1551 1554 DisplayIO.setCursorPosition(((Text) it) 1552 1555 .getParagraphEndPosition()); … … 1710 1713 1711 1714 public void addAnnotation(Text item) { 1715 if (_annotations == null) { 1716 _annotations = new HashMap<String, Text>(); 1717 } 1712 1718 // Check if this item has already been processed 1713 1719 String[] tokens = item.getProcessedText(); … … 1755 1761 1756 1762 public boolean hasAnnotation(String annotation) { 1763 if (_annotations == null) 1764 refreshAnnotationList(); 1757 1765 return _annotations.containsKey(annotation.toLowerCase()); 1758 1766 } 1759 1767 1760 1768 public String getAnnotationValue(String annotation) { 1769 if (_annotations == null) 1770 refreshAnnotationList(); 1771 1761 1772 Text text = _annotations.get(annotation.toLowerCase()); 1762 1773 if (text == null) … … 1769 1780 } 1770 1781 1771 Map<String, Text> _annotations = n ew HashMap<String, Text>();1782 Map<String, Text> _annotations = null; 1772 1783 1773 1784 public void clearAnnotations() { 1774 _annotations .clear();1785 _annotations = null; 1775 1786 } 1776 1787 … … 1779 1790 } 1780 1791 1792 private void refreshAnnotationList() { 1793 if (_annotations == null) 1794 _annotations = new HashMap<String, Text>(); 1795 else 1796 _annotations.clear(); 1797 for (Text text : getTextItems()) { 1798 if (text.isAnnotation()) { 1799 addAnnotation(text); 1800 } 1801 } 1802 } 1803 1781 1804 public Collection<Text> getAnnotationItems() { 1805 if (_annotations == null) { 1806 refreshAnnotationList(); 1807 } 1782 1808 return _annotations.values(); 1783 1809 } … … 1851 1877 return vectorItems; 1852 1878 } 1879 1880 /** 1881 * Gets a list of all the text items on the frame. 1882 * 1883 * @return 1884 */ 1885 public Collection<Text> getTextItems() { 1886 Collection<Text> textItems = new ArrayList<Text>(); 1887 for (Item i : getItems(true)) { 1888 // only add up normal body text items 1889 if ((i instanceof Text)) { 1890 textItems.add((Text) i); 1891 } 1892 } 1893 return textItems; 1894 } 1853 1895 } -
trunk/src/org/expeditee/gui/FrameGraphics.java
r154 r156 658 658 if (toDisconnect != null && !(i instanceof WidgetEdge)) { 659 659 Item.HighlightMode newMode = toDisconnect.getHighlightMode(); 660 if (Fr ame.itemAttachedToCursor())660 if (FreeItems.itemAttachedToCursor()) 661 661 newMode = Item.HighlightMode.Normal; 662 662 // unhighlight all the other dots -
trunk/src/org/expeditee/gui/FrameIO.java
r154 r156 567 567 } 568 568 } 569 570 569 return template; 571 570 } … … 947 946 948 947 Frame newFrame = FrameIO.CreateFrame(frameset, title, templateLink); 949 950 948 return newFrame; 951 949 } -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r154 r156 12 12 import java.util.ArrayList; 13 13 import java.util.Collection; 14 import java.util.Collections; 14 15 import java.util.HashSet; 15 16 import java.util.LinkedList; … … 444 445 Frame current = DisplayIO.getCurrentFrame(); 445 446 Item title = current.getTitleItem(); 446 List<Text> textItems = current.getBodyTextItems(false); 447 448 Collection<Text> currentItems = FrameUtils.getCurrentTextItems(); 449 List<Text> textItems = new ArrayList<Text>(); 450 // Move to the next text item in the box if 451 if (currentItems.contains(currentItem)) { 452 textItems.addAll(currentItems); 453 } else { 454 textItems.add(current.getTitleItem()); 455 textItems.addAll(current.getBodyTextItems(true)); 456 } 457 458 Collections.sort(textItems); 459 447 460 if (textItems.size() == 0) { 448 461 // If there are no text items on the frame its a NoOp … … 484 497 return; 485 498 } 486 // If the user is on the title item487 if (current != null && title != null && title == currentItem) {488 if (down) {489 // Move to the first item490 DisplayIO.MoveCursorToEndOfItem(textItems.get(0));491 FrameGraphics.Repaint();492 }493 return;494 }495 499 496 500 // Find the current item... then move to the next item … … 498 502 499 503 int nextIndex = i + (down ? 1 : -1); 500 if (nextIndex >= 0) { 501 if (nextIndex < textItems.size()) { 502 DisplayIO.MoveCursorToEndOfItem(textItems.get(nextIndex)); 503 } 504 } else if (title != null) { 505 DisplayIO.MoveCursorToEndOfItem(title); 504 if (nextIndex >= 0 && nextIndex < textItems.size()) { 505 DisplayIO.MoveCursorToEndOfItem(textItems.get(nextIndex)); 506 } else { 507 DisplayIO.MoveCursorToEndOfItem(currentItem); 506 508 } 507 509 FrameGraphics.Repaint(); … … 894 896 // get whatever the user is pointing at 895 897 Item on = FrameUtils.getCurrentItem(); 898 896 899 // check for enclosed mode 897 900 if (on == null && key.ordinal() < FunctionKey.AudienceMode.ordinal()) { 898 901 Collection<Item> enclosed = FrameUtils.getCurrentItems(on); 899 902 900 903 if (enclosed != null && enclosed.size() > 0) { 901 904 // ensure only one dot\line is present in the list … … 1054 1057 1055 1058 // Get the list of items that must be dropped 1056 List< Item> column = DisplayIO.getCurrentFrame().getColumn(1059 List<Text> column = DisplayIO.getCurrentFrame().getColumn( 1057 1060 toDropFrom); 1058 1061 … … 1071 1074 Text dummyItem = null; 1072 1075 1073 if (Fr ame.textItemAttachedToCursor()) {1074 dummyItem = (Text) Fr ame.getItemAttachedToCursor();1076 if (FreeItems.textAttachedToCursor()) { 1077 dummyItem = (Text) FreeItems.getItemAttachedToCursor(); 1075 1078 String autoBullet = getAutoBullet(dummyItem.getText()); 1076 1079 … … 1080 1083 } 1081 1084 dummyItem = createText(); 1082 if (Fr ame.textItemAttachedToCursor()) {1083 Text t = (Text) Fr ame.getItemAttachedToCursor();1085 if (FreeItems.textAttachedToCursor()) { 1086 Text t = (Text) FreeItems.getItemAttachedToCursor(); 1084 1087 dummyItem.setSize(t.getSize()); 1085 1088 int lines = t.getTextList().size(); … … 1144 1147 } 1145 1148 } 1146 if (!Fr ame.textItemAttachedToCursor() && !dummyItem.isEmpty()) {1149 if (!FreeItems.textAttachedToCursor() && !dummyItem.isEmpty()) { 1147 1150 DisplayIO.getCurrentFrame().addItem(dummyItem); 1148 1151 } 1149 1152 1150 1153 // Move the item to the cursor position 1151 if (Fr ame.itemAttachedToCursor()) {1154 if (FreeItems.itemAttachedToCursor()) { 1152 1155 DisplayIO.setCursorPosition(dummyItem.getX(), dummyItem 1153 1156 .getY()); 1154 Item firstItem = Fr ame.getItemAttachedToCursor();1157 Item firstItem = FreeItems.getItemAttachedToCursor(); 1155 1158 int deltaX = firstItem.getX() - dummyItem.getX(); 1156 1159 int deltaY = firstItem.getY() - dummyItem.getY(); … … 1164 1167 } 1165 1168 if (dummyItem.getText().length() == 0 1166 || Fr ame.itemAttachedToCursor())1169 || FreeItems.itemAttachedToCursor()) 1167 1170 dummyItem.getParentOrCurrentFrame().removeItem(dummyItem); 1168 1171 dummyItem.setRightMargin(FrameGraphics.getMaxFrameSize().width); … … 1349 1352 // if the user is not pointing to any item 1350 1353 if (item == null) { 1351 if (Fr ame.itemAttachedToCursor())1354 if (FreeItems.itemAttachedToCursor()) 1352 1355 toSize.addAll(FreeItems.getInstance()); 1353 1356 else { … … 1532 1535 Frame currentFrame = DisplayIO.getCurrentFrame(); 1533 1536 if (item == null) { 1534 if (Fr ame.itemAttachedToCursor()) {1537 if (FreeItems.itemAttachedToCursor()) { 1535 1538 color = FreeItems.getInstance().get(0).getColor(); 1536 1539 } else { … … 1596 1599 1597 1600 if (setBackgroundColor) { 1598 if (item == null && Fr ame.itemAttachedToCursor()) {1601 if (item == null && FreeItems.itemAttachedToCursor()) { 1599 1602 for (Item i : FreeItems.getInstance()) 1600 1603 i.setBackgroundColor(color); … … 1604 1607 } 1605 1608 } else { 1606 if (item == null && Fr ame.itemAttachedToCursor()) {1609 if (item == null && FreeItems.itemAttachedToCursor()) { 1607 1610 for (Item i : FreeItems.getInstance()) 1608 1611 i.setColor(color); -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r147 r156 246 246 NavigationActions.ResetLastAddToBack(); 247 247 // System.out.println(modifiersEx); 248 if (_mouseDown == 0) 249 _lastMouseClickDate = new Date(); 250 248 251 int buttonPressed = e.getButton(); 249 252 _mouseDown += buttonPressed; 250 251 _lastMouseClickDate = new Date();252 253 _lastClickedOn = FrameUtils.getCurrentItem(); 253 254 // load any frame if necessary … … 321 322 if (buttonPressed != MouseEvent.BUTTON1 322 323 && (_context == CONTEXT_FREESPACE || _context == CONTEXT_AT_ENCLOSURE) 323 && Fr ame.itemAttachedToCursor()) {324 && FreeItems.itemAttachedToCursor()) { 324 325 FrameGraphics.changeHighlightMode(_lastHighlightedItem, 325 326 Item.HighlightMode.None); 326 327 327 _lastHighlightedItem = Fr ame.getItemAttachedToCursor();328 _lastHighlightedItem = FreeItems.getItemAttachedToCursor(); 328 329 for (Item i : FreeItems.getInstance()) { 329 330 i.setHighlightColor(Item.DEPRESSED_HIGHLIGHT); … … 444 445 Item.HighlightMode.None); 445 446 446 if (Fr ame.itemAttachedToCursor()) {447 if (FreeItems.itemAttachedToCursor()) { 447 448 move(FreeItems.getInstance()); 448 449 } … … 461 462 if (lastRanged != null) { 462 463 463 Item i = Fr ame.getItemAttachedToCursor();464 Item i = FreeItems.getItemAttachedToCursor(); 464 465 if (i != null && i instanceof Text) { 465 466 lastRanged.replaceSelectedText(((Text) i).getText()); … … 518 519 return; 519 520 } 520 // if the entire text is selected then pickup the item 521 if (lastRanged.getSelectionSize() == lastRanged.getLength()) { 521 // if the entire text is selected and its not a line end then 522 // pickup the item 523 boolean entireText = lastRanged.getSelectionSize() == lastRanged 524 .getLength(); 525 if (entireText && !lastRanged.isLineEnd()) { 522 526 pickup(lastRanged); 523 527 lastRanged.clearSelection(); 524 FrameGraphics. Repaint();528 FrameGraphics.refresh(true); 525 529 return; 526 530 } else { 527 531 ranged.setText(lastRanged.cutSelectedText()); 532 ranged.setWidth(lastRanged.getWidth()); 533 // If its the whole text then replace last ranged with a dot 534 if (entireText) { 535 Item dot = FrameKeyboardActions.replaceText(lastRanged); 536 dot.setHighlightMode(HighlightMode.None); 537 } 528 538 } 529 539 // if the user is copying text from the item … … 539 549 } 540 550 ranged.setText(lastRanged.copySelectedText()); 551 ranged.setWidth(lastRanged.getWidth()); 541 552 } 542 553 … … 545 556 ranged.setPosition(DisplayIO.getMouseX(), FrameMouseActions.getY()); 546 557 pickup(ranged); 547 548 558 lastRanged.clearSelection(); 549 FrameGraphics.Repaint(); 559 lastRanged.setHighlightMode(HighlightMode.None); 560 refreshHighlights(); 561 FrameGraphics.refresh(false); 550 562 return; 551 563 } … … 591 603 if (e.getButton() == MouseEvent.BUTTON2) { 592 604 SessionStats.AddFrameEvent("Mu"); 593 middleButton(clickedOn, clickedIn );605 middleButton(clickedOn, clickedIn, e.isShiftDown()); 594 606 return; 595 607 } … … 609 621 * This method handles all left-click actions 610 622 */ 611 private staticvoid leftButton(Item clicked, Collection<Item> clickedIn) {623 private void leftButton(Item clicked, Collection<Item> clickedIn) { 612 624 // if the user is pointing at something then either follow the link or 613 625 // do TDFC … … 710 722 if (clicked.isLineEnd() 711 723 || clicked.getAllConnected().contains( 712 Fr ame.getItemAttachedToCursor())) {724 FreeItems.getItemAttachedToCursor())) { 713 725 return true; 714 726 } … … 718 730 return false; 719 731 720 Item attachedToCursor = Fr ame.getItemAttachedToCursor();732 Item attachedToCursor = FreeItems.getItemAttachedToCursor(); 721 733 722 734 if (clicked instanceof Text … … 731 743 public static void middleButton() { 732 744 Item currentItem = FrameUtils.getCurrentItem(); 733 middleButton(currentItem, FrameUtils.getCurrentItems(currentItem)); 745 getInstance().middleButton(currentItem, 746 FrameUtils.getCurrentItems(currentItem), false); 734 747 updateCursor(); 735 748 } … … 737 750 public static void rightButton() { 738 751 Item currentItem = FrameUtils.getCurrentItem(); 739 rightButton(currentItem, FrameUtils.getCurrentItems(currentItem)); 752 getInstance().rightButton(currentItem, 753 FrameUtils.getCurrentItems(currentItem)); 740 754 updateCursor(); 741 755 } … … 743 757 public static void leftButton() { 744 758 Item currentItem = FrameUtils.getCurrentItem(); 745 leftButton(currentItem, FrameUtils.getCurrentItems(currentItem)); 759 getInstance().leftButton(currentItem, 760 FrameUtils.getCurrentItems(currentItem)); 746 761 updateCursor(); 747 762 } … … 750 765 * This method handles all middle-click actions 751 766 */ 752 private static void middleButton(Item clicked, Collection<Item> clickedIn) { 767 private void middleButton(Item clicked, Collection<Item> clickedIn, 768 boolean isShiftDown) { 753 769 // if the cursor has Items attached 754 if (Fr ame.itemAttachedToCursor()) {770 if (FreeItems.itemAttachedToCursor()) { 755 771 // if the user is pointing at something, merge the items (if 756 772 // possible) … … 763 779 return; 764 780 } 765 Item merger = Fr ame.getItemAttachedToCursor();781 Item merger = FreeItems.getItemAttachedToCursor(); 766 782 assert (merger != null); 767 Collection<Item> left = merge(FreeItems.getInstance(), clicked); 783 Collection<Item> left = null; 784 // when anchoring a line end onto a text line end, holding shift 785 // prevents the line ends from being merged 786 if (isShiftDown) { 787 left = FreeItems.getInstance(); 788 } else { 789 left = merge(FreeItems.getInstance(), clicked); 790 } 768 791 anchor(left); 769 792 FreeItems.getInstance().clear(); 770 FrameGraphics.Repaint();771 793 updateCursor(); 794 // Make sure the dot goes away when anchoring a line end behind 795 // a text line end 796 if (isShiftDown) { 797 refreshHighlights(); 798 } 772 799 return; 773 800 // otherwise, anchor the items 774 801 } else { 775 if(clickedIn != null && FreeItems.getInstance().size() == 1){ 776 Item item = Frame.getItemAttachedToCursor(); 777 if(item instanceof Text){ 778 Text text = (Text)item; 779 if(AttributeUtils.setAttribute(text, text)){ 780 clickedIn.removeAll(FrameUtils.getEnclosingLineEnds().iterator().next().getAllConnected()); 781 for(Item i: clickedIn){ 802 if (clickedIn != null && FreeItems.getInstance().size() == 1) { 803 Item item = FreeItems.getItemAttachedToCursor(); 804 if (item instanceof Text) { 805 Text text = (Text) item; 806 if (AttributeUtils.setAttribute(text, text)) { 807 clickedIn.removeAll(FrameUtils 808 .getEnclosingLineEnds().iterator().next() 809 .getAllConnected()); 810 for (Item i : clickedIn) { 782 811 AttributeUtils.setAttribute(i, text); 783 812 } … … 786 815 } 787 816 } 788 817 789 818 // if a line is being rubber-banded, check for auto 790 819 // straightening … … 974 1003 * This method handles all right-click action 975 1004 */ 976 private staticvoid rightButton(Item clicked, Collection<Item> clickedIn) {1005 private void rightButton(Item clicked, Collection<Item> clickedIn) { 977 1006 // if the cursor has Items attached, then anchor a copy of them 978 1007 979 1008 List<Item> copies = null; 980 if (Fr ame.itemAttachedToCursor()) {1009 if (FreeItems.itemAttachedToCursor()) { 981 1010 // if the user is clicking on something, merge the items 982 1011 // unless it is a point onto somethin other than a lineEnd or a dot 983 1012 if (clicked != null 984 1013 // TODO Change the items merge methods so the logic is simplified 985 && (!(Fr ame.getItemAttachedToCursor() instanceof Dot)1014 && (!(FreeItems.getItemAttachedToCursor() instanceof Dot) 986 1015 || clicked instanceof Dot || clicked.isLineEnd())) { 987 1016 // check permissions … … 1673 1702 refreshHighlights(); 1674 1703 1675 if (Fr ame.itemAttachedToCursor()) {1704 if (FreeItems.itemAttachedToCursor()) { 1676 1705 move(FreeItems.getInstance()); 1677 1706 // System.out.println(FreeItems.getInstance().size()); … … 1767 1796 1768 1797 // disable cursor changes when the cursor has items attached 1769 if (Fr ame.itemAttachedToCursor()1798 if (FreeItems.itemAttachedToCursor() 1770 1799 && DisplayIO.getCursor() != Item.TEXT_CURSOR) 1771 1800 _forceArrowCursor = false; … … 1849 1878 1850 1879 public static void resetOffset() { 1851 if (Fr ame.itemAttachedToCursor()) {1880 if (FreeItems.itemAttachedToCursor()) { 1852 1881 _offX = DisplayIO.getMouseX() 1853 1882 - FreeItems.getInstance().get(0).getX() … … 1891 1920 1892 1921 // repaint things if necessary 1893 if (Fr ame.itemAttachedToCursor())1922 if (FreeItems.itemAttachedToCursor()) 1894 1923 move(FreeItems.getInstance()); 1895 1924 } … … 1918 1947 linker.setLink("" + next.getNumber()); 1919 1948 1920 for (Item i : next.get BodyTextItems(true)) {1949 for (Item i : next.getTextItems()) { 1921 1950 // Set the link for @Parent annotation item if one 1922 1951 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_PARENT) … … 1955 1984 return; 1956 1985 1957 if (Fr ame.itemAttachedToCursor())1986 if (FreeItems.itemAttachedToCursor()) 1958 1987 return; 1959 1988 … … 1983 2012 _offX = _offY = 0; 1984 2013 2014 Frame current = DisplayIO.getCurrentFrame(); 1985 2015 // check if the user is pointing at the frame's framename 1986 2016 if (toDelete != null 1987 && toDelete == DisplayIO.getCurrentFrame().getNameItem()) {1988 DisplayIO.getCurrentFrame().clear(false);2017 && toDelete == current.getNameItem()) { 2018 current.clear(false); 1989 2019 FrameGraphics.Repaint(); 1990 2020 return; … … 1992 2022 1993 2023 // if the user is deleting items attached to the cursor 1994 if (Fr ame.itemAttachedToCursor()) {2024 if (FreeItems.itemAttachedToCursor()) { 1995 2025 // if this is an item-swap 1996 2026 if (FreeItems.getInstance().size() == 1 … … 2085 2115 } 2086 2116 2087 Frame current = toDelete.getParent();2088 if ( current != null) {2089 current.setChanged(true);2117 Frame parent = toDelete.getParent(); 2118 if (parent != null) { 2119 parent.setChanged(true); 2090 2120 } 2091 2121 Collection<Item> toUndo = null; … … 2114 2144 } 2115 2145 SessionStats.DeletedItems(toUndo); 2116 if ( current != null) {2117 current.addAllToUndo(toUndo);2118 current.removeAllItems(toUndo); // toDelete.getConnected()2146 if (parent != null) { 2147 parent.addAllToUndo(toUndo); 2148 parent.removeAllItems(toUndo); // toDelete.getConnected() 2119 2149 } 2120 2150 // reset the mouse cursor 2121 2151 updateCursor(); 2122 ItemUtils.EnclosedCheck( current.getItems());2152 ItemUtils.EnclosedCheck(parent.getItems()); 2123 2153 if (toDelete.hasOverlay()) { 2124 FrameUtils.Parse( current, false);2154 FrameUtils.Parse(parent, false); 2125 2155 FrameGraphics.requestRefresh(false); 2126 2156 } … … 2570 2600 Set<Frame> checkEnclosure = new HashSet<Frame>(); 2571 2601 for (Item i : toAnchor) { 2572 // if (!i.hasVector())2573 2602 // if (!i.hasVector()) 2603 anchor(i, false); 2574 2604 checkEnclosure.add(i.getParentOrCurrentFrame()); 2575 2605 bReparse |= i.hasOverlay(); … … 2737 2767 // TODO: Check why the new constrained line is not repainted immediately 2738 2768 FrameGraphics.requestRefresh(true); 2769 FrameGraphics.refresh(true); 2739 2770 } 2740 2771 -
trunk/src/org/expeditee/gui/FrameUtils.java
r154 r156 140 140 * @return 141 141 */ 142 public static int Align(List< Item> toAlign, boolean moveAll, int adjust) {142 public static int Align(List<Text> toAlign, boolean moveAll, int adjust) { 143 143 Collections.sort(toAlign); 144 144 … … 148 148 149 149 // get the first item 150 Itemfrom = toAlign.get(0);150 Text from = toAlign.get(0); 151 151 if (from.getParent() == null) 152 152 from = toAlign.get(1); … … 154 154 155 155 Frame curr = from.getParent(); 156 Item above = curr.getItemAbove(from);156 Text above = curr.getTextAbove(from); 157 157 158 158 String lastBullet = ""; 159 159 160 160 if (above != null && curr.isNormalTextItem(above)) 161 lastBullet = FrameKeyboardActions.getAutoBullet(((Text) above) 162 .getText()); 161 lastBullet = FrameKeyboardActions.getAutoBullet(above.getText()); 163 162 else { 164 lastBullet = FrameKeyboardActions.getBullet( ((Text) toAlign.get(0))163 lastBullet = FrameKeyboardActions.getBullet(toAlign.get(0) 165 164 .getText()); 166 165 } … … 168 167 // renumber... 169 168 for (int i = 0; i < toAlign.size(); i++) { 170 assert toAlign.get(i) instanceof Text; 171 172 Text currentText = ((Text) toAlign.get(i)); 169 170 Text currentText = toAlign.get(i); 173 171 String currentBullet = FrameKeyboardActions 174 172 .getAutoBullet(currentText.getText()); … … 329 327 330 328 // move any anchored connected items 331 if (Fr ame.itemAttachedToCursor()) {329 if (FreeItems.itemAttachedToCursor()) { 332 330 List<Item> toAdd = new ArrayList<Item>(); 333 331 List<Item> toCheck = new ArrayList<Item>(FreeItems.getInstance()); … … 531 529 UserSettings.TitleTemplate = profile.getTitleItem(); 532 530 533 List<Text> items = profile.getBodyTextItems(true, true);534 535 531 // check for all tags setting user values 536 for (Text item : items) {532 for (Text item : profile.getTextItems()) { 537 533 if (!item.isAnnotation()) 538 534 continue; … … 1464 1460 } 1465 1461 LastEdited = lastEdited; 1466 1462 1467 1463 if (toReparse != null) { 1468 1464 Parse(toReparse, false); … … 1475 1471 1476 1472 public static Collection<Text> getCurrentTextItems() { 1477 Collection<Text> currentTextItems = new Linked List<Text>();1473 Collection<Text> currentTextItems = new LinkedHashSet<Text>(); 1478 1474 Collection<Item> currentItems = getCurrentItems(null); 1479 1475 if (currentItems != null) { -
trunk/src/org/expeditee/gui/FreeItems.java
r123 r156 4 4 5 5 import org.expeditee.items.Item; 6 import org.expeditee.items.Text; 6 7 7 8 public class FreeItems extends ArrayList<Item> { … … 43 44 } 44 45 46 public static boolean itemAttachedToCursor() { 47 return getInstance().size() > 0; 48 } 49 50 public static boolean textAttachedToCursor() { 51 return itemAttachedToCursor() 52 && getInstance().get(0) instanceof Text; 53 } 54 55 public static Item getItemAttachedToCursor() { 56 if (itemAttachedToCursor()) 57 return getInstance().get(0); 58 return null; 59 } 60 61 public static Text getTextAttachedToCursor() { 62 if(textAttachedToCursor()) 63 return (Text)getInstance().get(0); 64 return null; 65 } 66 45 67 // 46 68 // @Override -
trunk/src/org/expeditee/items/Item.java
r154 r156 31 31 import org.expeditee.gui.FrameKeyboardActions; 32 32 import org.expeditee.gui.FrameUtils; 33 import org.expeditee.gui.FreeItems; 33 34 import org.expeditee.gui.MessageBay; 34 35 import org.expeditee.gui.Overlay; … … 988 989 public void performActions() { 989 990 Frame sourceFrame = null; 991 Item sourceItem = FreeItems.getItemAttachedToCursor(); 992 if(sourceItem == null){ 993 sourceItem = this; 994 } 995 990 996 // if a link exists make it the source frame for this action 991 997 if (getLink() != null) { … … 1000 1006 1001 1007 for (String s : getAction()) { 1002 Actions.PerformAction(sourceFrame, this, s);1008 Actions.PerformAction(sourceFrame, sourceItem, s); 1003 1009 } 1004 1010 } … … 1064 1070 Simple.ProgramFinished(); 1065 1071 } 1072 //Need to repaint any highlights etc 1073 FrameGraphics.requestRefresh(true); 1066 1074 } 1067 1075 … … 2378 2386 return _anchorBottom; 2379 2387 } 2388 2389 public String getText() { 2390 return toString(); 2391 } 2380 2392 } -
trunk/src/org/expeditee/items/ItemUtils.java
r154 r156 91 91 * @return True if an Item was found that is the given Tag, False otherwise. 92 92 */ 93 public static boolean ContainsTag( List<Item> items, int tag) {93 public static boolean ContainsTag(Collection<Item> items, int tag) { 94 94 return ContainsTag(items, GetTag(tag)); 95 95 } 96 96 97 public static boolean ContainsTag( List<Item> items, String tag) {97 public static boolean ContainsTag(Collection<Item> items, String tag) { 98 98 return (FindTag(items, tag) != null); 99 99 } 100 100 101 public static boolean ContainsExactTag( List<Item> items, int tag) {101 public static boolean ContainsExactTag(Collection<Item> items, int tag) { 102 102 return ContainsExactTag(items, GetTag(tag)); 103 103 } 104 104 105 public static boolean ContainsExactTag( List<Item> items, String tag) {105 public static boolean ContainsExactTag(Collection<Item> items, String tag) { 106 106 return (FindExactTag(items, tag) != null); 107 107 } … … 133 133 * is found 134 134 */ 135 public static Text FindTag( List<Item> items, String toFind) {135 public static Text FindTag(Collection<Item> items, String toFind) { 136 136 for (Item i : items) { 137 137 if (i instanceof Text && i.isAnnotation()) … … 142 142 } 143 143 144 public static Item FindExactTag( List<Item> items, String toFind) {144 public static Item FindExactTag(Collection<Item> items, String toFind) { 145 145 for (Item i : items) { 146 146 if (i instanceof Text && i.isAnnotation()) -
trunk/src/org/expeditee/items/Text.java
r154 r156 25 25 26 26 import org.expeditee.gui.DisplayIO; 27 import org.expeditee.gui.Frame; 27 28 import org.expeditee.gui.FrameGraphics; 28 29 import org.expeditee.gui.FrameKeyboardActions; … … 1165 1166 // This needs to be fixed!! 1166 1167 private void rebuild(boolean limitWidth) { 1168 // TODO make this more efficient so it only clears annotation list when 1169 // it really has to 1170 if (isAnnotation()) { 1171 Frame parent = getParent(); 1172 //parent can be null when running tests 1173 if (parent != null) { 1174 parent.clearAnnotations(); 1175 } 1176 } 1177 1167 1178 // if there is no text, there is nothing to do 1168 1179 if (_text == null || _text.length() == 0) { … … 1755 1766 clearSelection(); 1756 1767 setAlpha(0); 1768 if (isLineEnd()) 1769 DisplayIO.setCursor(Item.DEFAULT_CURSOR); 1757 1770 } 1758 1771 … … 1801 1814 String text = getText().toLowerCase(); 1802 1815 // TODO make it so can just check the _overlay variable 1803 // Mike cant remember the reason _overlay var cant be use! opps1804 if (!text.startsWith("@"))1816 // Mike cant remember the reason _overlay var cant be use! opps 1817 if (!text.startsWith("@")) 1805 1818 return false; 1806 1819 return text.startsWith("@o") || text.startsWith("@ao") -
trunk/src/org/expeditee/items/XRayable.java
r154 r156 164 164 return; 165 165 } 166 if(action .size() == 0)166 if(action == null || action.size() == 0) 167 167 invalidateAll(); 168 168 _source.setActions(action);
Note:
See TracChangeset
for help on using the changeset viewer.