[Schmitzm-commits] r2337 - in trunk/schmitzm-core/src/main: java/de/schmitzm/swing resources/de/schmitzm/swing/resource/images
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Sun Jun 9 19:14:37 CEST 2013
Author: mojays
Date: 2013-06-09 19:14:36 +0200 (Sun, 09 Jun 2013)
New Revision: 2337
Added:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AboutDialog.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AboutDialogMartinSchmitz.java
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/images/martin-schmitz.png
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/InfoDialog.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
Log:
AboutDialog and AboutDialogMartinSchmitz
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AboutDialog.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AboutDialog.java (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AboutDialog.java 2013-06-09 17:14:36 UTC (rev 2337)
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ *
+ * This file is part of the SCHMITZM library - a collection of utility
+ * classes based on Java 1.6, focusing (not only) on Java Swing
+ * and the Geotools library.
+ *
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ *
+ * Contributors:
+ * Martin O. J. Schmitz - initial API and implementation
+ * Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Frame;
+
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+
+import net.miginfocom.swing.MigLayout;
+
+/**
+ * The "AboutDialog" extends the {@link InfoDialog} by the
+ * application name.
+ * @author Martin O.J. Schmitz
+ *
+ */
+public class AboutDialog extends InfoDialog {
+ /** Panel which contains the application name (and more components defined by sub-classes). */
+ protected JPanel headerPanel;
+ /** Label which contains application name. */
+ protected JLabel applNameLabel;
+
+ /**
+ * Creates new frame.
+ */
+ public AboutDialog(Frame owner, String applName) {
+ super(owner);
+ applNameLabel.setText(applName);
+ }
+
+
+ /**
+ * Extends the info dialog by application name.
+ */
+ @Override
+ public void init() {
+ super.init();
+ this.headerPanel = new JPanel();
+ headerPanel.setLayout( new MigLayout("wrap 1","10[grow, center]10","[center]") );
+ headerPanel.setBackground(Color.WHITE); // because of image!
+ headerPanel.setBorder( BorderFactory.createRaisedBevelBorder() );
+
+ this.applNameLabel = new JLabel("dummy"); // application name set in constructor
+ applNameLabel.setFont( applNameLabel.getFont().deriveFont(Font.BOLD).deriveFont(40f) );
+ applNameLabel.setHorizontalAlignment(JLabel.CENTER);
+
+ headerPanel.add(applNameLabel,"growx");
+
+ getContentPane().add(headerPanel,BorderLayout.NORTH);
+ pack();
+ }
+
+}
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AboutDialogMartinSchmitz.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AboutDialogMartinSchmitz.java (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AboutDialogMartinSchmitz.java 2013-06-09 17:14:36 UTC (rev 2337)
@@ -0,0 +1,80 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ *
+ * This file is part of the SCHMITZM library - a collection of utility
+ * classes based on Java 1.6, focusing (not only) on Java Swing
+ * and the Geotools library.
+ *
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ *
+ * Contributors:
+ * Martin O. J. Schmitz - initial API and implementation
+ * Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.Frame;
+
+import javax.swing.JLabel;
+
+/**
+ * Application information dialog ("About"), especially for applications developed
+ * by Martin Schmitz.
+ * @author Martin O.J. Schmitz
+ *
+ */
+public class AboutDialogMartinSchmitz extends AboutDialog {
+ /** Label which contains the company icon (nemaplot). */
+ protected JLabel companyLabel;
+ /** Label which contains the developer contact. */
+ protected JLabel developerLabel;
+
+ /**
+ * Creates new frame.
+ */
+ public AboutDialogMartinSchmitz(Frame owner, String applName) {
+ super(owner, applName);
+ }
+
+ /**
+ * Extends the info dialog by Martin Schmitz company logo.
+ */
+ @Override
+ public void init() {
+ super.init();
+
+ this.companyLabel = new JLabel(SwingUtil.ICON_MARTIN_SCHMITZ);
+ companyLabel.setHorizontalAlignment(JLabel.LEFT);
+
+ this.developerLabel = new JLabel("created by: ");
+ developerLabel.setFont( applNameLabel.getFont().deriveFont(Font.ITALIC).deriveFont(16f) );
+ developerLabel.setHorizontalAlignment(JLabel.RIGHT);
+
+ headerPanel.add(developerLabel,"split 2, growx");
+ headerPanel.add(companyLabel,"growx");
+
+ getContentPane().add(headerPanel,BorderLayout.NORTH);
+ SwingUtil.setPreferredWidth(this, 500);
+ SwingUtil.setPreferredHeight(this, 350);
+ pack();
+ }
+
+}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/InfoDialog.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/InfoDialog.java 2013-06-09 15:06:36 UTC (rev 2336)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/InfoDialog.java 2013-06-09 17:14:36 UTC (rev 2337)
@@ -61,6 +61,7 @@
*/
public InfoDialog(Frame owner) {
super(owner, SwingUtil.R("InfoDialog.Title"),true);
+ updateInformation();
}
@@ -73,7 +74,7 @@
// Remove cancel button
buttonPanel.remove( cancelButton );
- infoTableModel = new InfoTableModel();
+ infoTableModel = createTableModel();
infoTable = new SortableJTable( infoTableModel );
// infoTable.setTableHeader(null);
infoTable.getColumnModel().getColumn(0).setPreferredWidth(100);
@@ -131,6 +132,9 @@
* @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
*/
public static class InfoTableModel extends AbstractTableModel {
+ /** Holds the number of rows defined by this class. Set in {@link #initRows()}. */
+ protected int BASE_ROW_COUNT = 0;
+
/** Column headers */
protected List<String> COL_NAMES;
/** Row titles */
@@ -154,6 +158,9 @@
/** Metadaten der JDBC-Verbindung. */
private DatabaseMetaData connMetaData = null;
+ /**
+ * Creates new table model.
+ */
public InfoTableModel() {
super();
initRows();
@@ -172,6 +179,7 @@
ROW_NAMES.add(SwingUtil.R("InfoDialog.JVM.Memory"));
ROW_NAMES.add(SwingUtil.R("InfoDialog.Timezone"));
ROW_NAMES.add(SwingUtil.R("InfoDialog.Contact"));
+ BASE_ROW_COUNT = ROW_NAMES.size();
}
/**
@@ -266,26 +274,25 @@
public Object getValueAt(int row, int col) {
if ( col == 0 )
return ROW_NAMES.get(row);
- else
- try {
- switch( row ) {
- case 0: return versionNo;
- case 1: return versionDate;
- case 2: return System.getProperty("java.version");
- case 3: long freeMem = Runtime.getRuntime().freeMemory();
- long totMem = Runtime.getRuntime().totalMemory();
- long usedMem = totMem - freeMem;
- double freeMemPerc = freeMem * 100.0 / totMem;
- return MEM_FORMAT.format( totMem*1.0/LangUtil.MB_BYTES ) + " / " +
- MEM_FORMAT.format( usedMem*1.0/LangUtil.MB_BYTES ) + " / " +
- MEM_FORMAT.format( freeMem*1.0/LangUtil.MB_BYTES ) + " MB (" +
- MEM_FORMAT.format( freeMemPerc ) + "% "+SwingUtil.R("InfoDialog.JVM.Memory.available")+")";
- case 4: return LangUtil.getTimezoneDescription(TimeZone.LONG);
- case 5: return contact;
- }
- } catch (Exception err) {
- return "<"+SwingUtil.R("Error")+": "+err.getMessage()+">";
+ try {
+ switch( row ) {
+ case 0: return versionNo;
+ case 1: return versionDate;
+ case 2: return System.getProperty("java.version");
+ case 3: long freeMem = Runtime.getRuntime().freeMemory();
+ long totMem = Runtime.getRuntime().totalMemory();
+ long usedMem = totMem - freeMem;
+ double freeMemPerc = freeMem * 100.0 / totMem;
+ return MEM_FORMAT.format( totMem*1.0/LangUtil.MB_BYTES ) + " / " +
+ MEM_FORMAT.format( usedMem*1.0/LangUtil.MB_BYTES ) + " / " +
+ MEM_FORMAT.format( freeMem*1.0/LangUtil.MB_BYTES ) + " MB (" +
+ MEM_FORMAT.format( freeMemPerc ) + "% "+SwingUtil.R("InfoDialog.JVM.Memory.available")+")";
+ case 4: return LangUtil.getTimezoneDescription(TimeZone.LONG);
+ case 5: return contact;
}
+ } catch (Exception err) {
+ return "<"+SwingUtil.R("Error")+": "+err.getMessage()+">";
+ }
return null;
}
}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java 2013-06-09 15:06:36 UTC (rev 2336)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java 2013-06-09 17:14:36 UTC (rev 2337)
@@ -287,7 +287,9 @@
/** Icon of default checkbox with state disabled and unchecked */
public static final ImageIcon ICON_CHECKBOX_DISABLED_UNCHECKED = SwingUtil.createImageIconFromResourcePath(SwingUtil.class, "resource/icons/checkbox/disabled_unchecked.png", null);
-
+ /** Developer icon of Martin Schmitz */
+ public static final ImageIcon ICON_MARTIN_SCHMITZ = SwingUtil.createImageIconFromResourcePath(SwingUtil.class, "resource/images/martin-schmitz.png", null);
+
/**
* Modus "Innen".
*
Added: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/images/martin-schmitz.png
===================================================================
(Binary files differ)
Property changes on: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/images/martin-schmitz.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
More information about the Schmitzm-commits
mailing list