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 |
|
---|
19 | package org.expeditee.actions;
|
---|
20 |
|
---|
21 | import java.awt.Graphics;
|
---|
22 | import java.awt.Robot;
|
---|
23 | import java.util.List;
|
---|
24 | import java.util.concurrent.TimeUnit;
|
---|
25 | import java.util.stream.Collectors;
|
---|
26 |
|
---|
27 | import javax.swing.JFrame;
|
---|
28 | import javax.swing.JPanel;
|
---|
29 |
|
---|
30 | import org.expeditee.gio.swing.SwingGraphicsManager;
|
---|
31 | import org.expeditee.gio.swing.SwingInputManager;
|
---|
32 | import org.expeditee.gui.DisplayController;
|
---|
33 | import org.expeditee.gui.MessageBay;
|
---|
34 | import org.expeditee.items.Constraint;
|
---|
35 | import org.expeditee.items.Item;
|
---|
36 |
|
---|
37 | import com.sun.glass.events.KeyEvent;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * This class is used for temporary debugging actions that will get removed from
|
---|
41 | * the final product.
|
---|
42 | *
|
---|
43 | * @author jdm18
|
---|
44 | *
|
---|
45 | */
|
---|
46 | public class Debug {
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Outputs the list of constraints all Items in the current Frame have.
|
---|
50 | */
|
---|
51 | public static void ShowConstraints() {
|
---|
52 | List<Item> items = DisplayController.getCurrentFrame().getItems();
|
---|
53 |
|
---|
54 | for (Item i : items)
|
---|
55 | if (i.isLineEnd()) {
|
---|
56 | System.out.println(i.getID());
|
---|
57 |
|
---|
58 | for (Constraint c : i.getConstraints())
|
---|
59 | if (c.getOppositeEnd(i) != null)
|
---|
60 | System.out.println("\t"
|
---|
61 | + c.getOppositeEnd(i).getID());
|
---|
62 | else
|
---|
63 | System.out.println("\tNULL");
|
---|
64 |
|
---|
65 | System.out.println("------------");
|
---|
66 | }
|
---|
67 |
|
---|
68 | System.out.println("==================");
|
---|
69 | }
|
---|
70 |
|
---|
71 | public static void PrintLine() {
|
---|
72 | System.out.println("Action");
|
---|
73 | }
|
---|
74 |
|
---|
75 | @SuppressWarnings("serial")
|
---|
76 | public static void GraphicsTranslateTest() {
|
---|
77 | final JFrame f = new JFrame();
|
---|
78 | f.setContentPane(new JPanel() {
|
---|
79 | public void paintComponent(Graphics g) {
|
---|
80 | final int pos = 10;
|
---|
81 | final int size = 100;
|
---|
82 | int translate = 10;
|
---|
83 | for(int i = 0; i < 5; i++) {
|
---|
84 | g.translate(translate, translate);
|
---|
85 | g.drawRect(pos, pos, size, size);
|
---|
86 | g.translate(-translate, -translate);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | });
|
---|
90 | f.setSize(400, 400);
|
---|
91 | f.setVisible(true);
|
---|
92 | }
|
---|
93 |
|
---|
94 | public static void RobotTest() {
|
---|
95 | try {
|
---|
96 | final Robot screenWin = new Robot();//SwingInputManager.getInstance()._robot;
|
---|
97 | while(true) {
|
---|
98 | System.err.println("Sleeping 2 secs");
|
---|
99 | TimeUnit.SECONDS.sleep(2);
|
---|
100 | System.err.println("Robot move to (100,300)");
|
---|
101 | screenWin.mouseMove(100, 300);
|
---|
102 | }
|
---|
103 | } catch (Exception e) {
|
---|
104 | e.printStackTrace();
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | public static void TestFastInput() {
|
---|
109 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_A, 'A'));
|
---|
110 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_B, 'B'));
|
---|
111 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_C, 'C'));
|
---|
112 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_D, 'D'));
|
---|
113 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_E, 'E'));
|
---|
114 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_F, 'F'));
|
---|
115 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_G, 'G'));
|
---|
116 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_H, 'H'));
|
---|
117 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_I, 'I'));
|
---|
118 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_J, 'J'));
|
---|
119 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_K, 'K'));
|
---|
120 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_L, 'L'));
|
---|
121 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_M, 'M'));
|
---|
122 | SwingInputManager.getInstance().keyTyped(new java.awt.event.KeyEvent(SwingGraphicsManager.getInstance().getJFrame(), KeyEvent.PRESS, System.currentTimeMillis(), 0, KeyEvent.VK_N, 'N'));
|
---|
123 | }
|
---|
124 |
|
---|
125 | public static void HowManyMinWidths() {
|
---|
126 | MessageBay.displayMessage(DisplayController.getCurrentFrame().getItems().stream().filter(t -> t.getMinWidth() != null).collect(Collectors.toList()).size() + "");
|
---|
127 | }
|
---|
128 | }
|
---|