[Schmitzm-commits] r735 - in trunk/src/schmitzm: jfree/feature/style jfree/resource/locales lang

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 1 18:15:27 CET 2010


Author: mojays
Date: 2010-03-01 18:15:25 +0100 (Mon, 01 Mar 2010)
New Revision: 735

Modified:
   trunk/src/schmitzm/jfree/feature/style/FeatureChartAxisStyle.java
   trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle.properties
   trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle_de.properties
   trunk/src/schmitzm/lang/LangUtil.java
Log:
Normalization added to axis label

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartAxisStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartAxisStyle.java	2010-03-01 16:38:12 UTC (rev 734)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartAxisStyle.java	2010-03-01 17:15:25 UTC (rev 735)
@@ -37,6 +37,7 @@
 import org.jfree.chart.axis.DateAxis;
 import org.jfree.chart.axis.NumberAxis;
 
+import schmitzm.jfree.JFreeChartUtil;
 import schmitzm.jfree.chart.style.ChartAxisStyle;
 import schmitzm.lang.LangUtil;
 import skrueger.i8n.Translation;
@@ -117,31 +118,27 @@
       return;
     }
 
-    // Determine the aggregation title to display with unit
-    String funcTitle = null;
+    // Determine the unit, aggregation function title and normalization
+    // to display with the axis title
+    String unitStr = isUnitVisible() ? getUnitString() : null;
+    String funcStr = null;
+    String normStr = null; 
     for (int i=0; i<chartStyle.getAxisCount(); i++)
       if ( chartStyle.getAxisStyle(i) == this ) {
-        // ToDo: ??? von welchem Attribut die Aggr.Function verwenden
-        //       Ist 'i' richtig?
+        // ToDo: ??? von welchem Attribut die Aggr.Function und
+        //       Normalisierung verwenden. Ist 'i' richtig?
         if ( chartStyle.getAttributeAggregation(i) != null )
-          funcTitle = chartStyle.getAttributeAggregation(i).getTitle();
+          funcStr = chartStyle.getAttributeAggregation(i).getTitle();
+        if ( chartStyle.isAttributeNormalized(i) )
+          normStr = JFreeChartUtil.R("FeatureChartAxisStyle.normalized");
         break;
       }
     
-    // If unit or function is set, add it to axis title
+    // If unit, function or normalization is set, add it to axis title
     String axisLabel = getLabel();
-    String unitLabel = (isUnitVisible() && !"".equals(getUnitString())) ? getUnitString() : null;
-    if ( funcTitle != null && !"".equals(funcTitle.trim())) {
-      if ( unitLabel != null )
-        unitLabel += ", " + funcTitle.trim();
-      else
-        unitLabel = funcTitle.trim();
-    }
-    if ( unitLabel != null && !"".equals(unitLabel.trim()) ) {
+    String unitLabel = LangUtil.listString(", ",unitStr,funcStr,normStr);
+    if ( unitLabel != null && !"".equals(unitLabel) )
       axisLabel += " ["+unitLabel.trim()+"]";
-    }
-
-    // Apply common attributes
     axis.setLabel( axisLabel );
   }
 

Modified: trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle.properties	2010-03-01 16:38:12 UTC (rev 734)
+++ trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle.properties	2010-03-01 17:15:25 UTC (rev 735)
@@ -51,6 +51,8 @@
 ChartType_POINT.Title=pointchart
 ChartType_POINT.Object.Title=points
 
+FeatureChartAxisStyle.normalized=normalized
+
 AggregationFunction.COUNT.Title=Count
 AggregationFunction.COUNT.Desc=Count of features
 AggregationFunction.SUM.Title=Sum

Modified: trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle_de.properties
===================================================================
--- trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle_de.properties	2010-03-01 16:38:12 UTC (rev 734)
+++ trunk/src/schmitzm/jfree/resource/locales/JFreeResourceBundle_de.properties	2010-03-01 17:15:25 UTC (rev 735)
@@ -51,6 +51,8 @@
 ChartType_POINT.Title=Punktdiagramm
 ChartType_POINT.Object.Title=Punkte
 
+FeatureChartAxisStyle.normalized=normalisiert
+
 AggregationFunction.COUNT.Title=Anzahl
 AggregationFunction.COUNT.Desc=Anzahl der Feature
 AggregationFunction.SUM.Title=Summe

Modified: trunk/src/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/src/schmitzm/lang/LangUtil.java	2010-03-01 16:38:12 UTC (rev 734)
+++ trunk/src/schmitzm/lang/LangUtil.java	2010-03-01 17:15:25 UTC (rev 735)
@@ -81,6 +81,28 @@
 			return "null";
 		return object.getClass().getSimpleName();
 	}
+	
+	/**
+	 * Haengt Strings aneinander, getrennt durch Trennzeichen. 
+	 * @param delim   Trennzeichen (kann {@code null} sein)
+	 * @param strList Liste von Strings ({@code null}-Elemente und leere Strings
+	 *                werden ignoriert
+	 * @return
+	 */
+	public static String listString(String delim, String... strList) {
+	  StringBuffer resultStr = new StringBuffer();
+	  for (int i=0; i<strList.length; i++) {
+	    // ignore item if it it null or empty
+	    if ( strList[i] == null || "".equals(strList[i].trim()) )
+	      continue;
+	    // append delimiter (if necessary)
+	    if ( resultStr.length() > 0 && delim != null )
+	      resultStr.append(delim);
+	    // append string
+	    resultStr.append(strList[i].trim());
+	  }
+	  return resultStr.toString();
+	}
 
 	/**
 	 * Prueft, ob ein {@link Enum} ein spezielles Feld besitzt.



More information about the Schmitzm-commits mailing list