Changeset 1102 for trunk/src/org/expeditee/actions/Misc.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Misc.java
r1079 r1102 19 19 package org.expeditee.actions; 20 20 21 import java.awt.Color;22 import java.awt.Desktop;23 import java.awt.Image;24 import java.awt.image.BufferedImage;25 import java.awt.image.VolatileImage;26 21 import java.io.BufferedReader; 27 22 import java.io.File; … … 31 26 import java.io.InputStreamReader; 32 27 import java.lang.reflect.Method; 33 import java.net.URI;34 import java.net.URISyntaxException;35 28 import java.net.URL; 36 29 import java.net.URLClassLoader; … … 39 32 import java.util.LinkedList; 40 33 import java.util.List; 41 import java.util.Map;42 34 import java.util.Map.Entry; 43 import java.util.Set;44 35 import java.util.jar.Attributes; 45 36 import java.util.jar.JarFile; 46 37 47 import javax.imageio.ImageIO; 48 38 import org.expeditee.core.Colour; 39 import org.expeditee.core.Image; 40 import org.expeditee.core.Point; 41 import org.expeditee.gio.EcosystemManager; 42 import org.expeditee.gio.gesture.StandardGestureActions; 49 43 import org.expeditee.gui.AttributeUtils; 50 import org.expeditee.gui.Browser;51 44 import org.expeditee.io.Conversion; 52 import org.expeditee.gui.Display IO;45 import org.expeditee.gui.DisplayController; 53 46 import org.expeditee.io.ExpReader; 54 47 import org.expeditee.gui.Frame; 55 48 import org.expeditee.gui.FrameGraphics; 56 49 import org.expeditee.gui.FrameIO; 57 import org.expeditee.gui.FrameKeyboardActions;58 import org.expeditee.gui.FrameMouseActions;59 50 import org.expeditee.gui.FrameUtils; 60 51 import org.expeditee.gui.FreeItems; … … 63 54 import org.expeditee.gui.Reminders; 64 55 import org.expeditee.gui.TimeKeeper; 65 import org.expeditee.importer.FrameDNDTransferHandler;66 56 import org.expeditee.items.Item; 67 57 import org.expeditee.items.ItemUtils; … … 69 59 import org.expeditee.items.Text; 70 60 import org.expeditee.items.XRayable; 71 import org.expeditee.items.widgets. InteractiveWidget;61 import org.expeditee.items.widgets.Widget; 72 62 import org.expeditee.items.widgets.WidgetCorner; 73 63 import org.expeditee.items.widgets.WidgetEdge; … … 83 73 import org.nfunk.jep.ParseException; 84 74 85 import com.lowagie.text.Font;86 87 75 88 76 89 77 /** 90 * A list of miscellaneous Actions and Actionsspecific to Expeditee78 * A list of miscellaneous Actions specific to Expeditee 91 79 * 92 80 */ … … 96 84 * Causes the system to beep 97 85 */ 98 public static void beep() { 99 java.awt.Toolkit.getDefaultToolkit().beep(); 86 public static void beep() 87 { 88 EcosystemManager.getMiscManager().beep(); 100 89 } 101 90 … … 161 150 * Treats a string as a URL and attempts to open it 162 151 */ 163 public static void openURL(String siteURL){ 164 165 try { 166 URL check = new URL(siteURL); 167 Desktop.getDesktop().browse(new URI(siteURL)); 168 169 } catch (IOException| URISyntaxException e) { 170 171 MessageBay.displayMessage("'" + siteURL + "' is not a valid URL"); 172 } 152 public static void openURL(String siteURL) 153 { 154 boolean success = EcosystemManager.getMiscManager().browse(siteURL); 155 156 if (!success) MessageBay.displayMessage("'" + siteURL + "' is not a valid URL"); 173 157 } 174 158 /** … … 177 161 public static void setRestorePoint() 178 162 { 179 Frame current = Display IO.getCurrentFrame();163 Frame current = DisplayController.getCurrentFrame(); 180 164 current.change(); 181 165 FrameIO.SaveFrameAsRestore(current, true, true); … … 185 169 */ 186 170 public static void display() { 187 FrameGraphics.refresh(false);171 DisplayController.requestRefresh(false); 188 172 } 189 173 190 174 public static String getWindowSize() { 191 return Browser.getWindows()[0].getSize().toString();175 return EcosystemManager.getGraphicsManager().getWindowSize().toString(); 192 176 } 193 177 … … 205 189 */ 206 190 public static void toggleAudienceMode() { 207 FrameGraphics.ToggleAudienceMode();191 DisplayController.ToggleAudienceMode(); 208 192 } 209 193 … … 212 196 */ 213 197 public static void toggleTwinFramesMode() { 214 Display IO.ToggleTwinFrames();198 DisplayController.toggleTwinFrames(); 215 199 } 216 200 … … 227 211 for (String action : actions) { 228 212 if (!action.equalsIgnoreCase("runitem")) { 229 Actions.PerformAction(Display IO.getCurrentFrame(), current,213 Actions.PerformAction(DisplayController.getCurrentFrame(), current, 230 214 action); 231 215 } … … 249 233 String deletedFrameName = FrameIO.DeleteFrame(toDelete); 250 234 if (deletedFrameName != null) { 251 Display IO.Back();235 DisplayController.Back(); 252 236 // Remove any links on the previous frame to the one being 253 237 // deleted 254 Frame current = Display IO.getCurrentFrame();238 Frame current = DisplayController.getCurrentFrame(); 255 239 for (Item i : current.getItems()) 256 240 if (i.getLink() != null … … 312 296 // copy the item and switch 313 297 item = item.copy(); 314 item.setPosition(Display IO.getMouseX(), FrameMouseActions.getY());298 item.setPosition(DisplayController.getMousePosition()); 315 299 } 316 300 return item; … … 327 311 Collection<Item> copies = ItemUtils.CopyItems(items); 328 312 Item first = items.iterator().next(); 329 float deltaX = Display IO.getMouseX() - first.getX();330 float deltaY = FrameMouseActions.getY() - first.getY();313 float deltaX = DisplayController.getMouseX() - first.getX(); 314 float deltaY = DisplayController.getMouseY() - first.getY(); 331 315 for (Item i : copies) { 332 316 if (i.isVisible()) … … 334 318 i.setParent(null); 335 319 } 336 FrameMouseActions.pickup(copies);337 FrameGraphics.Repaint();320 StandardGestureActions.pickup(copies); 321 DisplayController.requestRefresh(true); 338 322 } 339 323 … … 347 331 * The Color to give the Item. 348 332 */ 349 public static void SetItemBackgroundColor(Item toChange, Colo r toUse) {333 public static void SetItemBackgroundColor(Item toChange, Colour toUse) { 350 334 if (toChange == null) 351 335 return; 352 336 353 337 toChange.setBackgroundColor(toUse); 354 FrameGraphics.Repaint();338 DisplayController.requestRefresh(true); 355 339 } 356 340 … … 364 348 * The Color to give the Item. 365 349 */ 366 public static void SetItemColor(Item toChange, Colo r toUse) {350 public static void SetItemColor(Item toChange, Colour toUse) { 367 351 if (toChange == null) 368 352 return; 369 353 370 354 toChange.setColor(toUse); 371 FrameGraphics.Repaint();355 DisplayController.requestRefresh(true); 372 356 } 373 357 … … 428 412 public static void attachStatsToCursor(String itemText) { 429 413 SessionStats.CreatedText(); 430 Frame current = Display IO.getCurrentFrame();414 Frame current = DisplayController.getCurrentFrame(); 431 415 Item text = current.getStatsTextItem(itemText); 432 FrameMouseActions.pickup(text);433 FrameGraphics.Repaint();416 StandardGestureActions.pickup(text); 417 DisplayController.requestRefresh(true); 434 418 } 435 419 436 420 public static void attachTextToCursor(String itemText) { 437 421 SessionStats.CreatedText(); 438 Frame current = Display IO.getCurrentFrame();422 Frame current = DisplayController.getCurrentFrame(); 439 423 Item text = current.getTextItem(itemText); 440 FrameMouseActions.pickup(text);441 FrameGraphics.Repaint();424 StandardGestureActions.pickup(text); 425 DisplayController.requestRefresh(true); 442 426 } 443 427 … … 494 478 } 495 479 496 for (Entry<String, java.awt.Font> entry: Text.FONT_WHEEL_ADDITIONAL_LOOKUP.entrySet()){480 for (Entry<String, org.expeditee.core.Font> entry: Text.FONT_WHEEL_ADDITIONAL_LOOKUP.entrySet()){ 497 481 498 482 String fontName = entry.getKey(); … … 585 569 */ 586 570 public static void jpegFrame() { 587 ImageFrame(Display IO.getCurrentFrame().getName(), "JPEG");571 ImageFrame(DisplayController.getCurrentFrame().getName(), "JPEG"); 588 572 } 589 573 … … 610 594 } 611 595 612 public static String SaveImage( BufferedImage screen, String format,596 public static String SaveImage(Image screen, String format, 613 597 String directory, String fileName) { 614 598 String suffix = "." + format.toLowerCase(); … … 633 617 634 618 // If the image is successfully written out return the fileName 635 if ( ImageIO.write(screen,format, out))619 if (screen.writeToDisk(format, out)) 636 620 return fileName; 637 621 … … 647 631 Image oldBuffer = frame.getBuffer(); 648 632 frame.setBuffer(null); 649 // Jpeg only works properly with vol itile frames633 // Jpeg only works properly with volatile frames 650 634 // Png transparency only works with bufferedImage form 651 Image frameBuffer = FrameGraphics.getBuffer(frame, false, format 652 .equalsIgnoreCase("jpeg")); 653 // Make sure overlay stuff doesnt disapear on the frame visible on the 635 Image frameBuffer = FrameGraphics.getFrameImage(frame, null, null, false, format.equalsIgnoreCase("jpeg")); 636 // Make sure overlay stuff doesnt disappear on the frame visible on the 654 637 // screen 655 638 frame.setBuffer(oldBuffer); 656 BufferedImage screen = null; 657 658 if (frameBuffer instanceof VolatileImage) { 659 // If its the current frame it will be a volitive image 660 screen = ((VolatileImage) frameBuffer).getSnapshot(); 661 } else { 662 assert (frameBuffer instanceof BufferedImage); 663 screen = (BufferedImage) frameBuffer; 664 } 665 return SaveImage(screen, format, directory, frame.getExportFileName()); 639 640 return SaveImage(frameBuffer, format, directory, frame.getExportFileName()); 666 641 } 667 642 … … 842 817 current.setActions(null); 843 818 844 FrameGraphics.Repaint();819 DisplayController.requestRefresh(true); 845 820 } 846 821 … … 932 907 text.setFormula(formulaFullCase); 933 908 if (text.isFloating()) { 934 text.setPosition(FrameMouseActions.MouseX,935 FrameMouseActions.MouseY);936 FrameMouseActions.resetOffset();909 Point cursorPos = EcosystemManager.getInputManager().getCursorPosition(); 910 text.setPosition(cursorPos.x, cursorPos.y); 911 StandardGestureActions.resetOffset(); 937 912 } else { 938 913 text.getParentOrCurrentFrame().change(); … … 956 931 public static void attachToCursor(Item item) { 957 932 item.setParent(null); 958 FrameMouseActions.pickup(item);959 FrameGraphics.Repaint();933 StandardGestureActions.pickup(item); 934 DisplayController.requestRefresh(true); 960 935 } 961 936 … … 965 940 i.invalidateAll(); 966 941 } 967 FrameMouseActions.pickup(items);942 StandardGestureActions.pickup(items); 968 943 // TODO figure out why this isnt repainting stuff immediately 969 944 // All of text item doesnt repaint until the cursor is moved 970 FrameGraphics.requestRefresh(true);945 DisplayController.requestRefresh(true); 971 946 } 972 947 … … 980 955 } 981 956 try { 982 FrameDNDTransferHandler.getInstance().importFileList(files, 983 FrameMouseActions.getPosition()); 957 EcosystemManager.getDragAndDropManager().importFileList(files, EcosystemManager.getInputManager().getCursorPosition()); 984 958 } catch (Exception e) { 985 959 } … … 990 964 if (file.exists()) { 991 965 try { 992 FrameDNDTransferHandler.getInstance().importFile(file, 993 FrameMouseActions.getPosition()); 966 EcosystemManager.getDragAndDropManager().importFile(file, EcosystemManager.getInputManager().getCursorPosition()); 994 967 } catch (Exception e) { 995 968 e.printStackTrace(); … … 1021 994 } 1022 995 1023 float curX = FrameMouseActions.MouseX; 1024 float curY = FrameMouseActions.MouseY; 996 Point cursorPos = DisplayController.getMousePosition(); 997 float curX = cursorPos.x; 998 float curY = cursorPos.y; 1025 999 1026 1000 Collection<Item> newItems = new LinkedList<Item>(); 1027 1001 Item[] d = new Item[sides]; 1028 1002 // create dots 1029 Frame current = Display IO.getCurrentFrame();1003 Frame current = DisplayController.getCurrentFrame(); 1030 1004 for (int i = 0; i < d.length; i++) { 1031 1005 d[i] = current.createDot(); … … 1053 1027 } 1054 1028 1055 Colo r newColor = item.getColor();1029 Colour newColor = item.getColor(); 1056 1030 if (newColor != null) { 1057 1031 d[0].setColor(item.getColor()); … … 1068 1042 1069 1043 ItemUtils.EnclosedCheck(newItems); 1070 FrameGraphics.refresh(false);1044 DisplayController.requestRefresh(false); 1071 1045 1072 1046 return d[0]; … … 1077 1051 } 1078 1052 1079 public static void print(String file) { 1080 try { 1081 if (Browser._theBrowser.isMinimumVersion6()) { 1082 if (Desktop.isDesktopSupported()) { 1083 Desktop.getDesktop().print(new File(file)); 1084 } 1085 } 1086 } catch (Exception e) { 1087 MessageBay.errorMessage("Printing error: " + e.getMessage()); 1088 } 1053 public static void print(String file) 1054 { 1055 String errorMessage = EcosystemManager.getMiscManager().print(file); 1056 1057 if (errorMessage != null) MessageBay.errorMessage("Printing error: " + errorMessage); 1089 1058 } 1090 1059 … … 1129 1098 * @throws Exception 1130 1099 */ 1131 public static void startLoboBrowser(Item text) throws Exception {1100 /* public static void startLoboBrowser(Item text) throws Exception { 1132 1101 if (!(text instanceof Text)) { 1133 1102 MessageBay.errorMessage("Must be a text item."); … … 1154 1123 1155 1124 FrameMouseActions.pickup(browser.getItems()); // attach browser widget to mouse 1156 } 1125 }*/ 1157 1126 1158 1127 /** … … 1161 1130 * @throws Exception 1162 1131 */ 1163 public static void startLoboBrowserNewFrame(Item text) throws Exception { 1132 public static void startLoboBrowserNewFrame(Item text) throws Exception 1133 { 1164 1134 if (!(text instanceof Text)) { 1165 1135 MessageBay.errorMessage("Must be a text item."); 1166 1136 return; 1167 1137 } 1138 1168 1139 if(text.getLink() != null) { // text item can't already have a link 1169 1140 MessageBay.errorMessage("Text item already has link."); … … 1176 1147 FrameUtils.Parse(frame); 1177 1148 1178 for( InteractiveWidget iw : frame.getInteractiveWidgets()) { // may be other widgets on frame1149 for(Widget iw : frame.getInteractiveWidgets()) { // may be other widgets on frame 1179 1150 if(iw instanceof org.expeditee.items.widgets.Browser) { 1180 1151 // Set browser to 'full screen' 1181 iw.setSize(-1, -1, -1, -1, Browser._theBrowser.getWidth(), Browser._theBrowser.getHeight() 1182 - MessageBay.MESSAGE_BUFFER_HEIGHT - 80); 1152 iw.setSize(-1, -1, -1, -1, DisplayController.getFramePaintArea().getWidth(), DisplayController.getFramePaintArea().getHeight() - 80); 1183 1153 1184 1154 // If there is a text item attached to cursor use it as url for browser 1185 if (FreeItems.textOnlyAttachedToCursor()) {1155 if (FreeItems.textOnlyAttachedToCursor()) { 1186 1156 text.setLink("" + frame.getNumber()); 1187 1157 ((org.expeditee.items.widgets.Browser)iw).navigate(text.getText()); … … 1190 1160 ((org.expeditee.items.widgets.Browser)iw).navigate("http://www.waikato.ac.nz"); 1191 1161 Text t = new Text("http://www.waikato.ac.nz"); 1192 t.setParent(Display IO.getCurrentFrame()); // set parent of text source for InteractiveWidget.createWidget()1193 t.setXY( FrameMouseActions.getX(), FrameMouseActions.getY());1162 t.setParent(DisplayController.getCurrentFrame()); // set parent of text source for InteractiveWidget.createWidget() 1163 t.setXY(DisplayController.getFloatMouseX(), DisplayController.getFloatMouseY()); 1194 1164 t.setLink("" + frame.getNumber()); // link url text to new browser frame 1195 FrameMouseActions.pickup(t); // Attach new text link to cursor1165 StandardGestureActions.pickup(t); // Attach new text link to cursor 1196 1166 } 1197 1167 } … … 1201 1171 } 1202 1172 1203 private static boolean startWidget(String name) throws Exception { 1173 private static boolean startWidget(String name) throws Exception 1174 { 1204 1175 String fullName = Actions.getClassName(name); 1205 1176 if(fullName == null) { … … 1210 1181 FreeItems.getInstance().clear(); 1211 1182 Text wt = new Text("@iw:" + fullName); // create new text item for browser widget 1212 wt.setParent(Display IO.getCurrentFrame()); // set parent of text source for InteractiveWidget.createWidget()1213 wt.setXY( FrameMouseActions.getX(), FrameMouseActions.getY()); // move to the mouse cursor1214 InteractiveWidget widget = InteractiveWidget.createWidget(wt);1215 FrameMouseActions.pickup(widget.getItems());1183 wt.setParent(DisplayController.getCurrentFrame()); // set parent of text source for InteractiveWidget.createWidget() 1184 wt.setXY(DisplayController.getMouseX(), DisplayController.getMouseY()); // move to the mouse cursor 1185 Widget widget = Widget.createWidget(wt); 1186 StandardGestureActions.pickup(widget.getItems()); 1216 1187 1217 1188 return true; … … 1223 1194 } 1224 1195 1225 Actions.PerformAction(Display IO.getCurrentFrame(), null, command);1196 Actions.PerformAction(DisplayController.getCurrentFrame(), null, command); 1226 1197 } 1227 1198 … … 1241 1212 if(name == "action" || name == "agent") { 1242 1213 if(args.length() > 0) { 1243 Actions.PerformAction(Display IO.getCurrentFrame(), null, args);1214 Actions.PerformAction(DisplayController.getCurrentFrame(), null, args); 1244 1215 } else { 1245 1216 MessageBay.displayMessage("Please specify an action/agent name"); … … 1324 1295 if (i instanceof WidgetEdge || i instanceof WidgetCorner) { 1325 1296 continue; 1326 } 1327 else { 1297 } else { 1328 1298 int new_x = i.getX(); 1329 1299 int new_y = i.getY(); … … 1345 1315 } 1346 1316 // update the polygon, otherwise stuff moves but leaves it's outline behind 1347 i. updatePolygon();1348 } 1349 1350 for ( InteractiveWidget iw : frame.getInteractiveWidgets()) {1317 i.invalidateBounds(); 1318 } 1319 1320 for (Widget iw : frame.getInteractiveWidgets()) { 1351 1321 1352 1322 int new_x = iw.getX(); … … 1368 1338 frame.change(); 1369 1339 // redraw everything 1370 FrameKeyboardActions.Refresh();1340 StandardGestureActions.Refresh(); 1371 1341 } 1372 1342 … … 1505 1475 public static void GitPushFrame() { 1506 1476 1507 FrameKeyboardActions.Save();1508 1509 Frame current = Display IO.getCurrentFrame();1477 StandardGestureActions.Save(); 1478 1479 Frame current = DisplayController.getCurrentFrame(); 1510 1480 String userName = UserSettings.ProfileName.get(); 1511 1481 … … 1544 1514 1545 1515 public static void GitPullFrame() { 1546 Frame current = Display IO.getCurrentFrame();1516 Frame current = DisplayController.getCurrentFrame(); 1547 1517 1548 1518 List<String> cmd_array = new ArrayList<String>(); … … 1554 1524 1555 1525 FrameIO.Reload(); 1556 FrameKeyboardActions.Refresh();1526 StandardGestureActions.Refresh(); 1557 1527 } 1558 1528
Note:
See TracChangeset
for help on using the changeset viewer.