source: trunk/src/org/expeditee/actions/Debug.java@ 1134

Last change on this file since 1134 was 1134, checked in by bln4, 6 years ago

org.expeditee.actions.Debug ->

Added an action that demonstrates the issue with Robot on specific systems (such as David's laptop)

File size: 4.9 KB
Line 
1/**
2 * Debug.java
3 * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package org.expeditee.actions;
20
21import java.awt.AWTException;
22import java.awt.Robot;
23import java.util.List;
24import java.util.concurrent.TimeUnit;
25
26import org.expeditee.gio.swing.SwingGraphicsManager;
27import org.expeditee.gio.swing.SwingInputManager;
28import org.expeditee.gui.DisplayController;
29import org.expeditee.items.Constraint;
30import org.expeditee.items.Item;
31
32import com.sun.glass.events.KeyEvent;
33
34/**
35 * This class is used for temporary debugging actions that will get removed from
36 * the final product.
37 *
38 * @author jdm18
39 *
40 */
41public class Debug {
42
43 /**
44 * Outputs the list of constraints all Items in the current Frame have.
45 */
46 public static void ShowConstraints() {
47 List<Item> items = DisplayController.getCurrentFrame().getItems();
48
49 for (Item i : items)
50 if (i.isLineEnd()) {
51 System.out.println(i.getID());
52
53 for (Constraint c : i.getConstraints())
54 if (c.getOppositeEnd(i) != null)
55 System.out.println("\t"
56 + c.getOppositeEnd(i).getID());
57 else
58 System.out.println("\tNULL");
59
60 System.out.println("------------");
61 }
62
63 System.out.println("==================");
64 }
65
66 public static void PrintLine() {
67 System.out.println("Action");
68 }
69
70 public static void RobotTest() {
71 try {
72 final Robot screenWin = new Robot();//SwingInputManager.getInstance()._robot;
73 while(true) {
74 System.err.println("Sleeping 2 secs");
75 TimeUnit.SECONDS.sleep(2);
76 System.err.println("Robot move to (100,300)");
77 screenWin.mouseMove(100, 300);
78 }
79 } catch (Exception e) {
80 e.printStackTrace();
81 }
82 }
83
84 public static void TestFastInput() {
85 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_A, 'A'));
86 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_B, 'B'));
87 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_C, 'C'));
88 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_D, 'D'));
89 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_E, 'E'));
90 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_F, 'F'));
91 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_G, 'G'));
92 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_H, 'H'));
93 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_I, 'I'));
94 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_J, 'J'));
95 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_K, 'K'));
96 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_L, 'L'));
97 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_M, 'M'));
98 SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_N, 'N'));
99 }
100}
Note: See TracBrowser for help on using the repository browser.