1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package org.ximtec.igesture.tool.view.testbench;
27
28 import java.beans.PropertyChangeEvent;
29 import java.util.logging.Logger;
30
31 import org.ximtec.igesture.algorithm.Algorithm;
32 import org.ximtec.igesture.algorithm.AlgorithmException;
33 import org.ximtec.igesture.algorithm.AlgorithmFactory;
34 import org.ximtec.igesture.configuration.Configuration;
35 import org.ximtec.igesture.core.Gesture;
36 import org.ximtec.igesture.core.ResultSet;
37 import org.ximtec.igesture.io.GestureDevice;
38 import org.ximtec.igesture.tool.core.Command;
39 import org.ximtec.igesture.tool.core.Controller;
40 import org.ximtec.igesture.tool.core.DefaultController;
41 import org.ximtec.igesture.tool.core.EdtProxy;
42 import org.ximtec.igesture.tool.core.ExecCmd;
43 import org.ximtec.igesture.tool.core.TabbedView;
44 import org.ximtec.igesture.tool.explorer.ExplorerTreeController;
45 import org.ximtec.igesture.tool.explorer.ExplorerTreeModel;
46 import org.ximtec.igesture.tool.service.SwingMouseReaderService;
47 import org.ximtec.igesture.tool.util.NodeInfoFactory;
48 import org.ximtec.igesture.tool.view.MainModel;
49 import org.ximtec.igesture.tool.view.testbench.panel.ConfigurationPanel;
50
51 public class TestbenchController extends DefaultController {
52
53 private static final Logger LOGGER = Logger
54 .getLogger(TestbenchController.class.getName());
55
56 private ITestBenchView testbenchView;
57
58 private MainModel mainModel;
59
60 private ExplorerTreeController explorerTreeController;
61
62 public final static String CMD_RECOGNIZE = "recognize";
63
64 public TestbenchController(Controller parentController) {
65 super(parentController);
66
67 mainModel = getLocator().getService(
68 MainModel.IDENTIFIER, MainModel.class);
69
70 initController();
71 }
72
73 private void initController() {
74 testbenchView = EdtProxy.newInstance(new TestbenchView(this), ITestBenchView.class);
75
76 ExplorerTreeModel explorerModel = new ExplorerTreeModel(mainModel
77 .getAlgorithmList(), NodeInfoFactory.createTestBenchNodeInfo(this));
78 explorerTreeController = new ExplorerTreeController(this, testbenchView,
79 explorerModel);
80
81 addController(explorerTreeController);
82 }
83
84 @Override
85 public TabbedView getView() {
86 return testbenchView;
87 }
88
89 @ExecCmd(name = CMD_RECOGNIZE)
90 protected void executeRecognize(Command command) {
91 try {
92 Algorithm algorithm = AlgorithmFactory
93 .createAlgorithm((Configuration) command.getSender());
94
95
96
97
98
99
100
101
102 GestureDevice<?, ?> gestureDevice = getLocator().getSharedDevice(ConfigurationPanel.IDENTIFIER);
103
104 if (gestureDevice.getGesture() != null) {
105
106 Gesture<?> gesture = gestureDevice.getGesture();
107 ResultSet resultSet = algorithm.recognise(gesture);
108
109 if (explorerTreeController.getExplorerTreeView() instanceof ConfigurationPanel) {
110 ConfigurationPanel panel = (ConfigurationPanel) explorerTreeController
111 .getExplorerTreeView();
112 panel.setResultList(resultSet.getResults());
113 }
114 }
115
116 } catch (AlgorithmException e) {
117 e.printStackTrace();
118 }
119
120 }
121
122 @Override
123 public void propertyChange(PropertyChangeEvent evt) {
124 LOGGER.info("PropertyChange");
125
126 super.propertyChange(evt);
127 }
128 }