Index: GrayScaleOperation.java
===================================================================
--- GrayScaleOperation.java	(revision 43861)
+++ GrayScaleOperation.java	(revision 43862)
@@ -23,24 +23,19 @@
 package org.gvsig.raster.lib.legend.impl.operations.grayscale;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
-import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
 import org.gvsig.raster.lib.buffer.api.Band;
 import org.gvsig.raster.lib.buffer.api.BufferLocator;
 import org.gvsig.raster.lib.buffer.api.BufferManager;
 import org.gvsig.raster.lib.buffer.api.NoData;
-import org.gvsig.raster.lib.buffer.api.exceptions.BufferException;
 import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
 import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
 import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
-import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation;
 import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
 import org.gvsig.raster.lib.legend.api.RasterLegendManager;
 import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
 import org.gvsig.raster.lib.legend.spi.AbstractColoredOperation;
-import org.gvsig.tools.locator.LocatorException;
 
 
 /**
@@ -54,7 +49,7 @@
      *
      */
     public GrayScaleOperation(OperationFactory factory) {
-        this.factory = factory;
+        super(factory);
     }
 
     @Override
@@ -65,20 +60,20 @@
 
         try {
 
-            if (!(colorInterpretation.hasAnyRGBBand() || colorInterpretation.hasAnyGrayBand())) {
+            if (!(getInputColorInterpretation().hasAnyRGBBand() || getInputColorInterpretation().hasAnyGrayBand())) {
                 throw new UnsupportedOperationException(
                     "The color interpretation of input buffer isn't RGB nor GRAYSCALE");
             }
 
-            int[] inputBandTypes = buffer.getBandTypes();
-            if (colorInterpretation.hasAnyRGBBand()) {
-                if ((colorInterpretation.getBand(ColorInterpretation.RED_BAND)>=0 && inputBandTypes[colorInterpretation.getBand(ColorInterpretation.RED_BAND)] != BufferManager.TYPE_BYTE)
-                    || (colorInterpretation.getBand(ColorInterpretation.GREEN_BAND)>=0 && inputBandTypes[colorInterpretation.getBand(ColorInterpretation.GREEN_BAND)] != BufferManager.TYPE_BYTE)
-                    || (colorInterpretation.getBand(ColorInterpretation.BLUE_BAND)>=0 && inputBandTypes[colorInterpretation.getBand(ColorInterpretation.BLUE_BAND)] != BufferManager.TYPE_BYTE)) {
+            int[] inputBandTypes = getInputBuffer().getBandTypes();
+            if (getInputColorInterpretation().hasAnyRGBBand()) {
+                if ((getInputColorInterpretation().getBand(ColorInterpretation.RED_BAND)>=0 && inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.RED_BAND)] != BufferManager.TYPE_BYTE)
+                    || (getInputColorInterpretation().getBand(ColorInterpretation.GREEN_BAND)>=0 && inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.GREEN_BAND)] != BufferManager.TYPE_BYTE)
+                    || (getInputColorInterpretation().getBand(ColorInterpretation.BLUE_BAND)>=0 && inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.BLUE_BAND)] != BufferManager.TYPE_BYTE)) {
                     throw new UnsupportedOperationException("The type of bands isn't BYTE");
                 }
-            } else if (colorInterpretation.hasAnyGrayBand()) {
-                if ((colorInterpretation.getBand(ColorInterpretation.GRAY_BAND)>=0 && inputBandTypes[colorInterpretation.getBand(ColorInterpretation.GRAY_BAND)] != BufferManager.TYPE_BYTE)) {
+            } else if (getInputColorInterpretation().hasAnyGrayBand()) {
+                if ((getInputColorInterpretation().getBand(ColorInterpretation.GRAY_BAND)>=0 && inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.GRAY_BAND)] != BufferManager.TYPE_BYTE)) {
                     throw new UnsupportedOperationException("The type of band gray isn't BYTE");
                 }
             } else {
@@ -86,49 +81,48 @@
                     "The color interpretation of input buffer isn't RGB nor GRAYSCALE");
             }
 
-            int sourceBands = this.buffer.getBandCount();
-            NoData[] sourceNoDatas = this.buffer.getBandNoData();
-            int[] sourceTypes = this.buffer.getBandTypes();
+            int sourceBands = this.getInputBuffer().getBandCount();
+            NoData[] sourceNoDatas = this.getInputBuffer().getBandNoData();
+            int[] sourceTypes = this.getInputBuffer().getBandTypes();
 
-            List<String> colorInterpretations = new ArrayList<String>();
-            List<NoData> noDatas = new ArrayList<NoData>();
-            List<Integer> types = new ArrayList<Integer>();
+            List<String> colorInterpretations = new ArrayList<>();
+            List<NoData> noDatas = new ArrayList<>();
+            List<Integer> types = new ArrayList<>();
 
             colorInterpretations.add(ColorInterpretation.GRAY_BAND);
             types.add(BufferManager.TYPE_BYTE);
             noDatas.add(null);
 
-            if (colorInterpretation.hasAlphaBand()) {
-                if(sourceTypes[colorInterpretation.getAlphaBand()]!=BufferManager.TYPE_BYTE){
+            if (getInputColorInterpretation().hasAlphaBand()) {
+                if(sourceTypes[getInputColorInterpretation().getAlphaBand()]!=BufferManager.TYPE_BYTE){
                     throw new UnsupportedOperationException("The type of ALPHA band isn't BYTE");
                 }
                 colorInterpretations.add(ColorInterpretation.ALPHA_BAND);
-                types.add(sourceTypes[colorInterpretation.getAlphaBand()]);
-                noDatas.add(sourceNoDatas[colorInterpretation.getAlphaBand()]);
+                types.add(sourceTypes[getInputColorInterpretation().getAlphaBand()]);
+                noDatas.add(sourceNoDatas[getInputColorInterpretation().getAlphaBand()]);
             }
 
-            if (copyUnprocessedBands) {
+            if (mustCopyUnprocessedBands()) {
                 for (int band = 0; band < sourceBands; band++) {
-                    if (!isProcessableBand(band) && !colorInterpretation.isAlphaInterpretation(band)) {
-                        colorInterpretations.add(colorInterpretation.get(band));
+                    if (!isProcessableBand(band) && !getInputColorInterpretation().isAlphaInterpretation(band)) {
+                        colorInterpretations.add(getInputColorInterpretation().get(band));
                         noDatas.add(sourceNoDatas[band]);
-                        types.add(this.buffer.getBandTypes()[band]);
+                        types.add(this.getInputBuffer().getBandTypes()[band]);
                     }
                 }
             }
-            outputColorInterpretation =
-                legendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
-            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, outputColorInterpretation);
-            int[] typesInt = new int[types.size()];
-            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
-                int i = 0;
-                Integer type = (Integer) iterator.next();
-                typesInt[i] = type.intValue();
-            }
-            this.outputBuffer =
-                manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
-                    noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
-        } catch (LocatorException | BufferException | CreateEnvelopeException e) {
+            setOutputColorInterpretation(
+                legendManager.createColorInterpretation(colorInterpretations));
+            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getOutputColorInterpretation());
+            this.setOutputBuffer(
+                manager.createBuffer(
+                        this.getInputBuffer().getRows(), 
+                        this.getInputBuffer().getColumns(), 
+                        this.getTypesAsArray(types),
+                        this.getNoDatasAsArray(noDatas), 
+                        this.getInputBuffer().getProjection(), 
+                        this.getInputBuffer().getEnvelope()));
+        } catch (Exception e) {
             throw new ProcessingOperationException(e);
         }
     }
@@ -139,25 +133,25 @@
             super.process();
             List<Integer> bandsToProcess = new ArrayList<Integer>();
 
-            Band outputBufferBand = outputBuffer.getBand(0);
+            Band outputBufferBand = getOutputBuffer().getBand(0);
             boolean processed = false;
-            if (copyUnprocessedBands) {
-                int bands = this.buffer.getBandCount();
-                int outBand = colorInterpretation.hasAlphaBand() ? 2 : 1;
+            if (mustCopyUnprocessedBands()) {
+                int bands = this.getInputBuffer().getBandCount();
+                int outBand = getInputColorInterpretation().hasAlphaBand() ? 2 : 1;
                 for (int band = 0; band < bands; band++) {
                     if (isProcessableBand(band)) {
-                        if (colorInterpretation.isGrayInterpretation(band)) {
-                            outputBufferBand.copyFrom(this.buffer.getBand(band));
+                        if (getInputColorInterpretation().isGrayInterpretation(band)) {
+                            outputBufferBand.copyFrom(this.getInputBuffer().getBand(band));
                             processed = true;
                         } else {
                             bandsToProcess.add(band);
                         }
-                    } else if (colorInterpretation.isAlphaInterpretation(band)) {
-                        outputBuffer.getBand(outputColorInterpretation.getAlphaBand()).copyFrom(
-                            this.buffer.getBand(band));
+                    } else if (getInputColorInterpretation().isAlphaInterpretation(band)) {
+                        getOutputBuffer().getBand(getOutputColorInterpretation().getAlphaBand()).copyFrom(
+                            this.getInputBuffer().getBand(band));
                     } else {
-                        outputBuffer.getBand(outBand).copyFrom(
-                            this.buffer.getBand(band));
+                        getOutputBuffer().getBand(outBand).copyFrom(
+                            this.getInputBuffer().getBand(band));
                         outBand++;
                     }
                 }
@@ -165,11 +159,11 @@
 
             if (!processed) {
                 Object[] rowBandsBuffer = new Object[bandsToProcess.size()];
-                for (int row = 0; row < this.buffer.getRows(); row++) {
+                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
                     for (int i = 0; i < bandsToProcess.size(); i++) {
                         Integer band = bandsToProcess.get(i);
                         if (isProcessableBand(band)) {
-                            Band bufferBand = buffer.getBand(band);
+                            Band bufferBand = getInputBuffer().getBand(band);
                             rowBandsBuffer[i] = bufferBand.createRowBuffer();
                             bufferBand.fetchRow(row, rowBandsBuffer[i]);
                         }
@@ -188,12 +182,13 @@
      * @param band
      * @return
      */
-    private boolean isProcessableBand(int band) {
-        return isRGBorGrayBand(band) && this.buffer.getBandTypes()[band] == BufferManager.TYPE_BYTE;
+    @Override
+    protected boolean isProcessableBand(int band) {
+        return isRGBorGrayBand(band) && this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_BYTE;
     }
 
     private boolean isRGBorGrayBand(int band) {
-        String bandColorInterpretation = colorInterpretation.get(band);
+        String bandColorInterpretation = getInputColorInterpretation().get(band);
         return (bandColorInterpretation.equals(ColorInterpretation.RED_BAND)
             || bandColorInterpretation.equals(ColorInterpretation.GREEN_BAND)
             || bandColorInterpretation.equals(ColorInterpretation.BLUE_BAND) || bandColorInterpretation
