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;
38 * @param inParent parent frame
40 public AboutScreen(JFrame inParent)
42 super(inParent, I18nManager.getText("dialog.about.title"));
43 getContentPane().add(makeContents());
48 * @return the contents of the window as a Component
50 private Component makeContents()
52 JPanel mainPanel = new JPanel();
53 mainPanel.setLayout(new BorderLayout());
55 JTabbedPane tabPane = new JTabbedPane();
56 mainPanel.add(tabPane, BorderLayout.CENTER);
58 JPanel aboutPanel = new JPanel();
59 aboutPanel.setLayout(new BoxLayout(aboutPanel, BoxLayout.Y_AXIS));
60 aboutPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
61 JLabel titleLabel = new JLabel("Prune");
62 titleLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
63 titleLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
64 aboutPanel.add(titleLabel);
65 JLabel versionLabel = new JLabel(I18nManager.getText("dialog.about.version") + ": " + GpsPruner.VERSION_NUMBER);
66 versionLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
67 aboutPanel.add(versionLabel);
68 JLabel buildLabel = new JLabel(I18nManager.getText("dialog.about.build") + ": " + GpsPruner.BUILD_NUMBER);
69 buildLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
70 aboutPanel.add(buildLabel);
71 aboutPanel.add(new JLabel(" "));
72 StringBuffer descBuffer = new StringBuffer();
73 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext1")).append("</p>");
74 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext2")).append("</p>");
75 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext3")).append("</p>");
76 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.translatedby")).append("</p>");
77 JEditorPane descPane = new JEditorPane("text/html", descBuffer.toString());
78 descPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
79 descPane.setEditable(false);
80 descPane.setOpaque(false);
81 descPane.setAlignmentX(JEditorPane.CENTER_ALIGNMENT);
83 aboutPanel.add(descPane);
84 aboutPanel.add(new JLabel(" "));
85 tabPane.add(I18nManager.getText("dialog.about.title"), aboutPanel);
87 // Second pane for system info
88 JPanel sysInfoPanel = new JPanel();
89 GridBagLayout gridBag = new GridBagLayout();
90 sysInfoPanel.setLayout(gridBag);
91 GridBagConstraints constraints = new GridBagConstraints();
92 constraints.weightx = 0.0; constraints.weighty = 0.0;
93 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
94 new JLabel(I18nManager.getText("dialog.about.systeminfo.os") + " : "),
96 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
97 new JLabel(System.getProperty("os.name")),
99 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
100 new JLabel(I18nManager.getText("dialog.about.systeminfo.java") + " : "),
102 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
103 new JLabel(System.getProperty("java.runtime.version")),
105 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
106 new JLabel(I18nManager.getText("dialog.about.systeminfo.java3d") + " : "),
108 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
109 new JLabel(I18nManager.getText(WindowFactory.isJava3dEnabled()?"dialog.about.yes":"dialog.about.no")),
111 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
112 new JLabel(I18nManager.getText("dialog.about.systeminfo.povray") + " : "),
114 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
115 new JLabel(I18nManager.getText(ExternalTools.isPovrayInstalled()?"dialog.about.yes":"dialog.about.no")),
117 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
118 new JLabel(I18nManager.getText("dialog.about.systeminfo.exiftool") + " : "),
120 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
121 new JLabel(I18nManager.getText(ExternalTools.isExiftoolInstalled()?"dialog.about.yes":"dialog.about.no")),
123 tabPane.add(I18nManager.getText("dialog.about.systeminfo"), sysInfoPanel);
125 // Third pane for credits
126 JPanel creditsPanel = new JPanel();
127 gridBag = new GridBagLayout();
128 creditsPanel.setLayout(gridBag);
129 constraints = new GridBagConstraints();
130 constraints.weightx = 0.0; constraints.weighty = 0.0;
132 addToGridBagPanel(creditsPanel, gridBag, constraints,
133 new JLabel(I18nManager.getText("dialog.about.credits.code") + " : "),
135 addToGridBagPanel(creditsPanel, gridBag, constraints,
136 new JLabel("activityworkshop.net"),
138 addToGridBagPanel(creditsPanel, gridBag, constraints,
139 new JLabel(I18nManager.getText("dialog.about.credits.exifcode") + " : "),
141 addToGridBagPanel(creditsPanel, gridBag, constraints,
142 new JLabel("Drew Noakes"),
144 addToGridBagPanel(creditsPanel, gridBag, constraints,
145 new JLabel(I18nManager.getText("dialog.about.credits.icons") + " : "),
147 addToGridBagPanel(creditsPanel, gridBag, constraints,
148 new JLabel("Eclipse"),
150 addToGridBagPanel(creditsPanel, gridBag, constraints,
151 new JLabel(I18nManager.getText("dialog.about.credits.translators") + " : "),
153 addToGridBagPanel(creditsPanel, gridBag, constraints,
154 new JLabel("Ramon, Miguel, Inés, Piotr"),
156 addToGridBagPanel(creditsPanel, gridBag, constraints,
157 new JLabel(I18nManager.getText("dialog.about.credits.translations") + " : "),
159 addToGridBagPanel(creditsPanel, gridBag, constraints,
160 new JLabel("Open Office, Gpsdrive, Babelfish, Leo, Launchpad"),
162 addToGridBagPanel(creditsPanel, gridBag, constraints,
163 new JLabel(I18nManager.getText("dialog.about.credits.devtools") + " : "),
165 addToGridBagPanel(creditsPanel, gridBag, constraints,
166 new JLabel("Mandriva Linux, Sun Java, Eclipse, Svn, Gimp"),
168 addToGridBagPanel(creditsPanel, gridBag, constraints,
169 new JLabel(I18nManager.getText("dialog.about.credits.othertools") + " : "),
171 addToGridBagPanel(creditsPanel, gridBag, constraints,
172 new JLabel("Garble, Kate, Povray, Exiftool, Inkscape, Google Earth"),
174 addToGridBagPanel(creditsPanel, gridBag, constraints,
175 new JLabel(I18nManager.getText("dialog.about.credits.thanks") + " : "),
177 addToGridBagPanel(creditsPanel, gridBag, constraints,
178 new JLabel("Friends and loved ones, for encouragement and support"),
180 tabPane.add(I18nManager.getText("dialog.about.credits"), creditsPanel);
182 // OK button at the bottom
183 JPanel okPanel = new JPanel();
184 okPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
185 _okButton = new JButton(I18nManager.getText("button.ok"));
186 _okButton.addActionListener(new ActionListener()
188 public void actionPerformed(ActionEvent e)
193 _okButton.addKeyListener(new KeyListener() {
194 public void keyPressed(KeyEvent e)
196 if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {dispose();}
198 public void keyTyped(KeyEvent e) {}
199 public void keyReleased(KeyEvent e) {}
201 okPanel.add(_okButton);
202 mainPanel.add(okPanel, BorderLayout.SOUTH);
207 * Helper function to reduce complexity of gui making code
208 * when adding labels to a GridBagLayout
209 * @param inPanel panel to add to
210 * @param inLayout GridBagLayout object
211 * @param inConstraints GridBagConstraints object
212 * @param inLabel label to add
216 private static void addToGridBagPanel(JPanel inPanel, GridBagLayout inLayout, GridBagConstraints inConstraints,
217 JLabel inLabel, int inX, int inY)
219 // set x and y in constraints
220 inConstraints.gridx = inX;
221 inConstraints.gridy = inY;
223 inConstraints.anchor = (inX == 0?GridBagConstraints.EAST:GridBagConstraints.WEST);
224 // set constraints to label
225 inLayout.setConstraints(inLabel, inConstraints);
226 // add label to panel
227 inPanel.add(inLabel);
239 _okButton.requestFocus();