[Schmitzm-commits] r292 - in trunk/src: schmitzm/jfree/chart/style schmitzm/jfree/feature schmitzm/jfree/resource/locales skrueger/i8n skrueger/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Aug 5 14:34:16 CEST 2009


Author: alfonx
Date: 2009-08-05 14:34:15 +0200 (Wed, 05 Aug 2009)
New Revision: 292

Modified:
   trunk/src/schmitzm/jfree/chart/style/ChartType.java
   trunk/src/schmitzm/jfree/feature/FeatureCategoryDatasetSelectionModel.java
   trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle.properties
   trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle_de.properties
   trunk/src/skrueger/i8n/Translation.java
   trunk/src/skrueger/swing/TranslationEditJPanel.java
   trunk/src/skrueger/swing/TranslationJTextField.java
Log:
* Big Code Cleanup in Atlas-Framework
* More options in DesignAtlasChart

Modified: trunk/src/schmitzm/jfree/chart/style/ChartType.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartType.java	2009-08-05 07:01:39 UTC (rev 291)
+++ trunk/src/schmitzm/jfree/chart/style/ChartType.java	2009-08-05 12:34:15 UTC (rev 292)
@@ -171,4 +171,17 @@
 		}
 	}
 
+	/**
+	 * Returns a localized title for the objects drawn in this chart. For a
+	 * bar-chart it would be "bar", for a line-chart it would be "line"
+	 */
+	public String getObjectName() {
+		final String resource = JFreeChartUtil.R(getClass().getSimpleName()
+				+ "_" + toString() + ".Object.Title");
+		if (resource == null
+				|| resource.equals(ResourceProvider.MISSING_RESOURCE_STRING))
+			return getTitle();
+		return resource;
+	}
+
 };

Modified: trunk/src/schmitzm/jfree/feature/FeatureCategoryDatasetSelectionModel.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/FeatureCategoryDatasetSelectionModel.java	2009-08-05 07:01:39 UTC (rev 291)
+++ trunk/src/schmitzm/jfree/feature/FeatureCategoryDatasetSelectionModel.java	2009-08-05 12:34:15 UTC (rev 292)
@@ -36,7 +36,6 @@
 import org.jfree.data.general.DatasetGroup;
 
 import schmitzm.jfree.chart.selection.CategoryDatasetSelectionModel;
-import schmitzm.jfree.chart.selection.SeriesDatasetSelectionModel;
 import schmitzm.lang.LangUtil;
 
 /**

Modified: trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle.properties	2009-08-05 07:01:39 UTC (rev 291)
+++ trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle.properties	2009-08-05 12:34:15 UTC (rev 292)
@@ -27,32 +27,6 @@
 #    Martin O. J. Schmitz - initial API and implementation
 #    Stefan A. Krüger - additional utility classes
 ##########
-#This file is part of the SCHMITZM library - a collection of utility 
-#classes based on Java 1.6, focussing (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. Krüger - additional utility classes
-##########
 # --------------------------------------------------------------------------
 # ------ Default Translations (english) for JFreeChart GUI components ------
 # ------ in Package schmitz.jfree                                     ------
@@ -64,11 +38,15 @@
 diagram.bars=bars
 diagram.areas=areas
 
-ChartType_BAR.Desc=Its a great thing to have a few barcharts at hand.
 ChartType_BAR.Title=barchart
-
+ChartType_BAR.Object.Title=bars
 ChartType_SCATTER.Title=scatterplot
+ChartType_SCATTER.Object.Title=points
 ChartType_PIE.Title=piechart
+ChartType_PIE.Object.Title=part
 ChartType_AREA.Title=areachart
+ChartType_AREA.Object.Title=area
 ChartType_LINE.Title=linechart
+ChartType_LINE.Object.Title=line
 ChartType_POINT.Title=pointchart
+ChartType_POINT.Object.Title=points

Modified: trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle_de.properties
===================================================================
--- trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle_de.properties	2009-08-05 07:01:39 UTC (rev 291)
+++ trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle_de.properties	2009-08-05 12:34:15 UTC (rev 292)
@@ -27,32 +27,6 @@
 #    Martin O. J. Schmitz - initial API and implementation
 #    Stefan A. Krüger - additional utility classes
 ##########
-#This file is part of the SCHMITZM library - a collection of utility 
-#classes based on Java 1.6, focussing (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. Kr\u00fcger - additional utility classes
-##########
 # ---------------------------------------------------------------
 # ------ German Translations for JFreeChart GUI components ------
 # ------ in Package schmitz.jfree                          ------
@@ -64,11 +38,18 @@
 diagram.bars=Balken
 diagram.areas=Fl\u00E4chen
 
-ChartType_BAR.Desc=<html>Ein Balkendiagram ist eine tolle Sache.</html>
 ChartType_BAR.Title=Balkendiagramm
-
+ChartType_BAR.Object.Title=Balken
 ChartType_SCATTER.Title=Streudiagramm
+ChartType_SCATTER.Object.Title=Punkte
 ChartType_PIE.Title=Kreisdiagramm
+ChartType_PIE.Object.Title=Teil
 ChartType_AREA.Title=Fl\u00E4chendiagramm
+ChartType_AREA.Object.Title=Fl\u00E4chen
 ChartType_LINE.Title=Liniendiagramm
+ChartType_LINE.Object.Title=Linie
 ChartType_POINT.Title=Punktdiagramm
+ChartType_POINT.Object.Title=Punkte
+
+
+

Modified: trunk/src/skrueger/i8n/Translation.java
===================================================================
--- trunk/src/skrueger/i8n/Translation.java	2009-08-05 07:01:39 UTC (rev 291)
+++ trunk/src/skrueger/i8n/Translation.java	2009-08-05 12:34:15 UTC (rev 292)
@@ -29,12 +29,15 @@
  ******************************************************************************/
 package skrueger.i8n;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
+import java.util.Random;
 
 import javax.swing.JComponent;
 
@@ -67,6 +70,8 @@
 		setActiveLang(locale.getLanguage());
 	}
 
+	private List<ActionListener> actionListeners = new ArrayList<ActionListener>();
+
 	@Override
 	/*
 	 * @comment To make a copy of a translation see methods toOneLine() and
@@ -302,4 +307,28 @@
 		}
 	}
 
+	public void addTranslationChangeListener(ActionListener actionListener) {
+		actionListeners.add(actionListener);
+	}
+	
+	public boolean removeTranslationChangeListener(ActionListener actionListener) {
+		return actionListeners.remove(actionListener);
+	}
+
+	public void fireTranslationChangedEvents() {
+		ActionEvent ae = new ActionEvent(this, new Random().nextInt(),  "");
+		
+		for (ActionListener al : actionListeners) {
+			al.actionPerformed( ae);
+		}
+	}
+	
+	@Override
+	public String put(String key, String value) {
+		String result = super.put(key, value);
+		fireTranslationChangedEvents();
+		return result;
+	}
+	
+	
 }

Modified: trunk/src/skrueger/swing/TranslationEditJPanel.java
===================================================================
--- trunk/src/skrueger/swing/TranslationEditJPanel.java	2009-08-05 07:01:39 UTC (rev 291)
+++ trunk/src/skrueger/swing/TranslationEditJPanel.java	2009-08-05 12:34:15 UTC (rev 292)
@@ -33,11 +33,11 @@
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Random;
 import java.util.Set;
+import java.util.WeakHashMap;
 
 import javax.swing.BorderFactory;
 import javax.swing.JLabel;
@@ -61,7 +61,7 @@
  * 
  * @author Stefan Alfons Krüger
  */
-public class TranslationEditJPanel extends JPanel  {
+public class TranslationEditJPanel extends JPanel {
 	static final protected Logger LOGGER = Logger
 			.getLogger(TranslationEditJPanel.class);
 
@@ -74,6 +74,8 @@
 	 */
 	private Set<JTextField> langTextFields = new HashSet<JTextField>();
 
+	private WeakHashMap<ActionListener, ActionListener> actionListeners = new WeakHashMap<ActionListener, ActionListener>();
+
 	/**
 	 * Creates a {@link JPanel} that asks the user for the translation of a
 	 * String in several languages
@@ -125,8 +127,8 @@
 				langDesc.setLabelFor(langTextField);
 				translationGrid.add(langDesc);
 				translationGrid.add(langTextField);
-				
-				langTextFields .add(langTextField);
+
+				langTextFields.add(langTextField);
 			}
 
 			// Lay out the panel.
@@ -147,30 +149,25 @@
 		return trans;
 	}
 
-	public void addActionListener(final ActionListener actionListener) {
-		for (final JTextField langTextField : langTextFields){
-			langTextField.addKeyListener( new KeyListener(){
+	public void addTranslationChangeListener(final ActionListener al) {
+		final ActionListener actionListener = new ActionListener() {
 
-				@Override
-				public void keyPressed(KeyEvent e) {
-				}
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				al.actionPerformed(new ActionEvent(TranslationEditJPanel.this,
+						new Random().nextInt(), ""));
+			}
 
-				@Override
-				public void keyReleased(KeyEvent e) {
-				}
-
-				@Override
-				public void keyTyped(KeyEvent e) {
-					actionListener.actionPerformed(new ActionEvent(TranslationEditJPanel.this, 0, ""));
-				}
-				
-			});
-		}
+		};
+		actionListeners.put(al, actionListener);
+		getTranslation().addTranslationChangeListener(actionListener);
 	}
 
-	public void removeActionListener(ActionListener actionListener) {
-		for (JTextField langTextField : langTextFields){
-			langTextField.removeActionListener(actionListener);
+	public void removeTranslationChangeListener(ActionListener al) {
+		if (actionListeners.get(al) != null) {
+			ActionListener actionListener = actionListeners.get(al);
+			getTranslation().removeTranslationChangeListener(actionListener);
+			actionListeners.remove(actionListener);
 		}
 	}
 

Modified: trunk/src/skrueger/swing/TranslationJTextField.java
===================================================================
--- trunk/src/skrueger/swing/TranslationJTextField.java	2009-08-05 07:01:39 UTC (rev 291)
+++ trunk/src/skrueger/swing/TranslationJTextField.java	2009-08-05 12:34:15 UTC (rev 292)
@@ -47,36 +47,39 @@
  * 
  */
 public class TranslationJTextField extends JTextField {
-	static final Logger log = Logger.getLogger(TranslationJTextField.class);
-    int wasValid = 99; // 0 = false, 1 = true, 99 = undefined 
+	static final protected Logger LOGGER = Logger
+			.getLogger(TranslationJTextField.class);
+	int wasValid = 99; // 0 = false, 1 = true, 99 = undefined
 	private String langCode;
 	private Translation trans;
-	
+
 	/**
-	 * This RED indicates a missing translation 
+	 * This RED indicates a missing translation
 	 * 
 	 * TODO to properties ;-)
 	 */
-	final static public Color emptyColor = new Color(240,190,190);
+	final static public Color emptyColor = new Color(240, 190, 190);
 
 	/**
 	 * Creates a new {@link TranslationJTextField}
-	 * @param trans 
+	 * 
+	 * @param trans
 	 * @param langCode
 	 */
 	public TranslationJTextField(Translation trans, String langCode) {
 		super(trans.get(langCode));
 		this.trans = trans;
 		this.langCode = langCode;
-		
-		/** SK: Change  26.Mai 
-		 * Use the default for an empty field **/
+
+		/**
+		 * SK: Change 26.Mai Use the default for an empty field
+		 **/
 		if (trans.get(langCode) == null) {
-			String defaultTrans = trans.get( Translation.DEFAULT_KEY);
+			String defaultTrans = trans.get(Translation.DEFAULT_KEY);
 			trans.put(langCode, defaultTrans);
-			setText( defaultTrans );
+			setText(defaultTrans);
 		}
-		
+
 		checkValid();
 
 		// This Listener colors the JTextfiel red if it is empty
@@ -102,27 +105,22 @@
 	}
 
 	/**
-	 * If the getText == "". then set Background color red.
-	 * This change is only done if the state really changed.
-	 * And directly store the change in the {@link Translation} object
+	 * If the getText().equals("") sets background color to red. The method also
+	 * stored the changed string into the {@link Translation} object.
 	 */
 	protected void checkValid() {
-		
+
 		String trimmedText = getText().trim();
-		
+
 		if (trimmedText.equals("")) {
 			// Not valid
-			if (wasValid != 0) {		
-				setBackground( emptyColor );
+			if (wasValid != 0) {
+				setBackground(emptyColor);
 				repaint();
 				wasValid = 0;
 			}
-			
-			// TODO testen! hat sich das bewährt?
-			// Directly store the change in the Translation Object
-			// trans.remove( langCode );
-			trans.put( langCode, trimmedText );
-			
+
+
 		} else {
 			// valid
 			if (wasValid != 1) {
@@ -131,9 +129,9 @@
 				wasValid = 1;
 			}
 			// Directly store the change in the Translation Object
-			trans.put( langCode, trimmedText );
 		}
-		
-	}
 
+//		LOGGER.debug("putting '"+trimmedText+"' into the translation");
+		trans.put(langCode, trimmedText);
+	}
 }



More information about the Schmitzm-commits mailing list