Revision 8682 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.legend/org.gvsig.raster.lib.legend.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/colortable/ColorTableOperation.java

View differences:

ColorTableOperation.java
34 34
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException;
35 35
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
36 36
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
37
import org.gvsig.raster.lib.buffer.impl.exceptions.ProcessingOperationException;
37
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
38 38
import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation;
39 39
import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
40 40
import org.gvsig.raster.lib.legend.api.RasterLegendManager;
41 41
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
42 42
import org.gvsig.raster.lib.legend.impl.ColorManager;
43 43
import org.gvsig.raster.lib.legend.impl.RasterLegendManagerServices;
44
import org.gvsig.raster.lib.legend.spi.AbstractColoredOperation;
44 45
import org.gvsig.tools.locator.LocatorException;
45 46

  
46 47

  
......
48 49
 * @author fdiaz
49 50
 *
50 51
 */
51
public class ColorTableOperation extends AbstractOperation {
52
public class ColorTableOperation extends AbstractColoredOperation {
52 53

  
53
    static public String COLOR_INTERPRETATION_PARAM = "color_interpretation";
54
    static public String COPY_UNPROCESSED_BANDS_PARAM = "copy_unprocessed_bands";
55
    static public String OUTPUT_COLOR_INTERPRETATION_PARAM = "output_color_interpretation";
56

  
57
    private ColorInterpretation colorInterpretation;
58
    private boolean copyUnprocessedBands;
59
    private ColorInterpretation outputColorInterpretation;
60 54
    private RowProcessor rowProcessor;
61 55

  
62 56

  
......
70 64

  
71 65
    @Override
72 66
    public void preProcess() throws BufferOperationException {
67
        super.preProcess();
73 68
        BufferManager manager = BufferLocator.getBufferManager();
74 69
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
75 70

  
76
        colorInterpretation = (ColorInterpretation) this.parameters.getDynValue(COLOR_INTERPRETATION_PARAM);
77
        if (this.parameters.hasDynValue(COPY_UNPROCESSED_BANDS_PARAM)) {
78
            copyUnprocessedBands = (Boolean) this.parameters.getDynValue(COPY_UNPROCESSED_BANDS_PARAM);
79
        } else {
80
            copyUnprocessedBands = true;
81
        }
82

  
83 71
        try {
84 72
            if (!colorInterpretation.isPalette()) {
85 73
                throw new UnsupportedOperationException("The color interpretation of input buffer isn't Palette");
......
173 161

  
174 162
    @Override
175 163
    public void process() throws ProcessingOperationException {
164
        super.process();
176 165
        try {
177 166

  
178 167
            // List<Integer> bandsToProcess = new ArrayList<Integer>();
......
188 177
                }
189 178
            }
190 179

  
191
//            Object[] rowBandsBuffer = new Object[4];
192

  
193 180
            for (int row = 0; row < this.buffer.getRows(); row++) {
194 181
                Band bufferPaletteBand = buffer.getBand(colorInterpretation.getPaletteBand());
195 182
                Object rowBandBuffer = bufferPaletteBand.createRowBuffer();
196 183
                bufferPaletteBand.fetchRow(row, rowBandBuffer);
197
//                Band bufferBandMagenta = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.MAGENTA_BAND));
198
//                rowBandsBuffer[1] = bufferBandMagenta.createRowBuffer();
199
//                bufferBandMagenta.fetchRow(row, rowBandsBuffer[1]);
200
//                Band bufferBandYellow = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.YELLOW_BAND));
201
//                rowBandsBuffer[2] = bufferBandYellow.createRowBuffer();
202
//                bufferBandYellow.fetchRow(row, rowBandsBuffer[2]);
203
//                Band bufferBandBlack = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.BLACK_BAND));
204
//                rowBandsBuffer[3] = bufferBandBlack.createRowBuffer();
205
//                bufferBandBlack.fetchRow(row, rowBandsBuffer[3]);
206 184

  
207 185
                List<Object> outputRowBuffers = new ArrayList<Object>();
208 186
                for (int band = 0; band < 4; band++) {
......
227 205

  
228 206
    @Override
229 207
    public void postProcess() throws BufferOperationException {
230
        // TODO Auto-generated method stub
231

  
208
        super.postProcess();
232 209
    }
233 210

  
234
//    private void processRow(Object inputRow, List outputRows) {
235
//        ColorManager colorManager = ((RasterLegendManagerServices)RasterLegendLocator.getRasterLegendManager()).getColorManager();
236
//        Object[] inputNumberRow = (Object[]) inputRow; //new byte[((byte[]) inputRow).length];
237
//
238
//        int[] convertedValues = new int[3];
239
//        for (int i = 0; i < inputNumberRow.length; i++) {
240
//
241
//            byte[] rgb = colorInterpretation.getPalette().getRGBA(inputNumberRow[i]);
242
//
243
//            for (int band = 0; band < outputRows.size(); band++) {
244
//                ((byte[])(outputRows.get(band)))[i] = rgb[band];
245
//            }
246
//        }
247
//    }
248

  
249 211
    /**
250 212
     * @param band
251 213
     * @return

Also available in: Unified diff