001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.workbench.ui;
034:
035: import java.awt.BorderLayout;
036: import java.awt.GridBagConstraints;
037: import java.awt.GridBagLayout;
038: import java.awt.Insets;
039: import java.awt.event.ActionEvent;
040: import java.text.DecimalFormat;
041:
042: import javax.swing.BorderFactory;
043: import javax.swing.JButton;
044: import javax.swing.JDialog;
045: import javax.swing.JLabel;
046: import javax.swing.JPanel;
047: import javax.swing.JTabbedPane;
048: import javax.swing.SwingConstants;
049: import javax.swing.border.Border;
050:
051: import com.vividsolutions.jump.I18N;
052: import com.vividsolutions.jump.JUMPVersion;
053: import com.vividsolutions.jump.util.StringUtil;
054: import com.vividsolutions.jump.workbench.JUMPWorkbench;
055: import com.vividsolutions.jump.workbench.WorkbenchContext;
056:
057: /**
058: * Displays an About Dialog (Splash Screen).
059: */
060: //<<TODO:AESTHETICS>> Modify the image so that the green and red pieces have
061: //a smooth sinusoidal interface. [Jon Aquino]
062: //<<TODO:AESTHETICS>> The lettering on the image is a bit blocky. Fix. [Jon Aquino]
063: public class AboutDialog extends JDialog {
064: BorderLayout borderLayout2 = new BorderLayout();
065: Border border1;
066: JPanel buttonPanel = new JPanel();
067: JButton okButton = new JButton();
068: private JTabbedPane jTabbedPane1 = new JTabbedPane();
069: private JPanel infoPanel = new JPanel();
070: private BorderLayout borderLayout3 = new BorderLayout();
071: private JPanel jPanel1 = new JPanel();
072: private JLabel jLabel1 = new JLabel();
073: private JLabel jLabel2 = new JLabel();
074: private GridBagLayout gridBagLayout1 = new GridBagLayout();
075: private JLabel jLabel3 = new JLabel();
076: private JLabel jLabel4 = new JLabel();
077: private JPanel logoPanel = new JPanel();
078: private BorderLayout borderLayout1 = new BorderLayout();
079: private JLabel jLabel9 = new JLabel();
080: private JLabel jLabel10 = new JLabel();
081: private JLabel jLabel11 = new JLabel();
082: private JLabel lblJavaVersion = new JLabel();
083: private JLabel jLabel12 = new JLabel();
084: private JLabel lblFreeMemory = new JLabel();
085: private JLabel lblTotalMemory = new JLabel();
086: private JLabel jLabel13 = new JLabel();
087: private JLabel lblOSVersion = new JLabel();
088: private JLabel jLabel14 = new JLabel();
089: private JLabel lblCommittedMemory = new JLabel();
090: private JPanel pnlButtons = new JPanel();
091: private JButton btnGC = new JButton();
092: private SplashPanel splashPanel;
093:
094: public static AboutDialog instance(WorkbenchContext context) {
095: final String INSTANCE_KEY = AboutDialog.class.getName()
096: + " - INSTANCE";
097: if (context.getWorkbench().getBlackboard().get(INSTANCE_KEY) == null) {
098: AboutDialog aboutDialog = new AboutDialog(context
099: .getWorkbench().getFrame());
100: context.getWorkbench().getBlackboard().put(INSTANCE_KEY,
101: aboutDialog);
102: GUIUtil.centreOnWindow(aboutDialog);
103: }
104: return (AboutDialog) context.getWorkbench().getBlackboard()
105: .get(INSTANCE_KEY);
106: }
107:
108: private ExtensionsAboutPanel extensionsAboutPanel = new ExtensionsAboutPanel();
109:
110: private AboutDialog(WorkbenchFrame frame) {
111: super (frame, I18N.get("ui.AboutDialog.about-jump"), true);
112: extensionsAboutPanel.setPlugInManager(frame.getContext()
113: .getWorkbench().getPlugInManager());
114: this .splashPanel = new SplashPanel(JUMPWorkbench.splashImage(),
115: I18N.get("ui.AboutDialog.version") + " "
116: + JUMPVersion.CURRENT_VERSION);
117:
118: try {
119: jbInit();
120: pack();
121: } catch (Exception ex) {
122: ex.printStackTrace();
123: }
124: }
125:
126: void jbInit() throws Exception {
127: border1 = BorderFactory.createEmptyBorder(0, 0, 0, 0);
128: this .getContentPane().setLayout(borderLayout2);
129: this .setResizable(false);
130: okButton.setText("OK");
131: okButton.addActionListener(new java.awt.event.ActionListener() {
132: public void actionPerformed(ActionEvent e) {
133: okButton_actionPerformed(e);
134: }
135: });
136: infoPanel.setLayout(borderLayout3);
137: jLabel1.setToolTipText("");
138: jLabel1.setText("Martin Davis");
139: jLabel2.setFont(new java.awt.Font("Dialog", 3, 12));
140: jLabel2.setToolTipText("");
141: jLabel2.setText(I18N.get("ui.AboutDialog.development-team"));
142: jPanel1.setLayout(gridBagLayout1);
143: jLabel3.setText("David Zwiers");
144: jLabel4.setText("Alan Chang");
145: logoPanel.setLayout(borderLayout1);
146: jLabel9.setFont(new java.awt.Font("Dialog", 2, 12));
147: jLabel9.setText(I18N.get("ui.AboutDialog.free-memory"));
148: jLabel10.setFont(new java.awt.Font("Dialog", 2, 12));
149: jLabel10.setText(I18N.get("ui.AboutDialog.java-version"));
150: jLabel11.setFont(new java.awt.Font("Dialog", 3, 12));
151: jLabel11.setHorizontalAlignment(SwingConstants.LEFT);
152: jLabel11.setText(I18N.get("ui.AboutDialog.system-info"));
153: lblJavaVersion.setToolTipText("");
154: lblJavaVersion.setText("x");
155: jLabel12.setFont(new java.awt.Font("Dialog", 2, 12));
156: jLabel12.setText(I18N.get("ui.AboutDialog.total-memory"));
157: lblFreeMemory.setToolTipText("");
158: lblFreeMemory.setText("x");
159: lblTotalMemory.setText("x");
160: jLabel13.setFont(new java.awt.Font("Dialog", 2, 12));
161: jLabel13.setText(I18N.get("ui.AboutDialog.os"));
162: lblOSVersion.setText("x");
163: jLabel14.setFont(new java.awt.Font("Dialog", 2, 12));
164: jLabel14.setText(I18N.get("ui.AboutDialog.comitted-memory"));
165: lblCommittedMemory.setText("x");
166: btnGC.setText(I18N.get("ui.AboutDialog.garbage-collect"));
167: btnGC.addActionListener(new java.awt.event.ActionListener() {
168: public void actionPerformed(ActionEvent e) {
169: btnGC_actionPerformed(e);
170: }
171: });
172: jTabbedPane1.add(logoPanel, I18N.get("ui.AboutDialog.about"));
173: logoPanel.add(splashPanel, BorderLayout.CENTER);
174: this .getContentPane().add(buttonPanel, BorderLayout.SOUTH);
175: buttonPanel.add(okButton, null);
176: jTabbedPane1.setBounds(0, 0, 0, 0);
177: jTabbedPane1.addTab(I18N.get("ui.AboutDialog.info"), infoPanel);
178: jTabbedPane1
179: .addTab(StringUtil.toFriendlyName(extensionsAboutPanel
180: .getClass().getName(), "AboutPanel"),
181: extensionsAboutPanel);
182: infoPanel.add(jPanel1, BorderLayout.CENTER);
183: jPanel1.add(jLabel2, new GridBagConstraints(0, 6, 2, 1, 0.0,
184: 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
185: new Insets(20, 0, 0, 20), 0, 0));
186: jPanel1.add(jLabel1, new GridBagConstraints(2, 6, 1, 1, 0.0,
187: 0.0, GridBagConstraints.SOUTHWEST,
188: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
189: jPanel1.add(jLabel3, new GridBagConstraints(2, 7, 1, 1, 0.0,
190: 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
191: new Insets(0, 0, 0, 0), 0, 0));
192: jPanel1.add(jLabel4, new GridBagConstraints(2, 8, 1, 1, 0.0,
193: 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
194: new Insets(0, 0, 0, 0), 0, 0));
195: jPanel1.add(jLabel10, new GridBagConstraints(2, 0, 1, 1, 0.0,
196: 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
197: new Insets(0, 0, 0, 0), 0, 0));
198: jPanel1.add(jLabel11, new GridBagConstraints(0, 0, 2, 1, 0.0,
199: 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
200: new Insets(0, 0, 0, 0), 0, 0));
201: jPanel1.add(lblJavaVersion, new GridBagConstraints(3, 0, 1, 1,
202: 0.0, 0.0, GridBagConstraints.EAST,
203: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
204: this .getContentPane().add(jTabbedPane1, BorderLayout.NORTH);
205: jPanel1.add(jLabel13, new GridBagConstraints(2, 1, 1, 1, 0.0,
206: 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
207: new Insets(0, 0, 0, 0), 0, 0));
208: jPanel1.add(lblOSVersion, new GridBagConstraints(3, 1, 1, 1,
209: 0.0, 0.0, GridBagConstraints.EAST,
210: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
211: jPanel1.add(jLabel9, new GridBagConstraints(2, 4, 1, 1, 0.0,
212: 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
213: new Insets(0, 0, 0, 0), 0, 0));
214: jPanel1.add(jLabel12, new GridBagConstraints(2, 2, 1, 1, 0.0,
215: 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
216: new Insets(0, 0, 0, 0), 0, 0));
217: jPanel1.add(lblFreeMemory, new GridBagConstraints(3, 4, 1, 1,
218: 0.0, 0.0, GridBagConstraints.EAST,
219: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
220: jPanel1.add(lblTotalMemory, new GridBagConstraints(3, 2, 1, 1,
221: 0.0, 0.0, GridBagConstraints.EAST,
222: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
223: jPanel1.add(jLabel14, new GridBagConstraints(2, 3, 1, 1, 0.0,
224: 0.0, GridBagConstraints.CENTER,
225: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
226: jPanel1.add(lblCommittedMemory, new GridBagConstraints(3, 3, 1,
227: 1, 0.0, 0.0, GridBagConstraints.EAST,
228: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
229: jPanel1.add(pnlButtons, new GridBagConstraints(2, 5, 2, 1, 0.0,
230: 0.0, GridBagConstraints.CENTER,
231: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
232: pnlButtons.add(btnGC, null);
233: }
234:
235: public void setVisible(boolean b) {
236: if (b) {
237: DecimalFormat format = new DecimalFormat("###,###");
238: lblJavaVersion.setText(System.getProperty("java.version"));
239: lblOSVersion.setText(System.getProperty("os.name") + " ("
240: + System.getProperty("os.version") + ")");
241:
242: long totalMem = Runtime.getRuntime().totalMemory();
243: long freeMem = Runtime.getRuntime().freeMemory();
244: lblTotalMemory.setText(format.format(totalMem) + " bytes");
245: lblCommittedMemory.setText(format
246: .format(totalMem - freeMem)
247: + " bytes");
248: lblFreeMemory.setText(format.format(freeMem) + " bytes");
249: }
250:
251: super .setVisible(b);
252: }
253:
254: void okButton_actionPerformed(ActionEvent e) {
255: setVisible(false);
256: }
257:
258: void btnGC_actionPerformed(ActionEvent e) {
259: Runtime.getRuntime().gc();
260: setVisible(true);
261: }
262: }
|