Index: ColorTableOperation.java
===================================================================
--- ColorTableOperation.java	(revision 43861)
+++ ColorTableOperation.java	(revision 43862)
@@ -23,7 +23,6 @@
 package org.gvsig.raster.lib.legend.impl.operations.colortable;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
@@ -35,12 +34,9 @@
 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.impl.ColorManager;
-import org.gvsig.raster.lib.legend.impl.RasterLegendManagerServices;
 import org.gvsig.raster.lib.legend.spi.AbstractColoredOperation;
 import org.gvsig.tools.locator.LocatorException;
 
@@ -59,7 +55,7 @@
      *
      */
     public ColorTableOperation(OperationFactory factory) {
-        this.factory = factory;
+        super(factory);
     }
 
     @Override
@@ -69,11 +65,11 @@
         RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
 
         try {
-            if (!colorInterpretation.isPalette()) {
+            if (!getInputColorInterpretation().isPalette()) {
                 throw new UnsupportedOperationException("The color interpretation of input buffer isn't Palette");
             }
 
-            int bandType = this.buffer.getBand(colorInterpretation.getPaletteBand()).getDataType();
+            int bandType = this.getInputBuffer().getBand(getInputColorInterpretation().getPaletteBand()).getDataType();
             switch (bandType) {
             case BufferManager.TYPE_BYTE:
                 rowProcessor = new ByteRowProcessor();
@@ -94,17 +90,17 @@
                 rowProcessor = new DoubleRowProcessor();
                 break;
             default:
-                throw new IllegalArgumentException("Unknow type of band '"+colorInterpretation.getPaletteBand()+"'");
+                throw new IllegalArgumentException("Unknow type of band '"+getInputColorInterpretation().getPaletteBand()+"'");
             }
 
 
-            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.RED_BAND);
             colorInterpretations.add(ColorInterpretation.GREEN_BAND);
@@ -121,8 +117,8 @@
             noDatas.add(null);
             noDatas.add(null);
 
-//            if (colorInterpretation.hasAlphaBand()) {
-//                int alphaBand = colorInterpretation.getAlphaBand();
+//            if (getInputColorInterpretation().hasAlphaBand()) {
+//                int alphaBand = getInputColorInterpretation().getAlphaBand();
 //                if(sourceTypes[alphaBand]!=BufferManager.TYPE_BYTE){
 //                    throw new UnsupportedOperationException("The type of ALPHA band isn't BYTE");
 //                }
@@ -131,29 +127,28 @@
 //                noDatas.add(sourceNoDatas[alphaBand]);
 //            }
 
-            if (copyUnprocessedBands) {
+            if (mustCopyUnprocessedBands()) {
                 for (int band = 0; band < sourceBands; band++) {
                     if (!isProcessableBand(band)) {
                         colorInterpretations.add(ColorInterpretation.UNDEFINED_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();
-            }
+            setOutputColorInterpretation(
+                legendManager.createColorInterpretation(colorInterpretations));
+            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getOutputColorInterpretation());
 
-            this.outputBuffer =
-                manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
-                    noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
+            this.setOutputBuffer(
+                manager.createBuffer(
+                        this.getInputBuffer().getRows(), 
+                        this.getInputBuffer().getColumns(), 
+                        this.getTypesAsArray(types),
+                        this.getNoDatasAsArray(noDatas), 
+                        this.getInputBuffer().getProjection(), 
+                        this.getInputBuffer().getEnvelope()));
         } catch (LocatorException | BufferException | CreateEnvelopeException e) {
             throw new ProcessingOperationException(e);
         }
@@ -166,25 +161,25 @@
 
             // List<Integer> bandsToProcess = new ArrayList<Integer>();
 
-            if (copyUnprocessedBands) {
-                int bands = this.buffer.getBandCount();
-                int outBand = 4; //colorInterpretation.hasAlphaBand() ? 4 : 3;
+            if (mustCopyUnprocessedBands()) {
+                int bands = this.getInputBuffer().getBandCount();
+                int outBand = 4; //getInputColorInterpretation().hasAlphaBand() ? 4 : 3;
                 for (int band = 0; band < bands; band++) {
                     if (!isProcessableBand(band)) {
-                        outputBuffer.getBand(outBand).copyFrom(this.buffer.getBand(band));
+                        getOutputBuffer().getBand(outBand).copyFrom(this.getInputBuffer().getBand(band));
                         outBand++;
                     }
                 }
             }
 
-            for (int row = 0; row < this.buffer.getRows(); row++) {
-                Band bufferPaletteBand = buffer.getBand(colorInterpretation.getPaletteBand());
+            for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
+                Band bufferPaletteBand = getInputBuffer().getBand(getInputColorInterpretation().getPaletteBand());
                 Object rowBandBuffer = bufferPaletteBand.createRowBuffer();
                 bufferPaletteBand.fetchRow(row, rowBandBuffer);
 
-                List<Object> outputRowBuffers = new ArrayList<Object>();
+                List<Object> outputRowBuffers = new ArrayList<>();
                 for (int band = 0; band < 4; band++) {
-                    Band outputBufferBand = outputBuffer.getBand(band);
+                    Band outputBufferBand = getOutputBuffer().getBand(band);
                     Object outputRowBuffer = outputBufferBand.createRowBuffer();
                     outputRowBuffers.add(outputRowBuffer);
                 }
@@ -192,7 +187,7 @@
                 rowProcessor.processRow(rowBandBuffer, outputRowBuffers);
 
                 for (int band = 0; band < 4; band++) {
-                    Band outputBufferBand = outputBuffer.getBand(band);
+                    Band outputBufferBand = getOutputBuffer().getBand(band);
                     outputBufferBand.putRow(row, outputRowBuffers.get(band));
                 }
 
@@ -212,12 +207,13 @@
      * @param band
      * @return
      */
-    private boolean isProcessableBand(int band) {
+    @Override
+    protected boolean isProcessableBand(int band) {
         return isPaletteBand(band);
     }
 
     private boolean isPaletteBand(int band) {
-        return (colorInterpretation.getPaletteBand() == band);
+        return (getInputColorInterpretation().getPaletteBand() == band);
     }
 
 
@@ -231,7 +227,7 @@
         NoData noData;
 
         public AbstractRowProcessor() {
-            noData = buffer.getBand(colorInterpretation.getPaletteBand()).getNoData();
+            noData = getInputBuffer().getBand(getInputColorInterpretation().getPaletteBand()).getNoData();
         }
     }
 
@@ -265,7 +261,7 @@
                 }
             }
 
-            return colorInterpretation.getPalette().getRGBA(0xFF & (byte)value);
+            return getInputColorInterpretation().getPalette().getRGBA(0xFF & (byte)value);
         }
 
     }
@@ -295,7 +291,7 @@
                 return result;
             }
 
-            return colorInterpretation.getPalette().getRGBA(value);
+            return getInputColorInterpretation().getPalette().getRGBA(value);
         }
 
     }
@@ -325,7 +321,7 @@
                 return result;
             }
 
-            return colorInterpretation.getPalette().getRGBA(0xFFFF & (byte)value);
+            return getInputColorInterpretation().getPalette().getRGBA(0xFFFF & (byte)value);
         }
 
     }
@@ -355,7 +351,7 @@
                 return result;
             }
 
-            return colorInterpretation.getPalette().getRGBA(value);
+            return getInputColorInterpretation().getPalette().getRGBA(value);
         }
 
     }
@@ -384,7 +380,7 @@
                 return result;
             }
 
-            return colorInterpretation.getPalette().getRGBA(value);
+            return getInputColorInterpretation().getPalette().getRGBA(value);
         }
 
     }
@@ -415,7 +411,7 @@
                 return result;
             }
 
-            return colorInterpretation.getPalette().getRGBA(value);
+            return getInputColorInterpretation().getPalette().getRGBA(value);
         }
 
     }
