[Schmitzm-commits] r197 - in trunk/src/schmitzm: geotools/gui jfree/chart/style swing swing/resource/locales

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jul 7 17:57:32 CEST 2009


Author: mojays
Date: 2009-07-07 17:57:31 +0200 (Tue, 07 Jul 2009)
New Revision: 197

Modified:
   trunk/src/schmitzm/geotools/gui/FeatureLayerFilterDialog.java
   trunk/src/schmitzm/jfree/chart/style/ChartStyleUtil.java
   trunk/src/schmitzm/swing/OperationTreePanel.java
   trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
Log:
localization and filter for operators in dialog combo box

Modified: trunk/src/schmitzm/geotools/gui/FeatureLayerFilterDialog.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/FeatureLayerFilterDialog.java	2009-07-07 15:16:41 UTC (rev 196)
+++ trunk/src/schmitzm/geotools/gui/FeatureLayerFilterDialog.java	2009-07-07 15:57:31 UTC (rev 197)
@@ -119,6 +119,12 @@
         okButton.setEnabled( err == null );
         applyButton.setEnabled( err == null );
       }
+      @Override
+      protected boolean acceptOperator(String operator) {
+        // Operatoren durch Methode des Dialogs filtern
+        return super.acceptOperator(operator) &&
+               FeatureLayerFilterDialog.this.acceptOperator(operator);
+      }
     };
     okButton = new JButton( SwingUtil.RESOURCE.getString("Ok") );
     cancelButton = new JButton( SwingUtil.RESOURCE.getString("Cancel") );
@@ -167,6 +173,16 @@
   }
 
   /**
+   * Kann von Sub-Klassen ueberschrieben werden, um bestimmte Operatoren
+   * in der Auswahl-Liste auszublenden.
+   * @param operator ein Operator
+   * @return immer {@code true}
+   */
+  protected boolean acceptOperator(String operator) {
+    return true;
+  }
+
+  /**
    * Liefert das MapPane, fuer das {@link FeatureSelectedEvent FeatureSelectedEvents}
    * ausgeloest werden.
    */

Modified: trunk/src/schmitzm/jfree/chart/style/ChartStyleUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartStyleUtil.java	2009-07-07 15:16:41 UTC (rev 196)
+++ trunk/src/schmitzm/jfree/chart/style/ChartStyleUtil.java	2009-07-07 15:57:31 UTC (rev 197)
@@ -82,8 +82,15 @@
 		}
 	}
 
+	/**
+     * Writes a chart definition to {@link File}.
+	 * @param chartStyle a style
+	 * @param chartFile target file
+	 */
 	public static void writeStyleToXML(ChartStyle chartStyle, File chartFile) {
-		// TODO Auto-generated method stub
+	  // TODO: method must use a factory to differ FeatureChartStyles from
+	  //       "normal" styles
+	  throw new UnsupportedOperationException("ChartStyleUtil.writeStyleToXML(.) not yet implemented!");
 	}
 
 }

Modified: trunk/src/schmitzm/swing/OperationTreePanel.java
===================================================================
--- trunk/src/schmitzm/swing/OperationTreePanel.java	2009-07-07 15:16:41 UTC (rev 196)
+++ trunk/src/schmitzm/swing/OperationTreePanel.java	2009-07-07 15:57:31 UTC (rev 197)
@@ -108,46 +108,51 @@
     layoutConstraints.put(START_BUTTON,      new GridBagConstraints(0,1,1,1,0.0,0.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,10,5,10),0,0));
 
     // Zur Verfuegung stehende Operatoren
-    avOperators.add("&");            avOperatorsDesc.put("&",       "AND");
-    avOperators.add("|");            avOperatorsDesc.put("|",       "OR");
-    avOperators.add("!");            avOperatorsDesc.put("!",       "NOT");
-    avOperators.add("abs");          avOperatorsDesc.put("abs",     "abs(.)");
-    avOperators.add("sqrt");         avOperatorsDesc.put("sqrt",    "sqrt(.)");
-    avOperators.add("round");        avOperatorsDesc.put("round",   "round(.)");
-    avOperators.add("trunc");        avOperatorsDesc.put("trunc",   "trunc(.)");
-    avOperators.add("isNaN");        avOperatorsDesc.put("isNaN",   "isNaN(.)");
+    avOperators.add("&");            avOperatorsDesc.put("&",       getOpDesc("and"));
+    avOperators.add("|");            avOperatorsDesc.put("|",       getOpDesc("or"));
+    avOperators.add("!");            avOperatorsDesc.put("!",       getOpDesc("not"));
+    avOperators.add("abs");          avOperatorsDesc.put("abs",     getOpDesc("abs"));
+    avOperators.add("sqrt");         avOperatorsDesc.put("sqrt",    getOpDesc("sqrt"));
+    avOperators.add("round");        avOperatorsDesc.put("round",   getOpDesc("round"));
+    avOperators.add("trunc");        avOperatorsDesc.put("trunc",   getOpDesc("trunc"));
+    avOperators.add("isNaN");        avOperatorsDesc.put("isNaN",   getOpDesc("isNaN"));
     avOperators.add("NaN");
-    avOperators.add("random");       avOperatorsDesc.put("random",  "random value");
-    avOperators.add("sin");          avOperatorsDesc.put("sin",     "sin(.)");
-    avOperators.add("cos");          avOperatorsDesc.put("cos",     "cos(.)");
-    avOperators.add("tan");          avOperatorsDesc.put("tan",     "tan(.)");
-    avOperators.add("asin");         avOperatorsDesc.put("asin",    "arcsin(.)");
-    avOperators.add("acos");         avOperatorsDesc.put("acos",    "arccos(.)");
-    avOperators.add("atan");         avOperatorsDesc.put("atan",    "arctan(.)");
-    avOperators.add("exp");          avOperatorsDesc.put("exp",     "exp(.)");
-    avOperators.add("ln");           avOperatorsDesc.put("ln",      "ln(.)");
-    avOperators.add("log");          avOperatorsDesc.put("log",     "log(.)");
-    avOperators.add("str");          avOperatorsDesc.put("str",     "str(.)");
-    avOperators.add("val");          avOperatorsDesc.put("val",     "val(.)");
-    avOperators.add("len");          avOperatorsDesc.put("len",     "len(.)");
-    avOperators.add("toupper");      avOperatorsDesc.put("toupper", "toupper(.)");
-    avOperators.add("tolower");      avOperatorsDesc.put("tolower", "tolower(.)");
-    avOperators.add("ITE");          avOperatorsDesc.put("ITE",     "IF .. THEN .. ELSE");
-    avOperators.add("REGEX");        avOperatorsDesc.put("REGEX",   "REGEX(.,.)");
-    avOperators.add("SUBSTR");       avOperatorsDesc.put("SUBSTR",  "SUBSTRING(.,.,.)");
+    avOperators.add("random");       avOperatorsDesc.put("random",  getOpDesc("random"));
+    avOperators.add("sin");          avOperatorsDesc.put("sin",     getOpDesc("sin"));
+    avOperators.add("cos");          avOperatorsDesc.put("cos",     getOpDesc("cos"));
+    avOperators.add("tan");          avOperatorsDesc.put("tan",     getOpDesc("tan"));
+    avOperators.add("asin");         avOperatorsDesc.put("asin",    getOpDesc("asin"));
+    avOperators.add("acos");         avOperatorsDesc.put("acos",    getOpDesc("acos"));
+    avOperators.add("atan");         avOperatorsDesc.put("atan",    getOpDesc("atan"));
+    avOperators.add("exp");          avOperatorsDesc.put("exp",     getOpDesc("exp"));
+    avOperators.add("ln");           avOperatorsDesc.put("ln",      getOpDesc("ln"));
+    avOperators.add("log");          avOperatorsDesc.put("log",     getOpDesc("log"));
+    avOperators.add("str");          avOperatorsDesc.put("str",     getOpDesc("str"));
+    avOperators.add("val");          avOperatorsDesc.put("val",     getOpDesc("val"));
+    avOperators.add("len");          avOperatorsDesc.put("len",     getOpDesc("len"));
+    avOperators.add("toupper");      avOperatorsDesc.put("toupper", getOpDesc("toupper"));
+    avOperators.add("tolower");      avOperatorsDesc.put("tolower", getOpDesc("tolower"));
+    avOperators.add("ITE");          avOperatorsDesc.put("ITE",     getOpDesc("ite"));
+    avOperators.add("REGEX");        avOperatorsDesc.put("REGEX",   getOpDesc("regex"));
+    avOperators.add("SUBSTR");       avOperatorsDesc.put("SUBSTR",  getOpDesc("substr"));
     // Die "einfachen Operatoren" and Ende setzen, da diese eigentlich
     // menuell eingegeben werden und nicht so oft gebraucht werden
-    avOperators.add("+");
-    avOperators.add("-");
-    avOperators.add("*");
-    avOperators.add("/");
-    avOperators.add("^");
-    avOperators.add("=");
-    avOperators.add("<>");
-    avOperators.add("<");
-    avOperators.add("<=");
-    avOperators.add(">");
-    avOperators.add(">=");
+    avOperators.add("+");            avOperatorsDesc.put("+",  getOpDesc("plus"));
+    avOperators.add("-");            avOperatorsDesc.put("-",  getOpDesc("minus"));
+    avOperators.add("*");            avOperatorsDesc.put("*",  getOpDesc("multiply"));
+    avOperators.add("/");            avOperatorsDesc.put("/",  getOpDesc("divide"));
+    avOperators.add("^");            avOperatorsDesc.put("^",  getOpDesc("pow"));
+    avOperators.add("=");            avOperatorsDesc.put("=",  getOpDesc("eq"));
+    avOperators.add("<>");           avOperatorsDesc.put("<>", getOpDesc("ne"));
+    avOperators.add("<");            avOperatorsDesc.put("<",  getOpDesc("lt"));
+    avOperators.add("<=");           avOperatorsDesc.put("<=", getOpDesc("le"));
+    avOperators.add(">");            avOperatorsDesc.put(">",  getOpDesc("gt"));
+    avOperators.add(">=");           avOperatorsDesc.put(">=", getOpDesc("ge"));
+    
+    // Operatoren filtern
+    for (String op : new Vector<String>(avOperators))
+      if ( !acceptOperator(op) )
+        avOperators.remove(op);
 
     if (initGUI)
       initGUI();
@@ -206,8 +211,26 @@
     add( startButton, layoutConstraints.get(START_BUTTON) );
     add( operators,   layoutConstraints.get(OPERATOR_COMBOBOX) );
   }
+  
+  /**
+   * Kann von Sub-Klassen ueberschrieben werden, um bestimmte Operatoren
+   * in der Auswahl-Liste auszublenden.
+   * @param operator ein Operator
+   * @return immer {@code true}
+   */
+  protected boolean acceptOperator(String operator) {
+    return true;
+  }
 
   /**
+   * Liefert die Lokalisation fuer einen Operator. 
+   * @param opKey key fuer den Operator
+   */
+  private String getOpDesc(String opKey) {
+    return SwingUtil.RESOURCE.getString("OperationTreePanel.OpDesc."+opKey);
+  }
+
+  /**
    * Setzt die Labels des Panels neu. Die Beschriftungen werden in einer
    * Map hinterlegt und ueber die Konstanten {@link #RULE_LABEL}, {@link #RULE_TOOLTIP},
    * {@link #OPERATOR_LABEL} und {@link #START_BUTTON} angesprochen.

Modified: trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2009-07-07 15:16:41 UTC (rev 196)
+++ trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2009-07-07 15:57:31 UTC (rev 197)
@@ -33,3 +33,51 @@
 Operators=Operators
 Start=Start
 Calculate=Calculate
+OperationTreePanel.OpDesc.and=AND
+OperationTreePanel.OpDesc.or=OR
+OperationTreePanel.OpDesc.not=NOT
+OperationTreePanel.OpDesc.abs=abs(.)
+OperationTreePanel.OpDesc.sqrt=sqrt(.)
+OperationTreePanel.OpDesc.round=round(.)
+OperationTreePanel.OpDesc.trunc=trunc(.)
+OperationTreePanel.OpDesc.isNaN=isNaN(.)
+OperationTreePanel.OpDesc.NaN=NaN
+OperationTreePanel.OpDesc.random=random value
+OperationTreePanel.OpDesc.sin=sin(.)
+OperationTreePanel.OpDesc.cos=cos(.)
+OperationTreePanel.OpDesc.tan=tan(.)
+OperationTreePanel.OpDesc.asin=arcsin(.)
+OperationTreePanel.OpDesc.acos=arccos(.)
+OperationTreePanel.OpDesc.atan=arctan(.)
+OperationTreePanel.OpDesc.exp=exp(.)
+OperationTreePanel.OpDesc.ln=ln(.)
+OperationTreePanel.OpDesc.log=log(.)
+OperationTreePanel.OpDesc.str=str(.)
+OperationTreePanel.OpDesc.val=val(.)
+OperationTreePanel.OpDesc.len=len(.)
+OperationTreePanel.OpDesc.toupper=toupper(.)
+OperationTreePanel.OpDesc.tolower=tolower(.)
+OperationTreePanel.OpDesc.ite=IF .. THEN .. ELSE
+OperationTreePanel.OpDesc.regex=REGEX(.,.)
+OperationTreePanel.OpDesc.substr=SUBSTRING(.,.,.)
+OperationTreePanel.OpDesc.plus=+
+OperationTreePanel.OpDesc.minus=-
+OperationTreePanel.OpDesc.multiply=*
+OperationTreePanel.OpDesc.divide=/
+OperationTreePanel.OpDesc.pow=^
+OperationTreePanel.OpDesc.eq=\=
+OperationTreePanel.OpDesc.ne=<>
+OperationTreePanel.OpDesc.lt=<
+OperationTreePanel.OpDesc.le=<=
+OperationTreePanel.OpDesc.gt=>
+OperationTreePanel.OpDesc.ge=>=
+
+
+
+
+
+
+
+
+
+



More information about the Schmitzm-commits mailing list