Changeset 50
- Timestamp:
- 05/16/08 10:25:28 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Simple.java
r42 r50 9 9 import java.util.LinkedList; 10 10 import java.util.List; 11 import java.util.Random; 11 12 12 13 import org.expeditee.agents.DisplayTree; … … 26 27 import org.expeditee.items.Line; 27 28 import org.expeditee.items.Text; 29 import org.expeditee.items.Item.SelectedMode; 28 30 import org.expeditee.simple.BelowMinParametreCountException; 29 31 import org.expeditee.simple.Context; … … 206 208 } 207 209 } 208 210 // The statement below assumes there are no other programs running at 211 // the same time 212 assert (_programsRunning == 0); 209 213 // Report the number of test passed and failed 210 214 FrameGraphics.DisplayMessage("Total tests: " … … 239 243 240 244 private static void FlagError(Item item) { 241 // item.setColor(Color.CYAN);242 245 FrameUtils.DisplayFrame(item.getParent().getFrameName(), true); 246 item.setSelectedMode(SelectedMode.Normal); 243 247 item.setSelectionColor(Color.CYAN); 244 248 FrameIO.SaveFrame(item.getParent()); … … 349 353 endOfToken + 1)); 350 354 } else { 351 throw new Exception("Expected matching \" " 352 + code.toString()); 355 throw new RuntimeException("Expected matching \" "); 353 356 } 354 357 break; … … 745 748 throw new UnitTestFailedException("false", "true"); 746 749 return Status.OK; 750 } 751 if (tokens[0].equals("assertfail")) { 752 assertExactParametreCount(tokens, 0); 753 throw new UnitTestFailedException("pass", "fail"); 747 754 } else if (tokens[0].equals("assertnull")) { 748 755 assertExactParametreCount(tokens, 1); … … 1042 1049 1043 1050 return Status.OK; 1051 } else if (tokens[0].equals("getrandominteger")) { 1052 assertExactParametreCount(tokens, 3); 1053 int lowerBound = (int) context.getPrimitives().getIntegerValue( 1054 tokens[1]); 1055 int upperBound = (int) context.getPrimitives().getIntegerValue( 1056 tokens[2]); 1057 Random random = new Random(); 1058 long result = Math.abs(random.nextInt()) 1059 % (upperBound - lowerBound) + lowerBound; 1060 context.getPrimitives().setValue(tokens[3], 1061 new SInteger(result)); 1062 return Status.OK; 1063 } else if (tokens[0].equals("getrandomreal")) { 1064 assertExactParametreCount(tokens, 3); 1065 double lowerBound = context.getPrimitives().getDoubleValue( 1066 tokens[1]); 1067 double upperBound = context.getPrimitives().getDoubleValue( 1068 tokens[2]); 1069 Random random = new Random(); 1070 double result = random.nextDouble() * (upperBound - lowerBound) 1071 + lowerBound; 1072 context.getPrimitives().setValue(tokens[3], new SReal(result)); 1073 return Status.OK; 1074 } else if (tokens[0].equals("getrandomtextitem")) { 1075 assertExactParametreCount(tokens, 2); 1076 assertVariableType(tokens[1], 1, SPointer.framePrefix); 1077 assertVariableType(tokens[2], 2, SPointer.itemPrefix); 1078 List<Text> items = ((Frame) context.getPointers().getVariable( 1079 tokens[1]).getValue()).getBodyTextItems(false); 1080 Random random = new Random(); 1081 int itemIndex = random.nextInt(items.size()); 1082 context.getPointers() 1083 .setObject(tokens[2], items.get(itemIndex)); 1084 return Status.OK; 1044 1085 } 1045 1086 } else if (tokens[0].equals("or")) { … … 1136 1177 String command = getMessage(tokens, context, code.toString(), " ", 1137 1178 1); 1138 Process p = Runtime.getRuntime().exec(command); 1139 FrameGraphics.DisplayMessage(command, Color.darkGray); 1140 1141 BufferedReader stdInput = new BufferedReader(new InputStreamReader( 1142 p.getInputStream())); 1143 BufferedReader stdError = new BufferedReader(new InputStreamReader( 1144 p.getErrorStream())); 1145 String message = ""; 1146 while ((message = stdInput.readLine()) != null) { 1147 FrameGraphics.DisplayMessage(message); 1148 } 1149 while ((message = stdError.readLine()) != null) { 1150 FrameGraphics.ErrorMessage(message); 1179 try { 1180 Process p = Runtime.getRuntime().exec(command); 1181 FrameGraphics.DisplayMessage(command, Color.darkGray); 1182 1183 BufferedReader stdInput = new BufferedReader( 1184 new InputStreamReader(p.getInputStream())); 1185 BufferedReader stdError = new BufferedReader( 1186 new InputStreamReader(p.getErrorStream())); 1187 String message = ""; 1188 while ((message = stdInput.readLine()) != null) { 1189 FrameGraphics.DisplayMessage(message); 1190 } 1191 while ((message = stdError.readLine()) != null) { 1192 FrameGraphics.ErrorMessage(message); 1193 } 1194 } catch (Exception e) { 1195 throw new RuntimeException(e.getMessage()); 1151 1196 } 1152 1197 return Status.OK; … … 1666 1711 DisplayIO.setCurrentFrame(frame); 1667 1712 pause(thisFramesPause); 1668 1713 1669 1714 long freeMemory = runtime.freeMemory(); 1670 if (freeMemory < DisplayTree.GARBAGE_COLLECTION_THRESHOLD){1715 if (freeMemory < DisplayTree.GARBAGE_COLLECTION_THRESHOLD) { 1671 1716 runtime.gc(); 1672 FrameGraphics.DisplayMessage("Force Garbage Collection!"); 1717 FrameGraphics 1718 .DisplayMessage("Force Garbage Collection!"); 1673 1719 } 1674 1720 } … … 1693 1739 String fileName = context.getPrimitives().getStringValue(tokens[3]); 1694 1740 WriteTree wt = new WriteTree(format, fileName); 1695 if (wt.initialise(source)) {1741 if (wt.initialise(source)) { 1696 1742 wt.setStartFrame(source); 1697 1743 wt.run(); -
trunk/src/org/expeditee/agents/ComputeTree.java
r45 r50 3 3 import org.expeditee.gui.AttributeUtils; 4 4 import org.expeditee.gui.Frame; 5 import org.expeditee.gui.FrameGraphics;6 5 import org.expeditee.gui.FrameIO; 7 6 import org.expeditee.items.Item; -
trunk/src/org/expeditee/agents/DefaultAgent.java
r45 r50 1 1 package org.expeditee.agents; 2 2 3 import org.expeditee.gui.DisplayIO;4 3 import org.expeditee.gui.Frame; 5 4 import org.expeditee.gui.FrameGraphics; -
trunk/src/org/expeditee/agents/DisplayTree.java
r45 r50 4 4 import org.expeditee.gui.Frame; 5 5 import org.expeditee.gui.FrameGraphics; 6 import org.expeditee.gui.FrameUtils;7 import org.expeditee.gui.TimeKeeper;8 6 import org.expeditee.items.Item; 9 7 import org.expeditee.items.ItemUtils; -
trunk/src/org/expeditee/agents/SwitchyardTree.java
r45 r50 5 5 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.Text; -
trunk/src/org/expeditee/agents/TreeProcessor.java
r45 r50 4 4 import java.util.Stack; 5 5 6 import org.expeditee.gui.DisplayIO;7 6 import org.expeditee.gui.Frame; 8 7 import org.expeditee.gui.FrameIO; -
trunk/src/org/expeditee/agents/WriteTree.java
r45 r50 6 6 7 7 import org.expeditee.actions.Actions; 8 import org.expeditee.gui.DisplayIO;9 8 import org.expeditee.gui.Frame; 10 9 import org.expeditee.gui.FrameGraphics; -
trunk/src/org/expeditee/gui/AttributeUtils.java
r48 r50 66 66 _GetMethods = new LinkedList<Method>(); 67 67 _GetMethods.add(Item.class.getMethod("getDateCreated", param)); 68 68 69 69 _GetMethods.add(Item.class.getMethod("getColor", param)); 70 70 _GetMethods.add(Item.class.getMethod("getBackgroundColor", param)); … … 74 74 _GetMethods.add(Item.class.getMethod("getFillPattern", param)); 75 75 _GetMethods.add(Item.class.getMethod("getThickness", param)); 76 76 77 77 _GetMethods.add(Item.class.getMethod("getOwner", param)); 78 78 _GetMethods.add(Item.class.getMethod("getLinkMark", param)); … … 99 99 _GetMethods.add(Text.class.getMethod("getJustification", param)); 100 100 _GetMethods.add(Text.class.getMethod("getWidth", param)); 101 _GetMethods.add( Text.class.getMethod("getSize", param));101 _GetMethods.add(Item.class.getMethod("getSize", param)); 102 102 103 103 _GetMethods.add(Frame.class.getMethod("getOwner", param)); … … 111 111 Class[] pString = { String.class }; 112 112 Class[] pInt = { int.class }; 113 Class[] pFloat = { float.class }; 113 114 Class[] pColor = { Color.class }; 114 115 Class[] pBool = { boolean.class }; … … 119 120 _SetMethods = new HashMap<String, Method>(); 120 121 121 _SetMethods.put("size", Item.class.getMethod("setSize", pInt)); 122 _SetMethods.put("s", Item.class.getMethod("setSize", pInt)); 122 _SetMethods.put("thickness", Item.class.getMethod("setThickness", 123 pFloat)); 124 _SetMethods.put("t", Item.class.getMethod("setThickness", pFloat)); 123 125 124 126 _SetMethods.put("color", Item.class.getMethod("setColor", pColor)); … … 173 175 _SetMethods.put("family", Text.class 174 176 .getMethod("setFamily", pString)); 175 _SetMethods.put("face", Text.class.getMethod("setFontStyle", pString)); 176 _SetMethods.put("fontstyle", Text.class.getMethod("setFontStyle", pString)); 177 _SetMethods.put("face", Text.class.getMethod("setFontStyle", 178 pString)); 179 _SetMethods.put("fontstyle", Text.class.getMethod("setFontStyle", 180 pString)); 177 181 _SetMethods.put("justification", Text.class.getMethod( 178 182 "setJustification", pInt)); 179 183 _SetMethods.put("width", Text.class.getMethod("setWidth", pInt)); 184 _SetMethods.put("size", Item.class.getMethod("setSize", pInt)); 185 _SetMethods.put("s", Item.class.getMethod("setSize", pInt)); 180 186 181 187 _SetMethods.put("foregroundcolor", Frame.class.getMethod( … … 548 554 549 555 try { 550 Object[] params = Conversion.Convert(possible, value, 551 current); 556 Object[] params = Conversion.Convert(possible, value, current); 552 557 553 558 try { … … 561 566 e.printStackTrace(); 562 567 } catch (InvocationTargetException e) { 563 // TODO Auto-generated catch block 564 e.printStackTrace(); 568 FrameGraphics.DisplayMessage(toSet.getClass() 569 .getSimpleName() 570 + " type does not support that attribute."); 571 // e.printStackTrace(); 565 572 } 566 573 } catch (NumberFormatException e) { … … 620 627 public static void setSingleValue(Text text, String value) { 621 628 assert (value != null); 622 629 623 630 String oldText = text.getTextNoList(); 624 631 String attribute = stripAttribute(oldText); -
trunk/src/org/expeditee/gui/Browser.java
r25 r50 138 138 139 139 DisplayIO.setCurrentFrame(firstFrame); 140 DisplayIO.UpdateTitle(); 140 141 141 142 FrameKeyboardActions keyboardListner = new FrameKeyboardActions(); -
trunk/src/org/expeditee/gui/DisplayIO.java
r34 r50 60 60 * The title to display in the Title bar. 61 61 */ 62 public static final String TITLE = "Exp1 3May2008A";62 public static final String TITLE = "Exp15May2008A"; 63 63 64 64 private DisplayIO() { -
trunk/src/org/expeditee/gui/Frame.java
r47 r50 231 231 public List<Text> getBodyTextItems(boolean includeAnnotations) { 232 232 List<Text> bodyTextItems = new ArrayList<Text>(); 233 Text frameTitle = getTitle();234 235 233 for (Item i : getItems()) { 236 234 // only add up normal body text items … … 426 424 427 425 for (Item i : _body) 428 if (i.isVisible() && i != _frameName&& i.intersects(poly)) {426 if (i.isVisible() /*&& i != _frameName*/ && i.intersects(poly)) { 429 427 if (!results.contains(i)) 430 428 results.add(i); … … 730 728 line.getStartItem().addLine(line); 731 729 line.getEndItem().addLine(line); 730 } else { 731 i.setOffset(0, 0); 732 732 } 733 733 } … … 1133 1133 1134 1134 /** 1135 * Creates a new Text Item with no text. The newly created Item is a copy 1136 * the ItemTemplate if one is present, and inherits all the attributes of 1137 * the Template 1138 * 1139 * @return The newly created Text Item 1135 * Creates a new text item with the given text. 1136 * @param text 1137 * @return 1140 1138 */ 1141 1139 public Text createNewText(String text) { … … 1145 1143 } 1146 1144 1145 /** 1146 * Creates a new Text Item with no text. The newly created Item is a copy 1147 * the ItemTemplate if one is present, and inherits all the attributes of 1148 * the Template 1149 * 1150 * @return The newly created Text Item 1151 */ 1147 1152 public Text createBlankText(String templateType) { 1148 1153 Text t; -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r24 r50 16 16 import org.expeditee.actions.Simple; 17 17 import org.expeditee.io.Logger; 18 import org.expeditee.items.Constraint; 18 19 import org.expeditee.items.Dot; 19 20 import org.expeditee.items.Item; … … 121 122 // check for dot's being replaced with text 122 123 if (on != null && on instanceof Dot) { 124 if (ch == KeyEvent.VK_BACK_SPACE || ch == KeyEvent.VK_DELETE) { 125 return; 126 } 123 127 replaceDot((Dot) on, ch); 128 ItemUtils.EnclosedCheck(DisplayIO.getCurrentFrame().getItems()); 124 129 return; 125 130 } … … 183 188 } 184 189 185 p rivate static voidreplaceDot(Dot dot, char ch) {190 public static Text replaceDot(Dot dot, char ch) { 186 191 SessionStats.CreatedItem(); 187 192 Text text = createText(ch); 193 text.setPosition(dot.getPosition()); 194 text.setThickness(dot.getThickness()); 188 195 FrameUtils.LastEdited = text; 189 196 190 List<Line> lines = new LinkedList<Line>();191 lines.addAll(dot.getLines());197 //Copy the lines list so it can be modified 198 List<Line> lines = new LinkedList<Line>(dot.getLines()); 192 199 for (Line line : lines) 193 200 line.replaceEnd(dot, text); 194 195 dot.removeAllLines(); 201 196 202 DisplayIO.getCurrentFrame().removeItem(dot); 197 203 DisplayIO.getCurrentFrame().addItem(text); 198 return ;204 return text; 199 205 } 200 206 … … 206 212 List<Line> lines = new LinkedList<Line>(); 207 213 lines.addAll(text.getLines()); 208 for (Line line : lines) 214 if (lines.size() > 0) 215 dot.setColor(lines.get(0).getColor()); 216 for (Line line : lines){ 209 217 line.replaceEnd(text, dot); 210 text.removeAllLines(); 211 212 DisplayIO.getCurrentFrame().removeItem(text); 218 } 219 text.delete(); 213 220 DisplayIO.getCurrentFrame().addItem(dot); 214 221 DisplayIO.setCursor(Item.DEFAULT_CURSOR); … … 576 583 if (enclosed != null && enclosed.size() > 0) { 577 584 // ensure only one dot\line is present in the list 578 List< Dot> dots = FrameUtils.getEnclosingDots();585 List<Item> dots = FrameUtils.getEnclosingDots(); 579 586 List<Item> connected = dots.get(0).getAllConnected(); 580 587 … … 621 628 622 629 if (key == COLOR_CHANGE && connected.size() > 0) { 623 for ( Dotd : dots) {630 for (Item d : dots) { 624 631 SetFillColor(d); 625 632 break; … … 743 750 dummyItem = createText(); 744 751 if (Frame.textItemAttachedToCursor()) { 745 Text t = (Text) Frame.getItemAttachedToCursor();752 Text t = (Text) Frame.getItemAttachedToCursor(); 746 753 dummyItem.setSize(t.getSize()); 747 754 for (int i = 0; i < t.getText().size(); i++) { … … 987 994 */ 988 995 private static void SetSize(Item ip, int diff, boolean moveCursor) { 989 List<Item> toSize ;996 List<Item> toSize = new ArrayList<Item>(); 990 997 // the mouse is only moved when the Item is on the frame, not free 991 998 // boolean moveMouse = false; … … 995 1002 if (ip == null) { 996 1003 if (Frame.itemAttachedToCursor()) 997 toSize = new ArrayList<Item>(Frame.FreeItems);1004 toSize.addAll(Frame.FreeItems); 998 1005 else { 999 1006 FrameGraphics … … 1009 1016 } 1010 1017 toSet = ip; 1011 1012 toSize = toSet.getConnected(); 1013 // moveMouse = true; 1018 Item currentItem = FrameUtils.getCurrentItem(); 1019 1020 if (currentItem != null && (currentItem instanceof Text) 1021 && FrameUtils.getCurrentItems() == null) { 1022 toSize.add(currentItem); 1023 } else { 1024 toSize.addAll(toSet.getLines()); 1025 } 1014 1026 } 1015 1027 -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r47 r50 13 13 import java.util.List; 14 14 15 import javax.swing.SwingUtilities;16 15 import javax.swing.Timer; 17 16 18 17 import org.expeditee.actions.Actions; 19 18 import org.expeditee.actions.NavigationActions; 20 import org.expeditee.agents.Format;21 19 import org.expeditee.items.Constraint; 22 20 import org.expeditee.items.Dot; … … 223 221 224 222 _lastClickedIn = FrameUtils.getCurrentItems(); 223 // if (_lastClickedIn != null){ 224 // System.out.println(_lastClickedIn.size());} 225 225 226 226 SessionStats.MouseClicked(e.getButton()); … … 632 632 Item attachedToCursor = Frame.getItemAttachedToCursor(); 633 633 634 if (clicked instanceof Text && !(attachedToCursor instanceof Text)) { 634 if (clicked instanceof Text 635 && !(attachedToCursor instanceof Text || attachedToCursor 636 .isLineEnd())) { 635 637 return false; 636 638 } … … 692 694 if (toDisconnect != null) { 693 695 if (toDisconnect.getSelectedMode() == Item.SelectedMode.Normal) { 696 DisplayIO.setCursorPosition(toDisconnect 697 .getPosition(), false); 694 698 pickup(toDisconnect); 695 699 return; 696 700 } else { 697 701 List<Line> lines = toDisconnect.getLines(); 702 // This is to remove constraints from single lines 703 // with constraints... 704 // ie. partially deleted rectangles 698 705 if (lines.size() == 1) { 699 // remove constraints700 706 toDisconnect.removeAllConstraints(); 701 707 … … 706 712 } 707 713 // If we are then detatch the line and pick up its 708 // end 709 // point... 714 // end point... 710 715 Frame currentFrame = DisplayIO.getCurrentFrame(); 711 Item newPoint = toDisconnect.copy(); 712 newPoint.setID(currentFrame.getNextItemID()); 716 Item newPoint = null; 717 718 // If the point we are disconnecting is text... 719 // Then we want to leave the text behind 720 // And disconnect a point 721 if (toDisconnect instanceof Text) { 722 newPoint = new Dot(toDisconnect.getX(), 723 toDisconnect.getY(), -1); 724 Item.DuplicateItem(toDisconnect, newPoint); 725 } else { 726 newPoint = toDisconnect.copy(); 727 } 728 713 729 currentFrame.addItem(newPoint); 714 730 // remove the current item from the connected 715 731 // list for this item 716 for (Item i : lines) { 717 if (i == l) { 718 toDisconnect.removeLine(l); 719 break; 720 } 721 } 722 if (toDisconnect == l.getStartItem()) { 723 l.setStartItem(newPoint); 724 } else { 725 l.setEndItem(newPoint); 726 } 727 732 l.replaceEnd(toDisconnect, newPoint); 728 733 // remove unneeded constrains 729 List<Constraint> constraints = toDisconnect 730 .getConstraints(); 731 if (constraints != null) { 732 for (Constraint c : constraints) { 733 Item oppositeEnd = l 734 .getOppositeEnd(newPoint); 735 if (c.contains(oppositeEnd)) { 736 toDisconnect.removeConstraint(c); 737 oppositeEnd.removeConstraint(c); 738 break; 739 } 740 } 741 } 734 newPoint.removeAllConstraints(); 742 735 743 736 toDisconnect … … 746 739 .getPosition(), false); 747 740 pickup(newPoint); 748 741 ItemUtils.EnclosedCheck(toDisconnect.getCurrentFrame().getItems()); 749 742 return; 750 743 } 751 744 } 752 745 } 753 746 if (clicked.isLineEnd()) 747 DisplayIO.setCursorPosition(clicked.getPosition(), false); 754 748 pickup(clicked); 755 749 return; … … 1228 1222 if (Frame.FreeItems.size() == 2 && on instanceof Line) { 1229 1223 Line line = (Line) on; 1230 if (Frame.FreeItems.get(0) instanceof Dot)1231 line.showVirtualSpot( (Dot) Frame.FreeItems.get(0),1232 DisplayIO.getMouseX(), DisplayIO.getMouseY());1233 else if (Frame.FreeItems.get(1) instanceof Dot)1234 line.showVirtualSpot( (Dot) Frame.FreeItems.get(1),1235 DisplayIO.getMouseX(), DisplayIO.getMouseY());1224 if (Frame.FreeItems.get(0).isLineEnd()) 1225 line.showVirtualSpot(Frame.FreeItems.get(0), DisplayIO 1226 .getMouseX(), DisplayIO.getMouseY()); 1227 else if (Frame.FreeItems.get(1).isLineEnd()) 1228 line.showVirtualSpot(Frame.FreeItems.get(1), DisplayIO 1229 .getMouseX(), DisplayIO.getMouseY()); 1236 1230 else 1237 1231 // The user is pointing at another point or text item … … 1242 1236 // FrameGraphics.ChangeSelectionMode(on, 1243 1237 // Item.SelectedMode.Connected); 1238 // TODO: The method below is for the most part redundant 1244 1239 FrameGraphics.Highlight(on); 1245 1240 } … … 1256 1251 // highlighting 1257 1252 } else if (on == null) { 1258 List< Dot> enclosure = FrameUtils.getEnclosingDots();1253 List<Item> enclosure = FrameUtils.getEnclosingDots(); 1259 1254 if (enclosure != null && enclosure.size() > 1) { 1260 1255 if (enclosure.get(0).getLines().size() > 1 && … … 1289 1284 if (Frame.itemAttachedToCursor()) { 1290 1285 move(Frame.FreeItems); 1286 // System.out.println(Frame.FreeItems.size()); 1291 1287 } 1292 1288 … … 1300 1296 } 1301 1297 1302 private boolean ContainsOneOf(List< Dot> enclosure, List<Item> freeItems) {1298 private boolean ContainsOneOf(List<Item> enclosure, List<Item> freeItems) { 1303 1299 if (freeItems == null) 1304 1300 return false; … … 1311 1307 1312 1308 /** 1309 * Checks if lines are being rubber banded. 1310 * 1311 * @return true if the user is rubberBanding one or more lines 1312 */ 1313 private static boolean rubberBanding() { 1314 if (Frame.FreeItems.size() < 2) { 1315 return false; 1316 } 1317 1318 // if rubber-banding, there will be 1 lineend and the rest will be lines 1319 boolean foundLineEnd = false; 1320 for (Item i : Frame.FreeItems) { 1321 if (i.isLineEnd()) { 1322 if (foundLineEnd) { 1323 return false; 1324 } 1325 foundLineEnd = true; 1326 } else if (!(i instanceof Line)) { 1327 return false; 1328 } 1329 } 1330 return true; 1331 } 1332 1333 /** 1313 1334 * Updates the current mouse cursor to whatever it should be. i.e. Hidden 1314 1335 * when rubber-banding lines, otherwise default (arrow) 1315 1336 */ 1316 1337 private static void updateCursor() { 1317 // if rubber-banding, there will be exactly 2 items on the cursor 1318 if (Frame.FreeItems.size() != 2) 1338 if (rubberBanding()) { 1339 DisplayIO.setCursor(Item.HIDDEN_CURSOR); 1340 } else { 1319 1341 DisplayIO.setCursor(Item.DEFAULT_CURSOR); 1320 else { 1321 Dot d = null; 1322 // check that it is indeed a line being rubber-banded 1323 if (Frame.FreeItems.get(0) instanceof Line 1324 && Frame.FreeItems.get(1) instanceof Dot) 1325 d = (Dot) Frame.FreeItems.get(1); 1326 else if (Frame.FreeItems.get(1) instanceof Line 1327 && Frame.FreeItems.get(0) instanceof Dot) 1328 d = (Dot) Frame.FreeItems.get(0); 1329 1330 if (d != null) { 1331 DisplayIO.setCursor(Item.HIDDEN_CURSOR); 1332 } else 1333 DisplayIO.setCursor(Item.DEFAULT_CURSOR); 1334 } 1335 1342 } 1336 1343 } 1337 1344 … … 1578 1585 List<Item> toUndo = new LinkedList<Item>(); 1579 1586 1580 if (toDelete instanceof Dot) {1581 toUndo.addAll(deleteDot( (Dot)toDelete));1587 if (toDelete.isLineEnd()) { 1588 toUndo.addAll(deleteDot(toDelete)); 1582 1589 } else 1583 1590 toUndo.addAll(copy(toDelete.getConnected())); … … 1601 1608 List<Item> seen = new LinkedList<Item>(); 1602 1609 1610 // Mike: Removed code that checked for rectangles and removed them 1611 // completely!! 1612 1603 1613 // disconnect any connected items 1604 1614 for (Item i : itemList) { 1605 1615 if (i.getLines().size() > 0) { 1606 1607 // check for rectangle deletion 1608 if (itemList.size() == 3) { 1609 boolean rectangle = false; 1610 // check that this is indeed a rectangle 1611 for (Item check : itemList) 1612 if (check != i && !i.getLines().contains(check)) { 1613 rectangle = false; 1614 break; 1615 } else 1616 rectangle = true; 1617 1618 // if this is a rectangle, remove the entire 1619 // rectangle 1620 if (rectangle) { 1621 List<Item> copy = copy(i.getAllConnected()); 1622 current.addAllToUndo(copy); 1623 current.removeAllItems(i.getAllConnected()); 1624 itemList.clear(); 1625 // reset the mouse cursor 1626 updateCursor(); 1627 FrameGraphics.Repaint(); 1628 return; 1629 } 1630 } 1631 1632 List<Item> copy = deleteDot((Dot) i); 1616 List<Item> copy = deleteDot(i); 1633 1617 // add the copied items to the undo stack 1634 1618 for (Item cop : copy) … … 1666 1650 } 1667 1651 1668 private static List<Item> deleteDot( Dotdot) {1652 private static List<Item> deleteDot(Item dot) { 1669 1653 1670 1654 if (dot instanceof WidgetCorner) { // Brook … … 1750 1734 Dot dot = null; 1751 1735 // check that this is indeed a rectangle 1736 // This wont work now that corners can be Text items 1752 1737 for (Item check : merger) { 1753 if (dot == null && check instanceof Dot)1738 if (dot == null && check.isLineEnd()) 1754 1739 dot = (Dot) check; 1755 1740 else if (check != dot && !dot.getLines().contains(check)) { … … 1786 1771 mergee.removeAllConstraints(); 1787 1772 mergee.removeAllLines(); 1773 mergee.setThickness(4 * mergee.getThickness()); 1788 1774 return mergee.getAllConnected(); 1789 1775 } else { … … 1819 1805 } else { 1820 1806 // check for attribute merging 1821 if (i instanceof Text ) {1807 if (i instanceof Text && !i.isLineEnd()) { 1822 1808 Text txt = (Text) i; 1823 1809 … … 1826 1812 // set mouse position for text merges 1827 1813 if (mergee instanceof Text) 1828 // 18Feb Rob doesnt want cursor to jump when1829 // inserting text1830 1814 ((Text) mergee).insertText(txt.getTextNoList(), 1831 1815 DisplayIO.getMouseX(), DisplayIO … … 1833 1817 1834 1818 else if (mergee instanceof Dot) { 1835 mergee.getParent().removeItem(mergee); 1819 txt.setPosition(mergee.getPosition()); 1820 txt.setThickness(mergee.getThickness()); 1821 Frame parent = mergee.getParent(); 1822 parent.removeItem(mergee); 1823 anchor(txt); 1824 // change the end points of the lines to the text 1825 // item 1826 while (mergee.getLines().size() > 0) { 1827 Line l = mergee.getLines().get(0); 1828 l.replaceEnd(mergee, txt); 1829 } 1836 1830 break; 1837 1831 } … … 1898 1892 Frame.FreeItems.add(i); 1899 1893 1900 if (i instanceof Dot) 1901 ((Dot) i).setFloating(true); 1894 i.setFloating(true); 1902 1895 } 1903 1896 … … 1968 1961 1969 1962 public static void anchor(Item toAnchor) { 1970 // System.out.println("Anchor:" + toAnchor.getX() + "," + 1971 // toAnchor.getY()); 1972 1973 Frame current = null; 1974 1975 // if the item is from an overlay the parent will NOT be null 1976 if (toAnchor.getParent() == null) { 1977 current = DisplayIO.getCurrentFrame(); 1978 } else { 1979 current = toAnchor.getParent(); 1980 } 1981 // update the items ID to prevent conflicts with the current frame 1982 //if (toAnchor.getID() < 0 || current.getItems().contains(toAnchor)) 1983 // ; 1984 toAnchor.setID(current.getNextItemID()); 1985 toAnchor.setOffset(0, 0); 1986 toAnchor.setParent(current); 1987 1988 current.addItem(toAnchor); 1989 current.setResort(true); 1990 1991 toAnchor.setRelativeLink(); 1992 1993 if (toAnchor instanceof Dot) { 1994 for (Line line : ((Dot) toAnchor).getLines()) { 1995 if (line.getID() < 0 && !current.getItems().contains(line)) { 1996 line.setID(current.getNextItemID()); 1997 line.setSelectionColor(); 1998 // Mike: Why was this line here? 1999 // anchor(line); 2000 } 2001 } 2002 ((Dot) toAnchor).setFloating(false); 2003 } else if (toAnchor instanceof Text) { 2004 // ensure all text items have their selection cleared 2005 ((Text) toAnchor).clearSelection(); 2006 ((Text) toAnchor).setAlpha(0); 2007 } else if (toAnchor instanceof Line) { 2008 ((Line) toAnchor).fixArrowheadLength(); 2009 } 1963 toAnchor.anchor(); 2010 1964 2011 1965 FrameGraphics.Repaint(); 2012 ItemUtils.EnclosedCheck( current.getItems());1966 ItemUtils.EnclosedCheck(toAnchor.getCurrentFrame().getItems()); 2013 1967 } 2014 1968 … … 2049 2003 else 2050 2004 line.toggleArrowHeadLength(arg0.getWheelRotation()); 2051 line.getParent().change();2005 // line.getParent().change(); 2052 2006 FrameGraphics.Repaint(); 2053 2007 } … … 2061 2015 2062 2016 Item ip = FrameUtils.getCurrentItem(); 2063 if (ip != null && clicks > 1) 2017 if (ip != null && clicks > 1) { 2018 float size = ip.getSize(); 2019 if (ip instanceof Dot || ip instanceof Line) 2020 size = ip.getThickness(); 2064 2021 // base the number of clicks on the size of the object 2065 clicks = (int) Math.ceil(ip.getSize() / 20.0 * clicks); 2022 clicks = (int) Math.ceil(size / 20.0 * clicks); 2023 } 2066 2024 2067 2025 FrameKeyboardActions.functionKey(rotationType, clicks); -
trunk/src/org/expeditee/gui/FrameUtils.java
r36 r50 1071 1071 public static List<Item> getCurrentItems() { 1072 1072 1073 List< Dot> enclosure = getEnclosingDots();1073 List<Item> enclosure = getEnclosingDots(); 1074 1074 if (enclosure == null || enclosure.size() == 0) 1075 1075 return null; … … 1085 1085 } 1086 1086 1087 public static List< Dot> getEnclosingDots() {1087 public static List<Item> getEnclosingDots() { 1088 1088 // update enclosed shapes 1089 1089 Frame current = DisplayIO.getCurrentFrame(); 1090 1090 List<Item> items = current.getItems(); 1091 1091 1092 ArrayList< Dot> used = new ArrayList<Dot>(0);1093 ArrayList< Dot> seen = new ArrayList<Dot>(0);1092 ArrayList<Item> used = new ArrayList<Item>(0); 1093 ArrayList<Item> seen = new ArrayList<Item>(0); 1094 1094 1095 1095 for (Item i : items) 1096 if (i instanceof Dot) { 1097 Dot d = (Dot) i; 1098 if (d.isEnclosed() && !seen.contains(d)) { 1099 Polygon p = d.getEnclosedShape(); 1096 if (i.isLineEnd()) { 1097 if (i.isEnclosed() && !seen.contains(i)) { 1098 Polygon p = i.getEnclosedShape(); 1100 1099 if (p 1101 1100 .contains(DisplayIO.getMouseX(), DisplayIO 1102 1101 .getMouseY())) { 1103 1102 1104 used.add( d);1105 seen.addAll( d.getEnclosingDots());1103 used.add(i); 1104 seen.addAll(i.getEnclosingDots()); 1106 1105 } 1107 1106 } … … 1116 1115 // otherwise, determine which polygon is closest to the cursor 1117 1116 } else { 1118 Collections.sort(used, new Comparator< Dot>() {1119 public int compare( Dot d1, Dotd2) {1117 Collections.sort(used, new Comparator<Item>() { 1118 public int compare(Item d1, Item d2) { 1120 1119 Polygon p1 = d1.getEnclosedShape(); 1121 1120 Polygon p2 = d2.getEnclosedShape(); -
trunk/src/org/expeditee/io/ExpReader.java
r4 r50 37 37 38 38 private String _frameName; 39 39 40 40 /** 41 41 * Does nothing, location must be set before use … … 43 43 public ExpReader(String frameName) { 44 44 _frameName = frameName; 45 45 46 46 if (_ItemTags != null && _FrameTags != null) 47 47 return; 48 48 49 49 _ItemTags = new LinkedHashMap<Character, Method>(); 50 50 _FrameTags = new LinkedHashMap<Character, Method>(); … … 123 123 _ItemTags.put('k', Text.class.getMethod("setJustification", pInt)); 124 124 125 _ItemTags.put('h', Dot.class.getMethod("setThickness", pFloat));125 _ItemTags.put('h', Item.class.getMethod("setThickness", pFloat)); 126 126 _ItemTags.put('l', Item.class.getMethod("setLineIDs", pString)); 127 _ItemTags 128 . put('c', Dot.class.getMethod("setConstraintIDs", pString));127 _ItemTags.put('c', Item.class 128 .getMethod("setConstraintIDs", pString)); 129 129 130 130 // Lines and constraints are created differently … … 164 164 165 165 try { 166 // Framename must be set before setting the frame number166 // Framename must be set before setting the frame number 167 167 newFrame.setFrameName(_frameName); 168 168 169 169 // First read all the header lines 170 170 while (_reader.ready() && !(next = _reader.readLine()).equals("Z")) { … … 173 173 } 174 174 } 175 175 176 176 // Now read all the items 177 177 Item currentItem = null; 178 178 while (_reader.ready() && !(next = _reader.readLine()).equals("Z")) { 179 179 // if this is the start of a new item add a new item 180 if (isValidLine(next) 180 if (isValidLine(next)) { 181 181 if (getTag(next) == 'S') { 182 182 String value = getValue(next); 183 183 int id = Integer.parseInt(value.substring(2)); 184 184 185 185 switch (value.charAt(0)) { 186 case 'P': // check if its a point186 case 'P': // check if its a point 187 187 currentItem = new Dot(id); 188 _linePoints.put(currentItem.getID(), currentItem);189 188 break; 190 189 default: … … 192 191 break; 193 192 } 193 _linePoints.put(currentItem.getID(), currentItem); 194 194 newFrame.addItem(currentItem); 195 195 } else if (currentItem != null) { … … 232 232 java.awt.Point startend = separateValues(next.substring(2)); 233 233 234 Dot a = (Dot)_linePoints.get(startend.x);235 Dot b = (Dot)_linePoints.get(startend.y);234 Item a = _linePoints.get(startend.x); 235 Item b = _linePoints.get(startend.y); 236 236 237 237 new Constraint(a, b, idtype.x, idtype.y); … … 276 276 } catch (Exception e) { 277 277 System.out.println("Error running tag method: " + tag); 278 // e.printStackTrace();278 // e.printStackTrace(); 279 279 } 280 280 } … … 318 318 toRun.invoke(frame, vals); 319 319 } catch (Exception e) { 320 System.out.println("Error running method: " + toRun.toGenericString()); 320 System.out.println("Error running method: " 321 + toRun.toGenericString()); 321 322 e.printStackTrace(); 322 323 } -
trunk/src/org/expeditee/io/ExpWriter.java
r10 r50 12 12 import org.expeditee.gui.Frame; 13 13 import org.expeditee.items.Constraint; 14 import org.expeditee.items.Dot;15 14 import org.expeditee.items.InteractiveWidget; 16 15 import org.expeditee.items.Item; … … 106 105 _ItemTags.put("k", Text.class.getMethod("getJustification", param)); 107 106 108 _ItemTags.put("h", Dot.class.getMethod("getThickness", param));109 _ItemTags.put("l", Dot.class.getMethod("getLineIDs", param));110 _ItemTags.put("c", Dot.class.getMethod("getConstraintIDs", param));107 _ItemTags.put("h", Item.class.getMethod("getThickness", param)); 108 _ItemTags.put("l", Item.class.getMethod("getLineIDs", param)); 109 _ItemTags.put("c", Item.class.getMethod("getConstraintIDs", param)); 111 110 112 111 } catch (Exception e) { … … 148 147 // write out each Item in the Frame. 149 148 List<Item> items = frame.getItems(); 150 149 151 150 // iWidgets are handled specially since 8 items are written as one 152 151 List<InteractiveWidget> seenWidgets = new LinkedList<InteractiveWidget>(); … … 154 153 // do not write items with ID -1, also skip any lines 155 154 for (Item i : items) { 156 155 157 156 // Ensure only one of the WidgetCorners represent a single widget 158 157 if (i instanceof WidgetCorner) { 159 InteractiveWidget iw = ((WidgetCorner)i).getWidgetSource(); 160 if (seenWidgets.contains(iw)) continue; 158 InteractiveWidget iw = ((WidgetCorner) i).getWidgetSource(); 159 if (seenWidgets.contains(iw)) 160 continue; 161 161 seenWidgets.add(iw); 162 162 } 163 163 164 164 if (i.getID() >= 0 && !(i instanceof Line)) { 165 165 writeItem(i); 166 166 } 167 167 } 168 168 169 169 // write any lines or constraints 170 170 writeTerminator(); … … 172 172 writeTerminator(); 173 173 writeConstraintData(); 174 174 175 175 return; 176 176 } … … 179 179 Iterator<String> it = _FrameTags.keySet().iterator(); 180 180 Object[] param = {}; 181 181 182 182 while (it.hasNext()) { 183 183 String tag = it.next(); … … 217 217 218 218 // writes the given Item out to the file 219 // This method is not used to write out LINE items219 // This method is not used to write out LINE items 220 220 public void writeItem(Item item) throws IOException { 221 221 if (_writer == null) … … 227 227 else if (item instanceof WidgetCorner) 228 228 item = ((WidgetCorner) item).getWidgetSource().getSource(); 229 229 230 230 if (item.getLines().size() > 0) 231 231 writePoint(item); … … 233 233 writeClass(item); 234 234 // lines are saved at the end of the file 235 // So dont worry about them in here235 // So dont worry about them in here 236 236 else 237 237 System.out.println("Unknown Item: " + item.getID()); 238 238 239 239 writeLine(""); 240 240 } … … 259 259 if (lines != null && lines.size() > 0) { 260 260 for (Line line : lines) { 261 261 262 262 // Brook: widget edges are not saved 263 263 if (line instanceof WidgetEdge) { … … 289 289 Item i = _points.get(0); 290 290 291 if (i instanceof Dot) { 292 Dot p = (Dot) i; 293 294 // if there are any constraints to write 295 if (p.getConstraints() != null) { 296 List<Constraint> constraints = p.getConstraints(); 297 298 // do not write constraints that have already been 299 // written 300 for (Constraint c : constraints) { 301 if (_points.contains(c.getStart()) 302 && _points.contains(c.getEnd())) { 303 writeLine("C", c.getID() + " " 304 + c.getConstraintType()); 305 writeLine("s", c.getLineEnds()); 306 writeLine(""); 307 } 308 291 // if there are any constraints to write 292 if (i.getConstraints() != null) { 293 List<Constraint> constraints = i.getConstraints(); 294 295 // do not write constraints that have already been 296 // written 297 for (Constraint c : constraints) { 298 if (_points.contains(c.getStart()) 299 && _points.contains(c.getEnd())) { 300 writeLine("C", c.getID() + " " + c.getType()); 301 writeLine("s", c.getLineEnds()); 302 writeLine(""); 309 303 } 304 310 305 } 311 306 } -
trunk/src/org/expeditee/io/KMSWriter.java
r4 r50 339 339 && _points.contains(c.getEnd())) { 340 340 writeLine("C", c.getID() + " " 341 + c.get ConstraintType());341 + c.getType()); 342 342 writeLine("s", c.getLineEnds()); 343 343 } -
trunk/src/org/expeditee/items/Constraint.java
r4 r50 60 60 * constants defined in this class. 61 61 */ 62 public int get ConstraintType() {62 public int getType() { 63 63 return _type; 64 64 } … … 72 72 } 73 73 74 public boolean contains(Item d) {75 if (_start == d || _end == d)74 public boolean contains(Item i) { 75 if (_start == i || _end == i) 76 76 return true; 77 77 … … 97 97 } 98 98 99 public void replacePoint(Dot toReplace, Dot with) { 100 if (_start == toReplace) 99 public void replaceEnd(Item toReplace, Item with) { 100 assert(_start != _end); 101 if (_start == toReplace) { 101 102 _start = with; 102 103 if (_end == toReplace) 103 } else if (_end == toReplace) { 104 104 _end = with; 105 } 106 toReplace.removeConstraint(this); 107 with.addConstraint(this); 105 108 } 106 109 -
trunk/src/org/expeditee/items/Dot.java
r24 r50 1 1 package org.expeditee.items; 2 2 3 import java.awt.Color; 3 4 import java.awt.Graphics2D; 4 5 import java.awt.Polygon; … … 7 8 import java.util.LinkedList; 8 9 import java.util.List; 10 11 import org.expeditee.gui.Frame; 9 12 10 13 /** … … 22 25 private static final int _MINIMUM_DOT_SIZE = 6; 23 26 24 // contains all dots (including this one) that form an enclosure25 // if this dot is part of an enclosing shape26 private List<Dot> _enclosure = null;27 28 27 // the polygon surrounding this point, used for 'gravity' 29 28 private Polygon _poly = null; 30 31 // The thickness (in pixels) of this Point32 private float _thickness = -1;33 29 34 30 private int _pointType = Item.POINTTYPE_SQUARE; … … 82 78 @Override 83 79 public void setThickness(float thick) { 84 _thickness = thick;80 super.setThickness(thick); 85 81 86 82 updatePolygon(); 87 88 // update the size of any lines 83 } 84 85 @Override 86 public void setColor(Color c) { 87 super.setColor(c); 88 89 // update the colour of any lines 89 90 for (Line line : getLines()) 90 line.setThickness(thick); 91 } 92 93 /** 94 * Returns the thickness (in pixels) of this Dot. 95 * 96 * @return The 'thickness' of this Dot. (returns -1 if the thickness is not 97 * set). 98 */ 99 @Override 100 public float getThickness() { 101 return _thickness; 91 line.setColor(c); 102 92 } 103 93 … … 134 124 g.setColor(getPaintColor()); 135 125 136 int thick = (int) _thickness;126 int thick = (int) getThickness(); 137 127 if (thick < 2) 138 128 thick = 2; … … 216 206 217 207 @Override 218 public int getSize() {219 return (int) getThickness();220 }221 222 @Override223 public void setSize(int size) {224 }225 226 @Override227 208 public void setAnnotation(boolean val) { 228 209 } … … 277 258 278 259 if (merger instanceof Text) { 260 merger.setPosition(this.getPosition()); 279 261 List<Line> lines = new LinkedList<Line>(); 280 262 lines.addAll(getLines()); 281 263 for (Line line : lines) 282 264 line.replaceEnd(this, merger); 283 284 removeAllLines(); 265 this.delete(); 285 266 return merger; 286 267 } … … 300 281 } 301 282 302 /**303 * Sets the list of Dots (including this one) that form a closed shape.304 * Passing null sets this dot back to its normal (non-enclosed) state.305 *306 * @param enclosed307 * The List of Dots including this one that form a closed shape,308 * or null.309 */310 public void setEnclosedList(List<Dot> enclosed) {311 _enclosure = enclosed;312 }313 314 /**315 * Returns the polygon that represents the shape created by all the Dots in316 * this Dot's enclosed list. If the list is null, then null is returned.317 *318 * @return A Polygon the same shape and position as created by the Dots in319 * the enclosed list.320 */321 public Polygon getEnclosedShape() {322 if (_enclosure == null)323 return null;324 325 Polygon poly = new Polygon();326 for (Dot d : _enclosure) {327 poly.addPoint(d.getX(), d.getY());328 }329 330 return poly;331 }332 333 /**334 * Returns the list of Dots that, along with this Dot, form an enclosed335 * polygon. If this Dot is not part of an enclosure null may be returned.336 *337 * @return The List of Dots that form an enclosed shape with this Dot, or338 * null if this Dot is not part of an enclosure.339 */340 public List<Dot> getEnclosingDots() {341 return _enclosure;342 }343 344 /**345 * Returns whether this Dot has an assigned enclosure list of other Dots.346 * The result is the same as getEnclosedShape() != null.347 *348 * @return True if this Dot has an enclosure list of other Dots, false349 * otherwise.350 */351 public boolean isEnclosed() {352 return _enclosure != null;353 }354 355 283 @Override 356 284 public String getTypeAndID() { … … 370 298 l.delete(); 371 299 } 300 301 @Override 302 public void anchor() { 303 super.anchor(); 304 Frame current = getCurrentFrame(); 305 for (Line line : getLines()) { 306 if (line.getID() < 0 && !current.getItems().contains(line)) { 307 line.setID(current.getNextItemID()); 308 line.setSelectionColor(); 309 // Mike: Why was this line here? 310 // anchor(line); 311 } 312 } 313 } 314 315 @Override 316 public void addLine(Line line) { 317 super.addLine(line); 318 line.setColor(getColor()); 319 line.setThickness(getThickness()); 320 line.setLinePattern(getLinePattern()); 321 } 322 323 @Override 324 public void lineColorChanged(Color c) { 325 if (getColor() != c) { 326 setColor(c); 327 } 328 } 372 329 } -
trunk/src/org/expeditee/items/Item.java
r29 r50 33 33 * 34 34 */ 35 public abstract class Item implements Comparable<Item>, Runnable { 35 public abstract class Item implements Comparable<Item>, Runnable { 36 37 // contains all dots (including this one) that form an enclosure 38 // if this dot is part of an enclosing shape 39 private List<Item> _enclosure = null; 36 40 37 41 public static int PERMISSION_NONE = 0; 42 38 43 public static int PERMISSION_FOLLOW_LINKS = 1; 44 39 45 public static int PERMISSION_COPY = 2; 46 40 47 public static int PERMISSION_TDFC = 3; 48 41 49 public static int PERMISSION_FULL = 4; 42 50 43 51 public static final int NEAR_DISTANCE = 15; 44 52 45 53 /** 46 54 * The default Color to draw highlighting in … … 51 59 52 60 public static final Color DEPRESSED_HIGHLIGHT = Color.GREEN; 53 61 54 62 public static final Color DISCONNECT_HIGHLIGHT = Color.BLUE; 55 63 … … 74 82 75 83 protected static final double DEFAULT_ARROWHEAD_RATIO = 0.5; 76 84 77 85 public static final Color GREEN = Color.GREEN.darker(); 78 86 … … 81 89 * this Item. 82 90 */ 83 public static Color[] COLOR_WHEEL = { Color.BLACK, Color.RED, 84 Color.BLUE,Item.GREEN, Color.MAGENTA, Color.YELLOW.darker(),91 public static Color[] COLOR_WHEEL = { Color.BLACK, Color.RED, Color.BLUE, 92 Item.GREEN, Color.MAGENTA, Color.YELLOW.darker(), 85 93 DisplayIO.DEFAULT_BACKGROUND }; 86 94 87 public static Color[] FILL_COLOR_WHEEL = { Color.BLACK, new Color(255,150,150), 88 new Color(150,150,255), new Color(150,255,150), new Color(255,150,255), new Color(255,255,100), 89 DisplayIO.DEFAULT_BACKGROUND }; 95 public static Color[] FILL_COLOR_WHEEL = { Color.BLACK, 96 new Color(255, 150, 150), new Color(150, 150, 255), 97 new Color(150, 255, 150), new Color(255, 150, 255), 98 new Color(255, 255, 100), DisplayIO.DEFAULT_BACKGROUND }; 90 99 91 100 public static final int UNCHANGED_CURSOR = -100; … … 144 153 dest.setOffset(source.getOffset()); 145 154 dest.setOwner(source.getOwner()); 155 dest.setThickness(source.getThickness()); 146 156 dest.setSize(source.getSize()); 147 157 dest.setTopShadowColor(source.getTopShadowColor()); … … 167 177 return org.expeditee.gui.UserSettings.LineHighlight; 168 178 } 169 179 170 180 public enum SelectedMode { 171 181 None, Enclosed, Connected, Disconnect, Normal 172 182 } 173 183 174 184 public void setSelectedMode(SelectedMode mode) { 175 185 setSelectedMode(mode, DEFAULT_HIGHLIGHT); 176 186 } 177 187 178 188 protected SelectedMode _mode = SelectedMode.None; 179 189 180 190 private Point _offset = new Point(0, 0); 181 191 … … 213 223 214 224 private Color _colorFill = null; 215 225 216 226 private Color _color = null; 217 227 … … 249 259 250 260 // list of points constrained with this point 251 private List<Constraint> _constraints = n ull;261 private List<Constraint> _constraints = new ArrayList<Constraint>(); 252 262 253 263 private LinkedList<String> _actions = null; 254 264 255 265 private String _link_frameset = null; 256 266 … … 258 268 259 269 private String _fillPattern = null; 260 270 261 271 private boolean _visible = true; 262 272 263 273 private SelectedMode _lastMode = SelectedMode.None; 274 275 private float _thickness = -1.0F; 264 276 265 277 protected Item() { … … 300 312 */ 301 313 public void addConstraint(Constraint c) { 302 if (_constraints == null)303 _constraints = new ArrayList<Constraint>();304 305 314 // do not add duplicate constraint 306 315 if (_constraints.contains(c)) … … 320 329 return; 321 330 } 322 323 line.setColor(getColor());324 line.setSize(getSize());325 line.setLinePattern(getLinePattern());326 331 327 332 _lines.add(line); … … 381 386 final public String getAbsoluteLink() { 382 387 String link = getLink(); 383 388 384 389 if (link == null) 385 390 return null; 386 // assert (_parent!= null);387 if (_parent == null) {388 // if parent is null it is an item on the message box389 // so it must already be absolute390 assert (!FrameIO.isPositiveInteger(link));391 // assert (_parent!= null); 392 if (_parent == null) { 393 // if parent is null it is an item on the message box 394 // so it must already be absolute 395 assert (!FrameIO.isPositiveInteger(link)); 391 396 return link; 392 397 } … … 394 399 // if its a relative link then return absolute 395 400 if (FrameIO.isPositiveInteger(link)) { 396 return _parent.getFramesetName() 397 + Conversion.getFrameNumber(link); 401 return _parent.getFramesetName() + Conversion.getFrameNumber(link); 398 402 } 399 403 return link; … … 689 693 return _owner; 690 694 } 691 695 692 696 public Color getPaintBackgroundColor() { 693 697 if (_colorBackground == null) { … … 752 756 * @return The size of this Item. 753 757 */ 754 public abstract int getSize(); 755 756 public float getThickness() { 757 return 0; 758 public int getSize() { 759 return -1; 758 760 } 759 761 … … 809 811 if (p == null) 810 812 return false; 811 813 812 814 // return p.getBounds().intersects(getArea().getBounds()); 813 815 Area a = new Area(p); 814 816 815 817 a.intersect(this.getArea()); 816 818 return !a.isEmpty(); … … 830 832 831 833 public boolean isFrameName() { 832 if (this.getParent() == null || this.getParent().getFrameNameItem() != this) 834 if (this.getParent() == null 835 || this.getParent().getFrameNameItem() != this) 833 836 return false; 834 837 return true; … … 869 872 870 873 public boolean isNear(int x, int y) { 871 872 874 873 875 int xLeft = getPolygon().getBounds().x; 874 876 int yTop = getPolygon().getBounds().y; 875 876 return (x > xLeft - NEAR_DISTANCE && y > yTop - NEAR_DISTANCE 877 && x < xLeft + getBoundsWidth() + NEAR_DISTANCE 878 && y < yTop+ getBoundsHeight() + NEAR_DISTANCE);877 878 return (x > xLeft - NEAR_DISTANCE && y > yTop - NEAR_DISTANCE 879 && x < xLeft + getBoundsWidth() + NEAR_DISTANCE && y < yTop 880 + getBoundsHeight() + NEAR_DISTANCE); 879 881 } 880 882 … … 945 947 } 946 948 949 /** 950 * Removes all constraints that this item has. 951 * 952 */ 947 953 public void removeAllConstraints() { 948 if (_constraints != null) 949 _constraints.clear(); 954 while (_constraints.size() > 0) { 955 Constraint c = _constraints.get(0); 956 c.getEnd().removeConstraint(c); 957 c.getStart().removeConstraint(c); 958 } 950 959 } 951 960 … … 1015 1024 1016 1025 if (_parent == null) 1017 framesetName = DisplayIO.getCurrentFrame() 1018 .getFramesetName(); 1026 framesetName = DisplayIO.getCurrentFrame().getFramesetName(); 1019 1027 else 1020 1028 framesetName = _parent.getFramesetName(); … … 1118 1126 public void setColor(Color c) { 1119 1127 _color = c; 1120 1121 // update the colour of any lines1122 for (Line line : getLines())1123 line.setColor(c);1124 1128 } 1125 1129 … … 1275 1279 1276 1280 // update the position of any dots that are constrained by this one 1277 if (_constraints != null) { 1278 for (Constraint c : _constraints) { 1279 Item other = c.getOppositeEnd(this); 1280 1281 // only set the position if the other dot is still fixed to the 1282 // frame 1283 if (!other.isFloating()) { 1284 if (c.getConstraintType() == Constraint.HORIZONTAL 1285 && other.getY() != getY()) 1286 other.setY(getY()); 1287 1288 if (c.getConstraintType() == Constraint.VERTICAL 1289 && other.getX() != getX()) 1290 other.setX(getX()); 1291 } 1281 for (Constraint c : _constraints) { 1282 Item other = c.getOppositeEnd(this); 1283 1284 // only set position if the other dot is still fixed to the 1285 // frame 1286 if (!other.isFloating()) { 1287 if (c.getType() == Constraint.HORIZONTAL 1288 && other.getY() != getY()) 1289 other.setY(getY()); 1290 1291 if (c.getType() == Constraint.VERTICAL 1292 && other.getX() != getX()) 1293 other.setX(getX()); 1292 1294 } 1293 1295 } … … 1316 1318 * Dots this is the thickness. 1317 1319 */ 1318 public abstract void setSize(int size); 1319 1320 public void setThickness(float thick) throws UnsupportedOperationException { 1321 throw new UnsupportedOperationException( 1322 "Item type does not support thickness attribute!"); 1320 public void setSize(int size) { 1321 } 1322 1323 public void setThickness(float thick) { 1324 _thickness = thick; 1325 // update the size of any lines 1326 for (Line line : getLines()) 1327 line.setThickness(thick); 1328 } 1329 1330 /** 1331 * Returns the thickness (in pixels) of this Dot. 1332 * 1333 * @return The 'thickness' of this Dot. (returns -1 if the thickness is not 1334 * set). 1335 */ 1336 public float getThickness() { 1337 return _thickness; 1323 1338 } 1324 1339 … … 1386 1401 return Item.UNCHANGED_CURSOR; 1387 1402 } 1388 1403 1389 1404 private void updateArrowPolygon() { 1390 1405 if (getArrowheadLength() < 0 || getArrowheadRatio() < 0) … … 1404 1419 } 1405 1420 } 1406 1421 1407 1422 protected abstract void updatePolygon(); 1408 1423 … … 1414 1429 return _visible; 1415 1430 } 1416 1417 1418 1431 1419 1432 // BROOK: Overrideable 1420 public void onRemovedFromFrame() {} 1421 public void onAddedToFrame(boolean isOverlayed, int overlayLevel) {} 1422 public void onParentFameHidden() {} // because of caching 1423 public void onParentFameShown(boolean isOverlayed, int overlayLevel) {} // because of caching 1433 public void onRemovedFromFrame() { 1434 } 1435 1436 public void onAddedToFrame(boolean isOverlayed, int overlayLevel) { 1437 } 1438 1439 public void onParentFameHidden() { 1440 } // because of caching 1441 1442 public void onParentFameShown(boolean isOverlayed, int overlayLevel) { 1443 } // because of caching 1424 1444 1425 1445 public void setSelectedMode(SelectedMode mode, Color color) { … … 1440 1460 return _mode; 1441 1461 } 1462 1463 public void anchor() { 1464 Frame current = getCurrentFrame(); 1465 setID(current.getNextItemID()); 1466 setOffset(0, 0); 1467 setParent(current); 1468 1469 current.addItem(this); 1470 current.setResort(true); 1471 setRelativeLink(); 1472 setFloating(false); 1473 } 1474 1475 /** 1476 * Gets the parent frame if it is set or the current frame if this item does 1477 * not have a parent set. 1478 * 1479 * @return 1480 */ 1481 public Frame getCurrentFrame() { 1482 // if the item is from an overlay the parent will NOT be null 1483 if (getParent() == null) { 1484 return DisplayIO.getCurrentFrame(); 1485 } 1486 return getParent(); 1487 } 1488 1489 /** 1490 * Sets the list of Dots (including this one) that form a closed shape. 1491 * Passing null sets this dot back to its normal (non-enclosed) state. 1492 * 1493 * @param enclosed 1494 * The List of Dots including this one that form a closed shape, 1495 * or null. 1496 */ 1497 public void setEnclosedList(List<Item> enclosed) { 1498 _enclosure = enclosed; 1499 } 1500 1501 /** 1502 * Returns the polygon that represents the shape created by all the Dots in 1503 * this Dot's enclosed list. If the list is null, then null is returned. 1504 * 1505 * @return A Polygon the same shape and position as created by the Dots in 1506 * the enclosed list. 1507 */ 1508 public Polygon getEnclosedShape() { 1509 if (_enclosure == null) 1510 return null; 1511 1512 Polygon poly = new Polygon(); 1513 for (Item d : _enclosure) { 1514 poly.addPoint(d.getX(), d.getY()); 1515 } 1516 1517 return poly; 1518 } 1519 1520 /** 1521 * Returns the list of Dots that, along with this Dot, form an enclosed 1522 * polygon. If this Dot is not part of an enclosure null may be returned. 1523 * 1524 * @return The List of Dots that form an enclosed shape with this Dot, or 1525 * null if this Dot is not part of an enclosure. 1526 */ 1527 public List<Item> getEnclosingDots() { 1528 return _enclosure; 1529 } 1530 1531 /** 1532 * Returns whether this Dot has an assigned enclosure list of other Dots. 1533 * The result is the same as getEnclosedShape() != null. 1534 * 1535 * @return True if this Dot has an enclosure list of other Dots, false 1536 * otherwise. 1537 */ 1538 public boolean isEnclosed() { 1539 return _enclosure != null; 1540 } 1541 1542 public boolean isLineEnd() { 1543 return _lines.size() > 0; 1544 } 1545 1546 /** 1547 * Method that is called to notify an item that is on the end of a line that 1548 * its line has changed color. 1549 * 1550 * @param c 1551 * the new color for the line 1552 */ 1553 protected void lineColorChanged(Color c) { 1554 for (Line l : getLines()) { 1555 if (l.getColor() != c) 1556 l.setColor(c); 1557 } 1558 } 1442 1559 } -
trunk/src/org/expeditee/items/ItemUtils.java
r26 r50 450 450 for (Constraint c : consts) { 451 451 if (c.contains(line.getEndItem())) { 452 if (c.get ConstraintType() == Constraint.VERTICAL) {452 if (c.getType() == Constraint.VERTICAL) { 453 453 vConst.add(line.getStartItem()); 454 454 vConst.add(line.getEndItem()); … … 659 659 _seen.clear(); 660 660 661 // get all dots on the Frame662 List< Dot> dots = new ArrayList<Dot>(0);661 // get all lineEnds on the Frame 662 List<Item> lineEnds = new ArrayList<Item>(0); 663 663 for (Item i : items) { 664 if (i instanceof Dot) { 665 Dot d = (Dot) i; 666 d.setEnclosedList(null); 667 668 if (d.getLines().size() == 2) 669 dots.add(d); 670 } 671 } 672 673 // if there are no dots on the Frame, then there can't be an enclosure 674 if (dots.size() == 0) 664 if (i.isLineEnd()) { 665 i.setEnclosedList(null); 666 667 if (i.getLines().size() == 2) 668 lineEnds.add(i); 669 } 670 } 671 672 // if there are no line endpoints on the Frame, then there can't be an enclosure 673 if (lineEnds.size() == 0) 675 674 return; 676 675 677 676 //TODO optimise this code!! 678 // iterate through all the dots679 for ( Dot searchFor : dots) {677 // iterate through all the lineEnds 678 for (Item searchFor : lineEnds) { 680 679 _seen.clear(); 681 680 … … 683 682 _seen.add(l); 684 683 if (traverse(searchFor, l.getOppositeEnd(searchFor))) { 685 _path.add( (Dot)l.getOppositeEnd(searchFor));686 687 for ( Dot d: _path)688 d.setEnclosedList(_path);689 690 _path = new ArrayList< Dot>(0);684 _path.add(l.getOppositeEnd(searchFor)); 685 686 for (Item i : _path) 687 i.setEnclosedList(_path); 688 689 _path = new ArrayList<Item>(0); 691 690 692 691 break; … … 699 698 private static List<Line> _seen = new ArrayList<Line>(); 700 699 701 private static List< Dot> _path = new ArrayList<Dot>();702 703 private static boolean traverse( DottoFind, Item searchFrom) {700 private static List<Item> _path = new ArrayList<Item>(); 701 702 private static boolean traverse(Item toFind, Item searchFrom) { 704 703 if (toFind == null || searchFrom == null 705 || ! (searchFrom instanceof Dot))704 || !searchFrom.isLineEnd()) 706 705 return false; 707 706 … … 716 715 _seen.add(l); 717 716 if (traverse(toFind, l.getOppositeEnd(searchFrom))) { 718 _path.add( (Dot)l.getOppositeEnd(searchFrom));717 _path.add(l.getOppositeEnd(searchFrom)); 719 718 return true; 720 719 } -
trunk/src/org/expeditee/items/Line.java
r21 r50 81 81 82 82 // initialise the line size 83 float thick; 84 85 if (_start instanceof Dot && _end instanceof Dot) 86 thick = (((Dot) _start).getThickness() + ((Dot) _end) 87 .getThickness()) / 2.0f; 88 else if (_start instanceof Dot) 89 thick = ((Dot) _start).getThickness(); 90 else if (_end instanceof Dot) 91 thick = ((Dot) _end).getThickness(); 92 else 83 float thick = (_start.getThickness() + _end.getThickness()) / 2.0f; 84 85 if (thick < 0) 93 86 thick = 1; 87 /* 88 * if (_start instanceof Dot && _end instanceof Dot) thick = (((Dot) 89 * _start).getThickness() + ((Dot) _end) .getThickness()) / 2.0f; else 90 * if (_start instanceof Dot) thick = ((Dot) _start).getThickness(); 91 * else if (_end instanceof Dot) thick = ((Dot) _end).getThickness(); 92 * else thick = 1; 93 */ 94 94 95 95 setThickness(thick); … … 134 134 135 135 /** 136 * Replaces either the start or end point of this Line with the given Dot. 137 * This is used when merging two Dots. 136 * Replaces either the start or end point of this Line with the given 137 * LineEnd. This is used when merging LineEnds. It will also add and remove 138 * the line from the LineEnds as well as adjust constraints. 138 139 * 139 140 * @param replace … … 144 145 */ 145 146 public void replaceEnd(Item replace, Item with) { 146 if (_start == replace) 147 Item otherEnd = null; 148 if (_start == replace) { 147 149 setStartItem(with); 148 else 150 otherEnd = _end; 151 } else if (_end == replace) { 149 152 setEndItem(with); 153 otherEnd = _start; 154 } 155 // if no end was replaced 156 if (otherEnd == null) 157 return; 158 // Copy the constraints list so the endPoints list can be modified 159 List<Constraint> constraints = new ArrayList<Constraint>(replace 160 .getConstraints()); 161 // Now change all the constraints for this line only 162 for (int i = 0; i < constraints.size(); i++) { 163 Constraint c = constraints.get(i); 164 if (c.contains(otherEnd)) { 165 c.replaceEnd(replace, with); 166 } 167 } 150 168 } 151 169 … … 154 172 _start.removeLine(this); 155 173 156 if (!(start instanceof Dot)) { 157 _startOffset.x = _start.getX() - start.getX(); 158 _startOffset.y = _start.getY() - start.getY(); 159 } else { 174 /* 175 * if (!(start instanceof Dot)) { _startOffset.x = _start.getX() - 176 * start.getX(); _startOffset.y = _start.getY() - start.getY(); } 177 * else 178 */{ 160 179 _startOffset.x = 0; 161 180 _startOffset.y = 0; … … 172 191 _end.removeLine(this); 173 192 174 if (!(end instanceof Dot)) {175 _endOffset.x = _end.getX() - end.getX();176 _endOffset.y = _end.getY() - end.getY();177 } else{193 /* 194 * if (!(end instanceof Dot)) { _endOffset.x = _end.getX() - 195 * end.getX(); _endOffset.y = _end.getY() - end.getY(); } else 196 */{ 178 197 _endOffset.x = 0; 179 198 _endOffset.y = 0; … … 211 230 } 212 231 232 @Override 213 233 public void setX(int x) { 214 234 } 215 235 236 @Override 216 237 public void setY(int y) { 217 238 } … … 287 308 g.setColor(getPaintColor()); 288 309 289 // if (this._mode == Item.SelectedMode.Disconnect)290 // 291 310 // if (this._mode == Item.SelectedMode.Disconnect) 311 // System.out.println("Disconnect mode!"); 312 292 313 if (_start instanceof Text && ((Text) _start).startsWith("@c")) { 293 314 g.setStroke(_lineStroke); … … 340 361 Point endOffset) { 341 362 // only draw an arrowhead if necessary 342 if (!(this._mode == Item.SelectedMode.Disconnect 343 && withArrow._mode == Item.SelectedMode.Disconnect) 344 && (!withArrow.hasVisibleArrow() 345 || withArrow.getLines().size() > 1)) 363 if (!(this._mode == Item.SelectedMode.Disconnect && withArrow._mode == Item.SelectedMode.Disconnect) 364 && (!withArrow.hasVisibleArrow() || withArrow.getLines().size() > 1)) 346 365 return; 347 366 … … 356 375 double arrowRatio = withArrow.getArrowheadRatio(); 357 376 358 // set the size of the disconnect indicator arrowhead359 if (this._mode == Item.SelectedMode.Disconnect) {360 // System.out.println("Disconnect mode!");377 // set the size of the disconnect indicator arrowhead 378 if (this._mode == Item.SelectedMode.Disconnect) { 379 // System.out.println("Disconnect mode!"); 361 380 arrowLength = 15; 362 381 arrowRatio = 0.3; 363 // Make sure the arrowhead positions get recalculated382 // Make sure the arrowhead positions get recalculated 364 383 withArrow.setArrowhead(null); 365 384 } 366 385 367 386 // if the arrowhead is 'auto', then one and only one end must be 368 387 // floating … … 489 508 return end; 490 509 } else if (distStart < DISCONNECT_THRESHHOLD) { 491 start._mode = Item.SelectedMode.Disconnect; 510 if (start.getLines().size() > 1 511 || start.getConstraints().size() > 0) 512 start._mode = Item.SelectedMode.Disconnect; 513 else 514 start._mode = Item.SelectedMode.Normal; 492 515 return start; 493 516 } else if (distEnd < DISCONNECT_THRESHHOLD) { 494 end._mode = Item.SelectedMode.Disconnect; 517 if (end.getLines().size() > 1 || end.getConstraints().size() > 0) 518 end._mode = Item.SelectedMode.Disconnect; 519 else 520 end._mode = Item.SelectedMode.Normal; 495 521 return end; 496 522 } … … 520 546 super.setColor(c); 521 547 522 if (_start.getColor() != c) 523 _start.setColor(c); 524 525 if (_end.getColor() != c) 526 _end.setColor(c); 527 } 528 529 @Override 530 public int getSize() { 531 return _start.getSize(); 532 } 533 534 @Override 535 public void setSize(int size) { 548 _start.lineColorChanged(c); 549 _end.lineColorChanged(c); 536 550 } 537 551 … … 543 557 thick = DEFAULT_THICKNESS; 544 558 545 if (_start instanceof Dot) { 546 Dot start = (Dot) _start; 547 if (start.getThickness() != thick) 548 start.setThickness(thick); 549 } 550 551 if (_end instanceof Dot) { 552 Dot end = (Dot) _end; 553 if (end.getThickness() != thick) 554 end.setThickness(thick); 555 } 559 if (_start.getThickness() != thick) 560 _start.setThickness(thick); 561 562 if (_end.getThickness() != thick) 563 _end.setThickness(thick); 556 564 557 565 int[] pattern = _start.getLinePattern(); … … 734 742 private Dot _virtualSpot = null; 735 743 736 public void showVirtualSpot( Dotorig, int mouseX, int mouseY) {744 public void showVirtualSpot(Item orig, int mouseX, int mouseY) { 737 745 if (orig.getLines().size() != 1) 738 746 return; … … 742 750 return; 743 751 744 Dot spot = orig.copy(); 752 Dot spot = new Dot(-1, orig.getX(), orig.getY()); 753 Item.DuplicateItem(orig, spot); 745 754 spot.setThickness(Math.max(this.getThickness(), 5)); 746 755 if (this.getColor() != Color.RED) … … 817 826 } 818 827 819 public Item forceMerge(Item merger, int mouseX, int mouseY) { 820 Dot spot = (Dot) merger; 821 822 if (spot.getConstraints() != null) 823 spot.getConstraints().clear(); 824 825 if (_end.getConstraints() != null) 826 _end.getConstraints().clear(); 827 828 if (_start.getConstraints() != null) 829 _start.getConstraints().clear(); 828 public Item forceMerge(Item spot, int mouseX, int mouseY) { 829 830 spot.removeAllConstraints(); 831 832 _end.removeAllConstraints(); 833 834 _start.removeAllConstraints(); 830 835 831 836 // calculate nearest point on line from spot … … 840 845 // if the line is horizontal 841 846 if (slope1 == 0) { 842 x = merger.getX();847 x = spot.getX(); 843 848 y = _start.getY(); 844 849 // if the line is vertical 845 850 } else if (slope2 == 0) { 846 851 x = _start.getX(); 847 y = merger.getY();852 y = spot.getY(); 848 853 // otherwise, the line is sloped 849 854 } else { … … 875 880 @Override 876 881 public Item merge(Item merger, int mouseX, int mouseY) { 877 if (!(merger instanceof Dot))882 if (!(merger.isLineEnd())) 878 883 return merger; 879 884 880 Dot spot = (Dot)merger;885 Item spot = merger; 881 886 882 887 // dots with multiple lines cannot be attached, nor can dots with no … … 1015 1020 _end.delete(); 1016 1021 } 1022 1023 @Override 1024 public void anchor() { 1025 super.anchor(); 1026 fixArrowheadLength(); 1027 } 1028 1029 /** 1030 * Removes constraints from the end points of this line. 1031 */ 1032 @Override 1033 public void removeAllConstraints() { 1034 // Find all constraints that include both the start and end. 1035 for (Constraint c : _start.getConstraints()) { 1036 if (c.contains(_end)) { 1037 _start.removeConstraint(c); 1038 _end.removeConstraint(c); 1039 } 1040 } 1041 } 1017 1042 } -
trunk/src/org/expeditee/items/Text.java
r41 r50 905 905 Rectangle textOutline = text.getLogicalHighlightShape(0, 906 906 text.getCharacterCount()).getBounds(); 907 textOutline.translate(getX(), textY); 907 textOutline.width += 2; 908 textOutline.height += 2; 909 910 textOutline.translate(getX() -1, textY - 1); 908 911 if (p.intersects(textOutline)) 909 912 return true; … … 1451 1454 @Override 1452 1455 public Item merge(Item merger, int mouseX, int mouseY) { 1453 if (merger instanceof Dot) { 1454 Dot d = (Dot) merger; 1456 1457 if (merger.isLineEnd()) { 1458 if (merger instanceof Text) 1459 insertText(((Text)merger).getTextNoList(), mouseX, mouseY); 1460 1461 //this.setPosition(merger.getPosition()); 1455 1462 List<Line> lines = new LinkedList<Line>(); 1456 lines.addAll(d.getLines()); 1457 for (Line line : lines) 1458 line.replaceEnd(d, this); 1459 1460 d.removeAllLines(); 1463 lines.addAll(merger.getLines()); 1464 for (Line line : lines){ 1465 line.replaceEnd(merger, this); 1466 } 1467 merger.delete(); 1468 this.setOffset(0,0); 1461 1469 return null; 1462 1470 } … … 1569 1577 setVisible(false); 1570 1578 } 1579 1580 @Override 1581 public void anchor() { 1582 super.anchor(); 1583 // ensure all text items have their selection cleared 1584 clearSelection(); 1585 setAlpha(0); 1586 } 1571 1587 }
Note:
See TracChangeset
for help on using the changeset viewer.