Revision: 4504
          http://sourceforge.net/p/jump-pilot/code/4504
Author:   bertazza
Date:     2015-06-18 15:50:25 +0000 (Thu, 18 Jun 2015)
Log Message:
-----------
Added Raster Styler to manage symbologies for 1-banded raster (available from 
raster layer contextual menu).

Modified Paths:
--------------
    core/trunk/ChangeLog
    core/trunk/scripts/default-plugins.xml
    core/trunk/src/org/openjump/core/rasterimage/RasterSymbology.java

Added Paths:
-----------
    core/trunk/src/org/openjump/core/rasterimage/styler/
    core/trunk/src/org/openjump/core/rasterimage/styler/ColorMapEntry.java
    core/trunk/src/org/openjump/core/rasterimage/styler/ColorUtils.java
    core/trunk/src/org/openjump/core/rasterimage/styler/RasterClassifier1D.java
    core/trunk/src/org/openjump/core/rasterimage/styler/RasterLegendPlugIn.java
    core/trunk/src/org/openjump/core/rasterimage/styler/RasterStyler.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/RasterStylesExtension.java
    core/trunk/src/org/openjump/core/rasterimage/styler/RasterStylesPlugIn.java
    core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java
    core/trunk/src/org/openjump/core/rasterimage/styler/StylePlugger.java
    core/trunk/src/org/openjump/core/rasterimage/styler/Utils.java
    core/trunk/src/org/openjump/core/rasterimage/styler/resources/
    
core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle.properties
    
core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle_en.properties
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorEditor.java
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorRenderer.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsLabelLegendComponent.java
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsTablePanel.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/CustomGradientColorsDialog.form
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/CustomGradientColorsDialog.java
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/GUIUtils.java
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientCanvas.java
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientComboBox.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientComboRenderer.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientLabelLegendComponent.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/GradientTablePanel.java
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/IntervalPanel.form
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/IntervalPanel.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/NoDataValueDialog.form
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/NoDataValueDialog.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterLegendDialog.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.form
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/RasterStylesDialog.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/SingleValuesPanel.form
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/SingleValuesPanel.java
    
core/trunk/src/org/openjump/core/rasterimage/styler/ui/StandardGradientColors.java
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.form
    core/trunk/src/org/openjump/core/rasterimage/styler/ui/StretchedPanel.java

Removed Paths:
-------------
    core/trunk/src/org/openjump/core/rasterimage/ColorMapEntry.java

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2015-06-18 15:11:19 UTC (rev 4503)
+++ core/trunk/ChangeLog        2015-06-18 15:50:25 UTC (rev 4504)
@@ -1,5 +1,9 @@
 # for display continuity sake please use 2 spaces instead of tabs
 
+2015-06-17 bertazza 
+  * added Raster Styler to manage symbologies for 1-banded raster
+  * (available from raster layer contextual menu)
+  
 2015-06-17 mmichaud <m.michael.mich...@orange.fr>
   * fix bug in dbf writer described in
     http://sourceforge.net/p/jump-pilot/mailman/message/34210973/

Modified: core/trunk/scripts/default-plugins.xml
===================================================================
--- core/trunk/scripts/default-plugins.xml      2015-06-18 15:11:19 UTC (rev 
4503)
+++ core/trunk/scripts/default-plugins.xml      2015-06-18 15:50:25 UTC (rev 
4504)
@@ -839,6 +839,10 @@
        
        <plug-in> org.openjump.core.ui.plugin.raster.RasterQueryPlugIn
        </plug-in>
+       
+       <extension>
+               org.openjump.core.rasterimage.styler.RasterStylesExtension
+       </extension>
 
        <!--- ======================= WINDOW menu 
=============================== -->
        <plug-in>

Deleted: core/trunk/src/org/openjump/core/rasterimage/ColorMapEntry.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/ColorMapEntry.java     
2015-06-18 15:11:19 UTC (rev 4503)
+++ core/trunk/src/org/openjump/core/rasterimage/ColorMapEntry.java     
2015-06-18 15:50:25 UTC (rev 4504)
@@ -1,32 +0,0 @@
-package org.openjump.core.rasterimage;
-
-import java.awt.Color;
-
-/**
- *
- * @author AdL
- */
-public class ColorMapEntry {
-
-    public ColorMapEntry(double upperValue, Color color) {
-        this.upperValue = upperValue;
-        this.color = color;
-    }
-
-    public ColorMapEntry(ColorMapEntry rangeAndColor) {
-        this.upperValue = rangeAndColor.getUpperValue();
-        this.color = rangeAndColor.getColor();
-    }    
-    
-    public double getUpperValue() {
-        return upperValue;
-    }
-
-    public Color getColor() {
-        return color;
-    }
-
-    private final double upperValue;
-    private final Color color;
-        
-}

Modified: core/trunk/src/org/openjump/core/rasterimage/RasterSymbology.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/RasterSymbology.java   
2015-06-18 15:11:19 UTC (rev 4503)
+++ core/trunk/src/org/openjump/core/rasterimage/RasterSymbology.java   
2015-06-18 15:50:25 UTC (rev 4504)
@@ -2,6 +2,7 @@
 
 import java.awt.Color;
 import java.util.TreeMap;
+import org.openjump.core.rasterimage.styler.ColorMapEntry;
 
 /**
  *
@@ -77,7 +78,7 @@
                     return downColorMapEntry.getColor();
                 } else {
                     double distDown = value - 
downColorMapEntry.getUpperValue();
-                    double distUp = upColorMapEntry.getUpperValue() - value;
+                    double distUp = upColorMapEntry.getUpperValue()- value;
 
                     double relDist = distDown / (distUp + distDown);
 
@@ -95,6 +96,9 @@
         } else if(colorMapType == ColorMapType.INTERVALS) {
             
             ColorMapEntry downColorMapEntry = getColorMapEntry(value);
+            if(downColorMapEntry == null) {
+                return null;
+            }
             return downColorMapEntry.getColor();
             
         } else {

Added: core/trunk/src/org/openjump/core/rasterimage/styler/ColorMapEntry.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/ColorMapEntry.java      
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/ColorMapEntry.java      
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,33 @@
+package org.openjump.core.rasterimage.styler;
+
+import java.awt.Color;
+
+/**
+ * This class represents a cell value-colour pair.
+ * @author AdL
+ */
+public class ColorMapEntry {
+
+    public ColorMapEntry(double quantity, Color color) {
+        this.quantity = quantity;
+        this.color = color;
+    }
+
+    public ColorMapEntry(ColorMapEntry rangeAndColor) {
+        this.quantity = rangeAndColor.getUpperValue();
+        this.color = rangeAndColor.getColor();
+    }
+    
+    public double getUpperValue() {
+        return quantity;
+    }
+
+    public Color getColor() {
+        return color;
+    }
+ 
+    
+    private final double quantity;
+    private final Color color;
+    
+}

Added: core/trunk/src/org/openjump/core/rasterimage/styler/ColorUtils.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/ColorUtils.java         
                (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/ColorUtils.java 
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,46 @@
+package org.openjump.core.rasterimage.styler;
+
+import java.awt.Color;
+import java.util.Random;
+
+
+public class ColorUtils {
+    
+    public ColorUtils() {
+        random = new Random();
+    }
+    
+    public Color interpolateColor(Color startColor, Color endColor, double 
relDistance) throws Exception {
+        
+        if(relDistance <0 || relDistance > 1) {
+            throw new Exception("Relative distance out of range. Must be 
0-1."); //NOI18N
+        }
+        
+        //int red = (int) Math.round((double) c / (double) (colors.length - 1) 
* 255);
+        int red = interpolate(startColor.getRed(), endColor.getRed(), 
relDistance);
+        int green = interpolate(startColor.getGreen(), endColor.getGreen(), 
relDistance);
+        int blue = interpolate(startColor.getBlue(), endColor.getBlue(), 
relDistance);
+        
+        return new Color(red, green, blue);
+        
+    }
+    
+    private int interpolate(int startValue, int endValue, double relDistance) {
+        
+        return (int)Math.round(startValue * (1-relDistance) + endValue * 
(relDistance));
+        
+    }
+    
+    public Color randomColor() {
+        
+        int red = random.nextInt(256);
+        int green = random.nextInt(256);
+        int blue = random.nextInt(256);
+        
+        return new Color(red, green, blue);
+        
+    }
+    
+    private Random random;
+    
+}

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/RasterClassifier1D.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/RasterClassifier1D.java 
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/RasterClassifier1D.java 
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,22 @@
+package org.openjump.core.rasterimage.styler;
+
+import org.openjump.core.rasterimage.RasterImageLayer;
+
+public class RasterClassifier1D {
+    
+    public static double[] classifyEqualRange(RasterImageLayer 
rasterImageLayer, int classesCount, int band) {
+        
+        double[] breaks = new double[classesCount-1];
+        double min = rasterImageLayer.getMetadata().getStats().getMin(band);
+        double max = rasterImageLayer.getMetadata().getStats().getMax(band);
+        double delta = (max - min)/classesCount;
+        for (int i = 0; i < breaks.length; i++) {
+            breaks[i]=min + (delta*(i+1));
+        }  
+        
+        return breaks;
+        
+    }
+    
+    
+}

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/RasterLegendPlugIn.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/RasterLegendPlugIn.java 
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/RasterLegendPlugIn.java 
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,133 @@
+package org.openjump.core.rasterimage.styler;
+
+import org.openjump.core.rasterimage.styler.ui.GUIUtils;
+import org.openjump.core.rasterimage.styler.ui.RasterStylesDialog;
+import org.openjump.core.rasterimage.styler.ui.RasterLegendDialog;
+import com.vividsolutions.jump.task.TaskMonitor;
+import com.vividsolutions.jump.workbench.WorkbenchContext;
+import com.vividsolutions.jump.workbench.plugin.EnableCheck;
+import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
+import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
+import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.plugin.ThreadedPlugIn;
+import com.vividsolutions.jump.workbench.ui.images.IconLoader;
+import java.awt.Dimension;
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import org.openjump.core.apitools.LayerTools;
+import org.openjump.core.rasterimage.RasterImageLayer;
+import org.openjump.core.rasterimage.RasterSymbology;
+import org.openjump.core.ui.plugin.layer.pirolraster.RasterImageContextMenu;
+
+/**
+ * Plugin for displaying the raster (ASC, FLT formats) legend. 
+ * The menu is actived only is a raster layer is selected.
+ * @author GeomaticaEAmbiente
+ */
+public class RasterLegendPlugIn implements ThreadedPlugIn {
+    
+    @Override
+    public void initialize(PlugInContext context) throws Exception {
+       
+        /* Add item to pop-up menu, only for rasters */
+        JPopupMenu menu = RasterImageContextMenu.getInstance(context);
+        context.getFeatureInstaller().addPopupMenuPlugin(
+                menu, 
+                this, 
+                getName(), 
+                false, 
+                null, 
+                createEnableCheck(context.getWorkbenchContext()));
+        
+    }
+
+    @Override
+    public boolean execute(PlugInContext context) throws Exception {
+        
+        RasterImageLayer rasterImageLayer = (RasterImageLayer) 
LayerTools.getSelectedLayerable(context, RasterImageLayer.class);
+        String bboardKey = 
GUIUtils.getBBKey(rasterImageLayer.getImageFileName());
+        RasterStylesDialog symbologyDialog;
+        RasterSymbology rasterStyler = null;
+        double noDataValue = 0d;
+        //Check if the RasterStyles of raster has been set.
+        if(context.getWorkbenchContext().getBlackboard().get(bboardKey)!= 
null){            
+            
+            symbologyDialog = (RasterStylesDialog) 
context.getWorkbenchContext().getBlackboard().get(bboardKey);
+            rasterStyler  = symbologyDialog.getFinalRasterSymbolizer();
+            noDataValue = symbologyDialog.getNoDataValue();
+        }
+        
+        if(rasterStyler != null){
+            
+            if(rasterStyler.getColorMapEntries_tm().size() > 40){
+                JOptionPane.showMessageDialog(context.getWorkbenchFrame(), 
+                        bundle.getString("LegendDialog.More40Colors.message"), 
+                        RasterStylesExtension.extensionName, 
JOptionPane.INFORMATION_MESSAGE);
+                return false;
+            }
+            
+            RasterLegendDialog legendDialog = new 
RasterLegendDialog(context.getWorkbenchFrame(), 
+                    false, rasterStyler,noDataValue, 
rasterImageLayer.getName());
+           
+            legendDialog.setLocationRelativeTo(context.getWorkbenchFrame());
+            legendDialog.setMinimumSize(new Dimension(200, 300));
+            legendDialog.setPreferredSize(new Dimension(200, 400));
+            legendDialog.setAlwaysOnTop(true);
+            legendDialog.setVisible(true);
+            
+
+        }
+        
+        return false;
+        
+    }
+
+    @Override
+    public void run(TaskMonitor monitor, PlugInContext context) throws 
Exception {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+      
+    @Override
+    public String getName() {
+        return bundle.getString("LegendPlugIn.PlugInName.text");
+    }
+    
+    public Icon getIcon() {
+        return IconLoader.icon("eye.png");
+    }
+    
+    
+    public static MultiEnableCheck createEnableCheck(
+        final WorkbenchContext workbenchContext) {
+        
+        MultiEnableCheck multiEnableCheck = new MultiEnableCheck();
+        EnableCheckFactory checkFactory = new 
EnableCheckFactory(workbenchContext); 
+        
multiEnableCheck.add(checkFactory.createWindowWithLayerNamePanelMustBeActiveCheck());
+        
multiEnableCheck.add(checkFactory.createExactlyNLayerablesMustBeSelectedCheck(1,
 RasterImageLayer.class) );
+        
multiEnableCheck.add(checkFactory.createRasterImageLayerExactlyNBandsMustExistCheck(1));
+        
+        multiEnableCheck.add(new EnableCheck() {
+
+            @Override
+            public String check(JComponent component) {
+                
+                RasterImageLayer ril = (RasterImageLayer) 
LayerTools.getSelectedLayerable(workbenchContext, RasterImageLayer.class);
+                String bboardKey = GUIUtils.getBBKey(ril.getImageFileName());
+                return (workbenchContext.getBlackboard().get(bboardKey) != 
null) ? null : "Sign";
+            }
+        });
+//        
+    return multiEnableCheck;
+  }
+    
+//    private static String bboardKey;
+    private final java.util.ResourceBundle bundle = 
+            
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle");
 // NOI18N
+
+    
+
+    
+    
+}

Added: core/trunk/src/org/openjump/core/rasterimage/styler/RasterStyler.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/RasterStyler.java       
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/RasterStyler.java       
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,173 @@
+package org.openjump.core.rasterimage.styler;
+
+import java.util.TreeMap;
+
+/**
+ * This class represents the style to be associated to a raster image. A style
+ * is given as series of value-colour pairs. The values refer to the raster 
cell
+ * values, and the colours to the colours that the cells will take.
+ * There are two types of symbolizers: RAMP, INTERVALS. For the RAMP
+ * symbolizer, the cell colours will be interpolated from the given 
value-colour
+ * pairs. For the INTERVALS symbolizer, all the cells with value equal or above
+ * the value contained in the value-colour pair will take the associated 
colour.
+ * To create a single values symbology, use the INTERVALS symbolizer, providing
+ * a value-colour pair for every raster value.
+ * @author AdL
+ */
+public class RasterStyler {
+
+    /**
+     * Creates a new raster symbolizer of the given colour map type.
+     * @param colorMapType The colour map type to be used in this raster 
symbolizer.
+     * 
+     */
+    public RasterStyler(ColorMapType2 colorMapType) {
+        this.colorMapEntry_tm = new TreeMap<Double,ColorMapEntry>();
+        this.colorMapType = colorMapType;
+    }
+    
+    /**
+     * Adds a new value-colour pair to the symbology.
+     * @param colorMapEntry The new value-colour pair
+     * @throws Exception 
+     */
+    public void addColorMapEntry(ColorMapEntry colorMapEntry) throws Exception 
{
+        
+        colorMapEntry_tm.put(colorMapEntry.getUpperValue(), colorMapEntry);
+        
+    }
+
+    public void addColorMapEntries(ColorMapEntry[] colorMapEntries) throws 
Exception {
+        
+        for(ColorMapEntry colorMapEntry : colorMapEntries) {
+            colorMapEntry_tm.put(colorMapEntry.getUpperValue(), colorMapEntry);
+        }
+        
+    }
+    
+    /**
+     * Removes a value-colour pair from the symbology.
+     * @param cellValue The value to be removed.
+     */
+    public void removeColorMapEntry(double cellValue) {
+        colorMapEntry_tm.remove(cellValue);
+    }
+    
+    /**
+     * Returns the colour map entry associated to a cell value.
+     * @param cellValue The cell value.
+     * @return 
+     */
+    public ColorMapEntry getColorMapEntry(double cellValue) {
+
+        if(colorMapEntry_tm.floorEntry(cellValue) != null) {
+            return colorMapEntry_tm.floorEntry(cellValue).getValue();
+        }
+        return null;
+
+    }
+
+    /**
+     * Returns the colour map entry just above to the given cell value.
+     * @param cellValue The given cell value.
+     * @return 
+     */
+    public ColorMapEntry getNextColorMapEntry(double cellValue) {
+
+        if(colorMapEntry_tm.higherEntry(cellValue) != null) {
+            return colorMapEntry_tm.higherEntry(cellValue).getValue();
+        }
+        return null;
+        
+    }
+    
+    /**
+     * Returns an array of all the colour map entries.
+     * @return The colour map entries of the symbolizer.
+     */
+    public ColorMapEntry[] getColorMapEntries() {
+        
+        ColorMapEntry[] colorMapEntry = new 
ColorMapEntry[colorMapEntry_tm.size()];        
+        return colorMapEntry_tm.values().toArray(colorMapEntry);
+        
+    }
+    
+    /**
+     * Returns the colour map type.
+     * @return The colour map type.
+     */
+    public ColorMapType2 getColorMapType() {
+        return colorMapType;
+    }
+
+    /**
+     * Returns the level of transparency: 0 (no transparency) - 1 
(transparent).
+     * @return The transparency (0-1).
+     */
+    public double getTransparencyRatio() {
+        return transparencyRatio;
+    }
+
+    /**
+     * Sets the overall transparency: 0 (no transparency) - 1 (transparent).
+     * @param transparencyRatio Transparency level (0-1);
+     */
+    public void setTransparencyRatio(double transparencyRatio) {
+        this.transparencyRatio = transparencyRatio;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        
+        if(obj instanceof RasterStyler) {
+            
+            RasterStyler otherRasterSymbolizer = (RasterStyler) obj;
+            
+            // Compare color map type
+            if(this.getColorMapType() != 
otherRasterSymbolizer.getColorMapType()) {
+                return false;
+            }
+            
+            // Compare color map entries
+            ColorMapEntry[] thisColorMapEntries = this.getColorMapEntries();
+            ColorMapEntry[] otherColorMapEntries = 
otherRasterSymbolizer.getColorMapEntries();
+            
+            if(thisColorMapEntries.length != otherColorMapEntries.length) {
+                return false;
+            }
+            
+            for(int c=0; c<thisColorMapEntries.length; c++) {
+                if(thisColorMapEntries[c].getUpperValue() != 
otherColorMapEntries[c].getUpperValue()) {
+                    return false;
+                }
+                
if(!thisColorMapEntries[c].getColor().equals(otherColorMapEntries[c].getColor()))
 {
+                    return false;
+                }
+            }
+            
+            return this.getTransparencyRatio() == 
otherRasterSymbolizer.getTransparencyRatio();
+            
+        } else {
+            return super.equals(obj);
+        }
+        
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 79 * hash + (this.colorMapEntry_tm != null ? 
this.colorMapEntry_tm.hashCode() : 0);
+        hash = 79 * hash + (this.colorMapType != null ? 
this.colorMapType.hashCode() : 0);
+        hash = 79 * hash + (int) 
(Double.doubleToLongBits(this.transparencyRatio) ^ 
(Double.doubleToLongBits(this.transparencyRatio) >>> 32));
+        return hash;
+    }
+    
+    private final TreeMap<Double,ColorMapEntry> colorMapEntry_tm;
+    private final ColorMapType2 colorMapType;
+    private double transparencyRatio = 0;
+    
+    public enum ColorMapType2 {
+        RAMP, INTERVALS;
+    }
+    
+}

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/RasterStylesExtension.java
===================================================================
--- 
core/trunk/src/org/openjump/core/rasterimage/styler/RasterStylesExtension.java  
                            (rev 0)
+++ 
core/trunk/src/org/openjump/core/rasterimage/styler/RasterStylesExtension.java  
    2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,20 @@
+package org.openjump.core.rasterimage.styler;
+
+import com.vividsolutions.jump.workbench.plugin.Extension;
+import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+
+public class RasterStylesExtension extends Extension {
+
+    @Override
+    public void configure(PlugInContext pic) throws Exception {
+        
+        new RasterStylesPlugIn().initialize(pic);
+        new RasterLegendPlugIn().initialize(pic);
+        
+    }
+    
+    public static final String extensionName = "Raster Styles";
+    public static final String suffixBlackBKey = "_Styles";
+    
+}
+

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/RasterStylesPlugIn.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/RasterStylesPlugIn.java 
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/RasterStylesPlugIn.java 
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,104 @@
+package org.openjump.core.rasterimage.styler;
+
+import org.openjump.core.rasterimage.styler.ui.NoDataValueDialog;
+import org.openjump.core.rasterimage.styler.ui.RasterStylesDialog;
+import com.vividsolutions.jump.task.TaskMonitor;
+import com.vividsolutions.jump.workbench.WorkbenchContext;
+import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
+import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
+import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.plugin.ThreadedPlugIn;
+import javax.swing.JPopupMenu;
+import org.openjump.core.apitools.LayerTools;
+import org.openjump.core.rasterimage.RasterImageLayer;
+import org.openjump.core.rasterimage.styler.ui.GUIUtils;
+import org.openjump.core.ui.plugin.layer.pirolraster.RasterImageContextMenu;
+
+public class RasterStylesPlugIn implements ThreadedPlugIn {
+
+    @Override
+    public void run(TaskMonitor monitor, PlugInContext context) throws 
Exception {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates. //NOI18N
+    }
+
+    @Override
+    public void initialize(PlugInContext context) throws Exception {
+
+        /* Add item to pop-up menu, only for rasters */
+        JPopupMenu menu = RasterImageContextMenu.getInstance(context);
+        context.getFeatureInstaller().addPopupMenuPlugin(
+                menu,
+                this,
+                getName(),
+                false,
+                null,
+                createEnableCheck(context.getWorkbenchContext()));
+        
+    }
+
+    @Override
+    public boolean execute(PlugInContext context) throws Exception {
+        
+        RasterImageLayer rasterImageLayer = (RasterImageLayer) 
LayerTools.getSelectedLayerable(context, RasterImageLayer.class);
+        RasterStylesDialog symbologyDialog;
+        
+        String bboardKey = 
GUIUtils.getBBKey(rasterImageLayer.getImageFileName());        
+                
+        if(context.getWorkbenchContext().getBlackboard().get(bboardKey)!= 
null){            
+            
+            symbologyDialog = (RasterStylesDialog) 
context.getWorkbenchContext().getBlackboard().get(bboardKey);
+            symbologyDialog.setLocationRelativeTo(context.getWorkbenchFrame());
+            symbologyDialog.setVisible(true);
+            
+        } else {
+            
+            Double noDataValue;
+            //check if getNoDataValue() method in RasterImageLayer exist
+            try{
+
+                noDataValue = rasterImageLayer.getNoDataValue();
+
+            } catch (NoSuchMethodError e) {
+
+                NoDataValueDialog noDataDialog = new 
NoDataValueDialog(context.getWorkbenchFrame(), true);
+                
noDataDialog.setLocationRelativeTo(context.getWorkbenchFrame());
+                noDataDialog.setVisible(true);
+                
+                noDataValue = noDataDialog.getNoDataValue();
+                
+                if(noDataValue == null) {
+                    return false;
+                }
+            }           
+            
+            symbologyDialog = new RasterStylesDialog(
+                    context.getWorkbenchFrame(), true, 
context.getWorkbenchContext(),
+                    rasterImageLayer, 0);
+            symbologyDialog.setLocationRelativeTo(context.getWorkbenchFrame());
+            symbologyDialog.setVisible(true);
+                        
+        }
+        
+        return false;
+        
+    }
+
+    public static MultiEnableCheck createEnableCheck(
+            WorkbenchContext workbenchContext) {
+        
+        EnableCheckFactory checkFactory = new EnableCheckFactory(
+                workbenchContext);
+        MultiEnableCheck multiEnableCheck = new MultiEnableCheck();
+
+        
multiEnableCheck.add(checkFactory.createExactlyNLayerablesMustBeSelectedCheck(1,
 RasterImageLayer.class));
+        
multiEnableCheck.add(checkFactory.createRasterImageLayerExactlyNBandsMustExistCheck(1));
+
+        return multiEnableCheck;
+    }
+    
+    @Override
+    public String getName() {
+        return 
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.RasterStylesExtension.Name");
+    }
+    
+}

Added: core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java          
                (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/SLDReader.java  
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,81 @@
+package org.openjump.core.rasterimage.styler;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.IOException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import static javax.xml.parsers.DocumentBuilderFactory.newInstance;
+import javax.xml.parsers.ParserConfigurationException;
+import org.openjump.core.rasterimage.RasterSymbology;
+import org.openjump.core.rasterimage.RasterSymbology.ColorMapType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Utility class to read an GeoServer-style SLD file into a raster symbolizer.
+ * @author AdL
+ */
+public class SLDReader {
+
+    /**
+     * Reads the SLD file and creates a raster symbolizer.
+     * @param SLDFile The SLD file to be read.
+     * @return The raster symbolizer.
+     * @throws ParserConfigurationException
+     * @throws SAXException
+     * @throws IOException
+     * @throws Exception 
+     */
+    public static RasterSymbology read(File SLDFile) throws 
ParserConfigurationException, SAXException, IOException, Exception {
+    
+        DocumentBuilderFactory dbf = newInstance();
+        dbf.setNamespaceAware(true);
+        ColorMapType colorMapType = ColorMapType.RAMP;
+        
+        RasterSymbology rasterSymbolizer = null;
+        
+        Document doc = dbf.newDocumentBuilder().parse(SLDFile);
+        NodeList nodeList = doc.getElementsByTagName("RasterSymbolizer");
+        if(nodeList.getLength() == 1) {
+            NodeList opacity_nl = doc.getElementsByTagName("Opacity");
+            // TODO
+            
+            NodeList colorMap_nl = doc.getElementsByTagName("ColorMap");
+            for(int me=0; me<colorMap_nl.getLength(); me++) {
+                Element colorMap = (Element) colorMap_nl.item(me);
+                
+                /* Types: ramps, intervals, values */
+                String colorMapTypeAttribute = colorMap.getAttribute("type");
+                if(!colorMapTypeAttribute.equals("")) {
+                    colorMapType = 
ColorMapType.valueOf(colorMapTypeAttribute.toUpperCase());
+                }
+                
+                rasterSymbolizer = new RasterSymbology(colorMapType);
+                
+                NodeList colorMapElements_nl = 
colorMap.getElementsByTagName("ColorMapEntry");
+                
+                for(int cme=0; cme<colorMapElements_nl.getLength(); cme++) {
+                    Element colorMapEntryElement = (Element) 
colorMapElements_nl.item(cme);
+                    double quantity = 
Double.parseDouble(colorMapEntryElement.getAttribute("quantity"));
+                    Color color = 
hex2Rgb(colorMapEntryElement.getAttribute("color"));
+                    rasterSymbolizer.addColorMapEntry(quantity, color);
+                }
+
+            }
+        }    
+        
+        return rasterSymbolizer;
+        
+    }
+    
+    public static Color hex2Rgb(String colorStr) {
+        return new Color(
+                Integer.valueOf( colorStr.substring( 1, 3 ), 16 ),
+                Integer.valueOf( colorStr.substring( 3, 5 ), 16 ),
+                Integer.valueOf( colorStr.substring( 5, 7 ), 16 ) );
+    }
+    
+    
+}

Added: core/trunk/src/org/openjump/core/rasterimage/styler/StylePlugger.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/StylePlugger.java       
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/StylePlugger.java       
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,51 @@
+package org.openjump.core.rasterimage.styler;
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import org.openjump.core.rasterimage.RasterImageLayer;
+import org.openjump.core.rasterimage.RasterSymbology;
+
+/**
+ * This utility class plugs a given style into a raster image layer.
+ * @author AdL
+ */
+public class StylePlugger {
+
+    public StylePlugger(RasterImageLayer rasterImageLayer) {
+        this.rasterImageLayer = rasterImageLayer;
+    }
+    
+    /**
+     * Plugs the given style into the raster image layer.
+     * @param rasterSymbolizer The style.
+     * @param raster
+     */
+    public void plug(RasterSymbology rasterSymbolizer, Raster raster) {
+        
+        int width = raster.getWidth();
+        int height = raster.getHeight();
+        BufferedImage newImage = new BufferedImage(width, height, 
BufferedImage.TYPE_4BYTE_ABGR);
+        
+        for (int row = 0; row < height; row++) {
+            for (int col = 0; col < width; col++) {
+                Double value = raster.getSampleDouble(col, row, 0);            
                   
+                Color newColor = rasterSymbolizer.getColor(value); 
//getColor(value, rasterSymbolizer);
+                if(newColor == null) {
+                    /* Transparent cell */
+                    newImage.setRGB(col, row, Color.TRANSLUCENT);
+                } else {
+                    /* Non-transparent cell */
+                    newImage.setRGB(col, row, newColor.getRGB());
+                }
+            }
+        }
+
+        rasterImageLayer.setImage(newImage);
+        
rasterImageLayer.setTransparencyLevel(rasterSymbolizer.getTransparency());
+        
+    }
+    
+    private final RasterImageLayer rasterImageLayer;
+    
+}

Added: core/trunk/src/org/openjump/core/rasterimage/styler/Utils.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/Utils.java              
                (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/Utils.java      
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,57 @@
+package org.openjump.core.rasterimage.styler;
+
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import org.openjump.core.rasterimage.RasterImageLayer;
+
+/**
+ * 
+ * @author AdL
+ */
+public class Utils {
+    
+    public static double[] purgeNoData(Raster rasterData, RasterImageLayer 
rasterImageLayer) {
+        
+        /* Purge no data and take only one sample per value */
+        Set<Double> withoutNoData_s = new HashSet<Double>();
+        
+        for(int r=0; r<rasterData.getHeight(); r++) {
+            
+            for(int c=0; c<rasterData.getWidth(); c++) {
+                
+                double val;
+                if(rasterData.getDataBuffer().getDataType() == 
DataBuffer.TYPE_FLOAT) {
+                    val = rasterData.getSampleFloat(c, r, 0);
+                } else if(rasterData.getDataBuffer().getDataType() == 
DataBuffer.TYPE_DOUBLE) {
+                    val = rasterData.getSampleDouble(c, r, 0);
+                } else {
+                    val = rasterData.getSample(c, r, 0);
+                }
+
+                if(rasterImageLayer.isNoData(val)) {
+                    continue;
+                }
+                
+                withoutNoData_s.add(val);
+                
+            }
+            
+        }        
+        
+        Iterator iter = withoutNoData_s.iterator();
+        double[] values = new double[withoutNoData_s.size()];
+        int p=0;
+        while(iter.hasNext()) {
+            values[p] = (Double) iter.next();
+            p++;
+        }
+        
+        return values;
+        
+    }
+    
+    
+}

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle.properties
===================================================================
--- 
core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle.properties 
                            (rev 0)
+++ 
core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle.properties 
    2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,81 @@
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MinValue.text=0.0
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MaxValue.text=0.0
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jTextField_MinLabel.text=
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jTextField_MinLabel.text=Min
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MinLabel.text=Min:
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MaxLabel.toolTipText=
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MaxLabel.text=Max:
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MaxLabel.text=Max:
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jTextField_MaxLabel.text=
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jTextField_MaxLabel.text=Max
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jButton_custom.text=Custom
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jButton_Custom.text=Custom
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_Value.text=Value
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_Label.text=Label
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_Label.text=Label
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Apply.text=Apply
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Cancel.text=Close
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jCheckBox_NoDataValue.text=NoData
 value:
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_NoDataValueColor.text=
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transparency.text=Transparency:
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transp_0.text=
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transp_0.text=
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transp_100.text=
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transp_100.t
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transparency.text=Transparency
 (%):
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jTextField_TranspValue.text=0
+CustomGradientColors.jButton_Cancel.text=Cancel
+CustomGradientColors.jButton_AddRow.text=Add row
+CustomGradientColors.jLabel_Min.text=Min
+CustomGradientColors.jLabel_Max.text=Max
+GradientTablePanel.FractionValues.message=The values must be in ascending 
order \n and must not be equal values.
+GradientTablePanel.ColorsNumber.message=The colors must be at least two.
+NoDataValueDialog.jButton_Memorize.text=Memorize
+NoDataValueDialog.jButton_Cancel.text=Cancel
+NoDataValueDialog.jTextField_NoDataValue.text=-9999.0
+NoDataValueDialog.jLabel_Message.text=Set noData raster value.
+NoDataValueDialog.Values.message=The value entered is not valid.
+LegendDialog.Title.text=Legend
+LegendDialog.NoDataValue.text=NoData value
+LegendPlugIn.PlugInName.text=Legend
+ColorLabelLegendComponent.NoColor.ToolTipText=No color
+ColorLabelLegendComponent.ColorR.ToolTipText=Color: R=
+LegendDialog.More40Colors.message=The legend has more than 40 elements. It 
will not be displayed.
+CustomGradientColorsDialog.jLabel_Min.text=Min
+CustomGradientColorsDialog.jButton_RemoveRow.toolTipText=
+CustomGradientColorsDialog.jButton_RemoveRow.text=Remove row
+CustomGradientColorsDialog.jLabel_Max.text=Max
+CustomGradientColorsDialog.jButton_AddRow.text=Add row
+CustomGradientColorsDialog.jButton_Cancel.text=Cancel
+CustomGradientColorsDialog.jButton_Ok.text=Ok
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Restore.text=Restore
+org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Ramp=Ramp all
+org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Random=Random
+org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.message.SelectTwoRows=You
 need to selected two rows to ramp colors.
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.chooseNoDataColor=Choose
 color for nodata
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabStretched=Stretched
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabIntervals=Intervals
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabSingleValues=Single
 values
+IntervalPanel.jLabel.method=Method:
+IntervalPanel.jButton.RampAll=Ramp all
+IntervalPanel.jLabel.Classes=Classes:
+IntervalPanel.jButton.AddRow=Add row
+IntervalPanel.jButton.RemoveRow=Remove row
+IntervalPanel.jButton.Ramp=Ramp
+IntervalPanel.classMethods.EqualInterval=Equal interval
+IntervalPanel.classMethods.Jenks=Jenks
+IntervalPanel.classMethods.MaxBreaks=Max breaks
+IntervalPanel.classMethods.MeanStDev=Mean st. dev.
+IntervalPanel.classMethods.Quantiles=Quantiles
+IntervalPanel.message.ErrorWhileClassifying=Error while classifiyng data.
+IntervalPanel.classMethods.EqualInterval.SelectTowRowsToRamp=You need to 
selected two rows to ramp the colours between them.
+ColorsTablePanel.MinValue=Min. value
+ColorsTablePanel.Color=Color
+ColorsTablePanel.Value=Value
+ColorsTablePanel.ErrorInTable=Error in table: 
+org.openjump.core.rasterimage.styler.ui.ColorEditor.edit=edit
+org.openjump.core.rasterimage.styler.ui.ColorEditor.PickAColor=Pick a color
+org.openjump.core.rasterimage.styler.ui.ColorEditor.Transparent=Transparent
+org.openjump.core.rasterimage.styler.ui.ColorEditor.Cancel=Cancel
+org.openjump.core.rasterimage.styler.ui.ColorEditor.Ok=Ok
+org.openjump.core.rasterimage.styler.RasterStylesExtension.Name=Raster 
styles...

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle_en.properties
===================================================================
--- 
core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle_en.properties
                          (rev 0)
+++ 
core/trunk/src/org/openjump/core/rasterimage/styler/resources/Bundle_en.properties
  2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,80 @@
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MinValue.text=0.0
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MaxValue.text=0.0
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jTextField_MinLabel.text=
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jTextField_MinLabel.text=Min
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MinLabel.text=Min:
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MaxLabel.toolTipText=
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MaxLabel.text=Max:
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_MaxLabel.text=Max:
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jTextField_MaxLabel.text=
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jTextField_MaxLabel.text=Max
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jButton_custom.text=Custom
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jButton_Custom.text=Custom
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_Value.text=Value
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_Label.text=Label
+org.openjump.core.rasterimage.styler.ui.StretchedPanel.jLabel_Label.text=Label
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Apply.text=Apply
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Cancel.text=Close
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jCheckBox_NoDataValue.text=NoData
 value:
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_NoDataValueColor.text=
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transparency.text=Transparency:
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transp_0.text=
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transp_0.text=
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transp_100.text=
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transp_100.t
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jLabel_Transparency.text=Transparency
 (%):
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jTextField_TranspValue.text=0
+CustomGradientColors.jButton_Cancel.text=Cancel
+CustomGradientColors.jButton_AddRow.text=Add row
+CustomGradientColors.jLabel_Min.text=Min
+CustomGradientColors.jLabel_Max.text=Max
+GradientTablePanel.FractionValues.message=The values must be in ascending 
order \n and must not be equal values.
+GradientTablePanel.ColorsNumber.message=The colors must be at least two.
+NoDataValueDialog.jButton_Memorize.text=Memorize
+NoDataValueDialog.jButton_Cancel.text=Cancel
+NoDataValueDialog.jTextField_NoDataValue.text=-9999.0
+NoDataValueDialog.jLabel_Message.text=Set noData raster value.
+NoDataValueDialog.Values.message=The value entered is not valid.
+LegendDialog.Title.text=Legend
+LegendDialog.NoDataValue.text=NoData value
+LegendPlugIn.PlugInName.text=Legend
+ColorLabelLegendComponent.NoColor.ToolTipText=No color
+ColorLabelLegendComponent.ColorR.ToolTipText=Color: R=
+LegendDialog.More40Colors.message=The legend has more than 40 elements. It 
will not be displayed.
+CustomGradientColorsDialog.jLabel_Min.text=Min
+CustomGradientColorsDialog.jButton_RemoveRow.toolTipText=
+CustomGradientColorsDialog.jButton_RemoveRow.text=Remove row
+CustomGradientColorsDialog.jLabel_Max.text=Max
+CustomGradientColorsDialog.jButton_AddRow.text=Add row
+CustomGradientColorsDialog.jButton_Cancel.text=Cancel
+CustomGradientColorsDialog.jButton_Ok.text=Ok
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.jButton_Restore.text=Restore
+org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Ramp=Ramp all
+org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.jButton_Random=Random
+org.openjump.core.rasterimage.styler.ui.SingleValuesPanel.message.SelectTwoRows=You
 need to selected two rows to ramp colors.
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.chooseNoDataColor=Choose
 color for nodata
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabStretched=Stretched
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabIntervals=Intervals
+org.openjump.core.rasterimage.styler.ui.RasterStylesDialog.tabSingleValues=Single
 values
+IntervalPanel.jLabel.method=Method:
+IntervalPanel.jButton.RampAll=Ramp all
+IntervalPanel.jLabel.Classes=Classes:
+IntervalPanel.jButton.AddRow=Add row
+IntervalPanel.jButton.RemoveRow=Remove row
+IntervalPanel.jButton.Ramp=Ramp
+IntervalPanel.classMethods.EqualInterval=Equal interval
+IntervalPanel.classMethods.Jenks=Jenks
+IntervalPanel.classMethods.MaxBreaks=Max breaks
+IntervalPanel.classMethods.MeanStDev=Mean st. dev.
+IntervalPanel.classMethods.Quantiles=Quantiles
+IntervalPanel.message.ErrorWhileClassifying=Error while classifiyng data.
+IntervalPanel.classMethods.EqualInterval.SelectTowRowsToRamp=You need to 
selected two rows to ramp the colours between them.
+ColorsTablePanel.MinValue=Min. value
+ColorsTablePanel.Color=Color
+ColorsTablePanel.Value=Value
+ColorsTablePanel.ErrorInTable=Error in table: 
+org.openjump.core.rasterimage.styler.ui.ColorEditor.edit=edit
+org.openjump.core.rasterimage.styler.ui.ColorEditor.PickAColor=Pick a color
+org.openjump.core.rasterimage.styler.ui.ColorEditor.Transparent=Transparent
+org.openjump.core.rasterimage.styler.ui.ColorEditor.Cancel=Cancel
+org.openjump.core.rasterimage.styler.ui.ColorEditor.Ok=Ok

Added: core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorEditor.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorEditor.java     
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorEditor.java     
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle or the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */ 
+
+package org.openjump.core.rasterimage.styler.ui;
+
+/* 
+ * ColorEditor.java (compiles with releases 1.3 and 1.4) is used by 
+ * TableDialogEditDemo.java.
+ */
+
+import java.awt.AWTError;
+import java.awt.BorderLayout;
+import javax.swing.AbstractCellEditor;
+import javax.swing.table.TableCellEditor;
+import javax.swing.JButton;
+import javax.swing.JColorChooser;
+import javax.swing.JDialog;
+import javax.swing.JTable;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JCheckBox;
+import javax.swing.JPanel;
+
+public class ColorEditor extends AbstractCellEditor
+                         implements TableCellEditor,
+                                   ActionListener {
+    
+    private Component parent;
+    private Color currentColor;
+    private JButton button;
+    private JColorChooser colorChooser;
+    private JDialog jDialog_ColorPicker;
+    private JCheckBox jCheckBox_Transparent;
+    protected static final String EDIT = 
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.ColorEditor.edit");
+
+    public ColorEditor(Component parent) {
+        this.parent = parent;
+        //Set up the editor (from the table's point of view),
+        //which is a button.
+        //This button brings up the color chooser jDialog_ColorPicker,
+        //which is the editor from the user's point of view.
+        fixComponents();
+    }
+
+    private void fixComponents() {
+        button = new JButton();
+        button.setActionCommand(EDIT);
+        button.addActionListener(this);
+        button.setBorderPainted(false);
+        button.setFocusPainted(false);
+        button.setContentAreaFilled(false);
+        
+        //Set up the jDialog_ColorPicker that the button brings up.
+        colorChooser = new JColorChooser();
+//        jDialog_ColorPicker = JColorChooser.createDialog(button,
+//                                        "Pick a Color",
+//                                        true,  //modal
+//                                        colorChooser,
+//                                        this,  //OK button handler
+//                                        null); //no CANCEL button handler
+        
+        if(parent == null) {
+            throw new AWTError("No suitable parent found for Component."); 
//NOI18N
+        } else if (parent instanceof Dialog) {
+            jDialog_ColorPicker = new JDialog((Dialog) parent, 
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.ColorEditor.PickAColor"));
+        } else if (parent instanceof Frame) {
+            jDialog_ColorPicker = new JDialog((Frame) parent, 
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.ColorEditor.PickAColor"));
+        }
+        jDialog_ColorPicker.setLocationRelativeTo(parent);
+        jDialog_ColorPicker.setSize(500, 500);
+        jDialog_ColorPicker.setModal(true);
+        
+        jDialog_ColorPicker.getContentPane().setLayout(new BorderLayout());
+        colorChooser = new JColorChooser();
+        jDialog_ColorPicker.getContentPane().add(colorChooser, 
BorderLayout.NORTH);
+        
+        jCheckBox_Transparent = new 
JCheckBox(java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.ColorEditor.Transparent"));
+        jDialog_ColorPicker.getContentPane().add(jCheckBox_Transparent, 
BorderLayout.CENTER);
+        
+        JButton jButton_Cancel = new 
JButton(java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.ColorEditor.Cancel"));
+        jButton_Cancel.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                jDialog_ColorPicker.setVisible(false);
+            }
+        });
+        
+        JButton jButton_Ok = new 
JButton(java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle").getString("org.openjump.core.rasterimage.styler.ui.ColorEditor.Ok"));
+        jButton_Ok.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                currentColor = colorChooser.getColor();
+                if(jCheckBox_Transparent.isSelected()) {
+                    currentColor = new Color(
+                            currentColor.getRed(),
+                            currentColor.getGreen(),
+                            currentColor.getBlue(),
+                            0);
+                }
+                
+                jDialog_ColorPicker.setVisible(false);
+            }
+        });
+        
+        JPanel jPanel_Buttons = new JPanel(new FlowLayout());
+        jPanel_Buttons.add(jButton_Cancel);
+        jPanel_Buttons.add(jButton_Ok);
+        
+        jDialog_ColorPicker.getContentPane().add(jPanel_Buttons, 
BorderLayout.SOUTH);
+        
+    }
+    
+    /**
+     * Handles events from the editor button and from
+     * the jDialog_ColorPicker's OK button.
+     * @param e
+     */
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        if (EDIT.equals(e.getActionCommand())) {
+            //The user has clicked the cell, so
+            //bring up the jDialog_ColorPicker.
+            button.setBackground(currentColor);
+            colorChooser.setColor(currentColor);
+            jDialog_ColorPicker.setVisible(true);
+
+            //Make the renderer reappear.
+            fireEditingStopped();
+            
+        } else { //User pressed jDialog_ColorPicker's "OK" button.
+            currentColor = colorChooser.getColor();
+        }
+    }
+
+    //Implement the one CellEditor method that AbstractCellEditor doesn't.
+    @Override
+    public Object getCellEditorValue() {
+        return currentColor;
+    }
+
+    //Implement the one method defined by TableCellEditor.
+    @Override
+    public Component getTableCellEditorComponent(JTable table,
+                                                 Object value,
+                                                 boolean isSelected,
+                                                 int row,
+                                                 int column) {
+        currentColor = (Color)value;
+        return button;
+    }
+    
+    
+}

Added: core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorRenderer.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorRenderer.java   
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorRenderer.java   
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle or the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */ 
+
+package org.openjump.core.rasterimage.styler.ui;
+
+/* 
+ * ColorRenderer.java (compiles with releases 1.2, 1.3, and 1.4) is used by 
+ * TableDialogEditDemo.java.
+ */
+
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.border.Border;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Color;
+import java.awt.Component;
+
+public class ColorRenderer extends JLabel
+                           implements TableCellRenderer {
+    Border unselectedBorder = null;
+    Border selectedBorder = null;
+    boolean isBordered = true;
+
+    public ColorRenderer(boolean isBordered) {
+        this.isBordered = isBordered;
+        setOpaque(true); //MUST do this for background to show up.
+    }
+
+    @Override
+    public Component getTableCellRendererComponent(
+                            JTable table, Object color,
+                            boolean isSelected, boolean hasFocus,
+                            int row, int column) {
+        Color newColor = (Color)color;
+        setBackground(newColor);
+        if (isBordered) {
+            if (isSelected) {
+                if (selectedBorder == null) {
+                    selectedBorder = 
BorderFactory.createLineBorder(Color.BLACK);
+                }
+                setBorder(selectedBorder);
+            } else {
+                if (unselectedBorder == null) {
+                    unselectedBorder = 
BorderFactory.createLineBorder(Color.BLACK);
+                }
+                setBorder(unselectedBorder);
+            }
+        }
+        
+        setToolTipText("RGB value: " + newColor.getRed() + ", "
+                                     + newColor.getGreen() + ", "
+                                     + newColor.getBlue());
+        return this;
+    }
+}
\ No newline at end of file

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsLabelLegendComponent.java
===================================================================
--- 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsLabelLegendComponent.java
                              (rev 0)
+++ 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsLabelLegendComponent.java
      2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,115 @@
+package org.openjump.core.rasterimage.styler.ui;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.util.Map;
+import java.util.TreeMap;
+import javax.swing.JComponent;
+
+/**
+ *
+ * @author GeomaticaEAmbiente
+ */
+public class ColorsLabelLegendComponent extends JComponent {
+
+    /**
+     * Constructor to create the new component formed by a JButton and a 
JLabel.
+     *
+     * @param colorMapEntries
+     * @param noDataValue
+     * @param rasterName
+     * @throws Exception
+     */
+    public ColorsLabelLegendComponent(TreeMap<Double,Color> colorMapEntries, 
double noDataValue, String rasterName) throws Exception {
+
+        this.colorMapEntries_tm = colorMapEntries;
+        this.noDataValue = noDataValue;
+        this.rasterName = rasterName;
+    }
+
+    @Override
+    public void paintComponent(Graphics g) {
+        super.paintComponent(g);
+
+        int x = 20;
+        int y;
+        int startY = 45;
+        int step = 30;
+        int maxWidth = 100;
+        FontMetrics m = g.getFontMetrics();
+
+        int i = 0, w;
+        Color color;
+        Color noDataColor = null;
+
+        g.setColor(Color.white);
+        g.fillRect(0, 0, getWidth(), getHeight());
+        g.setColor(Color.black);
+
+        g.setFont(new Font("Tahoma", Font.BOLD, 12));
+        g.drawString(rasterName, x, 20);
+
+        g.setFont(new Font("Tahoma", Font.PLAIN, 11));
+
+        //for (int n = 0; n < colorMapEntry.length; n++) {//for (Iterator iter 
= pairs.iterator(); iter.hasNext();) {
+
+        for(Map.Entry<Double,Color> colorMapEntry : 
colorMapEntries_tm.entrySet()) {
+            
+            if (colorMapEntry.getKey() == noDataValue) {
+                noDataColor = colorMapEntry.getValue();
+                continue;
+            }
+
+            y = startY + (step * i++);
+
+            color = colorMapEntry.getValue();
+
+            g.setColor(color);
+            g.fillRect(x, y, 40, 25);
+            g.setColor(Color.black);
+            g.drawRect(x, y, 40, 25);
+
+            //g.setColor(Color.black);
+            String value = Double.toString(colorMapEntry.getKey());
+            g.drawString(value, x + 60, y + 18);
+
+            w = m.stringWidth(value);
+            if (w > maxWidth) {
+                maxWidth = w;
+            }
+        }
+
+        y = startY + (step * i++);
+
+        g.setFont(new Font("Tahoma", Font.ITALIC, 11));
+        g.drawString("NoDataValue", x, y + 20);
+
+        g.setFont(new Font("Tahoma", Font.PLAIN, 11));
+        y = startY + (step * i++);
+
+        g.setColor(Color.BLACK);
+
+        g.drawRect(x, y, 40, 25);
+        if(noDataColor != null){
+            g.setColor(noDataColor);
+            g.fillRect(x, y, 40, 25);
+            g.setColor(Color.BLACK);
+        }  
+        g.drawString(Double.toString(noDataValue), x + 60, y + 18);
+
+        dimension = new Dimension(maxWidth, startY + (step * i++));
+        setPreferredSize(dimension);
+
+    }
+
+    private final java.util.ResourceBundle bundle
+            = 
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle");
 // NOI18N
+    private final TreeMap<Double,Color> colorMapEntries_tm;
+    private final double noDataValue;
+    private Dimension dimension;
+    private final String rasterName;
+
+}

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsTablePanel.java
===================================================================
--- 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsTablePanel.java    
                            (rev 0)
+++ 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/ColorsTablePanel.java    
    2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,235 @@
+package org.openjump.core.rasterimage.styler.ui;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.GridLayout;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import org.openjump.core.rasterimage.styler.ColorMapEntry;
+import org.openjump.core.rasterimage.styler.ColorUtils;
+
+/**
+ * A SWING table used to represent class intervals values and corresponding
+ * colours. The colors can be changed using a color picker.
+ * @author 
+ */
+public class ColorsTablePanel extends JPanel {
+    
+    private ColorsTablePanel() {
+        super(new GridLayout(1,0));
+    }
+    
+    /**
+     * 
+     * @param parent
+     * @param tableType
+     * @param colorMapEntries
+     * @param noDataValue 
+     * @param integerValues 
+     */
+    public ColorsTablePanel(Component parent, TableType tableType,
+            ColorMapEntry[] colorMapEntries, Double noDataValue,
+            boolean integerValues) {
+        super(new GridLayout(1,0));
+        
+        if(tableType == TableType.INTERVALS) {
+            columnNames = new String[]{
+                
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle")
+                        .getString("ColorsTablePanel.MinValue"),
+                
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle")
+                        .getString("ColorsTablePanel.Color")};
+        } else if(tableType == TableType.VALUES) {
+            columnNames = new String[]{
+                
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle")
+                        .getString("ColorsTablePanel.Value"),
+                
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle")
+                        .getString("ColorsTablePanel.Color")};
+        }
+        this.noDataValue = noDataValue;
+        this.integerValues = integerValues;
+        
+        // Create table
+        table = new JTable();
+        table.setFillsViewportHeight(true);
+        JScrollPane scrollPane = new JScrollPane(table);
+        
+        // Color renderer
+        table.setDefaultRenderer(Color.class, new ColorRenderer(true));
+        table.setDefaultEditor(Color.class, new ColorEditor(parent));        
+        updateTable(colorMapEntries);
+        add(scrollPane);
+        
+    }
+
+    public final void updateTable(ColorMapEntry[] colorMapEntries) {
+        
+        /* Check if one entry == no data */
+        int noDataEntry = -1;
+            if(noDataValue != null) {
+            for(int c=0; c<colorMapEntries.length; c++) {
+                double value = colorMapEntries[c].getUpperValue();
+
+                if(value == noDataValue ||
+                        (Double.isInfinite(value) && 
Double.isInfinite(noDataValue)) ||
+                        (Double.isNaN(value) && Double.isNaN(noDataValue))) {
+                    noDataEntry = c;
+                    break;
+                }
+            }
+        }
+        
+        int numRows = colorMapEntries.length;
+        if(noDataEntry > -1) {
+            numRows--;
+        }
+        
+        Object[][] data = new Object[numRows][columnNames.length];
+        int r = 0;
+        for(int cme=0; cme<colorMapEntries.length; cme++) {
+            if(cme==noDataEntry) {
+                continue;
+            }
+            for(int c=0; c<columnNames.length; c++) {
+                if(c == COLUMN_VALUE) {
+                    data[r][c] = colorMapEntries[cme].getUpperValue();
+                    if(integerValues) {
+                        data[r][c] = (int) 
colorMapEntries[cme].getUpperValue();
+                    }
+                } else if (c == COLUMN_COLOR) {
+                    data[r][c] = colorMapEntries[cme].getColor();
+                }
+            }
+            r++;
+        }
+        
+        table.setModel(new DefaultTableModel(data, columnNames) {
+        
+            @Override
+            public Class getColumnClass(int c) {
+                return getValueAt(0, c).getClass();
+            }
+            
+        });
+                
+        // Headers: central alignment
+        ((DefaultTableCellRenderer)table.getTableHeader().getDefaultRenderer())
+                .setHorizontalAlignment(JLabel.CENTER);
+        
+        // Labels: central alignment
+        DefaultTableCellRenderer centralAlignment = new 
DefaultTableCellRenderer();
+        centralAlignment.setHorizontalAlignment(JLabel.CENTER);
+        
table.getColumnModel().getColumn(COLUMN_VALUE).setCellRenderer(centralAlignment);
+        
+        
+        
+    }
+    
+    public ColorMapEntry[] getColorMapEntries() throws Exception {
+        
+        if(table.isEditing()) {
+            table.getCellEditor().stopCellEditing();
+        }
+        
+        ColorMapEntry[] colorMapEntries;
+        try {
+            colorMapEntries = new ColorMapEntry[table.getRowCount()];
+            for(int r=0; r<colorMapEntries.length; r++) {
+                colorMapEntries[r] = new ColorMapEntry(
+                        Double.parseDouble(table.getValueAt(r, 
COLUMN_VALUE).toString()),
+                        (Color) table.getValueAt(r, COLUMN_COLOR));
+            }
+            return colorMapEntries;
+        } catch (Exception ex) {
+            throw new Exception(
+                    
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle")
+                            .getString("ColorsTablePanel.ErrorInTable") + ex);
+        }
+        
+    }
+    
+    public void addRows() {
+
+        int selRows [] = table.getSelectedRows();
+        if (selRows.length > 0) {
+            Color color = (Color) table.getValueAt(selRows[0], COLUMN_COLOR);
+            ((DefaultTableModel)table.getModel())
+                    .insertRow(selRows[0],new Object[]{null, color});
+        } else {
+            // Get last row colour
+            Color color = (Color) table.getValueAt(table.getRowCount()-1, 
COLUMN_COLOR); 
+            
+            ((DefaultTableModel)table.getModel())
+                    .addRow(new Object[]{null, color});
+            // select the last row
+            int lastRow = table.getRowCount() - 1;
+            table.getSelectionModel().setSelectionInterval(lastRow, lastRow);
+            table.scrollRectToVisible(table.getCellRect(lastRow, 1, true));
+        }        
+
+    }
+    
+    public void removeRow() {
+        int selRows [] = table.getSelectedRows();
+        for (int i = selRows.length - 1; i >= 0 ; --i) {
+            ((DefaultTableModel)table.getModel()).removeRow(selRows[i]);
+        }
+    }
+    
+    public int getSelectedRowsCount() {
+        return table.getSelectedRowCount();
+    }
+    
+    public void rampColors() throws Exception {
+    
+        int[] selRows = table.getSelectedRows();
+        if(selRows == null || selRows.length <= 1) {
+            return;
+        }
+        
+        int startRow = selRows[0];
+        int endRow = selRows[1];
+        
+        if(startRow >= endRow) {
+            return;
+        }
+        
+        if(endRow == startRow+1) {
+            return;
+        }
+        
+        Color startColor = (Color) table.getValueAt(startRow, COLUMN_COLOR);
+        Color endColor = (Color) table.getValueAt(endRow, COLUMN_COLOR);
+        ColorUtils colorUtils = new ColorUtils();
+        
+        for(int r=startRow+1; r<endRow; r++) {
+            double relDistance = (double) (r-startRow) / (double)(endRow - 
startRow);
+            Color newColor = colorUtils.interpolateColor(startColor, endColor, 
relDistance);
+            table.setValueAt(newColor, r, COLUMN_COLOR);
+        }
+        
+        
+    }
+    
+    public static final int COLUMN_VALUE = 0;
+    public static final int COLUMN_COLOR = 1;
+    
+    private JTable table;
+    private String[] columnNames;
+    private Double noDataValue;
+    private boolean integerValues;
+    
+    public enum TableType {
+        INTERVALS, VALUES;
+    }
+    
+    public JTable getTable(){
+        return table;
+    }
+    
+    
+    
+}

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/CustomGradientColorsDialog.form
===================================================================
--- 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/CustomGradientColorsDialog.form
                              (rev 0)
+++ 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/CustomGradientColorsDialog.form
      2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.9" 
type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="minimumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+      <Dimension value="[340, 220]"/>
+    </Property>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+    <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" 
value="1"/>
+    <AuxValue name="FormSettings_autoSetComponentName" 
type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_formBundle" type="java.lang.String" 
value="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" 
value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" 
type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" 
value="true"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" 
value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" 
type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" 
value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" 
value="2"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" 
value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-69,0,0,1,76"/>
+  </AuxValues>
+
+  <Layout 
class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="jPanel_ColorTable">
+      <Properties>
+        <Property name="border" type="javax.swing.border.Border" 
editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border 
info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+            <TitledBorder/>
+          </Border>
+        </Property>
+        <Property name="minimumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[300, 200]"/>
+        </Property>
+        <Property name="preferredSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[320, 150]"/>
+        </Property>
+      </Properties>
+      <Constraints>
+        <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+          <GridBagConstraints gridX="0" gridY="0" gridWidth="2" gridHeight="1" 
fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" 
insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+        </Constraint>
+      </Constraints>
+
+      <Layout 
class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JButton" name="jButton_RemoveRow">
+          <Properties>
+            <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString 
bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties"
 key="CustomGradientColorsDialog.jButton_RemoveRow.text" 
replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString 
bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties"
 key="CustomGradientColorsDialog.jButton_RemoveRow.toolTipText" 
replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
+            </Property>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" 
handler="jButton_RemoveRowActionPerformed"/>
+          </Events>
+          <Constraints>
+            <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="1" gridY="0" gridWidth="1" 
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" 
insetsBottom="5" insetsRight="2" anchor="22" weightX="1.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+        </Component>
+        <Component class="javax.swing.JButton" name="jButton_AddRow">
+          <Properties>
+            <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString 
bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties"
 key="CustomGradientColorsDialog.jButton_AddRow.text" 
replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
+            </Property>
+            <Property name="maximumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[93, 23]"/>
+            </Property>
+            <Property name="minimumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[93, 23]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[93, 23]"/>
+            </Property>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" 
handler="jButton_AddRowActionPerformed"/>
+          </Events>
+          <Constraints>
+            <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="0" gridY="0" gridWidth="1" 
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" 
insetsBottom="5" insetsRight="5" anchor="21" weightX="1.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+        </Component>
+        <Container class="javax.swing.JPanel" name="jPanel_Table">
+          <Properties>
+            <Property name="border" type="javax.swing.border.Border" 
editor="org.netbeans.modules.form.editors2.BorderEditor">
+              <Border 
info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+                <LineBorder/>
+              </Border>
+            </Property>
+            <Property name="minimumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[250, 80]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[250, 80]"/>
+            </Property>
+          </Properties>
+          <Constraints>
+            <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="0" gridY="1" gridWidth="2" 
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" 
insetsBottom="0" insetsRight="0" anchor="23" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout 
class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+        </Container>
+        <Container class="javax.swing.JPanel" name="jPanel_Gradient">
+          <Properties>
+            <Property name="border" type="javax.swing.border.Border" 
editor="org.netbeans.modules.form.editors2.BorderEditor">
+              <Border 
info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+                <LineBorder/>
+              </Border>
+            </Property>
+            <Property name="minimumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[40, 80]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[40, 80]"/>
+            </Property>
+          </Properties>
+          <Constraints>
+            <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="3" gridY="1" gridWidth="1" 
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" 
insetsBottom="0" insetsRight="10" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout 
class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+        </Container>
+        <Component class="javax.swing.JLabel" name="jLabel_Min">
+          <Properties>
+            <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString 
bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties"
 key="CustomGradientColorsDialog.jLabel_Min.text" 
replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
+            </Property>
+          </Properties>
+          <Constraints>
+            <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="3" gridY="0" gridWidth="1" 
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" 
insetsBottom="0" insetsRight="10" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+        </Component>
+        <Component class="javax.swing.JLabel" name="jLabel_Max">
+          <Properties>
+            <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString 
bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties"
 key="CustomGradientColorsDialog.jLabel_Max.text" 
replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
+            </Property>
+          </Properties>
+          <Constraints>
+            <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="3" gridY="2" gridWidth="1" 
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="0" 
insetsBottom="0" insetsRight="10" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JButton" name="jButton_Cancel">
+      <Properties>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties"
 key="CustomGradientColorsDialog.jButton_Cancel.text" 
replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" 
handler="jButton_CancelActionPerformed"/>
+      </Events>
+      <Constraints>
+        <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+          <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" 
fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" 
insetsRight="10" anchor="22" weightX="1.0" weightY="0.0"/>
+        </Constraint>
+      </Constraints>
+    </Component>
+    <Component class="javax.swing.JButton" name="jButton_Ok">
+      <Properties>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="com/geomaticaeambiente/openjump/rasterstyles/resources/Bundle.properties"
 key="CustomGradientColorsDialog.jButton_Ok.text" 
replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
+        </Property>
+        <Property name="maximumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[65, 23]"/>
+        </Property>
+        <Property name="minimumSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[65, 23]"/>
+        </Property>
+        <Property name="preferredSize" type="java.awt.Dimension" 
editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[65, 23]"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" handler="jButton_OkActionPerformed"/>
+      </Events>
+      <Constraints>
+        <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+          <GridBagConstraints gridX="1" gridY="1" gridWidth="1" gridHeight="1" 
fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" 
insetsRight="10" anchor="22" weightX="0.0" weightY="0.0"/>
+        </Constraint>
+      </Constraints>
+    </Component>
+  </SubComponents>
+</Form>

Added: 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/CustomGradientColorsDialog.java
===================================================================
--- 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/CustomGradientColorsDialog.java
                              (rev 0)
+++ 
core/trunk/src/org/openjump/core/rasterimage/styler/ui/CustomGradientColorsDialog.java
      2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,296 @@
+package org.openjump.core.rasterimage.styler.ui;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JOptionPane;
+import org.openjump.core.rasterimage.styler.ColorMapEntry;
+import org.openjump.core.rasterimage.styler.RasterStylesExtension;
+
+/**
+ *
+ * @author GeomaticaEAmbiente
+ */
+public class CustomGradientColorsDialog extends javax.swing.JDialog {
+
+    /**
+     * Creates new form CustomGradientColors
+     * @param parent
+     * @param modal
+     * @param colorMapEntries
+     */
+   
+    public CustomGradientColorsDialog(java.awt.Frame parent, boolean modal, 
ColorMapEntry[] colorMapEntries) {
+        super(parent, modal);
+        
+        this.colorMapEntries = colorMapEntries;
+        initComponents();
+        fixComponents();
+    }
+
+    /**
+     * This method is called from within the constructor to initialize the 
form.
+     * WARNING: Do NOT modify this code. The content of this method is always
+     * regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated 
Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+        java.awt.GridBagConstraints gridBagConstraints;
+
+        jPanel_ColorTable = new javax.swing.JPanel();
+        jButton_RemoveRow = new javax.swing.JButton();
+        jButton_AddRow = new javax.swing.JButton();
+        jPanel_Table = new javax.swing.JPanel();
+        jPanel_Gradient = new javax.swing.JPanel();
+        jLabel_Min = new javax.swing.JLabel();
+        jLabel_Max = new javax.swing.JLabel();
+        jButton_Cancel = new javax.swing.JButton();
+        jButton_Ok = new javax.swing.JButton();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setMinimumSize(new java.awt.Dimension(340, 220));
+        setResizable(false);
+        getContentPane().setLayout(new java.awt.GridBagLayout());
+
+        
jPanel_ColorTable.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
+        jPanel_ColorTable.setMinimumSize(new java.awt.Dimension(300, 200));
+        jPanel_ColorTable.setPreferredSize(new java.awt.Dimension(320, 150));
+        jPanel_ColorTable.setLayout(new java.awt.GridBagLayout());
+
+        java.util.ResourceBundle bundle = 
java.util.ResourceBundle.getBundle("org/openjump/core/rasterimage/styler/resources/Bundle");
 // NOI18N
+        
jButton_RemoveRow.setText(bundle.getString("CustomGradientColorsDialog.jButton_RemoveRow.text"));
 // NOI18N
+        
jButton_RemoveRow.setToolTipText(bundle.getString("CustomGradientColorsDialog.jButton_RemoveRow.toolTipText"));
 // NOI18N
+        jButton_RemoveRow.addActionListener(new 
java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jButton_RemoveRowActionPerformed(evt);
+            }
+        });
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 1;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
+        gridBagConstraints.weightx = 1.0;
+        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 2);
+        jPanel_ColorTable.add(jButton_RemoveRow, gridBagConstraints);
+
+        
jButton_AddRow.setText(bundle.getString("CustomGradientColorsDialog.jButton_AddRow.text"));
 // NOI18N
+        jButton_AddRow.setMaximumSize(new java.awt.Dimension(93, 23));
+        jButton_AddRow.setMinimumSize(new java.awt.Dimension(93, 23));
+        jButton_AddRow.setPreferredSize(new java.awt.Dimension(93, 23));
+        jButton_AddRow.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jButton_AddRowActionPerformed(evt);
+            }
+        });
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
+        gridBagConstraints.weightx = 1.0;
+        gridBagConstraints.insets = new java.awt.Insets(0, 10, 5, 5);
+        jPanel_ColorTable.add(jButton_AddRow, gridBagConstraints);
+
+        jPanel_Table.setBorder(javax.swing.BorderFactory.createLineBorder(new 
java.awt.Color(0, 0, 0)));
+        jPanel_Table.setMinimumSize(new java.awt.Dimension(250, 80));
+        jPanel_Table.setPreferredSize(new java.awt.Dimension(250, 80));
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 1;
+        gridBagConstraints.gridwidth = 2;
+        gridBagConstraints.anchor = 
java.awt.GridBagConstraints.FIRST_LINE_START;
+        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
+        jPanel_ColorTable.add(jPanel_Table, gridBagConstraints);
+
+        
jPanel_Gradient.setBorder(javax.swing.BorderFactory.createLineBorder(new 
java.awt.Color(0, 0, 0)));
+        jPanel_Gradient.setMinimumSize(new java.awt.Dimension(40, 80));
+        jPanel_Gradient.setPreferredSize(new java.awt.Dimension(40, 80));
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 3;
+        gridBagConstraints.gridy = 1;
+        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
+        jPanel_ColorTable.add(jPanel_Gradient, gridBagConstraints);
+
+        
jLabel_Min.setText(bundle.getString("CustomGradientColorsDialog.jLabel_Min.text"));
 // NOI18N
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 3;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
+        jPanel_ColorTable.add(jLabel_Min, gridBagConstraints);
+
+        
jLabel_Max.setText(bundle.getString("CustomGradientColorsDialog.jLabel_Max.text"));
 // NOI18N
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 3;
+        gridBagConstraints.gridy = 2;
+        gridBagConstraints.insets = new java.awt.Insets(3, 0, 0, 10);
+        jPanel_ColorTable.add(jLabel_Max, gridBagConstraints);
+
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.gridwidth = 2;
+        getContentPane().add(jPanel_ColorTable, gridBagConstraints);
+
+        
jButton_Cancel.setText(bundle.getString("CustomGradientColorsDialog.jButton_Cancel.text"));
 // NOI18N
+        jButton_Cancel.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jButton_CancelActionPerformed(evt);
+            }
+        });
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 1;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
+        gridBagConstraints.weightx = 1.0;
+        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
+        getContentPane().add(jButton_Cancel, gridBagConstraints);
+
+        
jButton_Ok.setText(bundle.getString("CustomGradientColorsDialog.jButton_Ok.text"));
 // NOI18N
+        jButton_Ok.setMaximumSize(new java.awt.Dimension(65, 23));
+        jButton_Ok.setMinimumSize(new java.awt.Dimension(65, 23));
+        jButton_Ok.setPreferredSize(new java.awt.Dimension(65, 23));
+        jButton_Ok.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jButton_OkActionPerformed(evt);
+            }
+        });
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 1;
+        gridBagConstraints.gridy = 1;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
+        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
+        getContentPane().add(jButton_Ok, gridBagConstraints);
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void jButton_AddRowActionPerformed(java.awt.event.ActionEvent evt) 
{//GEN-FIRST:event_jButton_AddRowActionPerformed
+
+        addRow();
+        
+    }//GEN-LAST:event_jButton_AddRowActionPerformed
+
+    private void jButton_RemoveRowActionPerformed(java.awt.event.ActionEvent 
evt) {//GEN-FIRST:event_jButton_RemoveRowActionPerformed
+
+        removeRow();
+        
+    }//GEN-LAST:event_jButton_RemoveRowActionPerformed
+
+    private void jButton_CancelActionPerformed(java.awt.event.ActionEvent evt) 
{//GEN-FIRST:event_jButton_CancelActionPerformed
+
+        colorMapEntries = null;
+        dispose();
+        
+    }//GEN-LAST:event_jButton_CancelActionPerformed
+
+    private void jButton_OkActionPerformed(java.awt.event.ActionEvent evt) 
{//GEN-FIRST:event_jButton_OkActionPerformed
+        
+        try {
+            okButton();
+        } catch (Exception ex) {
+            
Logger.getLogger(CustomGradientColorsDialog.class.getName()).log(Level.SEVERE, 
null, ex);
+        }
+        
+        
+    }//GEN-LAST:event_jButton_OkActionPerformed
+
+    private void fixComponents(){
+
+        this.setTitle(RasterStylesExtension.extensionName);
+        
+        colorsTablePanel = new GradientTablePanel(this, 
ColorsTablePanel.TableType.VALUES,
+        colorMapEntries, -9999.0, false, jPanel_Gradient);      
+        
+        colorsTablePanel.setMinimumSize(new java.awt.Dimension(250, 80));
+        colorsTablePanel.setPreferredSize(new java.awt.Dimension(250, 80)); 
+                
+        java.awt.GridBagConstraints gridBagConstraints = new 
java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 1;
+        gridBagConstraints.gridwidth = 2;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
+        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
+        
+        jPanel_ColorTable.remove(jPanel_Table);
+       
+        jPanel_ColorTable.add(colorsTablePanel, gridBagConstraints);
+        
+        //update gradient panel
+        GUIUtils utils = new GUIUtils();
+        utils.setGradientPanel(jPanel_Gradient, colorMapEntries);
+        
+        validate();
+    }
+    
+    /**
+     * Method to memorize the colors in the table in ColorMapEntry object.
+     * @throws Exception 
+     */
+    private void okButton() throws Exception{
+        
+        //Checks values
+        ColorMapEntry[] cme = colorsTablePanel.getColorMapEntries();
+        
+        //Check if colors are more than 1
+        if(cme.length < 2){
+            JOptionPane.showMessageDialog(this, 
+                    
bundle.getString("GradientTablePanel.ColorsNumber.message"), 
+                    RasterStylesExtension.extensionName, 
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }        
+        
+        //Memorizes fraction values
+        double[] values = new double[cme.length];        
+        for(int n=0; n<values.length; n++){
+            values[n] = cme[n].getUpperValue();
+        }
+        
+        //Checks if fraction are in ascending order and if there are two equal 
values
+        double tempValue = values[0];
+        for(int v=1; v<values.length; v++){
+            if(values[v] <= tempValue ||  values[v]>1){
+
+                    JOptionPane.showMessageDialog(this, 
+                            
bundle.getString("GradientTablePanel.FractionValues.message"), 
+                            RasterStylesExtension.extensionName, 
+                            JOptionPane.INFORMATION_MESSAGE);
+                return;
+            }
+            tempValue = values[v];
+        } 
+        
+        colorMapEntries = cme;
+        dispose();
+        
+    }
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton jButton_AddRow;
+    private javax.swing.JButton jButton_Cancel;
+    private javax.swing.JButton jButton_Ok;
+    private javax.swing.JButton jButton_RemoveRow;
+    private javax.swing.JLabel jLabel_Max;
+    private javax.swing.JLabel jLabel_Min;
+    private javax.swing.JPanel jPanel_ColorTable;
+    private javax.swing.JPanel jPanel_Gradient;
+    private javax.swing.JPanel jPanel_Table;
+    // End of variables declaration//GEN-END:variables
+
+    private GradientTablePanel colorsTablePanel;
+    private ColorMapEntry[] colorMapEntries;
+    private final java.util.ResourceBundle bundle = 
java.util.ResourceBundle.getBundle
+        ("org/openjump/core/rasterimage/styler/resources/Bundle"); // NOI18N
+    
+    public ColorMapEntry[] getColorMapEntries(){
+        return colorMapEntries;
+    }
+    
+    private void addRow(){
+        colorsTablePanel.addRows();
+    }
+    
+    private void removeRow() {
+        colorsTablePanel.removeRow();
+    }
+    
+}

Added: core/trunk/src/org/openjump/core/rasterimage/styler/ui/GUIUtils.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/styler/ui/GUIUtils.java        
                        (rev 0)
+++ core/trunk/src/org/openjump/core/rasterimage/styler/ui/GUIUtils.java        
2015-06-18 15:50:25 UTC (rev 4504)
@@ -0,0 +1,218 @@
+package org.openjump.core.rasterimage.styler.ui;
+
+import org.openjump.core.rasterimage.styler.RasterStylesExtension;
+import com.vividsolutions.jump.util.Range;
+import com.vividsolutions.jump.workbench.WorkbenchContext;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import javax.swing.JPanel;
+import org.openjump.core.rasterimage.styler.ColorMapEntry;
+import org.openjump.core.rasterimage.RasterImageLayer;
+
+/**
+ *
+ * @author GeomaticaEAmbiente
+ */
+public class GUIUtils {
+
+    /**
+     * Method to return the min value of a RasterImageLayer
+     *
+     * @param rasterData
+     * @param rasterImageLayer
+     * @return
+     */
+    public static Range getMinMaxRasterValue(double[] rasterData, 
RasterImageLayer rasterImageLayer) {
+
+        double minValue = Double.MAX_VALUE;
+        double maxValue = -minValue;
+
+        for (int v = 0; v < rasterData.length; v++) {
+
+            if (rasterData[v] < minValue && 
!(rasterImageLayer.isNoData(rasterData[v]))) {
+                minValue = rasterData[v];
+            }
+
+            if (rasterData[v] > maxValue && 
!(rasterImageLayer.isNoData(rasterData[v]))) {
+                maxValue = rasterData[v];
+            }
+        }
+
+        return new Range(minValue, true, maxValue, true);
+
+    }
+
+    /**
+     * Method to convert the trasparency value from 0-100 range (0 means that
+     * the color is completely opaque and 100 the color is completely
+     * trasparent) to 0-255 range (0 menas that the color is completely
+     * trasparent and 255 that the color is completely opaque)
+     *
+     * @param range_0_100_Value
+     * @return
+     */
+    public static int getAlpha_0_255Range(int range_0_100_Value) {
+
+        int traspValue_100 = 100 - range_0_100_Value;
+        int alphaValue = (255 * traspValue_100) / 100;
+
+        return alphaValue;
+    }
+
+    /*
+     * Method to convert the trasparency value from 0-100 range (0 means that 
the color 
+     * is completely opaque and 100 the color is completely trasparent) to 
0-1.0 range (0 menas that the color is
+     * completely opaque and 1.0 that the color is completely trasparent)
+     */
+    public static float getAlpha_DecimalRange(int range_0_100_Value) {
+
+//        float traspValue_100 = 100 - range_0_100_Value;
+        float alphaValue = range_0_100_Value / 100f;
+
+        return alphaValue;
+    }
+
+    /**
+     * Method for displayin in a panel a gradient
+     *
+     * @param panel Panel on which display the gradient

@@ Diff output truncated at 100000 characters. @@

------------------------------------------------------------------------------
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to