[Schmitzm-commits] r1277 - in trunk: src/org/geopublishing/atlasViewer/swing src/schmitzm/lang src/schmitzm/lang/resource/locales src/schmitzm/swing src/schmitzm/swing/resource/locales src_junit/skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 16 14:43:51 CET 2010


Author: alfonx
Date: 2010-11-16 14:43:51 +0100 (Tue, 16 Nov 2010)
New Revision: 1277

Added:
   trunk/src_junit/skrueger/geotools/LegendIconFeatureRendererTest.java
Modified:
   trunk/src/org/geopublishing/atlasViewer/swing/AtlasFeatureLayerFilterDialog.java
   trunk/src/schmitzm/lang/ResourceProviderOperator.java
   trunk/src/schmitzm/lang/resource/locales/LangResourceBundle.properties
   trunk/src/schmitzm/swing/SwingUtil.java
   trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
Log:


Modified: trunk/src/org/geopublishing/atlasViewer/swing/AtlasFeatureLayerFilterDialog.java
===================================================================
--- trunk/src/org/geopublishing/atlasViewer/swing/AtlasFeatureLayerFilterDialog.java	2010-11-16 11:51:41 UTC (rev 1276)
+++ trunk/src/org/geopublishing/atlasViewer/swing/AtlasFeatureLayerFilterDialog.java	2010-11-16 13:43:51 UTC (rev 1277)
@@ -64,6 +64,8 @@
 	 */
 	public static final FilterParser FILTER_PARSER = new CQLFilterParser();
 
+	private static final int WARN_CELLS = 15000;
+
 	static Logger LOGGER = Logger
 			.getLogger(AtlasFeatureLayerFilterDialog.class);
 
@@ -99,6 +101,20 @@
 		super(parent, mapPane, mapLayer, false, false);
 		this.attrMetaDataMap = styledFeatures.getAttributeMetaDataMap();
 		this.styedFeatures = styledFeatures;
+
+		// make a check on howmany feateurs we have an print a warning if too
+		// many
+		int numCells = styledFeatures.getFeatureCollectionFiltered().size()
+				* styledFeatures.getAttributeMetaDataMap()
+						.sortedValuesVisibleOnly().size();
+		if (numCells > WARN_CELLS) {
+			if (SwingUtil.askYesNo(parent, SwingUtil.R(
+					"AttributeTable.dialog.warnToManyCells", numCells)) == false) {
+				dispose();
+				return;
+			}
+		}
+
 		if (!styledFeatures.getFilter().equals(Filter.INCLUDE)) {
 			setFilterRule(CQL.toCQL(styledFeatures.getFilter()));
 		}

Modified: trunk/src/schmitzm/lang/ResourceProviderOperator.java
===================================================================
--- trunk/src/schmitzm/lang/ResourceProviderOperator.java	2010-11-16 11:51:41 UTC (rev 1276)
+++ trunk/src/schmitzm/lang/ResourceProviderOperator.java	2010-11-16 13:43:51 UTC (rev 1277)
@@ -43,9 +43,7 @@
 import java.util.Properties;
 import java.util.Set;
 
-import org.apache.commons.cli.BasicParser;
 import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.GnuParser;
 import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;

Modified: trunk/src/schmitzm/lang/resource/locales/LangResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/lang/resource/locales/LangResourceBundle.properties	2010-11-16 11:51:41 UTC (rev 1276)
+++ trunk/src/schmitzm/lang/resource/locales/LangResourceBundle.properties	2010-11-16 13:43:51 UTC (rev 1277)
@@ -1,56 +1,56 @@
-##########
-#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
-OperationTree.Integer=Integer
-OperationTree.Number=Number
-OperationTree.err.ParseErrorMess=Parse-Error at "${0}": ${1}
-OperationTree.err.UnexpectedEOR=Unexpected end of rule!
-OperationTree.err.UnexpectedError=Unexpected error!
-OperationTree.err.TokenNotExpected=${0} not expected
-OperationTree.err.MoreParamsExpected=${0} more function parameters expected. Bracket can not close!
-OperationTree.err.UnexpectedBracket=Bracket ${0} can not close ${1}
-OperationTree.err.BracketsNotClosed=Bracket(s) not closed: ${0}
-OperationTree.err.IllegalOperator=Illegal operator ${0}
-OperationTree.err.IllegalOperatorSyntax=Illegal ${0} syntax '${1}'
-OperationTree.err.ParamSepExpected=Parameter-Separator expected
-OperationTree.err.IllegalCharacter=Illegal character '${0}' (${1} expected)
-
-OperationTree.err.UnknownNode=Unknown operation tree node: ${0}
-OperationTree.err.UnknownOperator=Unknown operator: ${0}
-OperationTree.err.UnknownAliasOperator=Unknown alias operator: ${0}
-OperationTree.err.LessParams1=At least ${0} function parameters expected: ${1}(..)
-OperationTree.err.LessParams2=${0} function parameters expected: ${1}(..)
-OperationTree.err.IllegalParam=Illegal parameter ${0} for ${1}(..): ${2} expected
-
-ResourceProviderOperator.cli.info.help=Shows this help messages.
-ResourceProviderOperator.cli.info.operation=Operation which is processed.\nPossible values: ${0}\nDefault: ${1}
-ResourceProviderOperator.cli.info.bundles=Semicolon-separated list of the resource bundles which are processed.
-ResourceProviderOperator.cli.info.rootfolder=Root folder the resource bundle files can be found relatively to.\nDefault: ${0} (as it is the maven default)
-ResourceProviderOperator.cli.info.indicator=Prefix the bundle keys, which should be processed, are marked with.\nDefault: ${0}
-ResourceProviderOperator.cli.info.filein=Property file the configuration is taken from (command line parameters have higher priority!).\nDefault: ${0}
-ResourceProviderOperator.cli.info.fileout=Property file the configuration is stored in.\nDefault: ${0}
+##########
+#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
+OperationTree.Integer=Integer
+OperationTree.Number=Number
+OperationTree.err.ParseErrorMess=Parse-Error at "${0}": ${1}
+OperationTree.err.UnexpectedEOR=Unexpected end of rule!
+OperationTree.err.UnexpectedError=Unexpected error!
+OperationTree.err.TokenNotExpected=${0} not expected
+OperationTree.err.MoreParamsExpected=${0} more function parameters expected. Bracket can not close!
+OperationTree.err.UnexpectedBracket=Bracket ${0} can not close ${1}
+OperationTree.err.BracketsNotClosed=Bracket(s) not closed: ${0}
+OperationTree.err.IllegalOperator=Illegal operator ${0}
+OperationTree.err.IllegalOperatorSyntax=Illegal ${0} syntax '${1}'
+OperationTree.err.ParamSepExpected=Parameter-Separator expected
+OperationTree.err.IllegalCharacter=Illegal character '${0}' (${1} expected)
+
+OperationTree.err.UnknownNode=Unknown operation tree node: ${0}
+OperationTree.err.UnknownOperator=Unknown operator: ${0}
+OperationTree.err.UnknownAliasOperator=Unknown alias operator: ${0}
+OperationTree.err.LessParams1=At least ${0} function parameters expected: ${1}(..)
+OperationTree.err.LessParams2=${0} function parameters expected: ${1}(..)
+OperationTree.err.IllegalParam=Illegal parameter ${0} for ${1}(..): ${2} expected
+
+ResourceProviderOperator.cli.info.help=Shows this help messages.
+ResourceProviderOperator.cli.info.operation=Operation which is processed.\nPossible values: ${0}\nDefault: ${1}
+ResourceProviderOperator.cli.info.bundles=Semicolon-separated list of the resource bundles which are processed.
+ResourceProviderOperator.cli.info.rootfolder=Root folder the resource bundle files can be found relatively to.\nDefault: ${0} (as it is the maven default)
+ResourceProviderOperator.cli.info.indicator=Prefix the bundle keys, which should be processed, are marked with.\nDefault: ${0}
+ResourceProviderOperator.cli.info.filein=Property file the configuration is taken from (command line parameters have higher priority!).\nDefault: ${0}
+ResourceProviderOperator.cli.info.fileout=Property file the configuration is stored in.\nDefault: ${0}

Modified: trunk/src/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/src/schmitzm/swing/SwingUtil.java	2010-11-16 11:51:41 UTC (rev 1276)
+++ trunk/src/schmitzm/swing/SwingUtil.java	2010-11-16 13:43:51 UTC (rev 1277)
@@ -50,6 +50,7 @@
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -57,6 +58,7 @@
 import java.util.Locale;
 import java.util.Random;
 import java.util.StringTokenizer;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.imageio.ImageIO;
 import javax.swing.AbstractAction;
@@ -1536,4 +1538,42 @@
 
 	}
 
+	/**
+	 * Convenience method to ask a simple Yes/No question. It can be started
+	 * from any Thread and will always show on the EDT.
+	 */
+	public static boolean askYesNo(final Component owner, final String question) {
+
+		if (!SwingUtilities.isEventDispatchThread()) {
+			try {
+				final AtomicBoolean r = new AtomicBoolean();
+				SwingUtilities.invokeAndWait(new Runnable() {
+
+					@Override
+					public void run() {
+						final int result = JOptionPane.showConfirmDialog(owner,
+								question, R("GeneralQuestionDialogTitle"),
+								JOptionPane.YES_NO_OPTION,
+								JOptionPane.QUESTION_MESSAGE, null);
+						r.set(result == JOptionPane.YES_OPTION);
+					}
+				});
+
+				return r.get();
+			} catch (InterruptedException e) {
+				LOGGER.error(e);
+			} catch (InvocationTargetException e) {
+				LOGGER.error(e);
+			}
+			return false;
+		} else {
+			int result = JOptionPane.showConfirmDialog(owner, question,
+					R("GeneralQuestionDialogTitle"), JOptionPane.YES_NO_OPTION,
+					JOptionPane.QUESTION_MESSAGE, null);
+
+			return result == JOptionPane.YES_OPTION;
+		}
+
+	}
+
 }

Modified: trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2010-11-16 11:51:41 UTC (rev 1276)
+++ trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2010-11-16 13:43:51 UTC (rev 1277)
@@ -257,3 +257,7 @@
 AtlasStatusDialog.jnlp.upgrading=Upgrading ${0} (${1}%)
 AtlasStatusDialog.jnlp.validating=Validating ${0} (${1}%)
 AtlasStatusDialog.jnlp.downloadFailed=Download failed: ${0} ${1}
+
+
+GeneralQuestionDialogTitle=Question
+AttributeTable.dialog.warnToManyCells=<html>The table will contain ${0} cells and consume a lot of memory. The atlas might get slow.<br/>Are you sure you want to open the attribute table?</html>
\ No newline at end of file

Added: trunk/src_junit/skrueger/geotools/LegendIconFeatureRendererTest.java
===================================================================
--- trunk/src_junit/skrueger/geotools/LegendIconFeatureRendererTest.java	2010-11-16 11:51:41 UTC (rev 1276)
+++ trunk/src_junit/skrueger/geotools/LegendIconFeatureRendererTest.java	2010-11-16 13:43:51 UTC (rev 1277)
@@ -0,0 +1,42 @@
+package skrueger.geotools;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+import org.geotools.styling.Rule;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import schmitzm.geotools.styling.StylingUtil;
+import schmitzm.swing.TestingUtil;
+
+public class LegendIconFeatureRendererTest {
+
+	@Before
+	public void setUp() throws Exception {
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	@Test
+	public void testCreateImageForRule() throws IOException {
+		LegendIconFeatureRenderer r = LegendIconFeatureRenderer.getInstance();
+		Rule rule = StylingUtil.STYLE_BUILDER
+				.createRule(StylingUtil.STYLE_BUILDER.createPolygonSymbolizer());
+
+		StyledFS polyAs = TestingUtil.TestDatasetsVector.countryShp
+				.getStyledFS();
+
+		BufferedImage createImageForRule = r.createImageForRule(rule, polyAs
+				.getFeatureSource().getSchema(), new Dimension(50, 50));
+
+		assertNotNull(createImageForRule);
+	}
+
+}


Property changes on: trunk/src_junit/skrueger/geotools/LegendIconFeatureRendererTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the Schmitzm-commits mailing list