1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.jeuclid.app.mathviewer;
20
21 import java.io.File;
22
23 import javax.swing.JFrame;
24 import javax.swing.SwingUtilities;
25 import javax.swing.UIManager;
26 import javax.swing.UnsupportedLookAndFeelException;
27
28 import net.sourceforge.jeuclid.Constants;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32
33 import com.apple.eawt.Application;
34
35
36
37
38
39
40 public final class MathViewer {
41
42
43
44
45 public static final boolean OSX =
46 System.getProperty("mrj.version") != null;
47
48
49
50
51 private static final Log LOGGER = LogFactory.getLog(MathViewer.class);
52
53
54
55
56 private static File source;
57
58
59
60
61 private MathViewer() {
62
63 }
64
65
66
67
68
69
70 public static void main(final String[] args) {
71 MathViewer.source = null;
72 if (args.length > 0) {
73 MathViewer.source = new File(args[0]);
74 }
75 if (MathViewer.OSX) {
76 System.setProperty("apple.laf.useScreenMenuBar",
77 Constants.TRUE);
78 }
79
80 try {
81 UIManager.setLookAndFeel(UIManager
82 .getSystemLookAndFeelClassName());
83 } catch (final ClassNotFoundException e) {
84 MathViewer.LOGGER.debug(e);
85 } catch (final InstantiationException e) {
86 MathViewer.LOGGER.debug(e);
87 } catch (final IllegalAccessException e) {
88 MathViewer.LOGGER.debug(e);
89 } catch (final UnsupportedLookAndFeelException e) {
90 MathViewer.LOGGER.debug(e);
91 }
92 SwingUtilities.invokeLater(new Runnable() {
93 public void run() {
94 final MainFrame mainFrame = new MainFrame();
95 mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
96 if (MathViewer.OSX) {
97 final Application a = Application.getApplication();
98 a.setEnabledAboutMenu(true);
99 a.setEnabledPreferencesMenu(true);
100 a.addApplicationListener(new MainFrameAppListener(
101 mainFrame));
102 }
103 if (MathViewer.source != null) {
104 mainFrame.loadFile(MathViewer.source);
105 }
106 mainFrame.setVisible(true);
107 }
108 });
109 }
110 }