3 import java.awt.BorderLayout;
4 import java.awt.Component;
5 import java.awt.FlowLayout;
7 import java.awt.GridBagConstraints;
8 import java.awt.GridBagLayout;
9 import java.awt.event.ActionEvent;
10 import java.awt.event.ActionListener;
11 import java.awt.event.KeyEvent;
12 import java.awt.event.KeyListener;
14 import javax.swing.BorderFactory;
15 import javax.swing.BoxLayout;
16 import javax.swing.JButton;
17 import javax.swing.JDialog;
18 import javax.swing.JEditorPane;
19 import javax.swing.JFrame;
20 import javax.swing.JLabel;
21 import javax.swing.JPanel;
22 import javax.swing.JTabbedPane;
24 import tim.prune.ExternalTools;
25 import tim.prune.GpsPruner;
26 import tim.prune.I18nManager;
27 import tim.prune.threedee.WindowFactory;
30 * Class to represent the "About" popup window
32 public class AboutScreen extends JDialog
34 JButton _okButton = null;
39 public AboutScreen(JFrame inParent)
41 super(inParent, I18nManager.getText("dialog.about.title"));
42 getContentPane().add(makeContents());
47 * @return the contents of the window as a Component
49 private Component makeContents()
51 JPanel mainPanel = new JPanel();
52 mainPanel.setLayout(new BorderLayout());
54 JTabbedPane tabPane = new JTabbedPane();
55 mainPanel.add(tabPane, BorderLayout.CENTER);
57 JPanel aboutPanel = new JPanel();
58 aboutPanel.setLayout(new BoxLayout(aboutPanel, BoxLayout.Y_AXIS));
59 aboutPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
60 JLabel titleLabel = new JLabel("Prune");
61 titleLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
62 titleLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
63 aboutPanel.add(titleLabel);
64 JLabel versionLabel = new JLabel(I18nManager.getText("dialog.about.version") + ": " + GpsPruner.VERSION_NUMBER);
65 versionLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
66 aboutPanel.add(versionLabel);
67 JLabel buildLabel = new JLabel(I18nManager.getText("dialog.about.build") + ": " + GpsPruner.BUILD_NUMBER);
68 buildLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
69 aboutPanel.add(buildLabel);
70 aboutPanel.add(new JLabel(" "));
71 StringBuffer descBuffer = new StringBuffer();
72 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext1")).append("</p>");
73 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext2")).append("</p>");
74 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext3")).append("</p>");
75 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.translatedby")).append("</p>");
76 JEditorPane descPane = new JEditorPane("text/html", descBuffer.toString());
77 descPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
78 descPane.setEditable(false);
79 descPane.setOpaque(false);
80 descPane.setAlignmentX(JEditorPane.CENTER_ALIGNMENT);
82 aboutPanel.add(descPane);
83 aboutPanel.add(new JLabel(" "));
84 tabPane.add(I18nManager.getText("dialog.about.title"), aboutPanel);
86 // Second pane for system info
87 JPanel sysInfoPanel = new JPanel();
88 GridBagLayout gridBag = new GridBagLayout();
89 sysInfoPanel.setLayout(gridBag);
90 GridBagConstraints constraints = new GridBagConstraints();
91 constraints.weightx = 0.0; constraints.weighty = 0.0;
92 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
93 new JLabel(I18nManager.getText("dialog.about.systeminfo.os") + " : "),
95 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
96 new JLabel(System.getProperty("os.name")),
98 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
99 new JLabel(I18nManager.getText("dialog.about.systeminfo.java") + " : "),
101 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
102 new JLabel(System.getProperty("java.runtime.version")),
104 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
105 new JLabel(I18nManager.getText("dialog.about.systeminfo.java3d") + " : "),
107 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
108 new JLabel(I18nManager.getText(WindowFactory.isJava3dEnabled()?"dialog.about.yes":"dialog.about.no")),
110 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
111 new JLabel(I18nManager.getText("dialog.about.systeminfo.povray") + " : "),
113 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
114 new JLabel(I18nManager.getText(ExternalTools.isPovrayInstalled()?"dialog.about.yes":"dialog.about.no")),
116 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
117 new JLabel(I18nManager.getText("dialog.about.systeminfo.exiftool") + " : "),
119 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
120 new JLabel(I18nManager.getText(ExternalTools.isExiftoolInstalled()?"dialog.about.yes":"dialog.about.no")),
122 tabPane.add(I18nManager.getText("dialog.about.systeminfo"), sysInfoPanel);
124 // Third pane for credits
125 JPanel creditsPanel = new JPanel();
126 gridBag = new GridBagLayout();
127 creditsPanel.setLayout(gridBag);
128 constraints = new GridBagConstraints();
129 constraints.weightx = 0.0; constraints.weighty = 0.0;
131 addToGridBagPanel(creditsPanel, gridBag, constraints,
132 new JLabel(I18nManager.getText("dialog.about.credits.code") + " : "),
134 addToGridBagPanel(creditsPanel, gridBag, constraints,
135 new JLabel("activityworkshop.net"),
137 addToGridBagPanel(creditsPanel, gridBag, constraints,
138 new JLabel(I18nManager.getText("dialog.about.credits.exifcode") + " : "),
140 addToGridBagPanel(creditsPanel, gridBag, constraints,
141 new JLabel("Drew Noakes"),
143 addToGridBagPanel(creditsPanel, gridBag, constraints,
144 new JLabel(I18nManager.getText("dialog.about.credits.icons") + " : "),
146 addToGridBagPanel(creditsPanel, gridBag, constraints,
147 new JLabel("Eclipse"),
149 addToGridBagPanel(creditsPanel, gridBag, constraints,
150 new JLabel(I18nManager.getText("dialog.about.credits.translations") + " : "),
152 addToGridBagPanel(creditsPanel, gridBag, constraints,
153 new JLabel("Open Office, Gpsdrive, Babelfish, Leo"),
155 addToGridBagPanel(creditsPanel, gridBag, constraints,
156 new JLabel(I18nManager.getText("dialog.about.credits.devtools") + " : "),
158 addToGridBagPanel(creditsPanel, gridBag, constraints,
159 new JLabel("Mandriva Linux, Sun Java, Eclipse, Svn, Gimp"),
161 addToGridBagPanel(creditsPanel, gridBag, constraints,
162 new JLabel(I18nManager.getText("dialog.about.credits.othertools") + " : "),
164 addToGridBagPanel(creditsPanel, gridBag, constraints,
165 new JLabel("Garble, Kate, Povray, Inkscape, Google Earth"),
167 addToGridBagPanel(creditsPanel, gridBag, constraints,
168 new JLabel(I18nManager.getText("dialog.about.credits.thanks") + " : "),
170 addToGridBagPanel(creditsPanel, gridBag, constraints,
171 new JLabel("Friends and loved ones, for encouragement and support"),
173 tabPane.add(I18nManager.getText("dialog.about.credits"), creditsPanel);
175 // OK button at the bottom
176 JPanel okPanel = new JPanel();
177 okPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
178 _okButton = new JButton(I18nManager.getText("button.ok"));
179 _okButton.addActionListener(new ActionListener()
181 public void actionPerformed(ActionEvent e)
186 _okButton.addKeyListener(new KeyListener() {
187 public void keyPressed(KeyEvent e)
189 if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {dispose();}
191 public void keyTyped(KeyEvent e) {}
192 public void keyReleased(KeyEvent e) {}
194 okPanel.add(_okButton);
195 mainPanel.add(okPanel, BorderLayout.SOUTH);
200 * Helper function to reduce complexity of gui making code
201 * when adding labels to a GridBagLayout
202 * @param inPanel panel to add to
203 * @param inLayout GridBagLayout object
204 * @param inConstraints GridBagConstraints object
205 * @param inLabel label to add
209 private static void addToGridBagPanel(JPanel inPanel, GridBagLayout inLayout, GridBagConstraints inConstraints,
210 JLabel inLabel, int inX, int inY)
212 // set x and y in constraints
213 inConstraints.gridx = inX;
214 inConstraints.gridy = inY;
216 inConstraints.anchor = (inX == 0?GridBagConstraints.EAST:GridBagConstraints.WEST);
217 // set constraints to label
218 inLayout.setConstraints(inLabel, inConstraints);
219 // add label to panel
220 inPanel.add(inLabel);
232 _okButton.requestFocus();