[Schmitzm-commits] r461 - in branches/1.0-gt2-2.6/src: schmitzm/jfree/chart/style schmitzm/jfree/feature/style skrueger/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 13 11:22:27 CEST 2009


Author: alfonx
Date: 2009-10-13 11:22:23 +0200 (Tue, 13 Oct 2009)
New Revision: 461

Added:
   branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java
Modified:
   branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ScatterChartStyle.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java
   branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogAdapter.java
   branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java
Log:
* New class AtlasDialog is a standardized JDialog that reacts to ESC and disposes on WindowClose-Event.
* Regression BugFix: ChartDialog now correctly kills selection after close.
* AS-Bugfix: Class numbers are now correctly updated. No more black histogram images.

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ScatterChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ScatterChartStyle.java	2009-10-12 16:56:54 UTC (rev 460)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ScatterChartStyle.java	2009-10-13 09:22:23 UTC (rev 461)
@@ -108,6 +108,7 @@
    */
   @Override
   public JFreeChart applyToDataset(Dataset dataset) {
+	  
     if ( !(dataset instanceof XYDataset) )
       throw new UnsupportedOperationException("ScatterChartStyle can only be applied to XYDataset: "+LangUtil.getSimpleClassName(dataset));
 

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java	2009-10-12 16:56:54 UTC (rev 460)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java	2009-10-13 09:22:23 UTC (rev 461)
@@ -34,6 +34,8 @@
 import org.jfree.data.category.CategoryDataset;
 import org.jfree.data.general.Dataset;
 import org.jfree.data.xy.XYDataset;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
 
 import schmitzm.jfree.chart.style.ScatterChartStyle;
 
@@ -218,7 +220,7 @@
    * {@link FeatureCollection}) and calls {@link #applyToDataset(Dataset)}.
    */
   @Override
-  public JFreeChart applyToFeatureCollection(FeatureCollection fc) {
+  public JFreeChart applyToFeatureCollection(FeatureCollection<SimpleFeatureType, SimpleFeature> fc) {
     Dataset dataset = FeatureChartUtil.createDataset(fc,this);
     return applyToDataset(dataset);
   }

Added: branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java	2009-10-12 16:56:54 UTC (rev 460)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java	2009-10-13 09:22:23 UTC (rev 461)
@@ -0,0 +1,74 @@
+package skrueger.swing;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+
+import schmitzm.swing.SwingUtil;
+
+public class AtlasDialog extends JDialog {
+
+	public AtlasDialog(final Component parentWindow, String title) {
+		super(SwingUtil.getParentWindow(parentWindow), title);
+		initDialog();
+	}
+
+	public AtlasDialog(final Component parentWindow) {
+		this(parentWindow, null);
+	}
+
+	private void initDialog() {
+
+		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
+
+		addWindowListener(new WindowAdapter() {
+
+			@Override
+			public void windowClosing(WindowEvent e) {
+				close();
+			}
+
+		});
+	}
+
+	/**
+	 * Allows to close the {@link JDialog} from "outside". {@link AtlasDialog}
+	 * is not implementing {@link Cancellable}, so the dialog is just disposed.
+	 */
+	public boolean close() {
+		dispose();
+		return true;
+	}
+
+	/**
+	 * Since the registerKeyboardAction() method is part of the JComponent class
+	 * definition, you must define the Escape keystroke and register the
+	 * keyboard action with a JComponent, not with a JDialog. The JRootPane for
+	 * the JDialog serves as an excellent choice to associate the registration,
+	 * as this will always be visible. If you override the protected
+	 * createRootPane() method of JDialog, you can return your custom JRootPane
+	 * with the keystroke enabled:
+	 */
+	@Override
+	protected JRootPane createRootPane() {
+		final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
+		final JRootPane rootPane = new JRootPane();
+		rootPane.registerKeyboardAction(new ActionListener() {
+
+			public void actionPerformed(final ActionEvent e) {
+				close();
+			}
+
+		}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
+
+		return rootPane;
+	}
+}


Property changes on: branches/1.0-gt2-2.6/src/skrueger/swing/AtlasDialog.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Modified: branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogAdapter.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogAdapter.java	2009-10-12 16:56:54 UTC (rev 460)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogAdapter.java	2009-10-13 09:22:23 UTC (rev 461)
@@ -2,20 +2,10 @@
 
 import java.awt.Component;
 import java.awt.Dialog;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
 
-import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.JOptionPane;
-import javax.swing.JRootPane;
-import javax.swing.KeyStroke;
 
-import schmitzm.swing.SwingUtil;
-
 /**
  * An abstract {@link JDialog} that implements a basic structure of how
  * cancellable {@link JDialog}s work. The {@link JDialog} is designed to work on
@@ -24,39 +14,25 @@
  * 
  * Pressing ESC or clicking the "Close X" results in asking the user whether to Save/Cancel/Abort .  
  */
-public abstract class CancellableDialogAdapter extends JDialog implements
+public abstract class CancellableDialogAdapter extends AtlasDialog implements
 		CancellableDialog {
 
+	/** Has this dialog been canceled ?**/
 	protected boolean cancelled = false;
+	
+	public CancellableDialogAdapter(Component parentWindow) {
+		super(parentWindow);
+	}
 
+	public CancellableDialogAdapter(Component parentWindow, String title) {
+		super(parentWindow, title);
+	}
+
 	@Override
 	public boolean isCancelled() {
 		return cancelled;
 	}
 
-	public CancellableDialogAdapter(final Component parentWindow, String title) {
-		super(SwingUtil.getParentWindow(parentWindow), title);
-		initDialog();
-	}
-
-	public CancellableDialogAdapter(final Component parentWindow) {
-		this(parentWindow, null);
-	}
-
-	private void initDialog() {
-
-		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
-
-		addWindowListener(new WindowAdapter() {
-
-			@Override
-			public void windowClosing(WindowEvent e) {
-				close();
-			}
-
-		});
-	}
-
 	/**
 	 * Allows to close the {@link JDialog} from "outside". The user will be
 	 * asked and she may cancel the close process.
@@ -123,29 +99,5 @@
 	}
 	
 
-	/**
-	 * Since the registerKeyboardAction() method is part of the JComponent class
-	 * definition, you must define the Escape keystroke and register the
-	 * keyboard action with a JComponent, not with a JDialog. The JRootPane for
-	 * the JDialog serves as an excellent choice to associate the registration,
-	 * as this will always be visible. If you override the protected
-	 * createRootPane() method of JDialog, you can return your custom JRootPane
-	 * with the keystroke enabled:
-	 */
-	@Override
-	protected JRootPane createRootPane() {
-		final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
-		final JRootPane rootPane = new JRootPane();
-		rootPane.registerKeyboardAction(new ActionListener() {
 
-			public void actionPerformed(final ActionEvent e) {
-				close();
-			}
-
-		}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
-
-		return rootPane;
-	}
-
-
 }

Modified: branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java	2009-10-12 16:56:54 UTC (rev 460)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java	2009-10-13 09:22:23 UTC (rev 461)
@@ -11,7 +11,7 @@
 
 import org.apache.log4j.Logger;
 
-public abstract class DialogManager<KEY, DIALOG extends JDialog> {
+public abstract class DialogManager<KEY, DIALOG extends AtlasDialog> {
 	final static private Logger LOGGER = Logger.getLogger(DialogManager.class);
 
 	public abstract class FactoryInterface {
@@ -116,6 +116,7 @@
 			dialog.addWindowListener(new WindowAdapter() {
 				@Override
 				public void windowClosed(final WindowEvent e) {
+					dialog.setVisible(false);
 					factory.beforeDispose(dialog);
 					disposeInstanceFor(key);
 				}



More information about the Schmitzm-commits mailing list