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
27 package org.ximtec.igesture.geco;
28
29 import java.io.File;
30 import java.util.logging.Level;
31 import java.util.logging.Logger;
32
33 import javax.swing.ImageIcon;
34
35 import org.sigtec.graphix.SplashScreen;
36 import org.sigtec.util.FileHandler;
37 import org.ximtec.igesture.algorithm.AlgorithmException;
38 import org.ximtec.igesture.geco.gui.MainModel;
39 import org.ximtec.igesture.geco.gui.MainView;
40 import org.ximtec.igesture.geco.gui.action.OpenProjectAction;
41 import org.ximtec.igesture.geco.util.Constant;
42 import org.ximtec.igesture.geco.util.SystemTray;
43 import org.ximtec.igesture.util.XMLTool;
44
45
46
47
48
49
50
51
52
53 public class Geco {
54
55 private static final Logger LOGGER = Logger.getLogger(Geco.class.getName());
56
57 public static final String GECO_CONFIGURATION = "config/geco.xml";
58
59 private static final String DEFAULT_PROJECT = "mappings/defaultMappings.xml";
60
61 private static final String GECO_LOGO = "images/gecoLogo.png";
62
63 private static final String RUBINE_CONFIGURATION = "config/rubineconfiguration.xml";
64
65 public static final String CONFIG = "config";
66
67 private org.ximtec.igesture.configuration.Configuration configuration;
68
69 private Configuration gecoConfiguration;
70
71 private MainView view;
72
73
74 public Geco(String[] args) throws AlgorithmException {
75 ImageIcon logo = new ImageIcon(Geco.class.getClassLoader().getResource(
76 GECO_LOGO));
77 SplashScreen splashScreen = new SplashScreen(logo, false, 4000);
78 splashScreen.splash();
79 Logger.getAnonymousLogger().setLevel(Level.INFO);
80 LOGGER.info(Constant.INITIALISING);
81
82 if (args.length > 0) {
83 gecoConfiguration = new Configuration(args[0]);
84 }
85 else {
86 gecoConfiguration = new Configuration(GECO_CONFIGURATION);
87 }
88
89 configuration = XMLTool.importConfiguration(ClassLoader
90 .getSystemResourceAsStream(RUBINE_CONFIGURATION));
91 MainModel model = new MainModel(configuration, gecoConfiguration);
92 view = new MainView(model);
93 openMostRecentProject();
94 new SystemTray(view);
95 LOGGER.info(Constant.INITIALISED);
96 }
97
98
99
100
101
102
103
104 public static void main(String[] args) {
105 try {
106 new Geco(args);
107 }
108 catch (Exception e) {
109 e.printStackTrace();
110 }
111
112 }
113
114
115 private void openMostRecentProject() {
116 File file = null;
117 String filename = view.getModel().getGestureConfiguration()
118 .getMostRecentProject();
119
120 if ((filename == null) || (filename.equals(Constant.EMPTY_STRING))) {
121 file = FileHandler.getResource(DEFAULT_PROJECT);
122 }
123
124 (new OpenProjectAction(view)).openProject(file);
125 }
126
127 }