Changeset 1102 for trunk/src/org/expeditee/actions/Simple.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Simple.java
r947 r1102 19 19 package org.expeditee.actions; 20 20 21 import java.awt.Color; 22 import java.awt.Point; 23 import java.awt.event.InputEvent; 24 import java.awt.geom.Point2D; 21 //import java.awt.event.InputEvent; 25 22 import java.io.BufferedReader; 26 23 import java.io.InputStreamReader; … … 47 44 import org.expeditee.agents.SearchTree; 48 45 import org.expeditee.agents.WriteTree; 46 import org.expeditee.core.Colour; 47 import org.expeditee.core.Point; 48 import org.expeditee.gio.gesture.StandardGestureActions; 49 49 import org.expeditee.gui.AttributeUtils; 50 50 import org.expeditee.gui.AttributeValuePair; 51 51 import org.expeditee.gui.Browser; 52 import org.expeditee.gui.Display IO;52 import org.expeditee.gui.DisplayController; 53 53 import org.expeditee.gui.Frame; 54 import org.expeditee.gui.FrameGraphics;55 54 import org.expeditee.gui.FrameIO; 56 import org.expeditee.gui.FrameMouseActions;57 55 import org.expeditee.gui.FrameUtils; 58 56 import org.expeditee.gui.FreeItems; … … 156 154 private static int _stepPause = -1; 157 155 158 private static Colo r _stepColor;156 private static Colour _stepColor; 159 157 160 158 private static boolean _nextStatement; … … 173 171 174 172 public static void NewSimpleTest() { 175 Frame newSimpleTest = FrameIO.CreateFrame(Display IO.getCurrentFrame()173 Frame newSimpleTest = FrameIO.CreateFrame(DisplayController.getCurrentFrame() 176 174 .getFramesetName(), "Test", null); 177 175 List<String> actions = new ArrayList<String>(); … … 183 181 184 182 public static void NextTest() { 185 Frame next = Display IO.getCurrentFrame();183 Frame next = DisplayController.getCurrentFrame(); 186 184 do { 187 185 next = FrameIO.LoadNext(next); … … 191 189 192 190 public static void PreviousTest() { 193 Frame prev = Display IO.getCurrentFrame();191 Frame prev = DisplayController.getCurrentFrame(); 194 192 do { 195 193 prev = FrameIO.LoadPrevious(prev); … … 240 238 int testsFailed = 0; 241 239 242 FrameIO.SaveFrame(Display IO.getCurrentFrame(), false);240 FrameIO.SaveFrame(DisplayController.getCurrentFrame(), false); 243 241 MessageBay.displayMessage("Starting test suite: " + _frameset, 244 Colo r.CYAN);242 Colour.CYAN); 245 243 246 244 // Get the next number in the inf file for the _frameset … … 312 310 // Report the number of test passed and failed 313 311 MessageBay.displayMessage( 314 "Total tests: " + (testsPassed + testsFailed), Colo r.CYAN);312 "Total tests: " + (testsPassed + testsFailed), Colour.CYAN); 315 313 if (testsPassed > 0) 316 314 MessageBay.displayMessage("Passed: " + testsPassed, Item.GREEN); 317 315 if (testsFailed > 0) 318 MessageBay.displayMessage("Failed: " + testsFailed, Colo r.RED);316 MessageBay.displayMessage("Failed: " + testsFailed, Colour.RED); 319 317 // Remove items from the cursor... 320 318 FreeItems.getInstance().clear(); … … 350 348 //Have changed parameters, so it takes an Item, not just a Text item. 351 349 private static void RunFrame(Frame frame, Item current, 352 boolean acceptKeyboardInput, boolean step, int pause, Colo r color) {350 boolean acceptKeyboardInput, boolean step, int pause, Colour color) { 353 351 try { 354 352 if (current != null) { … … 358 356 */ 359 357 // DisplayIO.addToBack(current.getParent()); 360 Display IO.addToBack(DisplayIO.getCurrentFrame());358 DisplayController.addToBack(DisplayController.getCurrentFrame()); 361 359 } else { 362 360 /* TODO we should not have to pass an item just to run a frame! */ … … 365 363 } 366 364 367 _stepColor = color == null ? Colo r.green: color;368 _stepColor = new Colo r(_stepColor.getRed(), _stepColor.getGreen(),369 _stepColor.getBlue(), 50);365 _stepColor = color == null ? Colour.GREEN : color; 366 _stepColor = new Colour(_stepColor.getRed(), _stepColor.getGreen(), 367 _stepColor.getBlue(), Colour.FromComponent255(50)); 370 368 _stepPause = pause; 371 369 _step = step; … … 429 427 */ 430 428 public static void DebugFrame(Frame frame, Text current, float pause, 431 Colo r color) {429 Colour color) { 432 430 if (isProgramRunning()) { 433 431 stop(); … … 454 452 FrameUtils.DisplayFrame(item.getParent().getName(), true, true); 455 453 item.setHighlightMode(HighlightMode.Normal); 456 item.setHighlightColor(Colo r.CYAN);454 item.setHighlightColor(Colour.CYAN); 457 455 FrameIO.SaveFrame(item.getParent()); 458 456 } … … 499 497 500 498 if (_step) { 501 if (child != Display IO.getCurrentFrame()) {502 Display IO.setCurrentFrame(child, true);503 } 504 Display IO.addToBack(child);499 if (child != DisplayController.getCurrentFrame()) { 500 DisplayController.setCurrentFrame(child, true); 501 } 502 DisplayController.addToBack(child); 505 503 } 506 504 … … 524 522 AgentStats.ItemExecuted(); 525 523 try { 526 Colo r oldColor = item.getBackgroundColor();524 Colour oldColor = item.getBackgroundColor(); 527 525 if (_step) { 528 526 pause(item); … … 534 532 } else { 535 533 item.setHighlightMode(Item.HighlightMode.None); 534 item.setHighlightColorToDefault(); 536 535 } 537 536 } … … 541 540 && lastItemStatus != Status.FalseIf) { 542 541 if (_step) { 543 Display IO.removeFromBack();542 DisplayController.removeFromBack(); 544 543 } 545 544 return lastItemStatus; … … 565 564 566 565 if (_step) { 567 Display IO.removeFromBack();568 if (Display IO.getCurrentFrame() != current.getParent())569 Display IO.setCurrentFrame(current.getParent(), true);566 DisplayController.removeFromBack(); 567 if (DisplayController.getCurrentFrame() != current.getParent()) 568 DisplayController.setCurrentFrame(current.getParent(), true); 570 569 } 571 570 … … 583 582 return; 584 583 585 Colo r oldColor = item.getBackgroundColor();584 Colour oldColor = item.getBackgroundColor(); 586 585 item.setBackgroundColor(_stepColor); 587 586 item.setHighlightMode(Item.HighlightMode.None); 587 item.setHighlightColorToDefault(); 588 588 589 589 // Make sure we are on the frame with this item 590 590 Frame parent = item.getParentOrCurrentFrame(); 591 if (!parent.equals(Display IO.getCurrentFrame())) {592 Display IO.setCurrentFrame(parent, true);591 if (!parent.equals(DisplayController.getCurrentFrame())) { 592 DisplayController.setCurrentFrame(parent, true); 593 593 } 594 594 595 FrameGraphics.Repaint();595 DisplayController.requestRefresh(true); 596 596 597 597 int timeRemaining; … … 604 604 if (_stop) { 605 605 item.setBackgroundColor(oldColor); 606 item.setHighlightMode (HighlightMode.Normal, _stepColor);606 item.setHighlightModeAndColour(HighlightMode.Normal, _stepColor); 607 607 throw new Exception("Program terminated"); 608 608 } … … 1125 1125 // attribute without the value in the same item 1126 1126 if (!found && attributeItem != null) { 1127 Point2D.Float endPoint = attributeItem 1128 .getParagraphEndPosition(); 1127 Point endPoint = attributeItem.getParagraphEndPosition(); 1129 1128 1130 1129 for (Text text : targetFrame.getTextItems()) { … … 1217 1216 String stringColor = context.getPrimitives().getVariable( 1218 1217 tokens[2]).stringValue(); 1219 item.setBackgroundColor((Colo r) Conversion.Convert(1220 Colo r.class, stringColor));1218 item.setBackgroundColor((Colour) Conversion.Convert( 1219 Colour.class, stringColor)); 1221 1220 } else if (tokens[0].equals("setitemcolor")) { 1222 1221 assertVariableType(tokens[1], 1, SPointer.itemPrefix); … … 1226 1225 String stringColor = context.getPrimitives().getVariable( 1227 1226 tokens[2]).stringValue(); 1228 item.setColor((Colo r) Conversion.Convert(Color.class,1227 item.setColor((Colour) Conversion.Convert(Colour.class, 1229 1228 stringColor, item.getColor())); 1230 1229 … … 1377 1376 // attribute without the value in the same item 1378 1377 if (!found && attributeItem != null) { 1379 Point2D.Float endPoint = attributeItem 1380 .getParagraphEndPosition(); 1378 Point endPoint = attributeItem.getParagraphEndPosition(); 1381 1379 1382 1380 for (Text text : targetFrame.getTextItems()) { … … 1484 1482 assertVariableType(tokens[1], 1, SPointer.framePrefix); 1485 1483 1486 Frame currentFrame = Display IO.getCurrentFrame();1484 Frame currentFrame = DisplayController.getCurrentFrame(); 1487 1485 context.getPointers().setObject(tokens[1], currentFrame); 1488 1486 … … 1504 1502 && tokens.length > 2) { 1505 1503 Text text = (Text) currentItem; 1506 int cursorLinePos = text 1507 .getLinePosition(FrameMouseActions.getY()); 1504 int cursorLinePos = text.getLinePosition(DisplayController.getMouseY()); 1508 1505 context.getPrimitives().setValue(tokens[2], 1509 1506 new SInteger(cursorLinePos + 1)); 1510 1507 if (tokens.length > 3) { 1511 1508 int cursorCharPos = text.getCharPosition( 1512 cursorLinePos, Display IO.getMouseX())1509 cursorLinePos, DisplayController.getMouseX()) 1513 1510 .getCharIndex(); 1514 1511 context.getPrimitives().setValue(tokens[3], … … 1532 1529 1533 1530 //no frame specified by user so use current frame. 1534 getFrameName = Display IO.getCurrentFrame().getName();1531 getFrameName = DisplayController.getCurrentFrame().getName(); 1535 1532 getItem = Misc.getItemContainingData(data, FrameUtils.getFrame(getFrameName)); 1536 1533 } … … 1569 1566 1570 1567 //no frame specified by user so use current frame. 1571 getFrameName = Display IO.getCurrentFrame().getName();1568 getFrameName = DisplayController.getCurrentFrame().getName(); 1572 1569 getItem = Misc.getItemAtPosition(x, y, FrameUtils.getFrame(getFrameName)); 1573 1570 } … … 1662 1659 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1663 1660 // assertPrimitiveType(tokens[2], 2); 1664 Colo r itemColor = ((Item) context.getPointers()1661 Colour itemColor = ((Item) context.getPointers() 1665 1662 .getVariable(tokens[1]).getValue()) 1666 1663 .getPaintBackgroundColor(); … … 1672 1669 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1673 1670 // assertPrimitiveType(tokens[2], 2); 1674 Colo r itemColor = ((Item) context.getPointers()1671 Colour itemColor = ((Item) context.getPointers() 1675 1672 .getVariable(tokens[1]).getValue()).getPaintColor(); 1676 1673 String color = itemColor.getRed() + " " … … 1834 1831 double delay = context.getPrimitives().getDoubleValue(tokens[1]); 1835 1832 String s = getMessage(tokens, context, code.toString(), " ", 2); 1836 Display IO.typeStringDirect(delay, s);1833 DisplayController.typeStringDirect(delay, s); 1837 1834 } else if (tokens[0].equals("type") || tokens[0].equals("typenospaces")) { 1838 1835 … … 1840 1837 .equals("type") ? " " : "", 1); 1841 1838 1842 Display IO.typeStringDirect(0.025, s);1839 DisplayController.typeStringDirect(0.025, s); 1843 1840 } else if (tokens[0].equals("runstring")) { 1844 1841 String codeText = getMessage(tokens, context, code.toString(), " ", … … 1858 1855 // Process p = Runtime.getRuntime().exec(new String[]{"date", 1859 1856 // ">", "test.date"}); 1860 MessageBay.displayMessage(command, Colo r.darkGray);1857 MessageBay.displayMessage(command, Colour.DARK_GREY); 1861 1858 1862 1859 BufferedReader stdInput = new BufferedReader( … … 2028 2025 Item item = (Item) context.getPointers().getVariable(itemVar) 2029 2026 .getValue(); 2030 item 2031 .setPosition(FrameMouseActions.MouseX, 2032 FrameMouseActions.MouseY); 2033 FrameMouseActions.pickup(item); 2027 item.setPosition(DisplayController.getMouseX(), DisplayController.getMouseY()); 2028 StandardGestureActions.pickup(item); 2034 2029 } else if (tokens[0].equals("attachstrtocursor")) { 2035 2030 String stringVar = DEFAULT_STRING; … … 2040 2035 } 2041 2036 String s = context.getPrimitives().getStringValue(stringVar); 2042 Frame frame = Display IO.getCurrentFrame();2037 Frame frame = DisplayController.getCurrentFrame(); 2043 2038 Item item = frame.createNewText(s); 2044 item 2045 .setPosition(FrameMouseActions.MouseX, 2046 FrameMouseActions.MouseY); 2047 FrameMouseActions.pickup(item); 2039 item.setPosition(DisplayController.getMouseX(), DisplayController.getMouseY()); 2040 StandardGestureActions.pickup(item); 2048 2041 } else if (tokens[0].equals("additemtoframe")) { 2049 2042 String itemVar = DEFAULT_ITEM; … … 2410 2403 } 2411 2404 } 2412 Display IO.setCurrentFrame(frame, false);2405 DisplayController.setCurrentFrame(frame, false); 2413 2406 pause(thisFramesPause); 2414 2407 … … 2629 2622 tokens[3]) * 1000); 2630 2623 2631 int initialX = Display IO.getMouseX();2632 int initialY = FrameMouseActions.getY();2624 int initialX = DisplayController.getMouseX(); 2625 int initialY = DisplayController.getMouseY(); 2633 2626 2634 2627 final int timeInterval = 40; … … 2643 2636 Thread.yield(); 2644 2637 Thread.sleep(timeInterval); 2645 Display IO.setCursorPosition(newX, newY);2638 DisplayController.setCursorPosition(newX, newY); 2646 2639 // DisplayIO.repaint(); 2647 2640 } 2648 2641 // Thread.yield(); 2649 2642 Thread.sleep(milliseconds % timeInterval); 2650 Display IO.setCursorPosition(finalX, finalY);2643 DisplayController.setCursorPosition(finalX, finalY); 2651 2644 } else if (tokens[0].equals("glideitemto")) { 2652 2645 assertMinParametreCount(tokens, 3); … … 2686 2679 2687 2680 item.setPosition(newX, newY); 2688 FrameGraphics.Repaint();2681 DisplayController.requestRefresh(true); 2689 2682 } 2690 2683 // Thread.yield(); … … 2692 2685 item.setPosition(finalX, finalY); 2693 2686 // DisplayIO.setCursorPosition(finalX, finalY); 2694 FrameMouseActions.anchor(item);2687 StandardGestureActions.anchor(item); 2695 2688 FreeItems.getInstance().clear(); 2696 FrameGraphics.Repaint();2689 DisplayController.requestRefresh(true); 2697 2690 // FrameMouseActions.updateCursor(); 2698 2691 } … … 2740 2733 } else if (tokens[0].equals("pressleftbutton")) { 2741 2734 assertExactParametreCount(tokens, 0); 2742 DisplayIO.pressMouse(InputEvent.BUTTON1_MASK);2735 //DisplayIO.pressMouse(InputEvent.BUTTON1_MASK); TODO: Reinstate. cts16 2743 2736 } else if (tokens[0].equals("pressmiddlebutton")) { 2744 2737 assertExactParametreCount(tokens, 0); 2745 DisplayIO.pressMouse(InputEvent.BUTTON2_MASK);2738 //DisplayIO.pressMouse(InputEvent.BUTTON2_MASK); TODO: Reinstate. cts16 2746 2739 } else if (tokens[0].equals("pressrightbutton")) { 2747 2740 assertExactParametreCount(tokens, 0); 2748 DisplayIO.pressMouse(InputEvent.BUTTON3_MASK);2741 //DisplayIO.pressMouse(InputEvent.BUTTON3_MASK); TODO: Reinstate. cts16 2749 2742 } else if (tokens[0].equals("releaseleftbutton")) { 2750 2743 assertExactParametreCount(tokens, 0); 2751 DisplayIO.releaseMouse(InputEvent.BUTTON1_MASK);2744 //DisplayIO.releaseMouse(InputEvent.BUTTON1_MASK); TODO: Reinstate. cts16 2752 2745 } else if (tokens[0].equals("releasemiddlebutton")) { 2753 2746 assertExactParametreCount(tokens, 0); 2754 DisplayIO.releaseMouse(InputEvent.BUTTON2_MASK);2747 //DisplayIO.releaseMouse(InputEvent.BUTTON2_MASK); TODO: Reinstate. cts16 2755 2748 } else if (tokens[0].equals("releaserightbutton")) { 2756 2749 assertExactParametreCount(tokens, 0); 2757 DisplayIO.releaseMouse(InputEvent.BUTTON3_MASK);2750 //DisplayIO.releaseMouse(InputEvent.BUTTON3_MASK); TODO: Reinstate. cts16 2758 2751 } else if (tokens[0].equals("clickleftbutton")) { 2759 2752 assertExactParametreCount(tokens, 0); 2760 FrameMouseActions.leftButton();2753 // FrameMouseActions.leftButton(); TODO: Reinstate. cts16 2761 2754 // DisplayIO.clickMouse(InputEvent.BUTTON1_MASK); 2762 2755 } else if (tokens[0].equals("clickmiddlebutton")) { 2763 2756 assertExactParametreCount(tokens, 0); 2764 FrameMouseActions.middleButton();2757 // FrameMouseActions.middleButton(); TODO: Reinstate. cts16 2765 2758 // DisplayIO.clickMouse(InputEvent.BUTTON2_MASK); 2766 2759 } else if (tokens[0].equals("clickrightbutton")) { 2767 2760 assertExactParametreCount(tokens, 0); 2768 FrameMouseActions.rightButton();2761 // FrameMouseActions.rightButton(); TODO: Reinstate. cts16 2769 2762 // DisplayIO.clickMouse(InputEvent.BUTTON3_MASK); 2770 2763 } else if (tokens[0].equals("repaint")) { 2771 2764 assertExactParametreCount(tokens, 0); 2772 2765 // FrameGraphics.Repaint(); 2773 FrameGraphics.requestRefresh(true);2766 DisplayController.requestRefresh(true); 2774 2767 } else if (tokens[0].equals("add")) { 2775 2768 assertMaxParametreCount(tokens, 3); … … 2931 2924 int x = (int) context.getPrimitives().getIntegerValue(tokens[1]); 2932 2925 int y = (int) context.getPrimitives().getIntegerValue(tokens[2]); 2933 Display IO.setCursorPosition(x, y);2926 DisplayController.setCursorPosition(x, y); 2934 2927 2935 2928 … … 2981 2974 2982 2975 if (source == null) 2983 source = Display IO.getCurrentFrame();2976 source = DisplayController.getCurrentFrame(); 2984 2977 int lastParam = tokens.length - 1; 2985 2978 String resultVarName = null; … … 3102 3095 _programsRunning++; 3103 3096 AgentStats.reset(); 3104 MessageBay.displayMessage("Running SimpleProgram...", Colo r.BLUE);3097 MessageBay.displayMessage("Running SimpleProgram...", Colour.BLUE); 3105 3098 } 3106 3099
Note:
See TracChangeset
for help on using the changeset viewer.