Changeset 21
- Timestamp:
- 05/08/08 14:30:09 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r7 r21 244 244 */ 245 245 public static void PerformAction(Frame source, Item launcher, String command) { 246 FrameIO.SaveFrame(source, false); 247 246 248 // separate method name and parameter names 247 249 String mname = getName(command); … … 303 305 } catch (Exception e) { 304 306 Logger.Log(e); 305 //e.printStackTrace();307 e.printStackTrace(); 306 308 } 307 309 } -
trunk/src/org/expeditee/actions/Misc.java
r19 r21 18 18 import org.expeditee.gui.FrameMouseActions; 19 19 import org.expeditee.items.Item; 20 import org.expeditee.items.Picture; 20 21 import org.expeditee.items.Text; 21 22 import org.expeditee.stats.SessionStats; … … 203 204 * cursor via FrameMouseActions.pickup(Item) 204 205 */ 205 public static void Get CurrentStats() {206 public static void GetSessionStats() { 206 207 String stats = SessionStats.getCurrentStats(); 207 208 -
trunk/src/org/expeditee/actions/Simple.java
r19 r21 38 38 import org.expeditee.simple.UnitTestFailedException; 39 39 import org.expeditee.stats.AgentStats; 40 import org.expeditee.stats.SessionStats; 40 41 41 42 public class Simple { … … 236 237 // item.setColor(Color.CYAN); 237 238 FrameUtils.DisplayFrame(item.getParent().getFrameName(), true); 238 item.s howHighlight(true,Color.CYAN);239 item.setSelectionColor(Color.CYAN); 239 240 FrameIO.SaveFrame(item.getParent()); 240 241 } … … 312 313 Frame frame = i.getParent(); 313 314 314 if (i == frame.getTitle() || i == frame.getFrameNameItem() || i.isAnnotation()) { 315 if (i == frame.getTitle() || i == frame.getFrameNameItem() 316 || i.isAnnotation()) { 315 317 return false; 316 318 } … … 576 578 for (Text text : targetFrame.getBodyTextItems(true)) { 577 579 String s = text.getTextNoList().toLowerCase(); 578 580 579 581 if (s.startsWith(targetAttribute)) { 580 582 attributeItem = text; … … 847 849 } 848 850 } 849 850 851 return Status.OK; 851 852 } else if (tokens[0].startsWith("getframename")) { … … 872 873 frameName); 873 874 context.getPrimitives().setValue(tokens[2], filePath); 875 return Status.OK; 876 } else if (tokens[0].equals("getframelog")) { 877 assertExactParametreCount(tokens, 1); 878 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 879 880 String log = SessionStats.getFrameEventList(); 881 Text t; 882 try { 883 t = (Text) context.getPointers().getVariable(tokens[1]) 884 .getValue(); 885 t.setText(log); 886 } catch (Exception e) { 887 t = new Text(-1, log); 888 context.getPointers().setObject(tokens[1], t); 889 } 890 874 891 return Status.OK; 875 892 } … … 1005 1022 FrameIO.getFramesetList()); 1006 1023 return Status.OK; 1024 } else if (tokens[0].equals("getsessionstats")) { 1025 assertExactParametreCount(tokens, 1); 1026 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1027 1028 String stats = SessionStats.getCurrentStats(); 1029 Text t; 1030 try { 1031 t = (Text) context.getPointers().getVariable(tokens[1]) 1032 .getValue(); 1033 t.setText(stats); 1034 } catch (Exception e) { 1035 t = new Text(-1, stats); 1036 context.getPointers().setObject(tokens[1], t); 1037 } 1038 1039 return Status.OK; 1007 1040 } 1008 1041 } else if (tokens[0].equals("or")) { … … 1060 1093 || tokens[0].equals("errorln") || tokens[0].equals("errorline")) { 1061 1094 String message = getMessage(tokens, context, code.toString(), 1062 tokens[0].endsWith("nospaces") ? "" : " " );1095 tokens[0].endsWith("nospaces") ? "" : " ", 1); 1063 1096 1064 1097 if (tokens[0].equals("errorln") || tokens[0].equals("errorline")) … … 1067 1100 FrameGraphics.DisplayMessageAlways(message); 1068 1101 return Status.OK; 1069 } else if (tokens[0].equals("typein") 1070 || tokens[0].equals("typeinnospaces")) { 1102 } else if (tokens[0].equals("typeatrate")) { 1103 assertMinParametreCount(tokens, 1); 1104 double delay = context.getPrimitives().getDoubleValue(tokens[1]); 1105 String s = getMessage(tokens, context, code.toString(), " ", 2); 1106 for (int i = 0; i < s.length(); i++) { 1107 FrameKeyboardActions.processChar(s.charAt(i)); 1108 Thread.sleep((int) (delay * 1000)); 1109 } 1110 return Status.OK; 1111 } else if (tokens[0].equals("type") || tokens[0].equals("typenospaces")) { 1071 1112 1072 1113 String s = getMessage(tokens, context, code.toString(), tokens[0] 1073 .equals("type in") ? " " : "");1114 .equals("type") ? " " : "", 1); 1074 1115 for (int i = 0; i < s.length(); i++) { 1075 1116 FrameKeyboardActions.processChar(s.charAt(i)); 1076 1117 Thread.sleep(25); 1077 1118 } 1119 return Status.OK; 1120 } else if (tokens[0].equals("runstring")) { 1121 String codeText = getMessage(tokens, context, code.toString(), " ", 1122 1); 1123 Text dynamicCode = new Text(1, codeText); 1124 RunItem(dynamicCode, context, Status.OK); 1078 1125 return Status.OK; 1079 1126 } else if (tokens[0].startsWith("else")) { … … 1345 1392 } else if (tokens[0].equals("copyitem")) { 1346 1393 assertMinParametreCount(tokens, 2); 1347 assertVariableType(tokens[1],1,SPointer.itemPrefix); 1348 assertVariableType(tokens[2],2,SPointer.itemPrefix); 1349 Item item = (Item)context.getPointers().getVariable(tokens[1]).getValue(); 1394 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1395 assertVariableType(tokens[2], 2, SPointer.itemPrefix); 1396 Item item = (Item) context.getPointers().getVariable(tokens[1]) 1397 .getValue(); 1350 1398 Item copy = item.copy(); 1351 1399 context.getPointers().setObject(tokens[2], copy); 1352 1400 1353 1401 return Status.OK; 1354 } else if (tokens[0].equals("copyframeset")) {1402 } else if (tokens[0].equals("copyframeset")) { 1355 1403 assertMinParametreCount(tokens, 2); 1356 1404 String framesetToCopy = context.getPrimitives().getStringValue( … … 1369 1417 } else if (tokens[0].equals("copyframe")) { 1370 1418 assertMinParametreCount(tokens, 2); 1371 assertVariableType(tokens[1], 1,SPointer.framePrefix);1372 assertVariableType(tokens[2], 2,SPointer.framePrefix);1419 assertVariableType(tokens[1], 1, SPointer.framePrefix); 1420 assertVariableType(tokens[2], 2, SPointer.framePrefix); 1373 1421 Frame frameToCopy = (Frame) context.getPointers().getVariable( 1374 1422 tokens[1]).getValue(); … … 2063 2111 2064 2112 private static String getMessage(String[] tokens, Context context, 2065 String code, String separator) throws Exception { 2113 String code, String separator, int firstStringIndex) 2114 throws Exception { 2066 2115 StringBuilder message = new StringBuilder(); 2067 if (tokens.length == 1) {2116 if (tokens.length == firstStringIndex) { 2068 2117 message.append(context.getPrimitives().getVariable(DEFAULT_STRING) 2069 2118 .stringValue()); 2070 2119 } else { 2071 for (int i = 1; i < tokens.length; i++) {2120 for (int i = firstStringIndex; i < tokens.length; i++) { 2072 2121 if (Primitives.isPrimitive(tokens[i])) { 2073 2122 message.append(context.getPrimitives().getVariable( -
trunk/src/org/expeditee/agents/DisplayTree.java
r4 r21 61 61 @Override 62 62 protected void processFrame(Frame toProcess) { 63 FrameUtils.ResponseTimer.restart(); 64 63 65 // ignore loops 64 66 if (toProcess != DisplayIO.getCurrentFrame()) 65 67 FrameUtils.DisplayFrame(toProcess, false); 66 67 FrameUtils.ResponseTimer.restart();68 68 69 69 // parse the frame for any pause settings -
trunk/src/org/expeditee/gui/DisplayIO.java
r18 r21 59 59 * The title to display in the Title bar. 60 60 */ 61 public static final String TITLE = "Exp0 6May2008A";61 public static final String TITLE = "Exp08May2008B"; 62 62 63 63 private DisplayIO() { … … 88 88 cursorType = Item.TEXT_CURSOR; 89 89 90 // Do some stuff to adjust the cursor size based on the font size90 // Do some stuff to adjust the cursor size based on the font size 91 91 final int MEDIUM_CURSOR_CUTOFF = 31; 92 92 final int LARGE_CURSOR_CUTOFF = 62; … … 112 112 } 113 113 114 /*System.out.println("hs: " + hotspotPos + " start: " + start + " font: " 115 + size + " cursor: " + (cursorSize - start));*/ 114 /* 115 * System.out.println("hs: " + hotspotPos + " start: " + start + " font: " + 116 * size + " cursor: " + (cursorSize - start)); 117 */ 116 118 117 119 int[] pixels = new int[cursorSize * cursorSize]; … … 174 176 175 177 public static void setCursorPosition(int x, int y, boolean forceArrow) { 176 if (Frame.itemAttachedToCursor()) { 177 List<Item> toMove = Frame.FreeItems; 178 179 int deltax = x - FrameMouseActions.MouseX; 180 int deltay = y - FrameMouseActions.MouseY; 181 182 for (Item move : toMove) { 183 move.setPosition(move.getX() + deltax, move.getY() + deltay); 184 } 185 186 // FrameGraphics.Repaint(); 187 188 // if (!item.getArea().contains(x, y)) 189 // item.setPosition(x, y); 190 } 178 int deltax = x - FrameMouseActions.MouseX; 179 int deltay = y - FrameMouseActions.MouseY; 191 180 192 181 if (_TwinFrames) { … … 195 184 } 196 185 197 // cheat198 FrameMouseActions.setForceArrow(forceArrow);199 200 186 // ensures the cursor doesn't fall behind while waiting for robot 201 187 FrameMouseActions.MouseX = x; 202 188 FrameMouseActions.MouseY = y; 203 189 204 _Robot.mouseMove((int)_Browser.getContentPane().getLocationOnScreen().getX() + x, (int)_Browser.getContentPane().getLocationOnScreen().getY() + y); 190 if (Frame.itemAttachedToCursor()) { 191 List<Item> toMove = Frame.FreeItems; 192 for (Item move : toMove) { 193 move.setPosition(move.getX() + deltax, move.getY() + deltay); 194 } 195 } 196 197 // cheat 198 FrameMouseActions.setForceArrow(forceArrow); 199 _Robot.mouseMove((int) _Browser.getContentPane().getLocationOnScreen() 200 .getX() 201 + x, (int) _Browser.getContentPane().getLocationOnScreen() 202 .getY() 203 + y); 205 204 } 206 205 … … 330 329 FrameIO.ResumeCache(); 331 330 } 332 331 333 332 // If the frames are the same then the items for the 334 333 // frame that is just about to hide will still be in view 335 334 // so only notify items that they are hidden if the 336 335 // frames differ. 337 if (_CurrentFrames[getCurrentSide()] != null &&338 _CurrentFrames[0] != _CurrentFrames[1]) {336 if (_CurrentFrames[getCurrentSide()] != null 337 && _CurrentFrames[0] != _CurrentFrames[1]) { 339 338 for (Item i : _CurrentFrames[getCurrentSide()].getItems()) { 340 i.onParentFameHidden(); 339 i.onParentFameHidden(); 341 340 } 342 341 } 343 342 _CurrentFrames[getCurrentSide()] = frame; 344 345 // BROOK 343 344 // BROOK 346 345 for (Item i : _CurrentFrames[getCurrentSide()].getItems()) { 347 346 i.onParentFameShown(); 348 347 } 349 348 } else { 350 // Notifying items on the frame being hidden that they 349 // Notifying items on the frame being hidden that they 351 350 // are about to be hidden. 352 351 // ie. Widgets use this method to remove themselves from 353 // the JPanel352 // the JPanel 354 353 if (_CurrentFrames[getCurrentSide()] != null) { 355 354 for (Item i : _CurrentFrames[getCurrentSide()].getItems()) { 356 i.onParentFameHidden(); 355 i.onParentFameHidden(); 357 356 } 358 357 } 359 358 360 359 _CurrentFrames[getCurrentSide()] = frame; 361 360 frame.setMaxSize(FrameGraphics.getMaxFrameSize()); 362 361 363 362 // Notify items on the frame being displayed that they are in view 364 // ie. widgets use this method to add themselves to the content pane363 // ie. widgets use this method to add themselves to the content pane 365 364 for (Item i : _CurrentFrames[getCurrentSide()].getItems()) { 366 365 i.onParentFameShown(); … … 369 368 370 369 FrameGraphics.Repaint(); 371 UpdateTitle();372 370 } 373 371 … … 539 537 if (i.getLink() != null 540 538 && i.getAbsoluteLink().toLowerCase().equals(oldFrame)) { 541 i.showHighlight(true, BACK_HIGHLIGHT_COLOR); 542 //check if its an @f item and if so update the buffer 539 i.setSelectedMode(Item.SelectedMode.Normal, 540 BACK_HIGHLIGHT_COLOR); 541 // check if its an @f item and if so update the buffer 543 542 if (i instanceof Picture) { 544 Picture p = (Picture) i;543 Picture p = (Picture) i; 545 544 p.refresh(); 546 545 } -
trunk/src/org/expeditee/gui/FrameCreator.java
r19 r21 41 41 } 42 42 _name = name; 43 _lastY += toUse.getTitle().getPosition().y; 44 45 //Check for @Start 46 for (Item it : toUse.getItems()) { 47 if (it instanceof Text) { 48 Text t = (Text) it; 49 if (t.getTextNoList().toLowerCase().equals("@start") || 50 t.getTextNoList().toLowerCase().startsWith("@start:")) { 51 t.stripFirstWord(); 52 53 if (t.getTextNoList().equals("")){ 54 _lastY = t.getY(); 55 _lastX = t.getX(); 56 t.delete(); 57 break; 58 } 59 } 60 } 61 } 62 _current = toUse; 43 resetGlobals(toUse); 63 44 64 45 // set positions of next\prev frame links … … 91 72 FrameIO.SaveFrame(_current, false); 92 73 93 // update\reset globals 94 _current = newFrame; 95 _lastY = START_Y + _current.getTitle().getPosition().y; 96 ; 97 _lastX = START_X; 74 resetGlobals(newFrame); 98 75 _maxX = 0; 99 76 return true; … … 101 78 return false; 102 79 } 80 } 81 82 private void resetGlobals(Frame toUse) { 83 _lastY = START_Y + toUse.getTitle().getPosition().y; 84 _lastX = START_X; 85 //Check for @Start 86 for (Item it : toUse.getItems()) { 87 if (it instanceof Text) { 88 Text t = (Text) it; 89 if (t.getTextNoList().toLowerCase().equals("@start") || 90 t.getTextNoList().toLowerCase().startsWith("@start:")) { 91 t.stripFirstWord(); 92 93 if (t.getTextNoList().equals("")){ 94 _lastY = t.getY(); 95 _lastX = t.getX(); 96 t.delete(); 97 break; 98 } 99 } 100 } 101 } 102 _current = toUse; 103 103 } 104 104 -
trunk/src/org/expeditee/gui/FrameGraphics.java
r19 r21 191 191 && (!isAudienceMode() 192 192 || (isAudienceMode() && !i.isAnnotation()) || i == FrameUtils.LastEdited)) { 193 /* 194 * // do not paint the name of overlay frames if (i.getParent() == 195 * null || i.getParent() == DisplayIO.getCurrentFrame() || 196 * i.getParent() == DisplayIO.getOppositeFrame() || i != 197 * i.getParent().getFrameNameItem()) { 198 */ 193 199 194 Graphics2D tg = (Graphics2D) g.create(); 200 195 i.paint(tg); … … 260 255 iw.paint(bg); 261 256 } 262 257 263 258 PaintPictures(bg, paintItems); 264 259 … … 314 309 PaintLines(bg, Frame.FreeItems); 315 310 } 316 311 317 312 if (paintOverlay) { 318 313 PaintItem(bg, toPaint.getFrameNameItem()); 319 314 } 320 315 321 316 // BROOK: Ensure popups are repainted 322 317 if (Browser._theBrowser != null) … … 408 403 g.drawImage(_MessageBuffer, 0, _MaxSize.height, null); 409 404 g.dispose(); 410 411 } 412 413 414 405 406 } 407 408 /** 409 * Paints the message area 410 * @param g 411 * @param background 412 */ 415 413 private static void paintMessage(Graphics2D g, Color background) { 416 414 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, … … 497 495 * erased. 498 496 */ 499 public static void Highlight(Item i , boolean val, boolean changeMouse) {497 public static void Highlight(Item i) { 500 498 if ((i instanceof Line)) { 501 499 // Check if within 20% of the end of the line … … 506 504 // Brook: Widget Edges do not have such a context 507 505 if (toDisconnect != null && !(i instanceof WidgetEdge)) { 508 if(Frame.itemAttachedToCursor())509 return;510 511 // unhighlight all the other dots506 Item.SelectedMode newMode = toDisconnect.getSelectedMode(); 507 if (Frame.itemAttachedToCursor()) 508 newMode = Item.SelectedMode.Normal; 509 // unhighlight all the other dots 512 510 for (Item conn : toDisconnect.getAllConnected()) { 513 conn.s howHighlight(false);511 conn.setSelectedMode(Item.SelectedMode.None); 514 512 } 515 //highlight the dot that will be in disconnect mode516 toDisconnect.showDisconnectHighlight(val);517 toDisconnect.set FilledHighlight(true);513 l.setSelectedMode(newMode); 514 // highlight the dot that will be in disconnect mode 515 toDisconnect.setSelectedMode(newMode); 518 516 } else { 519 517 List<Item> connected = i.getAllConnected(); 520 518 for (Item conn : connected) { 521 conn.showHighlight(val); 522 conn.setFilledHighlight(false); 519 conn.setSelectedMode(Item.SelectedMode.Connected); 523 520 } 524 521 } 525 522 } else { 526 i.showHighlight(val); 527 i.setFilledHighlight(true); 528 } 529 523 i.setSelectedMode(Item.SelectedMode.Normal); 524 } 525 526 Repaint(); 527 } 528 529 public static void ChangeSelectionMode(Item item, Item.SelectedMode newMode) { 530 if (item == null) 531 return; 532 533 for(Item i: item.getAllConnected()) 534 i.setSelectedMode(newMode); 530 535 Repaint(); 531 536 } … … 567 572 568 573 public static void DisplayMessageAlways(String message) { 569 // _lastMessage = null;574 // _lastMessage = null; 570 575 displayMessage(message, null, Color.BLACK); 571 576 Misc.Beep(); … … 577 582 } 578 583 579 // private static String _lastMessage = null;584 // private static String _lastMessage = null; 580 585 581 586 private static void displayMessage(String message, String link, Color color) { 582 587 // add timestamp to message 583 // if (message.equals(_lastMessage))584 // 585 // _lastMessage = message;588 // if (message.equals(_lastMessage)) 589 // return; 590 // _lastMessage = message; 586 591 587 592 // message += _formatter.format(Calendar.getInstance().getTime()); … … 603 608 for (int i = 0; i < Messages.length; i++) { 604 609 if (Messages[i] == null) { 605 Messages[i] = new Text(-1, "@" + _MessageCount++ + ": " + message); 610 Messages[i] = new Text(-1, "@" + _MessageCount++ + ": " 611 + message); 606 612 Messages[i].setPosition(20, pos); 607 613 Messages[i].setOffset(0, -_MaxSize.height); … … 748 754 _SupressErrors = val; 749 755 } 750 751 756 752 757 private static void repaintPopups(Container parent, Graphics g) { 753 758 for (Component c : parent.getComponents()) { 754 if (c instanceof JPopupMenu && ((JPopupMenu)c).isVisible()) { 755 756 Point p = SwingUtilities.convertPoint(c, c.getLocation(), Browser._theBrowser.getContentPane()); 757 759 if (c instanceof JPopupMenu && ((JPopupMenu) c).isVisible()) { 760 761 Point p = SwingUtilities.convertPoint(c, c.getLocation(), 762 Browser._theBrowser.getContentPane()); 763 758 764 g.translate(p.x, p.y); 759 765 c.paint(g); 760 766 g.translate(-p.x, -p.y); 761 } else if (c instanceof Container &&762 c != Browser._theBrowser.getContentPane()) {763 repaintPopups((Container) c, g);767 } else if (c instanceof Container 768 && c != Browser._theBrowser.getContentPane()) { 769 repaintPopups((Container) c, g); 764 770 } 765 771 } -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r19 r21 559 559 } 560 560 561 public static void functionKey(int key) { 562 functionKey(key, 1); 563 } 564 561 565 /** 562 566 * Called when a Function key has been pressed, and performs the specific 563 567 * action based on the key. 564 568 */ 565 public static void functionKey(int key ) {569 public static void functionKey(int key, int repeat) { 566 570 // get whatever the user is pointing at 567 571 Item on = FrameUtils.getCurrentItem(); … … 594 598 if (resizeLines 595 599 || (!(ip instanceof Line) && !(ip instanceof Dot))) 596 SetSize(ip, 1, false);600 SetSize(ip, repeat, false); 597 601 break; 598 602 case SIZE_DOWN: 599 603 if (resizeLines 600 604 || (!(ip instanceof Line) && !(ip instanceof Dot))) 601 SetSize(ip, - 1, false);605 SetSize(ip, -repeat, false); 602 606 break; 603 607 // case COLOR_CHANGE: SetFillColor(ip); break; … … 632 636 break; 633 637 case SIZE_UP: 634 SetSize(on, 1, true);638 SetSize(on, repeat, true); 635 639 break; 636 640 case SIZE_DOWN: 637 SetSize(on, - 1, true);641 SetSize(on, -repeat, true); 638 642 break; 639 643 case COLOR_CHANGE: -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r10 r21 32 32 public class FrameMouseActions implements MouseListener, MouseMotionListener, 33 33 MouseWheelListener { 34 35 36 private FrameMouseActions() {}37 34 35 private FrameMouseActions() { 36 } 37 38 38 private static FrameMouseActions _instance = null; 39 39 40 40 public static FrameMouseActions getInstance() { 41 if (_instance == null) _instance = new FrameMouseActions(); 41 if (_instance == null) 42 _instance = new FrameMouseActions(); 42 43 return _instance; 43 44 } … … 198 199 public void mouseClicked(MouseEvent e) { 199 200 } 200 201 201 202 /** 202 203 * Each Item on the Frame is checked to determine if the mouse x,y … … 275 276 { 276 277 // This must happen before the previous code 278 // This is when the user is anchoring something 277 279 if (_context == CONTEXT_FREESPACE && Frame.itemAttachedToCursor()) { 280 FrameGraphics.ChangeSelectionMode(_lastHighlightedItem, Item.SelectedMode.None); 281 278 282 _lastHighlightedItem = Frame.getItemAttachedToCursor(); 279 } 280 // show depressed highlighting 281 if (_lastHighlightedItem != null) { 282 _lastHighlightedItem.showDepressedHighlight(true); 283 for (Item i : Frame.FreeItems) { 284 i.restoreLastMode(Item.DEPRESSED_HIGHLIGHT); 285 } 286 FrameGraphics.Repaint(); 287 // this is when the user is picking something up 288 } else if (_lastHighlightedItem != null) { 289 if (!(_lastHighlightedItem instanceof Line)) { 290 _lastHighlightedItem 291 .setSelectionColor(Item.DEPRESSED_HIGHLIGHT); 292 } else { 293 for (Item i : _lastHighlightedItem.getAllConnected()) { 294 i.setSelectionColor(Item.DEPRESSED_HIGHLIGHT); 295 } 296 } 283 297 FrameGraphics.Repaint(); 284 298 } … … 305 319 // This is where all the processing happens 306 320 public void mouseReleased(MouseEvent e) { 321 FrameUtils.ResponseTimer.restart(); 322 307 323 _mouseDown -= e.getButton(); 308 324 updateCursor(); … … 331 347 } 332 348 333 FrameUtils.ResponseTimer.restart();334 335 349 _ExtrudeMouseTimer.stop(); 336 350 _MouseTimer.stop(); … … 374 388 375 389 if (_lastHighlightedItem != null) 376 FrameGraphics.Highlight(_lastHighlightedItem, false, false); 390 FrameGraphics.ChangeSelectionMode(_lastHighlightedItem, 391 Item.SelectedMode.None); 377 392 378 393 if (Frame.itemAttachedToCursor()) { … … 578 593 if (clicked == null) 579 594 return false; 580 595 581 596 // Brook: widgets do not merge 582 if (clicked instanceof WidgetCorner) return false; 583 597 if (clicked instanceof WidgetCorner) 598 return false; 599 584 600 // Brook: widgets do not merge 585 if (clicked instanceof WidgetEdge) return false; 601 if (clicked instanceof WidgetEdge) 602 return false; 586 603 587 604 // System.out.println(Frame.FreeItems.size()); … … 655 672 656 673 if (toDisconnect != null) { 657 List<Line> lines = toDisconnect.getLines(); 658 if (lines.size() == 1) { 659 //remove constraints 660 toDisconnect.removeAllConstraints(); 661 662 DisplayIO.setCursorPosition(toDisconnect 663 .getPosition(), false); 674 if (toDisconnect.getSelectedMode() == Item.SelectedMode.Normal) { 664 675 pickup(toDisconnect); 665 676 return; 666 } 667 // If we are then detatch the line and pick up its end 668 // point... 669 Frame currentFrame = DisplayIO.getCurrentFrame(); 670 Item newPoint = toDisconnect.copy(); 671 newPoint.setID(currentFrame.getNextItemID()); 672 currentFrame.addItem(newPoint); 673 // remove the current item from the connected 674 // list for this item 675 for (Item i : lines) { 676 if (i == l) { 677 toDisconnect.removeLine(l); 678 break; 677 } else { 678 List<Line> lines = toDisconnect.getLines(); 679 if (lines.size() == 1) { 680 // remove constraints 681 toDisconnect.removeAllConstraints(); 682 683 DisplayIO.setCursorPosition(toDisconnect 684 .getPosition(), false); 685 pickup(toDisconnect); 686 return; 679 687 } 680 } 681 if (toDisconnect == l.getStartItem()) { 682 l.setStartItem(newPoint); 683 } else { 684 l.setEndItem(newPoint); 685 } 686 687 // remove unneeded constrains 688 List<Constraint> constraints = toDisconnect 689 .getConstraints(); 690 if (constraints != null) { 691 for (Constraint c : constraints) { 692 Item oppositeEnd = l.getOppositeEnd(newPoint); 693 if (c.contains(oppositeEnd)) { 694 toDisconnect.removeConstraint(c); 695 oppositeEnd.removeConstraint(c); 688 // If we are then detatch the line and pick up its 689 // end 690 // point... 691 Frame currentFrame = DisplayIO.getCurrentFrame(); 692 Item newPoint = toDisconnect.copy(); 693 newPoint.setID(currentFrame.getNextItemID()); 694 currentFrame.addItem(newPoint); 695 // remove the current item from the connected 696 // list for this item 697 for (Item i : lines) { 698 if (i == l) { 699 toDisconnect.removeLine(l); 696 700 break; 697 701 } 698 702 } 703 if (toDisconnect == l.getStartItem()) { 704 l.setStartItem(newPoint); 705 } else { 706 l.setEndItem(newPoint); 707 } 708 709 // remove unneeded constrains 710 List<Constraint> constraints = toDisconnect 711 .getConstraints(); 712 if (constraints != null) { 713 for (Constraint c : constraints) { 714 Item oppositeEnd = l 715 .getOppositeEnd(newPoint); 716 if (c.contains(oppositeEnd)) { 717 toDisconnect.removeConstraint(c); 718 oppositeEnd.removeConstraint(c); 719 break; 720 } 721 } 722 } 723 724 toDisconnect 725 .setSelectedMode(Item.SelectedMode.None); 726 DisplayIO.setCursorPosition(toDisconnect 727 .getPosition(), false); 728 pickup(newPoint); 729 730 return; 699 731 } 700 701 toDisconnect.showHighlight(false);702 DisplayIO.setCursorPosition(toDisconnect.getPosition(),703 false);704 pickup(newPoint);705 706 return;707 732 } 708 733 } 709 734 710 735 pickup(clicked); 711 736 return; … … 1110 1135 */ 1111 1136 public void mouseMoved(MouseEvent e) { 1112 // System.out.println("MouseMoved");1113 1114 1137 MouseX = e.getX(); 1115 1138 MouseY = e.getY(); … … 1134 1157 // threshold speed. If so it doesnt execute the code that checks if 1135 1158 // items underneath the cursor need to be highlighted. 1136 if (Frame.itemAttachedToCursor()) {1159 /*if (Frame.itemAttachedToCursor()) { 1137 1160 long time = e.getWhen() - _lastMouseEvent.getWhen(); 1138 1161 // System.out.println(time + " D:" + distance); … … 1141 1164 // System.out.println("Dont check highlight!"); 1142 1165 if (_lastHighlightedItem != null && !_lastHoldsHighlight) { 1143 FrameGraphics.Highlight(_lastHighlightedItem, false, true); 1144 } 1145 } 1146 } 1166 if(_lastHighlightedItem instanceof Text) { 1167 FrameGraphics.ChangeSelectionMode(_lastHighlightedItem, 1168 Item.SelectedMode.None); 1169 } 1170 } 1171 } 1172 }*/ 1147 1173 1148 1174 _lastMouseEvent = e; … … 1192 1218 DisplayIO.getMouseX(), DisplayIO.getMouseY()); 1193 1219 else 1194 FrameGraphics.Highlight(on, true, true); 1195 } else 1196 FrameGraphics.Highlight(on, true, true); 1197 1220 // The user is pointing at another point or text item 1221 // etc 1222 FrameGraphics.ChangeSelectionMode(on, 1223 Item.SelectedMode.Normal); 1224 } else { 1225 // FrameGraphics.ChangeSelectionMode(on, 1226 // Item.SelectedMode.Connected); 1227 FrameGraphics.Highlight(on); 1228 } 1198 1229 // if the last item highlighted is still highlighted, clear it 1199 1230 if (_lastHoldsHighlight) { … … 1201 1232 for (Item i : DisplayIO.getCurrentFrame().getItems()) 1202 1233 if (i.isHighlighted() && i != on) 1203 FrameGraphics.Highlight(i, false, false); 1234 FrameGraphics.ChangeSelectionMode(i, 1235 Item.SelectedMode.None); 1204 1236 } 1205 1237 … … 1209 1241 List<Dot> enclosure = FrameUtils.getEnclosingDots(); 1210 1242 if (enclosure != null && enclosure.size() > 1) { 1211 if (enclosure.get(0).getLines().size() > 1) { 1243 if (enclosure.get(0).getLines().size() > 1 && 1244 // check that the enclosure is not part of a point being 1245 // dragged in space 1246 !ContainsOneOf(enclosure, Frame.FreeItems)) { 1212 1247 on = enclosure.get(0).getLines().get(0); 1213 // FrameGraphics.Highlight(enclosure.get(0).getLines().get(0), 1214 // true, true); 1215 FrameGraphics.Highlight(on, true, true); 1248 FrameGraphics.ChangeSelectionMode(on, 1249 Item.SelectedMode.Enclosed); 1216 1250 } 1217 // for(Dot d : enclosure){1218 // FrameGraphics.Highlight(d, true, true);1219 // break;1220 // }1221 1251 } else if (_lastHighlightedItem != null) { 1222 1252 _lastHoldsHighlight = false; … … 1231 1261 if (_lastHighlightedItem != null && _lastHighlightedItem != on 1232 1262 && !_lastHoldsHighlight) { 1233 FrameGraphics.Highlight(_lastHighlightedItem, false, true); 1263 if (!_lastHighlightedItem.getAllConnected().contains(on)) 1264 FrameGraphics.ChangeSelectionMode(_lastHighlightedItem, 1265 Item.SelectedMode.None); 1234 1266 } 1235 1267 … … 1249 1281 1250 1282 _forceArrowCursor = true; 1283 } 1284 1285 private boolean ContainsOneOf(List<Dot> enclosure, List<Item> freeItems) { 1286 if (freeItems == null) 1287 return false; 1288 for (Item i : freeItems) { 1289 if (enclosure.contains(i)) 1290 return true; 1291 } 1292 return false; 1251 1293 } 1252 1294 … … 1342 1384 private static void back() { 1343 1385 checkTDFCItemWaiting(); 1344 1386 1345 1387 DisplayIO.Back(); 1346 1388 … … 1537 1579 List<Item> toUndo = new LinkedList<Item>(); 1538 1580 List<Item> seen = new LinkedList<Item>(); 1539 1581 1540 1582 // disconnect any connected items 1541 1583 for (Item i : itemList) { … … 1604 1646 1605 1647 private static List<Item> deleteDot(Dot dot) { 1606 1648 1607 1649 if (dot instanceof WidgetCorner) { // Brook 1608 1609 WidgetCorner wc = (WidgetCorner) dot;1650 1651 WidgetCorner wc = (WidgetCorner) dot; 1610 1652 List<Item> wccopy; 1611 1653 1612 1654 try { 1613 1655 wccopy = wc.getWidgetSource().copy().getItems(); … … 1616 1658 return new LinkedList<Item>(); 1617 1659 } 1618 1660 1619 1661 if (dot.getParent() != null) { 1620 1662 dot.getParent().removeAllItems(wc.getWidgetSource().getItems()); … … 1622 1664 return wccopy; 1623 1665 } else { 1624 1666 1625 1667 // create a backup copy of the dot 1626 1668 List<Item> copy = copy(dot.getConnected()); … … 1636 1678 } 1637 1679 } 1638 1680 1639 1681 // remove all lines being deleted 1640 1682 for (Item ic : dot.getConnected()) { 1641 if (ic instanceof Line && ((Line) ic).getOppositeEnd(dot) != null) { 1683 if (ic instanceof Line 1684 && ((Line) ic).getOppositeEnd(dot) != null) { 1642 1685 Line line = (Line) ic; 1643 1686 1644 1687 Item d = line.getOppositeEnd(dot); 1645 1688 d.removeLine(line); 1646 1689 1647 1690 // if the dot was only part of one line, it can be 1648 1691 // removed … … 1653 1696 copy.add(d); 1654 1697 } 1655 1698 1656 1699 if (dot.getParent() != null) 1657 1700 dot.getParent().removeItem(ic); … … 1807 1850 */ 1808 1851 public static void pickup(Item toGrab) { 1809 1810 // Brook: If the widget corner is being picked up. Instead refer to picking 1852 1853 // Brook: If the widget corner is being picked up. Instead refer to 1854 // picking 1811 1855 // up the edge for fixed-sized widgets so it is not so confusing 1812 1856 if (toGrab instanceof WidgetCorner) { … … 1816 1860 } 1817 1861 } 1818 1862 1819 1863 pickup(toGrab.getConnected()); 1820 1864 } … … 1923 1967 if (line.getID() < 0 && !current.getItems().contains(line)) { 1924 1968 line.setID(current.getNextItemID()); 1925 line.s howHighlight(true);1969 line.setSelectionColor(); 1926 1970 // Mike: Why was this line here? 1927 1971 // anchor(line); … … 1988 2032 } 1989 2033 1990 for (int i = 0; i < clicks; i++) 1991 FrameKeyboardActions.functionKey(rotationType); 2034 Item ip = FrameUtils.getCurrentItem(); 2035 if (ip != null && clicks > 1) 2036 //base the number of clicks on the size of the object 2037 clicks = (int)Math.ceil(ip.getSize() / 20.0 * clicks); 2038 2039 FrameKeyboardActions.functionKey(rotationType, clicks); 1992 2040 } else if (clicks == MOUSE_WHEEL_THRESHOLD) { 1993 2041 Item ip = FrameUtils.getCurrentItem(); … … 2029 2077 2030 2078 public static boolean isDelete(int modifiersEx) { 2031 2079 2032 2080 int onMask = MouseEvent.BUTTON3_DOWN_MASK 2033 2081 | MouseEvent.BUTTON2_DOWN_MASK; … … 2048 2096 2049 2097 public static boolean wasDeleteClicked() { 2050 if (_lastMouseClick == null) return false; 2098 if (_lastMouseClick == null) 2099 return false; 2051 2100 return isDelete(_lastMouseClick.getModifiersEx()); 2052 2101 } -
trunk/src/org/expeditee/gui/FrameUtils.java
r19 r21 246 246 247 247 for (Item i : current.getItems()) 248 i.s howHighlight(false);248 i.setSelectedMode(Item.SelectedMode.None); 249 249 return true; 250 250 } … … 354 354 _LastResponse = ResponseTimer.getElapsedSeconds(); 355 355 _ResponseTimeSum += _LastResponse; 356 DisplayIO.UpdateTitle(); 356 357 } 357 358 … … 454 455 return true; 455 456 } 456 457 457 458 /** 458 * Creates an interactive widget and adds it to a frame. 459 * If txt has noparent the parent will be set to frame.460 * 461 * @param frame 462 * 463 * 464 * @param txt 465 * 459 * Creates an interactive widget and adds it to a frame. If txt has no 460 * parent the parent will be set to frame. 461 * 462 * @param frame 463 * Frame to add widget to. Must not be null. 464 * 465 * @param txt 466 * Text to create the widget from. Must not be null. 466 467 * 467 468 * @return True if created/added. False if coul not create. … … 471 472 private static boolean createWidget(Frame frame, Text txt) { 472 473 473 if (frame == null) throw new NullPointerException("frame"); 474 if (txt == null) throw new NullPointerException("txt"); 475 474 if (frame == null) 475 throw new NullPointerException("frame"); 476 if (txt == null) 477 throw new NullPointerException("txt"); 478 476 479 // Safety 477 if (txt.getParent() == null) txt.setParent(frame); 478 480 if (txt.getParent() == null) 481 txt.setParent(frame); 482 479 483 InteractiveWidget iw = null; 480 484 481 485 try { 482 486 483 487 iw = InteractiveWidget.CreateWidget(txt); 484 488 485 489 } catch (InteractiveWidgetNotAvailableException e) { 486 490 e.printStackTrace(); 487 FrameGraphics.ErrorMessage("Cannot create iWidget: " + e.getMessage()); 488 489 } catch (IllegalArgumentException e) { 491 FrameGraphics.ErrorMessage("Cannot create iWidget: " 492 + e.getMessage()); 493 494 } catch (IllegalArgumentException e) { 490 495 e.printStackTrace(); 491 FrameGraphics.ErrorMessage("Cannot create iWidget: " + e.getMessage()); 492 } 493 494 if (iw == null) return false; 496 FrameGraphics.ErrorMessage("Cannot create iWidget: " 497 + e.getMessage()); 498 } 499 500 if (iw == null) 501 return false; 495 502 496 503 frame.removeItem(txt); 497 504 498 505 frame.addAllItems(iw.getItems()); 499 506 … … 682 689 // if XRayMode is on, replace pictures with their underlying text 683 690 if (FrameGraphics.isXRayMode()) { 684 691 685 692 // BROOK: Must handle these a little different 686 //List<InteractiveWidget> widgets = toParse.getInteractiveWidgets(); 693 // List<InteractiveWidget> widgets = 694 // toParse.getInteractiveWidgets(); 687 695 ArrayList<InteractiveWidget> widgets = new ArrayList<InteractiveWidget>(); 688 696 /* 697 * for (Item i : items) { if (i instanceof Picture) { 698 * toParse.removeItem(i); toParse.addItem(((Picture) i).getText()); } 699 * else if (i instanceof WidgetCorner) { toParse.removeItem(i); } 700 * else if (i instanceof WidgetEdge) { toParse.removeItem(i); } } 701 */ 689 702 for (Item i : items) { 690 703 if (i instanceof Picture) { … … 693 706 } else if (i instanceof WidgetCorner) { 694 707 toParse.removeItem(i); 695 } else if (i instanceof WidgetEdge) { 696 toParse.removeItem(i); 697 } 698 }*/ 699 for (Item i : items) { 700 if (i instanceof Picture) { 701 toParse.removeItem(i); 702 toParse.addItem(((Picture) i).getText()); 703 } else if (i instanceof WidgetCorner) { 704 toParse.removeItem(i); 705 InteractiveWidget iw = ((WidgetCorner)i).getWidgetSource(); 706 if (!widgets.contains(iw)) { // hmmm I should be using a set... meh 708 InteractiveWidget iw = ((WidgetCorner) i).getWidgetSource(); 709 if (!widgets.contains(iw)) { // hmmm I should be using a 710 // set... meh 707 711 widgets.add(iw); 708 712 } 709 } else if (i instanceof WidgetEdge) toParse.removeItem(i);710 }711 713 } else if (i instanceof WidgetEdge) 714 toParse.removeItem(i); 715 } 712 716 713 717 for (InteractiveWidget iw : widgets) { 714 718 toParse.addItem(iw.getSource()); 715 719 } 716 720 717 721 // update the list of items 718 722 items.clear(); … … 918 922 if (message.contains(x, y)) { 919 923 message.Permission = Item.PERMISSION_COPY; 920 } 921 possibles.add(message); 924 possibles.add(message); 925 } else 926 // Not sure why but if the line below is removed then 927 // several items can be highlighted at once 928 message.setSelectedMode(Item.SelectedMode.None); 922 929 } 923 930 } … … 927 934 if (FrameGraphics.MessageLink.contains(x, y)) { 928 935 FrameGraphics.MessageLink.Permission = Item.PERMISSION_COPY; 929 } 930 possibles.add(FrameGraphics.MessageLink); 931 } 932 y -= FrameGraphics.getMaxFrameSize().getHeight(); 936 possibles.add(FrameGraphics.MessageLink); 937 } 938 } 939 940 // this is taken into account in contains 941 // y -= FrameGraphics.getMaxFrameSize().height; 933 942 // otherwise, the mouse is on the frame 934 943 } else { … … 942 951 } else 943 952 LastEdited = null; 944 953 945 954 ArrayList<Item> checkList = new ArrayList<Item>(); 946 955 checkList.addAll(toCheck.getItems()); … … 1028 1037 return null; 1029 1038 1030 return getItemsEnclosedBy(DisplayIO.getCurrentFrame(), enclosure.get(0) 1031 .getEnclosedShape()); 1039 List<Item> enclosed = getItemsEnclosedBy(DisplayIO.getCurrentFrame(), 1040 enclosure.get(0).getEnclosedShape()); 1041 for (Item i : enclosed) { 1042 if (!enclosure.contains(i)) 1043 i.setSelectedMode(Item.SelectedMode.None); 1044 } 1045 1046 return enclosed; 1032 1047 } 1033 1048 … … 1123 1138 // if the item is on the frame 1124 1139 if (item.getParent() == frame || item.getParent() == null) { 1125 // TODO this is a bit of a hack...1126 // the1127 // item1128 // parent1129 // should1130 // really1131 // be1132 // set1133 // when1134 // the1135 // polygon1136 // is1137 // created...1138 1140 item.Permission = Item.PERMISSION_FULL; 1139 1141 results.add(item); -
trunk/src/org/expeditee/gui/MouseEventRouter.java
r14 r21 9 9 import java.awt.event.MouseEvent; 10 10 import java.awt.event.MouseWheelEvent; 11 import java.awt.event.MouseWheelListener; 11 12 12 13 import javax.swing.JComponent; … … 19 20 20 21 /** 21 * The gateway for mouse input; conditionally forwards mouse messages 22 * to swingcomponents / expeditee frames for the Browser22 * The gateway for mouse input; conditionally forwards mouse messages to swing 23 * components / expeditee frames for the Browser 23 24 * 24 25 * @author Brook Novak 25 * 26 * 26 27 */ 27 public class MouseEventRouter extends JComponent implements AWTEventListener { 28 28 public class MouseEventRouter extends JComponent implements AWTEventListener{ 29 29 30 30 private static final long serialVersionUID = 1L; 31 31 32 32 private JMenuBar _menuBar; 33 33 34 private Container _contentPane; 34 35 35 36 public MouseEventRouter(JMenuBar menuBar, Container contentPane) { 36 37 if (contentPane == null) throw new NullPointerException("contentPane"); 38 37 38 if (contentPane == null) 39 throw new NullPointerException("contentPane"); 40 39 41 // Listen for all AWT events (ensures popups are included) 40 Toolkit.getDefaultToolkit().addAWTEventListener(this, 41 AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); 42 42 Toolkit.getDefaultToolkit().addAWTEventListener( 43 this, 44 AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK 45 | AWTEvent.MOUSE_WHEEL_EVENT_MASK); 46 43 47 this._menuBar = menuBar; 44 48 this._contentPane = contentPane; 45 49 } 46 50 47 51 /** 48 52 * All events for every component in frame are fired to here 49 */ 53 */ 50 54 public void eventDispatched(AWTEvent event) { 51 52 routeMouseEvent((MouseEvent)event);53 54 } 55 55 if (event instanceof MouseEvent) { 56 routeMouseEvent((MouseEvent) event); 57 } 58 } 59 56 60 /** 57 * Forwards the mouse event to its appropriate destination. For events 58 * that belong to Expiditee space the events are consumed and manually59 * routed tothe mouse actions handler.61 * Forwards the mouse event to its appropriate destination. For events that 62 * belong to Expiditee space the events are consumed and manually routed to 63 * the mouse actions handler. 60 64 * 61 * @param e The mouse event for any component in the browser frame 65 * @param e 66 * The mouse event for any component in the browser frame 62 67 */ 63 68 private void routeMouseEvent(MouseEvent e) { 64 69 65 70 // First convert the point to expeditee space 66 Point containerPoint = SwingUtilities.convertPoint( 67 e.getComponent(), 68 e.getPoint(), 69 _contentPane); 70 71 Point containerPoint = SwingUtilities.convertPoint(e.getComponent(), e 72 .getPoint(), _contentPane); 73 71 74 if (containerPoint.y < 0) { // not in the content pane 72 73 if (_menuBar != null && containerPoint.y + _menuBar.getHeight() >= 0) { 74 //The mouse event is over the menu bar. 75 //Could handle specially. 76 } else { 77 //The mouse event is over non-system window 78 //decorations, such as the ones provided by 79 //the Java look and feel. 80 //Could handle specially. 81 } 82 75 76 if (_menuBar != null 77 && containerPoint.y + _menuBar.getHeight() >= 0) { 78 // The mouse event is over the menu bar. 79 // Could handle specially. 80 } else { 81 // The mouse event is over non-system window 82 // decorations, such as the ones provided by 83 // the Java look and feel. 84 // Could handle specially. 85 } 86 83 87 } else { 84 88 85 89 // Check to see if the mouse is over an expeditee item or 86 90 // whether an expeditee item is currently picked up 87 91 boolean forwardToExpiditee = false; 88 92 89 93 // Note: all frame.content pane events belong to expeditee 90 if (e.getSource() == _contentPane ||91 e.getSource() == Browser._theBrowser ||92 Frame.itemAttachedToCursor()) {94 if (e.getSource() == _contentPane 95 || e.getSource() == Browser._theBrowser 96 || Frame.itemAttachedToCursor()) { 93 97 forwardToExpiditee = true; 94 } else if (DisplayIO.getCurrentFrame() != null) { // is mouse over a specific expeditee item? 95 // NOTE: Do not use FrameUtils.getCurrentItem() - thats relevent for old mouse position only 98 } else if (DisplayIO.getCurrentFrame() != null) { // is mouse over 99 // a specific 100 // expeditee 101 // item? 102 // NOTE: Do not use FrameUtils.getCurrentItem() - thats relevent 103 // for old mouse position only 96 104 for (Item i : DisplayIO.getCurrentFrame().getItems()) { 97 105 if (i.getPolygon().contains(containerPoint)) { … … 101 109 } 102 110 } 103 111 104 112 if (forwardToExpiditee) { 105 106 // If forwarding to Expiditee ensure that widgets highlighting is enabled 107 // do give visual feedback yo users such that Expiditee has focus. 113 114 // If forwarding to Expiditee ensure that widgets highlighting 115 // is enabled 116 // do give visual feedback yo users such that Expiditee has 117 // focus. 108 118 InteractiveWidget.enableExepiteeHighlighting(true); 109 119 110 120 // Ensure that underlying widgets don't get the event 111 121 e.consume(); 112 122 113 123 // Create artificial mouse event and forward it to expeditee 114 MouseEvent expediteeEvent = SwingUtilities.convertMouseEvent( 115 e.getComponent(), e, _contentPane);116 124 MouseEvent expediteeEvent = SwingUtilities.convertMouseEvent(e 125 .getComponent(), e, _contentPane); 126 117 127 switch (e.getID()) { 118 128 case MouseEvent.MOUSE_MOVED: 119 129 FrameMouseActions.getInstance().mouseMoved(expediteeEvent); 120 130 121 131 // Ensure that expiditee has focus only if no popups exist 122 132 if (!Browser._theBrowser.getContentPane().isFocusOwner() … … 124 134 Browser._theBrowser.getContentPane().requestFocus(); 125 135 } 126 136 127 137 break; 128 138 case MouseEvent.MOUSE_CLICKED: 129 FrameMouseActions.getInstance().mouseClicked(expediteeEvent); 139 FrameMouseActions.getInstance() 140 .mouseClicked(expediteeEvent); 130 141 break; 131 142 case MouseEvent.MOUSE_PRESSED: 132 FrameMouseActions.getInstance().ProccessMousePressedEvent(expediteeEvent, e.getModifiersEx()); 143 FrameMouseActions.getInstance().ProccessMousePressedEvent( 144 expediteeEvent, e.getModifiersEx()); 133 145 break; 134 146 case MouseEvent.MOUSE_RELEASED: 135 FrameMouseActions.getInstance().mouseReleased(expediteeEvent); 147 FrameMouseActions.getInstance().mouseReleased( 148 expediteeEvent); 136 149 break; 137 150 case MouseEvent.MOUSE_WHEEL: 138 FrameMouseActions.getInstance().mouseWheelMoved((MouseWheelEvent)expediteeEvent); 151 FrameMouseActions.getInstance().mouseWheelMoved( 152 (MouseWheelEvent) expediteeEvent); 139 153 break; 140 154 case MouseEvent.MOUSE_ENTERED: 141 FrameMouseActions.getInstance().mouseEntered(expediteeEvent); 155 FrameMouseActions.getInstance() 156 .mouseEntered(expediteeEvent); 142 157 break; 143 158 case MouseEvent.MOUSE_EXITED: … … 145 160 break; 146 161 case MouseEvent.MOUSE_DRAGGED: 147 FrameMouseActions.getInstance().mouseDragged(expediteeEvent); 162 FrameMouseActions.getInstance() 163 .mouseDragged(expediteeEvent); 148 164 break; 149 165 } 150 166 151 152 167 } else { 153 154 // If forwarding to swing ensure that widgets are not highlighted 168 169 // If forwarding to swing ensure that widgets are not 170 // highlighted 155 171 // to give visual feedback yo users such that swing has focus. 156 172 InteractiveWidget.enableExepiteeHighlighting(false); 157 158 // Also bring expideditee behaviour to swing: Auto-focus on component 173 174 // Also bring expideditee behaviour to swing: Auto-focus on 175 // component 159 176 // whenever the mouse moves over it. 160 177 if (e.getID() == MouseEvent.MOUSE_MOVED) { 161 178 if (e.getSource() instanceof Component) { 162 Component target = (Component) e.getSource();179 Component target = (Component) e.getSource(); 163 180 if (!target.isFocusOwner()) { 164 181 target.requestFocus(); … … 169 186 } 170 187 } 171 188 172 189 public static boolean isPopupVisible() { 173 190 return isPopupVisible(Browser._theBrowser.getLayeredPane()); 174 191 } 175 192 176 193 private static boolean isPopupVisible(Container parent) { 177 194 178 195 for (Component c : parent.getComponents()) { 179 180 if (c instanceof JPopupMenu && ((JPopupMenu) c).isVisible()) {196 197 if (c instanceof JPopupMenu && ((JPopupMenu) c).isVisible()) { 181 198 return true; 182 183 } else if (c instanceof Container && 184 c != Browser._theBrowser.getContentPane()) { 185 if (isPopupVisible((Container)c)) return true; 199 200 } else if (c instanceof Container 201 && c != Browser._theBrowser.getContentPane()) { 202 if (isPopupVisible((Container) c)) 203 return true; 186 204 } 187 205 } 188 206 189 207 return false; 190 208 } 191 192 209 } -
trunk/src/org/expeditee/items/Dot.java
r7 r21 3 3 import java.awt.Graphics2D; 4 4 import java.awt.Polygon; 5 import java.awt.Rectangle; 5 6 import java.util.ArrayList; 6 7 import java.util.LinkedList; 7 8 import java.util.List; 9 10 import org.expeditee.gui.Frame; 8 11 9 12 /** … … 19 22 // Standard Item variables 20 23 24 private static final int _MINIMUM_DOT_SIZE = 6; 25 21 26 // contains all dots (including this one) that form an enclosure 22 27 // if this dot is part of an enclosing shape … … 32 37 33 38 private boolean _filled = true; 34 39 35 40 protected boolean _filledHighlight = false; 36 41 … … 108 113 @Override 109 114 public void paint(Graphics2D g) { 110 if (isHighlighted() ) {115 if (isHighlighted() /* && !Frame.FreeItems.contains(this) */) { 111 116 g.setColor(getHighlightColor()); 112 117 // Draw the highlighting rectangle surrounding the dot 113 118 // this is drawn even if its part of a rectangle 114 if (_filledHighlight) 115 g.fillPolygon(getPolygon()); 116 else 117 g.drawPolygon(getPolygon()); 119 Rectangle rect = getPolygon().getBounds(); 120 if (_mode == SelectedMode.Enclosed || 121 // Make sure single dots are highlighted filled 122 this.getConnected().size() <= 1) 123 g.fillRect(rect.x, rect.y, rect.width, rect.height); 124 else if (_mode == SelectedMode.Connected) 125 g.drawRect(rect.x, rect.y, rect.width, rect.height); 126 else if (_mode == SelectedMode.Normal) { 127 g.fillOval(rect.x, rect.y, rect.width, rect.height); 128 } 129 //System.out.println(_mode.toString()); 118 130 } 119 131 … … 129 141 130 142 int width = thick / 2; 131 132 // if(_thickness < 1)133 /*134 * if(_filled) g.fillRect(getX(), getY(), thick,thick); else135 * g.drawRect(getX(), getY(), thick,thick); else136 */137 143 138 144 if (_pointType == Item.POINTTYPE_CIRCLE) { … … 168 174 int thick = (int) Math.ceil(getThickness()); 169 175 // Sets a minimum size for the dot 170 thick = Math.max(thick, 10);176 thick = Math.max(thick, _MINIMUM_DOT_SIZE); 171 177 172 178 int x = getX() - thick / 2; … … 205 211 206 212 @Override 207 public int s howHighlight(boolean val) {208 super.s howHighlight(val);213 public int setSelectionColor() { 214 super.setSelectionColor(); 209 215 210 216 return Item.DEFAULT_CURSOR; … … 353 359 return "P " + getID(); 354 360 } 355 361 356 362 @Override 357 363 public void setFilledHighlight(boolean value) { 358 364 _filledHighlight = value; 359 365 } 360 366 361 367 @Override 362 368 public void delete() { 363 369 super.delete(); 364 365 for (Line l: this.getLines())370 371 for (Line l : this.getLines()) 366 372 l.delete(); 367 373 } -
trunk/src/org/expeditee/items/Item.java
r10 r21 168 168 } 169 169 170 public enum SelectedMode { 171 None, Enclosed, Connected, Disconnect, Normal 172 } 173 174 public void setSelectedMode(SelectedMode mode) { 175 setSelectedMode(mode, DEFAULT_HIGHLIGHT); 176 } 177 178 protected SelectedMode _mode = SelectedMode.None; 179 170 180 private Point _offset = new Point(0, 0); 171 181 … … 183 193 184 194 private boolean _highlight = true; 185 186 private boolean _isHighlighted = false;187 195 188 196 private Dimension _maxSize = null; … … 252 260 253 261 private boolean _visible = true; 262 263 private SelectedMode _lastMode = SelectedMode.None; 254 264 255 265 protected Item() { … … 838 848 */ 839 849 public boolean isHighlighted() { 840 return _ isHighlighted;850 return _mode != SelectedMode.None; 841 851 } 842 852 … … 1350 1360 } 1351 1361 1352 public int showDepressedHighlight(boolean val) {1353 _highlightThickness = DEFAULT_HIGHLIGHT_THICKNESS;1354 return showHighlight(val, DEPRESSED_HIGHLIGHT);1355 }1356 1357 public int showDisconnectHighlight(boolean val) {1358 _highlightThickness = DEFAULT_HIGHLIGHT_THICKNESS;1359 return showHighlight(val, DISCONNECT_HIGHLIGHT);1360 }1361 1362 1362 /** 1363 1363 * Paints any highlighting of this Item. This may include changing the … … 1369 1369 * @param val 1370 1370 * True if this Item should be highlighted, false if the 1371 * highlighting is being cleared. \1371 * highlighting is being cleared. 1372 1372 * @return The desired mouse cursor when this Item is highlighted (negative 1373 1373 * means no change) 1374 1374 */ 1375 public int showHighlight(boolean val) { 1375 public int setSelectionColor() { 1376 return setSelectionColor(DEFAULT_HIGHLIGHT); 1377 } 1378 1379 public int setSelectionColor(Color c) { 1376 1380 _highlightThickness = DEFAULT_HIGHLIGHT_THICKNESS; 1377 return showHighlight(val, DEFAULT_HIGHLIGHT);1378 }1379 1380 public int showHighlight(boolean val, Color c) {1381 _isHighlighted = val;1382 1381 if (c != null) 1383 1382 _highlightColor = c; … … 1387 1386 return Item.UNCHANGED_CURSOR; 1388 1387 } 1388 1389 1389 private void updateArrowPolygon() { 1390 1390 if (getArrowheadLength() < 0 || getArrowheadRatio() < 0) … … 1422 1422 public void onParentFameHidden() {} // because of caching 1423 1423 public void onParentFameShown() {} // because of caching 1424 1425 public void setSelectedMode(SelectedMode mode, Color color) { 1426 setSelectionColor(color); 1427 _lastMode = _mode; 1428 _mode = mode; 1429 } 1430 1431 public void restoreLastMode(Color selectionColor) { 1432 setSelectionColor(selectionColor); 1433 if (_mode != SelectedMode.None) 1434 return; 1435 _mode = _lastMode; 1436 _lastMode = SelectedMode.None; 1437 } 1438 1439 public SelectedMode getSelectedMode() { 1440 return _mode; 1441 } 1424 1442 } -
trunk/src/org/expeditee/items/Line.java
r7 r21 287 287 g.setColor(getPaintColor()); 288 288 289 //if (this._mode == Item.SelectedMode.Disconnect) 290 // System.out.println("Disconnect mode!"); 291 289 292 if (_start instanceof Text && ((Text) _start).startsWith("@c")) { 290 293 g.setStroke(_lineStroke); … … 337 340 Point endOffset) { 338 341 // only draw an arrowhead if necessary 339 if (!withArrow.hasVisibleArrow() || withArrow.getLines().size() > 1) 342 if (!(this._mode == Item.SelectedMode.Disconnect 343 && withArrow._mode == Item.SelectedMode.Disconnect) 344 && (!withArrow.hasVisibleArrow() 345 || withArrow.getLines().size() > 1)) 340 346 return; 341 347 … … 350 356 double arrowRatio = withArrow.getArrowheadRatio(); 351 357 358 //set the size of the disconnect indicator arrowhead 359 if (this._mode == Item.SelectedMode.Disconnect){ 360 //System.out.println("Disconnect mode!"); 361 arrowLength = 15; 362 arrowRatio = 0.3; 363 //Make sure the arrowhead positions get recalculated 364 withArrow.setArrowhead(null); 365 } 366 352 367 // if the arrowhead is 'auto', then one and only one end must be 353 368 // floating … … 464 479 int distEnd = (int) Math.sqrt(endX * endX + endY * endY); 465 480 466 final double THRESHHOLD = Math.min(0.2 * lineLength, 25.0); 467 468 if (distStart < THRESHHOLD) { 481 final double DISCONNECT_THRESHHOLD = Math.min(0.2 * lineLength, 25.0); 482 final double NORMAL_THRESHHOLD = Math.min(0.1 * lineLength, 13.0); 483 484 if (distStart < NORMAL_THRESHHOLD) { 485 start._mode = Item.SelectedMode.Normal; 469 486 return start; 470 } else if (distEnd < THRESHHOLD) { 487 } else if (distEnd < NORMAL_THRESHHOLD) { 488 end._mode = Item.SelectedMode.Normal; 471 489 return end; 490 } else if (distStart < DISCONNECT_THRESHHOLD) { 491 start._mode = Item.SelectedMode.Disconnect; 492 return start; 493 } else if (distEnd < DISCONNECT_THRESHHOLD) { 494 end._mode = Item.SelectedMode.Disconnect; 495 return end; 472 496 } 473 497 … … 476 500 477 501 @Override 478 public int s howHighlight(boolean val) {479 super.s howHighlight(val);502 public int setSelectionColor() { 503 super.setSelectionColor(); 480 504 481 505 return Item.UNCHANGED_CURSOR; -
trunk/src/org/expeditee/items/Picture.java
r7 r21 291 291 292 292 if (_isFrame) { 293 Frame frame = FrameIO.LoadFrame(_source.getLink()); 294 // if (frame.getBuffer() == null) 295 FrameGraphics.UpdateBuffer(frame, false); 296 _image = frame.getBuffer(); 293 if (_source.getLink() == null) { 294 Frame parent = getParent(); 295 if (parent != null){ 296 parent.removeItem(this); 297 parent.addItem(_source); 298 } 299 } else { 300 Frame frame = FrameIO.LoadFrame(_source.getLink()); 301 if (frame != null) { 302 FrameGraphics.UpdateBuffer(frame, false); 303 _image = frame.getBuffer(); 304 } 305 } 297 306 } 298 307 } … … 416 425 417 426 @Override 418 public int s howHighlight(boolean val) {419 super.s howHighlight(val);427 public int setSelectionColor() { 428 super.setSelectionColor(); 420 429 421 430 return Item.DEFAULT_CURSOR; -
trunk/src/org/expeditee/items/Text.java
r13 r21 23 23 24 24 import org.expeditee.gui.FrameMouseActions; 25 import org.expeditee.items.Item.SelectedMode; 25 26 26 27 /** … … 1325 1326 } 1326 1327 1327 @Override1328 public int showHighlight(boolean val) {1329 super.showHighlight(val);1330 1331 if (val)1332 return Item.UNCHANGED_CURSOR;1333 else1334 return Item.DEFAULT_CURSOR;1335 }1336 1337 1328 /** 1338 1329 * Determines if this text has any text in it. -
trunk/src/org/expeditee/simple/Context.java
r7 r21 225 225 226 226 public void createFrameset(String framesetNameVar, String successVar) 227 throws Exception { 228 // Get the values to be set 229 String framesetName = primitives_.getStringValue(framesetNameVar); 230 Frame firstFrame = FrameIO.CreateNewFrameset(framesetName); 231 232 if (successVar != null) { 233 Boolean success = firstFrame != null; 227 throws IncorrectTypeException { 228 boolean success = true; 229 try { 230 // Get the values to be set 231 String framesetName = primitives_.getStringValue(framesetNameVar); 232 Frame firstFrame = FrameIO.CreateNewFrameset(framesetName); 233 success = firstFrame != null; 234 } catch (Exception e) { 235 success = false; 236 } 237 if (successVar != null) { 234 238 primitives_.setValue(successVar, new SBoolean(success)); 235 239 } -
trunk/src/org/expeditee/simple/IncorrectTypeException.java
r4 r21 3 3 public class IncorrectTypeException extends RuntimeException { 4 4 static final long serialVersionUID = -7034897190745766939L; 5 5 6 6 public IncorrectTypeException(String type, int no) { 7 7 super("Expected param " + no + " to be " + type); -
trunk/src/org/expeditee/simple/Primitives.java
r4 r21 24 24 25 25 public void setValue(String variableName, SPrimitive newValue) 26 throws Exception {26 throws IncorrectTypeException { 27 27 try { 28 28 // if it is an existing variable change the value … … 49 49 * if the variable name is invalid 50 50 */ 51 public void add(String name, SPrimitive value) throws Exception {51 public void add(String name, SPrimitive value) throws IncorrectTypeException { 52 52 // figure out the type and add it... 53 53 SPrimitive newVar; -
trunk/src/org/expeditee/simple/SBoolean.java
r4 r21 12 12 } 13 13 14 public SBoolean(Boolean value) throws Exception {14 public SBoolean(Boolean value) throws IncorrectTypeException { 15 15 super(value); 16 16 } … … 44 44 45 45 @Override 46 public void setValue(SPrimitive v) throws Exception {46 public void setValue(SPrimitive v) throws IncorrectTypeException { 47 47 value_ = v.booleanValue(); 48 48 } -
trunk/src/org/expeditee/simple/SCharacter.java
r4 r21 50 50 51 51 @Override 52 public void setValue(SPrimitive v) throws Exception {52 public void setValue(SPrimitive v) throws IncorrectTypeException { 53 53 value_ = v.characterValue(); 54 54 } -
trunk/src/org/expeditee/simple/SInteger.java
r4 r21 53 53 54 54 @Override 55 public void setValue(SPrimitive v) throws Exception {55 public void setValue(SPrimitive v) throws IncorrectTypeException { 56 56 value_ = v.integerValue(); 57 57 } -
trunk/src/org/expeditee/simple/SPrimitive.java
r4 r21 15 15 } 16 16 17 public Long integerValue() throws Exception { 18 throw new Exception("Can not convert " + this.getClass().getName() 19 + " to Integer"); 17 public Long integerValue() throws IncorrectTypeException { 18 throw new IncorrectTypeException("integer",this.getClass().getName()); 20 19 } 21 20 22 public Boolean booleanValue() throws Exception { 23 throw new Exception("Can not convert " + this.getClass().getName() 24 + " to Boolean"); 21 public Boolean booleanValue() throws IncorrectTypeException { 22 throw new IncorrectTypeException("boolean", this.getClass().getName()); 25 23 } 26 24 27 public Double doubleValue() throws Exception { 28 throw new Exception("Can not convert " + this.getClass().getName() 29 + " to Real"); 25 public Double doubleValue() throws IncorrectTypeException { 26 throw new IncorrectTypeException("real", this.getClass().getName()); 30 27 } 31 28 32 public Character characterValue() throws Exception { 33 throw new Exception("Can not convert " + this.getClass().getName() 34 + " to Character"); 29 public Character characterValue() throws IncorrectTypeException { 30 throw new IncorrectTypeException("character", this.getClass().getName()); 35 31 } 36 32 37 public abstract void setValue(SPrimitive v) throws Exception;33 public abstract void setValue(SPrimitive v) throws IncorrectTypeException; 38 34 39 35 @Override 40 public void setValue(SVariable<T> v) throws Exception {36 public void setValue(SVariable<T> v) throws IncorrectTypeException { 41 37 if (v instanceof SPrimitive) { 42 38 setValue((SPrimitive<?>) v); 43 39 return; 44 40 } 45 throw new Exception("Can not set primitive variable withpointer");41 throw new IncorrectTypeException("primitive", "pointer"); 46 42 } 47 43 -
trunk/src/org/expeditee/simple/SReal.java
r4 r21 49 49 50 50 @Override 51 public void setValue(SPrimitive v) throws Exception {51 public void setValue(SPrimitive v) throws IncorrectTypeException { 52 52 value_ = v.doubleValue(); 53 53 } -
trunk/src/org/expeditee/stats/SessionStats.java
r7 r21 250 250 - _FrameAccessTime.getTime()); 251 251 252 _FrameEvents.add(Logger.EasyDateFormat("mm:ss ", elapsedTime) + " "252 _FrameEvents.add(Logger.EasyDateFormat("mm:ss:SSS", elapsedTime) + " " 253 253 + DisplayIO.getMouseX() + " " + DisplayIO.getMouseY() + " " 254 254 + description);
Note:
See TracChangeset
for help on using the changeset viewer.