Changeset 181 for trunk/src/org/expeditee/actions/Misc.java
- Timestamp:
- 08/01/08 16:38:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Misc.java
r176 r181 9 9 import java.io.IOException; 10 10 import java.lang.reflect.Method; 11 import java.text.NumberFormat;12 11 import java.util.ArrayList; 13 12 import java.util.Collection; 14 13 import java.util.List; 15 import java.util.Observable;16 import java.util.Observer;17 14 18 15 import javax.imageio.ImageIO; 19 16 20 import org.expeditee.gui.AttributeUtils;21 import org.expeditee.gui.AttributeValuePair;22 17 import org.expeditee.gui.DisplayIO; 23 18 import org.expeditee.gui.Frame; … … 25 20 import org.expeditee.gui.FrameIO; 26 21 import org.expeditee.gui.FrameMouseActions; 27 import org.expeditee.gui.FrameUtils;28 22 import org.expeditee.gui.MessageBay; 29 23 import org.expeditee.gui.TimeKeeper; … … 37 31 import org.expeditee.stats.TreeStats; 38 32 import org.nfunk.jep.Node; 39 import org.nfunk.jep.Variable;40 33 41 34 /** … … 47 40 * Causes the system to beep 48 41 */ 49 public static void Beep() {42 public static void beep() { 50 43 java.awt.Toolkit.getDefaultToolkit().beep(); 51 44 } … … 54 47 * Forces a repaint of the current Frame 55 48 */ 56 public static void Display() {57 FrameGraphics. ForceRepaint();49 public static void display() { 50 FrameGraphics.refresh(false); 58 51 } 59 52 … … 62 55 * hard disk 63 56 */ 64 public static void Restore() {57 public static void restore() { 65 58 FrameIO.Reload(); 66 59 // MessageBay.displayMessage("Restoration complete."); … … 70 63 * Toggles AudienceMode on or off 71 64 */ 72 public static void ToggleAudienceMode() {65 public static void toggleAudienceMode() { 73 66 FrameGraphics.ToggleAudienceMode(); 74 67 } … … 77 70 * Toggles TwinFrames mode on or off 78 71 */ 79 public static void ToggleTwinFramesMode() {72 public static void toggleTwinFramesMode() { 80 73 DisplayIO.ToggleTwinFrames(); 81 74 } … … 88 81 * The Item to read the Actions from 89 82 */ 90 public static void RunCurrentItem(Item current){83 public static void runItem(Item current) throws Exception { 91 84 if (current instanceof Text) { 92 85 List<String> actions = ((Text) current).getTextList(); 93 86 for (String action : actions) { 94 if (!action.equalsIgnoreCase("run currentitem")) {87 if (!action.equalsIgnoreCase("runitem")) { 95 88 Actions.PerformAction(DisplayIO.getCurrentFrame(), current, 96 89 action); … … 152 145 * from. 153 146 */ 154 public static voidGetItemFromChildFrame(Item current) {155 getFromChildFrame(current, false);147 public static Item GetItemFromChildFrame(Item current) { 148 return getFromChildFrame(current, false); 156 149 } 157 150 … … 169 162 * from. 170 163 */ 171 public static voidGetTextFromChildFrame(Item current) {172 getFromChildFrame(current, true);173 } 174 175 private static voidgetFromChildFrame(Item current, boolean textOnly) {164 public static Item GetTextFromChildFrame(Item current) { 165 return getFromChildFrame(current, true); 166 } 167 168 private static Item getFromChildFrame(Item current, boolean textOnly) { 176 169 Item item = getFirstBodyItemOnChildFrame(current, textOnly); 177 170 // if no item was found 178 if (item == null) { 179 return; 180 } 181 182 // copy the item and switch 183 item = item.copy(); 184 item.setPosition(DisplayIO.getMouseX(), FrameMouseActions.getY()); 185 item.setParent(null); 186 FrameMouseActions.pickup(item); 187 FrameGraphics.Repaint(); 171 if (item != null) { 172 // copy the item and switch 173 item = item.copy(); 174 item.setPosition(DisplayIO.getMouseX(), FrameMouseActions.getY()); 175 } 176 return item; 188 177 } 189 178 … … 218 207 * The Color to give the Item. 219 208 */ 220 public static void Set CurrentItemBackgroundColor(Item toChange, Color toUse) {209 public static void SetItemBackgroundColor(Item toChange, Color toUse) { 221 210 if (toChange == null) 222 211 return; … … 235 224 * The Color to give the Item. 236 225 */ 237 public static void Set CurrentItemColor(Item toChange, Color toUse) {226 public static void SetItemColor(Item toChange, Color toUse) { 238 227 if (toChange == null) 239 228 return; … … 255 244 * Creates a new Text Object containing statistics for the current tree. 256 245 */ 257 public static voidGetCometStats(Frame frame) {246 public static String GetCometStats(Frame frame) { 258 247 TimeKeeper timer = new TimeKeeper(); 259 248 MessageBay.displayMessage("Computing comet stats..."); 260 261 249 CometStats cometStats = new CometStats(frame); 262 attachStatsToCursor(cometStats.toString());250 String result = cometStats.toString(); 263 251 MessageBay.overwriteMessage("Comet stats time: " 264 252 + timer.getElapsedStringSeconds()); 265 } 266 267 public static void GetTreeStats(Frame frame) { 253 return result; 254 } 255 256 public static String GetTreeStats(Frame frame) { 268 257 TimeKeeper timer = new TimeKeeper(); 269 258 MessageBay.displayMessage("Computing tree stats..."); 270 259 271 260 TreeStats treeStats = new TreeStats(frame); 272 attachStatsToCursor(treeStats.toString());261 String result = treeStats.toString(); 273 262 MessageBay.overwriteMessage("Tree stats time: " 274 263 + timer.getElapsedStringSeconds()); 264 return result; 265 275 266 } 276 267 … … 302 293 * then attached to the cursor via FrameMouseActions.pickup(Item) 303 294 */ 304 public static void GetItemStats() {305 attachStatsToCursor(SessionStats.getItemStats());295 public static String getItemStats() { 296 return SessionStats.getItemStats(); 306 297 } 307 298 … … 312 303 * FrameMouseActions.pickup(Item) 313 304 */ 314 public static void GetEventStats() {315 attachStatsToCursor(SessionStats.getEventStats());305 public static String getEventStats() { 306 return SessionStats.getEventStats(); 316 307 } 317 308 … … 320 311 * file. 321 312 */ 322 public static void GetCurrentFrameFile() { 323 Frame current = DisplayIO.getCurrentFrame(); 324 attachStatsToCursor(FrameIO.ForceSaveFrame(current)); 313 public static String getFrameFile(Frame frame) { 314 return FrameIO.ForceSaveFrame(frame); 325 315 } 326 316 … … 328 318 * Creates a new Text Object containing the available fonts. 329 319 */ 330 public static void getFontNames() { 331 320 public static String getFontNames() { 332 321 Collection<String> availableFonts = Actions.getFonts().values(); 333 322 StringBuilder fontsList = new StringBuilder(); … … 337 326 fontsList.deleteCharAt(fontsList.length() - 1); 338 327 339 attachStatsToCursor(fontsList.toString());340 } 341 342 public static voidgetUnicodeCharacters(int start, int finish) {328 return fontsList.toString(); 329 } 330 331 public static String getUnicodeCharacters(int start, int finish) { 343 332 if (start < 0 && finish < 0) { 344 333 throw new RuntimeException("Parameters must be non negative"); … … 364 353 } 365 354 } 366 attachTextToCursor(charList.toString());355 return charList.toString(); 367 356 } 368 357 … … 373 362 * the start of the block 374 363 */ 375 public static voidgetUnicodeCharacters(int start) {376 getUnicodeCharacters(start, start + 256);377 } 378 379 public static voidgetMathSymbols() {380 getUnicodeCharacters('\u2200', '\u2300');364 public static String getUnicodeCharacters(int start) { 365 return getUnicodeCharacters(start, start + 256); 366 } 367 368 public static String getMathSymbols() { 369 return getUnicodeCharacters('\u2200', '\u2300'); 381 370 } 382 371 … … 384 373 * Resets the statistics back to zero. 385 374 */ 386 public static void ResetStats() {375 public static void repaint() { 387 376 StatsLogger.WriteStatsFile(); 388 377 SessionStats.resetStats(); … … 395 384 * The name of the Frame to save 396 385 */ 397 public static void JpegFrame(String framename) {386 public static void jpegFrame(String framename) { 398 387 ImageFrame(framename, "JPEG"); 399 388 } … … 403 392 * JpegFrame(currentFrame.getName()) 404 393 */ 405 public static void JpegFrame() {394 public static void jpegFrame() { 406 395 ImageFrame(DisplayIO.getCurrentFrame().getName(), "JPEG"); 407 396 } 408 397 409 public static void JPGFrame() {410 JpegFrame();398 public static void jpgFrame() { 399 jpegFrame(); 411 400 } 412 401 … … 455 444 assert (frame != null); 456 445 457 FrameGraphics.UpdateBuffer(frame, false); 458 446 Image oldBuffer = frame.getBuffer(); 447 frame.setBuffer(null); 448 // Jpeg only works properly with volitile frames 449 // Png transparency only works with bufferedImage form 450 Image frameBuffer = FrameGraphics.getBuffer(frame, false, format 451 .equalsIgnoreCase("jpeg")); 452 // Make sure overlay stuff doesnt disapear on the frame visible on the 453 // screen 454 frame.setBuffer(oldBuffer); 459 455 BufferedImage screen = null; 460 Image frameBuffer = frame.getBuffer(); 461 if (frame.getBuffer() instanceof BufferedImage) { 462 screen = (BufferedImage) frameBuffer; 463 } else if (frameBuffer instanceof VolatileImage) { 456 457 if (frameBuffer instanceof VolatileImage) { 458 // If its the current frame it will be a volitive image 464 459 screen = ((VolatileImage) frameBuffer).getSnapshot(); 465 460 } else { 466 assert (false); 461 assert (frameBuffer instanceof BufferedImage); 462 screen = (BufferedImage) frameBuffer; 467 463 } 468 464 return SaveImage(screen, format, directory, frame.getExportFileName()); … … 491 487 + format + " format"); 492 488 // if the frame was not loaded successfully, alert the user 493 } else 489 } else { 494 490 MessageBay.displayMessage("Frame '" + framename 495 491 + "' could not be found."); 492 } 496 493 } 497 494 … … 744 741 } 745 742 } 743 744 /** 745 * Attach an item to the cursor. 746 * 747 * @param item 748 */ 749 public static void attachToCursor(Item item) { 750 item.setParent(null); 751 FrameMouseActions.pickup(item); 752 FrameGraphics.Repaint(); 753 } 746 754 }
Note:
See TracChangeset
for help on using the changeset viewer.