[Schmitzm-commits] r1022 - in branches/2.2.x/src/schmitzm/geotools/gui: . resource/locales

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 20 22:15:12 CEST 2010


Author: alfonx
Date: 2010-09-20 22:15:04 +0200 (Mon, 20 Sep 2010)
New Revision: 1022

Modified:
   branches/2.2.x/src/schmitzm/geotools/gui/ColorMapTable.java
   branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
   branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties
   branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties
Log:
Improved the raster style (color map) editor, so that entries can be set to transparent.

Modified: branches/2.2.x/src/schmitzm/geotools/gui/ColorMapTable.java
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/gui/ColorMapTable.java	2010-09-20 18:28:42 UTC (rev 1021)
+++ branches/2.2.x/src/schmitzm/geotools/gui/ColorMapTable.java	2010-09-20 20:15:04 UTC (rev 1022)
@@ -37,6 +37,7 @@
 import org.geotools.styling.ColorMap;
 import org.geotools.styling.ColorMapEntry;
 
+import schmitzm.geotools.feature.FeatureUtil;
 import schmitzm.geotools.styling.StylingUtil;
 import schmitzm.swing.CaptionsChangeable;
 import schmitzm.swing.table.AbstractMutableTableModel;
@@ -59,7 +60,10 @@
   /** Key, um den 3. Tabellenkopf-Eintrag "Label" in der {@link CaptionsChangeable}-Map anzusprechen.
    *  @see #resetCaptions(Map)*/
   public static final String TABLEHEADER_LABEL = ColorMapTable.class.getName()+".Header.LABEL";
-
+  /** Key, um den 4. Tabellenkopf-Eintrag "Transparent" in der {@link CaptionsChangeable}-Map anzusprechen.
+   *  @see #resetCaptions(Map)*/
+  public static final String TABLEHEADER_OPACITY = ColorMapTable.class.getName()+".Header.OPACITY";
+  
   /**
    * Erzeugt eine neue Tabelle
    * @param colorMap darzustellende Farb-Palette
@@ -121,6 +125,9 @@
     caption = captionMap.get( TABLEHEADER_LABEL );
     if ( caption != null )
       header[2] = caption.toString();
+    caption = captionMap.get( TABLEHEADER_OPACITY );
+    if ( caption != null )
+      header[3] = caption.toString();
 
     ((ColorMapTableModel)getModel()).fireTableStructureChanged();
   }
@@ -132,7 +139,7 @@
   private static class ColorMapTableModel extends AbstractMutableTableModel {
     protected MutableTable table   = null;
     protected ColorMap     colMap   = null;
-    protected Class[]      colClass = new Class[]  {String.class, Color.class, String.class};
+    protected Class<?>[]      colClass = new Class[]  {String.class, Color.class, String.class, Boolean.class};
 
     /**
      * Erzeugt ein neues TableModel.
@@ -151,7 +158,8 @@
       return new String[] {
           GeotoolsGUIUtil.RESOURCE.getString(TABLEHEADER_QUANTITY),
           GeotoolsGUIUtil.RESOURCE.getString(TABLEHEADER_COLOR),
-          GeotoolsGUIUtil.RESOURCE.getString(TABLEHEADER_LABEL)
+          GeotoolsGUIUtil.RESOURCE.getString(TABLEHEADER_LABEL),
+          GeotoolsGUIUtil.RESOURCE.getString(TABLEHEADER_OPACITY)
       };
     }
 
@@ -162,10 +170,15 @@
      * @param col Spaltennummer (beginnend bei 0)
      */
     public void performChangeData(int row, int col) {
+    	
       if ( col != 1 )
         return;
+      
+      // Von Stefan hinzugefügt am 20.9.2010, damit die Farbe nicht editierbar ist, fall vollständige Transparenz aktiviert ist.
+       if (!isCellEditable(row, col)) return;
+    	
       ColorMapEntry entry = colMap.getColorMapEntry(row);
-      Color color = JColorChooser.showDialog(table,"Choose color",StylingUtil.getColorFromColorMapEntry(entry));
+      Color color = JColorChooser.showDialog(table,"Choose color",StylingUtil.getColorFromColorMapEntry(entry)); //i8n
       if ( color != null )
         entry.setColor( StylingUtil.STYLE_BUILDER.colorExpression(color) );
       //changeColorMapEntry( colMap.getColorMapEntry(row) );
@@ -259,15 +272,21 @@
       return colClass[col];
     }
 
-    /**
-     * Spezifiert, ob eine Zelle editierbar ist.
-     * @param row Zeilennummer (beginnend bei 0)
-     * @param col Spaltennummer (beginnend bei 0)
-     * @return <code>true</code> fuer Spalte 0 und 2, sonst <code>false</code>
-     */
-    public boolean isCellEditable(int row, int col) {
-      return col == 0 || col == 2;
-    }
+		/**
+		 * Spezifiert, ob eine Zelle editierbar ist.
+		 * 
+		 * @param row
+		 *            Zeilennummer (beginnend bei 0)
+		 * @param col
+		 *            Spaltennummer (beginnend bei 0)
+		 * @return <code>true</code> fuer Spalte 0 und 3, die zweite Farbspalte
+		 *         ist nur editierbar, wenn der eintrag nicht komplett
+		 *         durchsichtig ist.
+		 */
+		public boolean isCellEditable(int row, int col) {
+			return col == 0 || (col == 1 && (!(Boolean) getValueAt(row, 3)))
+					|| col == 3;
+		}
 
     /**
      * Liefert einen Wert der Tabelle
@@ -279,6 +298,7 @@
         case 0: return StylingUtil.getQuantityFromColorMapEntry( colMap.getColorMapEntry(row) );
         case 1: return StylingUtil.getColorFromColorMapEntry( colMap.getColorMapEntry(row) );
         case 2: return colMap.getColorMapEntry(row).getLabel();
+        case 3: return colMap.getColorMapEntry(row).getOpacity().toString().equals("0.0");
       }
       return null;
     }
@@ -300,6 +320,9 @@
                   break;
           case 2: colMap.getColorMapEntry(row).setLabel( (String)obj );
                   break;
+          case 3: colMap.getColorMapEntry(row).setOpacity( FeatureUtil.FILTER_FACTORY2.literal( (Boolean)obj ? 0. : 1.)
+        		 );
+          break;                  
         }
       } catch (Exception err) {
       }

Modified: branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2010-09-20 18:28:42 UTC (rev 1021)
+++ branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle.properties	2010-09-20 20:15:04 UTC (rev 1022)
@@ -84,6 +84,7 @@
 schmitzm.geotools.gui.ColorMapTable.Header.QUANTITY=Quantity
 schmitzm.geotools.gui.ColorMapTable.Header.COLOR=Color
 schmitzm.geotools.gui.ColorMapTable.Header.LABEL=Label
+schmitzm.geotools.gui.ColorMapTable.Header.OPACITY=Transparent
 schmitzm.geotools.gui.RasterPositionLabel.LABEL_PREFIX=Raster value
 schmitzm.geotools.gui.GeotoolsGUIUtil.Load=Load
 schmitzm.geotools.gui.GeotoolsGUIUtil.LoadRaster=Load raster

Modified: branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties	2010-09-20 18:28:42 UTC (rev 1021)
+++ branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_de.properties	2010-09-20 20:15:04 UTC (rev 1022)
@@ -78,6 +78,7 @@
 schmitzm.geotools.gui.ColorMapTable.Header.QUANTITY=Raster-Wert
 schmitzm.geotools.gui.ColorMapTable.Header.COLOR=Farbe
 schmitzm.geotools.gui.ColorMapTable.Header.LABEL=Label
+schmitzm.geotools.gui.ColorMapTable.Header.OPACITY=Transparent
 schmitzm.geotools.gui.RasterPositionLabel.LABEL_PREFIX=Raster-Wert
 schmitzm.geotools.gui.GeotoolsGUIUtil.Load=Laden
 schmitzm.geotools.gui.GeotoolsGUIUtil.LoadRaster=Raster laden

Modified: branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties	2010-09-20 18:28:42 UTC (rev 1021)
+++ branches/2.2.x/src/schmitzm/geotools/gui/resource/locales/GTResourceBundle_fr.properties	2010-09-20 20:15:04 UTC (rev 1022)
@@ -75,6 +75,7 @@
 schmitzm.geotools.gui.ColorMapTable.Header.QUANTITY=Valeur de trame
 schmitzm.geotools.gui.ColorMapTable.Header.COLOR=Couleur
 schmitzm.geotools.gui.ColorMapTable.Header.LABEL=Label
+schmitzm.geotools.gui.ColorMapTable.Header.OPACITY=Transparent
 schmitzm.geotools.gui.RasterPositionLabel.LABEL_PREFIX=Valeur de raster
 schmitzm.geotools.gui.GeotoolsGUIUtil.Load=Charger
 schmitzm.geotools.gui.GeotoolsGUIUtil.LoadRaster=Charger un raster



More information about the Schmitzm-commits mailing list