Revision 43862

View differences:

branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.api/src/main/java/org/gvsig/raster/lib/buffer/api/operations/Operation.java
25 25
import org.gvsig.raster.lib.buffer.api.Buffer;
26 26
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
27 27
import org.gvsig.tools.dynobject.DynObject;
28
import org.gvsig.tools.operations.OperationException;
29
import org.gvsig.tools.persistence.Persistent;
28
import org.gvsig.tools.task.TaskStatus;
30 29

  
31 30

  
32 31
/**
......
36 35
public interface Operation{
37 36

  
38 37
    /**
38
     * @param status
39 39
     * @param buffer
40 40
     * @param parameters
41 41
     * @return the buffer result of executing the operation
42
     * @throws OperationException
43 42
     * @throws BufferOperationException
44 43
     */
45
    public Buffer execute(Buffer buffer, DynObject parameters) throws BufferOperationException;
44
    public Buffer execute(TaskStatus status, Buffer buffer, DynObject parameters) throws BufferOperationException;
46 45

  
47 46
    /**
48 47
     * @return the factory
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.api/src/main/java/org/gvsig/raster/lib/buffer/api/operations/InvalidLookupParametersException.java
41 41
     * @author fdiaz
42 42
     *
43 43
     */
44
    public class Problem {
44
    public static class Problem {
45 45

  
46
        private String operation;
47
        private String parameterName;
48
        private String lookupParameterName;
46
        private final String operation;
47
        private final String parameterName;
48
        private final String lookupParameterName;
49 49

  
50 50
        /**
51 51
         * @param operation
......
108 108
    @Override
109 109
    public String getMessage() {
110 110
        StringBuilder message = new StringBuilder("Problems to validate lookup parameters:\n");
111
        for (Iterator<Problem> iterator = problems.iterator(); iterator.hasNext();) {
112
            Problem problem = (Problem) iterator.next();
111
        for (Problem problem : problems) {
113 112
            message.append("The parameter ");
114 113
            message.append(problem.parameterName);
115 114
            message.append("of the operation ");
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.api/src/main/java/org/gvsig/raster/lib/buffer/api/operations/OperationList.java
28 28
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
29 29
import org.gvsig.tools.dynobject.DynObject;
30 30
import org.gvsig.tools.observer.WeakReferencingObservable;
31
import org.gvsig.tools.operations.OperationException;
32 31
import org.gvsig.tools.persistence.Persistent;
33 32
import org.gvsig.tools.lang.Cloneable;
33
import org.gvsig.tools.task.TaskStatus;
34 34

  
35 35

  
36 36
/**
......
40 40
public interface OperationList extends List<OperationListEntry>, WeakReferencingObservable, Persistent, Cloneable {
41 41

  
42 42
    /**
43
     * @param status
43 44
     * @param buffer
44 45
     * @return the buffer result of executing the operations list in chained fashion
45
     * @throws OperationException
46 46
     * @throws BufferOperationException
47 47
     */
48
    public Buffer execute(Buffer buffer) throws BufferOperationException;
48
    public Buffer execute(TaskStatus status, Buffer buffer) throws BufferOperationException;
49 49

  
50 50
    /**
51 51
     * @param operation
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.api/src/main/java/org/gvsig/raster/lib/buffer/api/OperationManager.java
30 30
import org.gvsig.raster.lib.buffer.api.operations.OperationList;
31 31
import org.gvsig.raster.lib.buffer.api.operations.OperationListEntry;
32 32
import org.gvsig.tools.dynobject.DynObject;
33
import org.gvsig.tools.task.TaskStatus;
33 34

  
34 35

  
35 36
/**
......
85 86
    public OperationFactory getOperationFactory(String name);
86 87

  
87 88
    /**
89
     * @param status
88 90
     * @param name
89 91
     * @param buffer
90 92
     * @param parameters
91 93
     * @return the buffer result of executing the operation
92 94
     * @throws BufferOperationException
93 95
     */
94
    public Buffer execute (String name, Buffer buffer, DynObject parameters) throws BufferOperationException;
96
    public Buffer execute (TaskStatus status, String name, Buffer buffer, DynObject parameters) throws BufferOperationException;
95 97

  
96 98

  
97 99
};
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/raster/lib/legend/impl/DefaultRasterLegendManager.java
219 219
    }
220 220

  
221 221
    @Override
222
    public ColorInterpretation createColorInterpretation(List<String> coloInterpretations) {
223
        String[] x = coloInterpretations.toArray(new String[coloInterpretations.size()]);
224
        return new DefaultColorInterpretation(x);
225
    }
226

  
227
    @Override
222 228
    public ColorInterpretation createColorInterpretation(String definedColorInterpretation) {
223 229
        return new DefaultColorInterpretation(definedColorInterpretation);
224 230
    }
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/cmyktorgb/CMYKToRGBOperation.java
23 23
package org.gvsig.raster.lib.legend.impl.operations.cmyktorgb;
24 24

  
25 25
import java.util.ArrayList;
26
import java.util.Iterator;
27 26
import java.util.List;
28 27

  
29 28
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
......
35 34
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
36 35
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
37 36
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
38
import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation;
39 37
import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
40 38
import org.gvsig.raster.lib.legend.api.RasterLegendManager;
41 39
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
......
56 54
     *
57 55
     */
58 56
    public CMYKToRGBOperation(OperationFactory factory) {
59
        this.factory = factory;
57
        super(factory);
60 58
    }
61 59

  
62 60
    @Override
......
67 65

  
68 66

  
69 67
        try {
70
            if (!colorInterpretation.isCMYK()) {
68
            if (!this.getInputColorInterpretation().isCMYK()) {
71 69
                throw new UnsupportedOperationException("The color interpretation of input buffer isn't CMYK");
72 70
            }
73 71

  
74
            int[] inputBandTypes = buffer.getBandTypes();
75
            if (inputBandTypes[colorInterpretation.getBand(ColorInterpretation.CYAN_BAND)] != BufferManager.TYPE_BYTE
76
                || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.MAGENTA_BAND)] != BufferManager.TYPE_BYTE
77
                || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.YELLOW_BAND)] != BufferManager.TYPE_BYTE
78
                || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.BLACK_BAND)] != BufferManager.TYPE_BYTE) {
72
            int[] inputBandTypes = getInputBuffer().getBandTypes();
73
            if (inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.CYAN_BAND)] != BufferManager.TYPE_BYTE
74
                || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.MAGENTA_BAND)] != BufferManager.TYPE_BYTE
75
                || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.YELLOW_BAND)] != BufferManager.TYPE_BYTE
76
                || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.BLACK_BAND)] != BufferManager.TYPE_BYTE) {
79 77
                throw new UnsupportedOperationException("The type of bands isn't BYTE");
80 78
            }
81 79

  
82
            int sourceBands = this.buffer.getBandCount();
83
            NoData[] sourceNoDatas = this.buffer.getBandNoData();
84
            int[] sourceTypes = this.buffer.getBandTypes();
80
            int sourceBands = this.getInputBuffer().getBandCount();
81
            NoData[] sourceNoDatas = this.getInputBuffer().getBandNoData();
82
            int[] sourceTypes = this.getInputBuffer().getBandTypes();
85 83

  
86
            List<String> colorInterpretations = new ArrayList<String>();
87
            List<NoData> noDatas = new ArrayList<NoData>();
88
            List<Integer> types = new ArrayList<Integer>();
84
            List<String> colorInterpretations = new ArrayList<>();
85
            List<NoData> noDatas = new ArrayList<>();
86
            List<Integer> types = new ArrayList<>();
89 87

  
90 88
            colorInterpretations.add(ColorInterpretation.RED_BAND);
91 89
            colorInterpretations.add(ColorInterpretation.GREEN_BAND);
......
99 97
            noDatas.add(null);
100 98
            noDatas.add(null);
101 99

  
102
            if (colorInterpretation.hasAlphaBand()) {
103
                int alphaBand = colorInterpretation.getAlphaBand();
100
            if (getInputColorInterpretation().hasAlphaBand()) {
101
                int alphaBand = getInputColorInterpretation().getAlphaBand();
104 102
                if(sourceTypes[alphaBand]!=BufferManager.TYPE_BYTE){
105 103
                    throw new UnsupportedOperationException("The type of ALPHA band isn't BYTE");
106 104
                }
......
109 107
                noDatas.add(sourceNoDatas[alphaBand]);
110 108
            }
111 109

  
112
            if (copyUnprocessedBands) {
110
            if (mustCopyUnprocessedBands()) {
113 111
                for (int band = 0; band < sourceBands; band++) {
114
                    if (!isProcessableBand(band) && !colorInterpretation.isAlphaInterpretation(band)) {
112
                    if (!isProcessableBand(band) && !getInputColorInterpretation().isAlphaInterpretation(band)) {
115 113
                        colorInterpretations.add(ColorInterpretation.UNDEFINED_BAND);
116 114
                        noDatas.add(sourceNoDatas[band]);
117
                        types.add(this.buffer.getBandTypes()[band]);
115
                        types.add(this.getInputBuffer().getBandTypes()[band]);
118 116
                    }
119 117
                }
120 118
            }
121 119

  
122
            outputColorInterpretation =
123
                legendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
124
            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, outputColorInterpretation);
125
            int[] typesInt = new int[types.size()];
126
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
127
                int i = 0;
128
                Integer type = (Integer) iterator.next();
129
                typesInt[i] = type.intValue();
130
            }
120
            setOutputColorInterpretation(
121
                legendManager.createColorInterpretation(colorInterpretations));
122
            this.setParameter(
123
                    OUTPUT_COLOR_INTERPRETATION_PARAM, 
124
                    getOutputColorInterpretation());
131 125

  
132
            this.outputBuffer =
133
                manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
134
                    noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
126

  
127
            this.setOutputBuffer(
128
                manager.createBuffer(
129
                        this.getInputBuffer().getRows(), 
130
                        this.getInputBuffer().getColumns(), 
131
                        this.getTypesAsArray(types),
132
                        this.getNoDatasAsArray(noDatas), 
133
                        this.getInputBuffer().getProjection(), 
134
                        this.getInputBuffer().getEnvelope()));
135 135
        } catch (LocatorException | BufferException | CreateEnvelopeException e) {
136 136
            throw new ProcessingOperationException(e);
137 137
        }
......
143 143
            super.process();
144 144
            // List<Integer> bandsToProcess = new ArrayList<Integer>();
145 145

  
146
            if (copyUnprocessedBands) {
147
                int bands = this.buffer.getBandCount();
148
                int outBand = colorInterpretation.hasAlphaBand() ? 4 : 3;
146
            if (mustCopyUnprocessedBands()) {
147
                int bands = this.getInputBuffer().getBandCount();
148
                int outBand = getInputColorInterpretation().hasAlphaBand() ? 4 : 3;
149 149
                for (int band = 0; band < bands; band++) {
150
                    if (colorInterpretation.isAlphaInterpretation(band)) {
151
                        outputBuffer.getBand(outputColorInterpretation.getAlphaBand()).copyFrom(
152
                            this.buffer.getBand(band));
150
                    if (getInputColorInterpretation().isAlphaInterpretation(band)) {
151
                        getOutputBuffer().getBand(getInputColorInterpretation().getAlphaBand()).copyFrom(
152
                            this.getInputBuffer().getBand(band));
153 153
                    } else if (!isProcessableBand(band)) {
154
                        outputBuffer.getBand(outBand).copyFrom(this.buffer.getBand(band));
154
                        getOutputBuffer().getBand(outBand).copyFrom(this.getInputBuffer().getBand(band));
155 155
                        outBand++;
156 156
                    }
157 157
                }
......
159 159

  
160 160
            Object[] rowBandsBuffer = new Object[4];
161 161

  
162
            for (int row = 0; row < this.buffer.getRows(); row++) {
163
                Band bufferBandCyan = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.CYAN_BAND));
162
            for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
163
                Band bufferBandCyan = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.CYAN_BAND));
164 164
                rowBandsBuffer[0] = bufferBandCyan.createRowBuffer();
165 165
                bufferBandCyan.fetchRow(row, rowBandsBuffer[0]);
166
                Band bufferBandMagenta = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.MAGENTA_BAND));
166
                Band bufferBandMagenta = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.MAGENTA_BAND));
167 167
                rowBandsBuffer[1] = bufferBandMagenta.createRowBuffer();
168 168
                bufferBandMagenta.fetchRow(row, rowBandsBuffer[1]);
169
                Band bufferBandYellow = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.YELLOW_BAND));
169
                Band bufferBandYellow = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.YELLOW_BAND));
170 170
                rowBandsBuffer[2] = bufferBandYellow.createRowBuffer();
171 171
                bufferBandYellow.fetchRow(row, rowBandsBuffer[2]);
172
                Band bufferBandBlack = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.BLACK_BAND));
172
                Band bufferBandBlack = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.BLACK_BAND));
173 173
                rowBandsBuffer[3] = bufferBandBlack.createRowBuffer();
174 174
                bufferBandBlack.fetchRow(row, rowBandsBuffer[3]);
175 175

  
176
                List<Object> outputRowBuffers = new ArrayList<Object>();
176
                List<Object> outputRowBuffers = new ArrayList<>();
177 177
                for (int band = 0; band < 3; band++) {
178
                    Band outputBufferBand = outputBuffer.getBand(band);
178
                    Band outputBufferBand = getOutputBuffer().getBand(band);
179 179
                    Object outputRowBuffer = outputBufferBand.createRowBuffer();
180 180
                    outputRowBuffers.add(outputRowBuffer);
181 181
                }
......
183 183
                processRow(rowBandsBuffer, outputRowBuffers);
184 184

  
185 185
                for (int band = 0; band < 3; band++) {
186
                    Band outputBufferBand = outputBuffer.getBand(band);
186
                    Band outputBufferBand = getOutputBuffer().getBand(band);
187 187
                    outputBufferBand.putRow(row, outputRowBuffers.get(band));
188 188
                }
189 189

  
......
221 221
     * @param band
222 222
     * @return
223 223
     */
224
    private boolean isProcessableBand(int band) {
225
        return isCMYKBand(band) && this.buffer.getBandTypes()[band] == BufferManager.TYPE_BYTE;
224
    @Override
225
    protected boolean isProcessableBand(int band) {
226
        return isCMYKBand(band) && this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_BYTE;
226 227
    }
227 228

  
228 229
    private boolean isCMYKBand(int band) {
229
        String bandColorInterpretation = colorInterpretation.get(band);
230
        String bandColorInterpretation = getInputColorInterpretation().get(band);
230 231
        return (bandColorInterpretation.equals(ColorInterpretation.CYAN_BAND)
231 232
            || bandColorInterpretation.equals(ColorInterpretation.MAGENTA_BAND)
232 233
            || bandColorInterpretation.equals(ColorInterpretation.YELLOW_BAND)
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/rgbtocmyk/RGBToCMYKOperation.java
23 23
package org.gvsig.raster.lib.legend.impl.operations.rgbtocmyk;
24 24

  
25 25
import java.util.ArrayList;
26
import java.util.Iterator;
27 26
import java.util.List;
28 27

  
29 28
import org.slf4j.Logger;
......
60 59
     *
61 60
     */
62 61
    public RGBToCMYKOperation(OperationFactory factory) {
63
        this.factory = factory;
62
        super(factory);
64 63
    }
65 64

  
66 65
    @Override
......
70 69
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
71 70

  
72 71
        try {
73
            if (!(colorInterpretation.isGray() || colorInterpretation.isRGB())) {
72
            if (!(getInputColorInterpretation().isGray() || getInputColorInterpretation().isRGB())) {
74 73
                throw new UnsupportedOperationException(
75 74
                    "The color interpretation of input buffer isn't RGB nor GRAYSCALE");
76 75
            }
77 76

  
78
            int[] inputBandTypes = buffer.getBandTypes();
79
            if (colorInterpretation.isGray()) {
80
                if (inputBandTypes[colorInterpretation.getBand(ColorInterpretation.GRAY_BAND)] != BufferManager.TYPE_BYTE) {
77
            int[] inputBandTypes = getInputBuffer().getBandTypes();
78
            if (getInputColorInterpretation().isGray()) {
79
                if (inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.GRAY_BAND)] != BufferManager.TYPE_BYTE) {
81 80
                    throw new UnsupportedOperationException("The type of GRAY band isn't BYTE");
82 81
                }
83
            } else if (colorInterpretation.isRGB()) {
84
                if (inputBandTypes[colorInterpretation.getBand(ColorInterpretation.RED_BAND)] != BufferManager.TYPE_BYTE
85
                    || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.GREEN_BAND)] != BufferManager.TYPE_BYTE
86
                    || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.BLUE_BAND)] != BufferManager.TYPE_BYTE) {
82
            } else if (getInputColorInterpretation().isRGB()) {
83
                if (inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.RED_BAND)] != BufferManager.TYPE_BYTE
84
                    || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.GREEN_BAND)] != BufferManager.TYPE_BYTE
85
                    || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.BLUE_BAND)] != BufferManager.TYPE_BYTE) {
87 86
                    throw new UnsupportedOperationException("The type of RGB bands isn't BYTE");
88 87
                }
89 88
            } else {
......
91 90
                    "The color interpretation of input buffer isn't RGB nor GRAYSCALE");
92 91
            }
93 92

  
94
            int sourceBands = this.buffer.getBandCount();
95
            NoData[] sourceNoDatas = this.buffer.getBandNoData();
96
            int[] sourceTypes = this.buffer.getBandTypes();
93
            int sourceBands = this.getInputBuffer().getBandCount();
94
            NoData[] sourceNoDatas = this.getInputBuffer().getBandNoData();
95
            int[] sourceTypes = this.getInputBuffer().getBandTypes();
97 96

  
98
            List<String> colorInterpretations = new ArrayList<String>();
99
            List<NoData> noDatas = new ArrayList<NoData>();
100
            List<Integer> types = new ArrayList<Integer>();
97
            List<String> colorInterpretations = new ArrayList<>();
98
            List<NoData> noDatas = new ArrayList<>();
99
            List<Integer> types = new ArrayList<>();
101 100

  
102 101
            colorInterpretations.add(ColorInterpretation.CYAN_BAND);
103 102
            colorInterpretations.add(ColorInterpretation.MAGENTA_BAND);
......
114 113
            noDatas.add(null);
115 114
            noDatas.add(null);
116 115

  
117
            if (colorInterpretation.hasAlphaBand()) {
118
                int alphaBand = colorInterpretation.getAlphaBand();
116
            if (getInputColorInterpretation().hasAlphaBand()) {
117
                int alphaBand = getInputColorInterpretation().getAlphaBand();
119 118
                if(sourceTypes[alphaBand]!=BufferManager.TYPE_BYTE){
120 119
                    throw new UnsupportedOperationException("The type of ALPHA band isn't BYTE");
121 120
                }
......
124 123
                noDatas.add(sourceNoDatas[alphaBand]);
125 124
            }
126 125

  
127
            if (copyUnprocessedBands) {
126
            if (mustCopyUnprocessedBands()) {
128 127
                for (int band = 0; band < sourceBands; band++) {
129
                    if (!isProcessableBand(band) && !colorInterpretation.isAlphaInterpretation(band)) {
128
                    if (!isProcessableBand(band) && !getInputColorInterpretation().isAlphaInterpretation(band)) {
130 129
                        colorInterpretations.add(ColorInterpretation.UNDEFINED_BAND);
131 130
                        noDatas.add(sourceNoDatas[band]);
132
                        types.add(this.buffer.getBandTypes()[band]);
131
                        types.add(this.getInputBuffer().getBandTypes()[band]);
133 132
                    }
134 133
                }
135 134
            }
136 135

  
137
            outputColorInterpretation =
138
                legendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
139
            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, outputColorInterpretation);
140
            int[] typesInt = new int[types.size()];
141
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
142
                int i = 0;
143
                Integer type = (Integer) iterator.next();
144
                typesInt[i] = type.intValue();
145
            }
136
            setOutputColorInterpretation(
137
                legendManager.createColorInterpretation(colorInterpretations));
138
            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getOutputColorInterpretation());
146 139

  
147
            this.outputBuffer =
148
                manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
149
                    noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
140
            this.setOutputBuffer(
141
                manager.createBuffer(
142
                        this.getInputBuffer().getRows(), 
143
                        this.getInputBuffer().getColumns(), 
144
                        this.getTypesAsArray(types),
145
                        this.getNoDatasAsArray(noDatas), 
146
                        this.getInputBuffer().getProjection(), 
147
                        this.getInputBuffer().getEnvelope()));
150 148
        } catch (LocatorException | BufferException | CreateEnvelopeException e) {
151 149
            throw new ProcessingOperationException(e);
152 150
        }
......
159 157

  
160 158
            // List<Integer> bandsToProcess = new ArrayList<Integer>();
161 159

  
162
            if (copyUnprocessedBands) {
163
                int bands = this.buffer.getBandCount();
164
                int outBand = colorInterpretation.hasAlphaBand() ? 5 : 4;
160
            if (mustCopyUnprocessedBands()) {
161
                int bands = this.getInputBuffer().getBandCount();
162
                int outBand = getInputColorInterpretation().hasAlphaBand() ? 5 : 4;
165 163
                for (int band = 0; band < bands; band++) {
166
                    if (colorInterpretation.isAlphaInterpretation(band)) {
167
                        outputBuffer.getBand(outputColorInterpretation.getAlphaBand()).copyFrom(
168
                            this.buffer.getBand(band));
164
                    if (getInputColorInterpretation().isAlphaInterpretation(band)) {
165
                        getOutputBuffer().getBand(getOutputColorInterpretation().getAlphaBand()).copyFrom(
166
                            this.getInputBuffer().getBand(band));
169 167
                    } else if (!isProcessableBand(band)) {
170
                        outputBuffer.getBand(outBand).copyFrom(this.buffer.getBand(band));
168
                        getOutputBuffer().getBand(outBand).copyFrom(this.getInputBuffer().getBand(band));
171 169
                        outBand++;
172 170
                    }
173 171
                }
......
175 173

  
176 174
            Object[] rowBandsBuffer = new Object[3];
177 175

  
178
            for (int row = 0; row < this.buffer.getRows(); row++) {
179
                if (colorInterpretation.isGray()) {
180
                    Band bufferBandGray = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.GRAY_BAND));
176
            for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
177
                if (getInputColorInterpretation().isGray()) {
178
                    Band bufferBandGray = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.GRAY_BAND));
181 179
                    rowBandsBuffer[0] = bufferBandGray.createRowBuffer();
182 180
                    bufferBandGray.fetchRow(row, rowBandsBuffer[0]);
183 181
                    rowBandsBuffer[1] = bufferBandGray.createRowBuffer();
......
185 183
                    rowBandsBuffer[2] = bufferBandGray.createRowBuffer();
186 184
                    bufferBandGray.fetchRow(row, rowBandsBuffer[2]);
187 185
                } else {
188
                    Band bufferBandRed = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.RED_BAND));
186
                    Band bufferBandRed = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.RED_BAND));
189 187
                    rowBandsBuffer[0] = bufferBandRed.createRowBuffer();
190 188
                    bufferBandRed.fetchRow(row, rowBandsBuffer[0]);
191
                    Band bufferBandGreen = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.GREEN_BAND));
189
                    Band bufferBandGreen = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.GREEN_BAND));
192 190
                    rowBandsBuffer[1] = bufferBandGreen.createRowBuffer();
193 191
                    bufferBandGreen.fetchRow(row, rowBandsBuffer[1]);
194
                    Band bufferBandBlue = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.BLUE_BAND));
192
                    Band bufferBandBlue = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.BLUE_BAND));
195 193
                    rowBandsBuffer[2] = bufferBandBlue.createRowBuffer();
196 194
                    bufferBandBlue.fetchRow(row, rowBandsBuffer[2]);
197 195
                }
198 196

  
199 197
                List<Object> outputRowBuffers = new ArrayList<Object>();
200 198
                for (int band = 0; band < 4; band++) {
201
                    Band outputBufferBand = outputBuffer.getBand(band);
199
                    Band outputBufferBand = getOutputBuffer().getBand(band);
202 200
                    Object outputRowBuffer = outputBufferBand.createRowBuffer();
203 201
                    outputRowBuffers.add(outputRowBuffer);
204 202
                }
......
206 204
                processRow(rowBandsBuffer, outputRowBuffers);
207 205

  
208 206
                for (int band = 0; band < 4; band++) {
209
                    Band outputBufferBand = outputBuffer.getBand(band);
207
                    Band outputBufferBand = getOutputBuffer().getBand(band);
210 208
                    outputBufferBand.putRow(row, outputRowBuffers.get(band));
211 209
                }
212 210

  
......
243 241
     * @param band
244 242
     * @return
245 243
     */
246
    private boolean isProcessableBand(int band) {
247
        return isRGBorGrayBand(band) && this.buffer.getBandTypes()[band] == BufferManager.TYPE_BYTE;
244
    @Override
245
    protected boolean isProcessableBand(int band) {
246
        return isRGBorGrayBand(band) && this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_BYTE;
248 247
    }
249 248

  
250 249
    private boolean isRGBorGrayBand(int band) {
251
        String bandColorInterpretation = colorInterpretation.get(band);
250
        String bandColorInterpretation = getInputColorInterpretation().get(band);
252 251
        return (bandColorInterpretation.equals(ColorInterpretation.RED_BAND)
253 252
            || bandColorInterpretation.equals(ColorInterpretation.GREEN_BAND)
254 253
            || bandColorInterpretation.equals(ColorInterpretation.BLUE_BAND) || bandColorInterpretation
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/hsltorgb/HSLToRGBOperation.java
56 56
     *
57 57
     */
58 58
    public HSLToRGBOperation(OperationFactory factory) {
59
        this.factory = factory;
59
        super(factory);
60 60
    }
61 61

  
62 62
    @Override
......
66 66
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
67 67

  
68 68
        try {
69
            if (!colorInterpretation.isHSL()) {
70
                throw new UnsupportedOperationException("The color interpretation of input buffer isn't HSL");
69
            if (!getInputColorInterpretation().isHSL()) {
70
                throw new UnsupportedOperationException("The color interpretation of input getInputBuffer() isn't HSL");
71 71
            }
72 72

  
73
            int[] inputBandTypes = buffer.getBandTypes();
74
            if (inputBandTypes[colorInterpretation.getBand(ColorInterpretation.HUE_BAND)] != BufferManager.TYPE_BYTE
75
                || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.SATURATION_BAND)] != BufferManager.TYPE_BYTE
76
                || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.LIGHTNESS_BAND)] != BufferManager.TYPE_BYTE) {
73
            int[] inputBandTypes = getInputBuffer().getBandTypes();
74
            if (inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.HUE_BAND)] != BufferManager.TYPE_BYTE
75
                || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.SATURATION_BAND)] != BufferManager.TYPE_BYTE
76
                || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.LIGHTNESS_BAND)] != BufferManager.TYPE_BYTE) {
77 77
                throw new UnsupportedOperationException("The type of bands isn't BYTE");
78 78
            }
79 79

  
80
            int sourceBands = this.buffer.getBandCount();
81
            NoData[] sourceNoDatas = this.buffer.getBandNoData();
82
            int[] sourceTypes = this.buffer.getBandTypes();
80
            int sourceBands = this.getInputBuffer().getBandCount();
81
            NoData[] sourceNoDatas = this.getInputBuffer().getBandNoData();
82
            int[] sourceTypes = this.getInputBuffer().getBandTypes();
83 83

  
84 84
            List<String> colorInterpretations = new ArrayList<String>();
85 85
            List<NoData> noDatas = new ArrayList<NoData>();
......
97 97
            noDatas.add(null);
98 98
            noDatas.add(null);
99 99

  
100
            if (colorInterpretation.hasAlphaBand()) {
101
                int alphaBand = colorInterpretation.getAlphaBand();
100
            if (getInputColorInterpretation().hasAlphaBand()) {
101
                int alphaBand = getInputColorInterpretation().getAlphaBand();
102 102
                if(sourceTypes[alphaBand]!=BufferManager.TYPE_BYTE){
103 103
                    throw new UnsupportedOperationException("The type of ALPHA band isn't BYTE");
104 104
                }
......
107 107
                noDatas.add(sourceNoDatas[alphaBand]);
108 108
            }
109 109

  
110
            if (copyUnprocessedBands) {
110
            if (mustCopyUnprocessedBands()) {
111 111
                for (int band = 0; band < sourceBands; band++) {
112
                    if (!isProcessableBand(band) && !colorInterpretation.isAlphaInterpretation(band)) {
113
                        colorInterpretations.add(colorInterpretation.get(band));
112
                    if (!isProcessableBand(band) && !getInputColorInterpretation().isAlphaInterpretation(band)) {
113
                        colorInterpretations.add(getInputColorInterpretation().get(band));
114 114
                        noDatas.add(sourceNoDatas[band]);
115
                        types.add(this.buffer.getBandTypes()[band]);
115
                        types.add(this.getInputBuffer().getBandTypes()[band]);
116 116
                    }
117 117
                }
118 118
            }
119 119

  
120
            outputColorInterpretation =
121
                legendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
122
            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, outputColorInterpretation);
123
            int[] typesInt = new int[types.size()];
124
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
125
                int i = 0;
126
                Integer type = (Integer) iterator.next();
127
                typesInt[i] = type.intValue();
128
            }
129

  
130
            this.outputBuffer =
131
                manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
132
                    noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
133
        } catch (LocatorException | BufferException | CreateEnvelopeException e) {
120
            setOutputColorInterpretation(
121
                legendManager.createColorInterpretation(colorInterpretations));
122
            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getOutputColorInterpretation());
123
            this.setOutputBuffer(
124
                manager.createBuffer(
125
                        this.getInputBuffer().getRows(), 
126
                        this.getInputBuffer().getColumns(), 
127
                        this.getTypesAsArray(types),
128
                        this.getNoDatasAsArray(noDatas), 
129
                        this.getInputBuffer().getProjection(), 
130
                        this.getInputBuffer().getEnvelope()));
131
        } catch (Exception e) {
134 132
            throw new ProcessingOperationException(e);
135 133
        }
136 134
    }
......
142 140

  
143 141
            // List<Integer> bandsToProcess = new ArrayList<Integer>();
144 142

  
145
            if (copyUnprocessedBands) {
146
                int bands = this.buffer.getBandCount();
147
                int outBand = colorInterpretation.hasAlphaBand() ? 4 : 3;
143
            if (mustCopyUnprocessedBands()) {
144
                int bands = this.getInputBuffer().getBandCount();
145
                int outBand = getInputColorInterpretation().hasAlphaBand() ? 4 : 3;
148 146
                for (int band = 0; band < bands; band++) {
149
                    if (colorInterpretation.isAlphaInterpretation(band)) {
150
                        outputBuffer.getBand(outputColorInterpretation.getAlphaBand()).copyFrom(
151
                            this.buffer.getBand(band));
147
                    if (getInputColorInterpretation().isAlphaInterpretation(band)) {
148
                        getOutputBuffer().getBand(getOutputColorInterpretation().getAlphaBand()).copyFrom(
149
                            this.getInputBuffer().getBand(band));
152 150
                    } else if (!isProcessableBand(band)) {
153
                        outputBuffer.getBand(outBand).copyFrom(this.buffer.getBand(band));
151
                        getOutputBuffer().getBand(outBand).copyFrom(this.getInputBuffer().getBand(band));
154 152
                        outBand++;
155 153
                    }
156 154
                }
......
158 156

  
159 157
            Object[] rowBandsBuffer = new Object[3];
160 158

  
161
            for (int row = 0; row < this.buffer.getRows(); row++) {
162
                Band bufferBandHue = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.HUE_BAND));
159
            for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
160
                Band bufferBandHue = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.HUE_BAND));
163 161
                rowBandsBuffer[0] = bufferBandHue.createRowBuffer();
164 162
                bufferBandHue.fetchRow(row, rowBandsBuffer[0]);
165
                Band bufferBandSaturation = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.SATURATION_BAND));
163
                Band bufferBandSaturation = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.SATURATION_BAND));
166 164
                rowBandsBuffer[1] = bufferBandSaturation.createRowBuffer();
167 165
                bufferBandSaturation.fetchRow(row, rowBandsBuffer[1]);
168
                Band bufferBandLightness = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.LIGHTNESS_BAND));
166
                Band bufferBandLightness = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.LIGHTNESS_BAND));
169 167
                rowBandsBuffer[2] = bufferBandLightness.createRowBuffer();
170 168
                bufferBandLightness.fetchRow(row, rowBandsBuffer[2]);
171 169

  
172 170
                List<Object> outputRowBuffers = new ArrayList<Object>();
173 171
                for (int band = 0; band < 3; band++) {
174
                    Band outputBufferBand = outputBuffer.getBand(band);
172
                    Band outputBufferBand = getOutputBuffer().getBand(band);
175 173
                    Object outputRowBuffer = outputBufferBand.createRowBuffer();
176 174
                    outputRowBuffers.add(outputRowBuffer);
177 175
                }
......
179 177
                processRow(rowBandsBuffer, outputRowBuffers);
180 178

  
181 179
                for (int band = 0; band < 3; band++) {
182
                    Band outputBufferBand = outputBuffer.getBand(band);
180
                    Band outputBufferBand = getOutputBuffer().getBand(band);
183 181
                    outputBufferBand.putRow(row, outputRowBuffers.get(band));
184 182
                }
185 183

  
......
216 214
     * @param band
217 215
     * @return
218 216
     */
219
    private boolean isProcessableBand(int band) {
220
        return isHSLBand(band) && this.buffer.getBandTypes()[band] == BufferManager.TYPE_BYTE;
217
    @Override
218
    protected boolean isProcessableBand(int band) {
219
        return isHSLBand(band) && this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_BYTE;
221 220
    }
222 221

  
223 222
    private boolean isHSLBand(int band) {
224
        String bandColorInterpretation = colorInterpretation.get(band);
223
        String bandColorInterpretation = getInputColorInterpretation().get(band);
225 224
        return (bandColorInterpretation.equals(ColorInterpretation.HUE_BAND)
226 225
            || bandColorInterpretation.equals(ColorInterpretation.SATURATION_BAND)
227 226
            || bandColorInterpretation.equals(ColorInterpretation.LIGHTNESS_BAND));
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/rgbtohsl/RGBToHSLOperation.java
23 23
package org.gvsig.raster.lib.legend.impl.operations.rgbtohsl;
24 24

  
25 25
import java.util.ArrayList;
26
import java.util.Iterator;
27 26
import java.util.List;
28 27

  
29 28
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
......
55 54
     *
56 55
     */
57 56
    public RGBToHSLOperation(OperationFactory factory) {
58
        this.factory = factory;
57
        super(factory);
59 58
    }
60 59

  
61 60
    @Override
......
65 64
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
66 65

  
67 66
        try {
68
            if (!(colorInterpretation.isGray() || colorInterpretation.isRGB())) {
67
            if (!(getInputColorInterpretation().isGray() || getInputColorInterpretation().isRGB())) {
69 68
                throw new UnsupportedOperationException(
70 69
                    "The color interpretation of input buffer isn't RGB nor GRAYSCALE");
71 70
            }
72 71

  
73
            int[] inputBandTypes = buffer.getBandTypes();
74
            if (colorInterpretation.isGray()) {
75
                if (inputBandTypes[colorInterpretation.getBand(ColorInterpretation.GRAY_BAND)] != BufferManager.TYPE_BYTE) {
72
            int[] inputBandTypes = getInputBuffer().getBandTypes();
73
            if (getInputColorInterpretation().isGray()) {
74
                if (inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.GRAY_BAND)] != BufferManager.TYPE_BYTE) {
76 75
                    throw new UnsupportedOperationException("The type of GRAY band isn't BYTE");
77 76
                }
78
            } else if (colorInterpretation.isRGB()) {
79
                if (inputBandTypes[colorInterpretation.getBand(ColorInterpretation.RED_BAND)] != BufferManager.TYPE_BYTE
80
                    || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.GREEN_BAND)] != BufferManager.TYPE_BYTE
81
                    || inputBandTypes[colorInterpretation.getBand(ColorInterpretation.BLUE_BAND)] != BufferManager.TYPE_BYTE) {
77
            } else if (getInputColorInterpretation().isRGB()) {
78
                if (inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.RED_BAND)] != BufferManager.TYPE_BYTE
79
                    || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.GREEN_BAND)] != BufferManager.TYPE_BYTE
80
                    || inputBandTypes[getInputColorInterpretation().getBand(ColorInterpretation.BLUE_BAND)] != BufferManager.TYPE_BYTE) {
82 81
                    throw new UnsupportedOperationException("The type of RGB bands isn't BYTE");
83 82
                }
84 83
            } else {
......
86 85
                    "The color interpretation of input buffer isn't RGB nor GRAYSCALE");
87 86
            }
88 87

  
89
            int sourceBands = this.buffer.getBandCount();
90
            NoData[] sourceNoDatas = this.buffer.getBandNoData();
91
            int[] sourceTypes = this.buffer.getBandTypes();
88
            int sourceBands = this.getInputBuffer().getBandCount();
89
            NoData[] sourceNoDatas = this.getInputBuffer().getBandNoData();
90
            int[] sourceTypes = this.getInputBuffer().getBandTypes();
92 91

  
93
            List<String> colorInterpretations = new ArrayList<String>();
94
            List<NoData> noDatas = new ArrayList<NoData>();
95
            List<Integer> types = new ArrayList<Integer>();
92
            List<String> colorInterpretations = new ArrayList<>();
93
            List<NoData> noDatas = new ArrayList<>();
94
            List<Integer> types = new ArrayList<>();
96 95

  
97 96
            colorInterpretations.add(ColorInterpretation.HUE_BAND);
98 97
            colorInterpretations.add(ColorInterpretation.SATURATION_BAND);
......
106 105
            noDatas.add(null);
107 106
            noDatas.add(null);
108 107

  
109
            if (colorInterpretation.hasAlphaBand()) {
110
                int alphaBand = colorInterpretation.getAlphaBand();
108
            if (getInputColorInterpretation().hasAlphaBand()) {
109
                int alphaBand = getInputColorInterpretation().getAlphaBand();
111 110
                if(sourceTypes[alphaBand]!=BufferManager.TYPE_BYTE){
112 111
                    throw new UnsupportedOperationException("The type of ALPHA band isn't BYTE");
113 112
                }
......
116 115
                noDatas.add(sourceNoDatas[alphaBand]);
117 116
            }
118 117

  
119
            if (copyUnprocessedBands) {
118
            if (mustCopyUnprocessedBands()) {
120 119
                for (int band = 0; band < sourceBands; band++) {
121
                    if (!isProcessableBand(band) && !colorInterpretation.isAlphaInterpretation(band)) {
122
                        colorInterpretations.add(colorInterpretation.get(band));
120
                    if (!isProcessableBand(band) && !getInputColorInterpretation().isAlphaInterpretation(band)) {
121
                        colorInterpretations.add(getInputColorInterpretation().get(band));
123 122
                        noDatas.add(sourceNoDatas[band]);
124
                        types.add(this.buffer.getBandTypes()[band]);
123
                        types.add(this.getInputBuffer().getBandTypes()[band]);
125 124
                    }
126 125
                }
127 126
            }
128 127

  
129
            outputColorInterpretation =
130
                legendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
131
            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, outputColorInterpretation);
132
            int[] typesInt = new int[types.size()];
133
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
134
                int i = 0;
135
                Integer type = (Integer) iterator.next();
136
                typesInt[i] = type.intValue();
137
            }
128
            setOutputColorInterpretation(
129
                legendManager.createColorInterpretation(colorInterpretations));
130
            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getOutputColorInterpretation());
138 131

  
139
            this.outputBuffer =
140
                manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
141
                    noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
132
            this.setOutputBuffer(
133
                manager.createBuffer(
134
                        this.getInputBuffer().getRows(), 
135
                        this.getInputBuffer().getColumns(), 
136
                        this.getTypesAsArray(types),
137
                        this.getNoDatasAsArray(noDatas), 
138
                        this.getInputBuffer().getProjection(), 
139
                        this.getInputBuffer().getEnvelope()));
142 140
        } catch (LocatorException | BufferException | CreateEnvelopeException e) {
143 141
            throw new ProcessingOperationException(e);
144 142
        }
......
151 149

  
152 150
            // List<Integer> bandsToProcess = new ArrayList<Integer>();
153 151

  
154
            if (copyUnprocessedBands) {
155
                int bands = this.buffer.getBandCount();
156
                int outBand = colorInterpretation.hasAlphaBand() ? 5 : 4;
152
            if (mustCopyUnprocessedBands()) {
153
                int bands = this.getInputBuffer().getBandCount();
154
                int outBand = getInputColorInterpretation().hasAlphaBand() ? 5 : 4;
157 155
                for (int band = 0; band < bands; band++) {
158
                    if (colorInterpretation.isAlphaInterpretation(band)) {
159
                        outputBuffer.getBand(outputColorInterpretation.getAlphaBand()).copyFrom(
160
                            this.buffer.getBand(band));
156
                    if (getInputColorInterpretation().isAlphaInterpretation(band)) {
157
                        getOutputBuffer().getBand(getOutputColorInterpretation().getAlphaBand()).copyFrom(
158
                            this.getInputBuffer().getBand(band));
161 159
                    } else if (!isProcessableBand(band)) {
162
                        outputBuffer.getBand(outBand).copyFrom(this.buffer.getBand(band));
160
                        getOutputBuffer().getBand(outBand).copyFrom(this.getInputBuffer().getBand(band));
163 161
                        outBand++;
164 162
                    }
165 163
                }
......
167 165

  
168 166
            Object[] rowBandsBuffer = new Object[3];
169 167

  
170
            for (int row = 0; row < this.buffer.getRows(); row++) {
171
                if (colorInterpretation.isGray()) {
172
                    Band bufferBandGray = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.GRAY_BAND));
168
            for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
169
                if (getInputColorInterpretation().isGray()) {
170
                    Band bufferBandGray = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.GRAY_BAND));
173 171
                    rowBandsBuffer[0] = bufferBandGray.createRowBuffer();
174 172
                    bufferBandGray.fetchRow(row, rowBandsBuffer[0]);
175 173
                    rowBandsBuffer[1] = bufferBandGray.createRowBuffer();
......
177 175
                    rowBandsBuffer[2] = bufferBandGray.createRowBuffer();
178 176
                    bufferBandGray.fetchRow(row, rowBandsBuffer[2]);
179 177
                } else {
180
                    Band bufferBandRed = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.RED_BAND));
178
                    Band bufferBandRed = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.RED_BAND));
181 179
                    rowBandsBuffer[0] = bufferBandRed.createRowBuffer();
182 180
                    bufferBandRed.fetchRow(row, rowBandsBuffer[0]);
183
                    Band bufferBandGreen = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.GREEN_BAND));
181
                    Band bufferBandGreen = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.GREEN_BAND));
184 182
                    rowBandsBuffer[1] = bufferBandGreen.createRowBuffer();
185 183
                    bufferBandGreen.fetchRow(row, rowBandsBuffer[1]);
186
                    Band bufferBandBlue = buffer.getBand(colorInterpretation.getBand(ColorInterpretation.BLUE_BAND));
184
                    Band bufferBandBlue = getInputBuffer().getBand(getInputColorInterpretation().getBand(ColorInterpretation.BLUE_BAND));
187 185
                    rowBandsBuffer[2] = bufferBandBlue.createRowBuffer();
188 186
                    bufferBandBlue.fetchRow(row, rowBandsBuffer[2]);
189 187
                }
190 188

  
191
                List<Object> outputRowBuffers = new ArrayList<Object>();
189
                List<Object> outputRowBuffers = new ArrayList<>();
192 190
                for (int band = 0; band < 3; band++) {
193
                    Band outputBufferBand = outputBuffer.getBand(band);
191
                    Band outputBufferBand = getOutputBuffer().getBand(band);
194 192
                    Object outputRowBuffer = outputBufferBand.createRowBuffer();
195 193
                    outputRowBuffers.add(outputRowBuffer);
196 194
                }
......
198 196
                processRow(rowBandsBuffer, outputRowBuffers);
199 197

  
200 198
                for (int band = 0; band < 3; band++) {
201
                    Band outputBufferBand = outputBuffer.getBand(band);
199
                    Band outputBufferBand = getOutputBuffer().getBand(band);
202 200
                    outputBufferBand.putRow(row, outputRowBuffers.get(band));
203 201
                }
204 202

  
......
233 231
     * @param band
234 232
     * @return
235 233
     */
236
    private boolean isProcessableBand(int band) {
237
        return isRGBorGrayBand(band) && this.buffer.getBandTypes()[band] == BufferManager.TYPE_BYTE;
234
    @Override
235
    protected boolean isProcessableBand(int band) {
236
        return isRGBorGrayBand(band) && this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_BYTE;
238 237
    }
239 238

  
240 239
    private boolean isRGBorGrayBand(int band) {
241
        String bandColorInterpretation = colorInterpretation.get(band);
240
        String bandColorInterpretation = getInputColorInterpretation().get(band);
242 241
        return (bandColorInterpretation.equals(ColorInterpretation.RED_BAND)
243 242
            || bandColorInterpretation.equals(ColorInterpretation.GREEN_BAND)
244 243
            || bandColorInterpretation.equals(ColorInterpretation.BLUE_BAND) || bandColorInterpretation
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/equalization/EqualizationOperation.java
38 38
import org.gvsig.raster.lib.buffer.api.statistics.HistogramBand;
39 39
import org.gvsig.raster.lib.buffer.api.statistics.Statistics;
40 40
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
41
import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation;
42 41
import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
43 42
import org.gvsig.raster.lib.legend.api.RasterLegendManager;
44 43
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
......
71 70
     *
72 71
     */
73 72
    public EqualizationOperation(OperationFactory factory) {
74
        this.factory = factory;
73
        super(factory);
75 74
    }
76 75

  
77 76
    @Override
......
80 79
        BufferManager manager = BufferLocator.getBufferManager();
81 80
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
82 81

  
83
        if(this.parameters.getDynClass().getDynField(STATISTICS_PARAM)!=null) {
84
            statistics = (Statistics) this.parameters.getDynValue(STATISTICS_PARAM);
82
        statistics = (Statistics) this.getParameter(STATISTICS_PARAM,null);
83
        if (statistics==null) {
84
            statistics = this.getInputBuffer().getStatistics(null);
85 85
        }
86
        if (statistics==null) {
87
            statistics = this.buffer.getStatistics(null);
88
        };
89 86
        histogramBands = statistics.getHistogram();
90 87

  
91
        int bands = this.buffer.getBandCount();
92
        NoData[] noData = this.buffer.getBandNoData();
88
        int bands = this.getInputBuffer().getBandCount();
89
        NoData[] noData = this.getInputBuffer().getBandNoData();
93 90

  
94 91

  
95
        if (copyUnprocessedBands) {
96
            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, colorInterpretation);
97
            noData = this.buffer.getBandNoData();
92
        if (mustCopyUnprocessedBands()) {
93
            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getInputColorInterpretation());
94
            noData = this.getInputBuffer().getBandNoData();
98 95
            try {
99
                this.outputBuffer =
100
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), this.buffer.getBandTypes(),
101
                        this.buffer.getBandNoData(), this.buffer.getProjection(), this.buffer.getEnvelope());
96
                this.setOutputBuffer(
97
                    manager.createBuffer(
98
                            this.getInputBuffer().getRows(), 
99
                            this.getInputBuffer().getColumns(), 
100
                            this.getInputBuffer().getBandTypes(),
101
                            this.getInputBuffer().getBandNoData(), 
102
                            this.getInputBuffer().getProjection(), 
103
                            this.getInputBuffer().getEnvelope()));
102 104
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
103 105
                throw new ProcessingOperationException(e);
104 106
            }
105 107
        } else {
106
            List<String> colorInterpretations = new ArrayList<String>();
107
            List<NoData> noDatas = new ArrayList<NoData>();
108
            List<Integer> types = new ArrayList<Integer>();
108
            List<String> colorInterpretations = new ArrayList<>();
109
            List<NoData> noDatas = new ArrayList<>();
110
            List<Integer> types = new ArrayList<>();
109 111
            for (int band = 0; band < bands; band++) {
110 112
                if (isProcessableBand(band)) {
111
                    colorInterpretations.add(colorInterpretation.get(band));
112
                    noDatas.add(this.buffer.getBandNoData()[band]);
113
                    types.add(this.buffer.getBandTypes()[band]);
113
                    colorInterpretations.add(getInputColorInterpretation().get(band));
114
                    noDatas.add(this.getInputBuffer().getBandNoData()[band]);
115
                    types.add(this.getInputBuffer().getBandTypes()[band]);
114 116
                }
115 117
            }
116
            if (colorInterpretation.hasAlphaBand()) {
118
            if (getInputColorInterpretation().hasAlphaBand()) {
117 119
                colorInterpretations.add(ColorInterpretation.ALPHA_BAND);
118 120
            }
119
            outputColorInterpretation = legendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
120
            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, outputColorInterpretation);
121
            int[] typesInt = new int[types.size()];
122
            for (Iterator iterator = types.iterator(); iterator.hasNext();) {
123
                int i = 0;
124
                Integer type = (Integer) iterator.next();
125
                typesInt[i] = type.intValue();
126
            }
121
            setOutputColorInterpretation(
122
                    legendManager.createColorInterpretation(colorInterpretations));
123
            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getOutputColorInterpretation());
127 124
            try {
128
                this.outputBuffer =
129
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
130
                        noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
131
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
125
                this.setOutputBuffer(
126
                    manager.createBuffer(
127
                            this.getInputBuffer().getRows(), 
128
                            this.getInputBuffer().getColumns(), 
129
                            this.getTypesAsArray(types),
130
                            this.getNoDatasAsArray(noDatas), 
131
                            this.getInputBuffer().getProjection(), 
132
                            this.getInputBuffer().getEnvelope()));
133
            } catch (Exception e) {
132 134
                throw new ProcessingOperationException(e);
133 135
            }
134 136
        }
......
139 141
            throw new ProcessingOperationException("There is no RGB band.", null);
140 142
        }
141 143
        for (Iterator<Integer> iterator = getBandsToProcess().iterator(); iterator.hasNext();) {
142
            Integer band = (Integer) iterator.next();
143
            int bandType = this.buffer.getBand(band).getDataType();
144
            Integer band = iterator.next();
145
            int bandType = this.getInputBuffer().getBand(band).getDataType();
144 146
            if(dataType!=null) {
145 147
                if(dataType!=bandType){
146 148
                    throw new IllegalArgumentException("All bands must be of same data type.");
......
302 304
    @Override
303 305
    public void process() throws ProcessingOperationException {
304 306
        super.process();
305
        for (int band=0; band<this.buffer.getBandCount(); band++){
307
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
306 308
            if (getBandsToProcess().contains(band)) {
307
                Band bufferBand = this.buffer.getBand(band);
308
                Band outputBufferBand = this.outputBuffer.getBand(band);
309
                Band bufferBand = this.getInputBuffer().getBand(band);
310
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
309 311

  
310
                for (int row = 0; row < this.buffer.getRows(); row++) {
312
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
311 313
                    Object rowBuffer = bufferBand.createRowBuffer();
312 314
                    bufferBand.fetchRow(row, rowBuffer);
313 315

  
......
320 322
                }
321 323
            } else {
322 324
                try {
323
                    this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
325
                    this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
324 326
                } catch (BandException e) {
325 327
                    throw new ProcessingOperationException(e);
326 328
                }
......
356 358
     */
357 359
    private List<Integer> getBandsToProcess() {
358 360
        if(bandsToProcess == null){
359
            int bands = this.buffer.getBandCount();
360
            bandsToProcess = new ArrayList<Integer>();
361
            int bands = this.getInputBuffer().getBandCount();
362
            bandsToProcess = new ArrayList<>();
361 363

  
362 364
            for (int band = 0; band < bands; band++) {
363 365
                if (isProcessableBand(band)) {
......
372 374
     * @param band
373 375
     * @return
374 376
     */
375
    private boolean isProcessableBand(int band) {
376
        return isRGBBand(band) && (this.buffer.getBandTypes()[band] == BufferManager.TYPE_BYTE
377
            || this.buffer.getBandTypes()[band] == BufferManager.TYPE_SHORT
378
            || this.buffer.getBandTypes()[band] == BufferManager.TYPE_USHORT
379
            || this.buffer.getBandTypes()[band] == BufferManager.TYPE_INT
377
    @Override
378
    protected boolean isProcessableBand(int band) {
379
        return isRGBBand(band) && (this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_BYTE
380
            || this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_SHORT
381
            || this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_USHORT
382
            || this.getInputBuffer().getBandTypes()[band] == BufferManager.TYPE_INT
380 383
        );
381 384
    }
382 385

  
383 386
    private boolean isRGBBand(int band) {
384
        String bandColorInterpretation = colorInterpretation.get(band);
387
        String bandColorInterpretation = getInputColorInterpretation().get(band);
385 388
        return (bandColorInterpretation.equals(ColorInterpretation.RED_BAND) ||
386 389
            bandColorInterpretation.equals(ColorInterpretation.GREEN_BAND) ||
387 390
            bandColorInterpretation.equals(ColorInterpretation.BLUE_BAND));
......
401 404
        public AbstractRowProcessor(int band) {
402 405
            this.band = band;
403 406
            this.histogram = statistics.getHistogram()[this.band];
404
            this.noData = buffer.getBand(this.band).getNoData();
407
            this.noData = getInputBuffer().getBand(this.band).getNoData();
405 408
        }
406 409
    }
407 410

  
......
429 432
            }
430 433

  
431 434
            //M?todo lahe
432
            int intValue = 0xFF & ((Byte) value).byteValue();
433
            int equalizationPositive = (int)lahe[getBandsToProcess().indexOf(new Integer(band))][intValue % (int)histogram.getNumValues()];
434
            int equalizationNegative = (int)laheNegative[getBandsToProcess().indexOf(new Integer(band))][nElements - (intValue % (int)histogram.getNumValues())];
435
            int intValue = 0xFF & ((Byte) value);
436
            int equalizationPositive = (int)lahe[getBandsToProcess().indexOf(band)][intValue % (int)histogram.getNumValues()];
437
            int equalizationNegative = (int)laheNegative[getBandsToProcess().indexOf(band)][nElements - (intValue % (int)histogram.getNumValues())];
435 438

  
436 439
            int resValue = ((nElements - equalizationNegative) + equalizationPositive) / 2;
437 440
            return (byte)(resValue & 0x000000ff);
......
461 464

  
462 465
            //M?todo lahe
463 466
            int intValue = ((Short) value).byteValue();
464
            int equalizationPositive = (int)lahe[getBandsToProcess().indexOf(new Integer(band))][intValue % (int)histogram.getNumValues()];
465
            int equalizationNegative = (int)laheNegative[getBandsToProcess().indexOf(new Integer(band))][nElements - (intValue % (int)histogram.getNumValues())];
467
            int equalizationPositive = (int)lahe[getBandsToProcess().indexOf(band)][intValue % (int)histogram.getNumValues()];
468
            int equalizationNegative = (int)laheNegative[getBandsToProcess().indexOf(band)][nElements - (intValue % (int)histogram.getNumValues())];
466 469

  
467 470
            int resValue = ((nElements - equalizationNegative) + equalizationPositive) / 2;
468 471
            return (short)resValue;
......
493 496

  
494 497
            //M?todo lahe
495 498
            int intValue = 0xFFFF & ((Short) value).byteValue();
496
            int equalizationPositive = (int)lahe[getBandsToProcess().indexOf(new Integer(band))][intValue % (int)histogram.getNumValues()];
497
            int equalizationNegative = (int)laheNegative[getBandsToProcess().indexOf(new Integer(band))][nElements - (intValue % (int)histogram.getNumValues())];
499
            int equalizationPositive = (int)lahe[getBandsToProcess().indexOf(band)][intValue % (int)histogram.getNumValues()];
500
            int equalizationNegative = (int)laheNegative[getBandsToProcess().indexOf(band)][nElements - (intValue % (int)histogram.getNumValues())];
498 501

  
499 502
            int resValue = ((nElements - equalizationNegative) + equalizationPositive) / 2;
500 503
            return (short)resValue;
......
526 529
            Double dValue = ((Number) value).doubleValue();
527 530

  
528 531
            //M?todo lahe
529
            int intValue = ((Integer) value).intValue();
530
            int equalizationPositive = (int)lahe[getBandsToProcess().indexOf(new Integer(band))][intValue % (int)histogram.getNumValues()];
531
            int equalizationNegative = (int)laheNegative[getBandsToProcess().indexOf(new Integer(band))][nElements - (intValue % (int)histogram.getNumValues())];
532
            int intValue = ((Integer) value);
533
            int equalizationPositive = (int)lahe[getBandsToProcess().indexOf(band)][intValue % (int)histogram.getNumValues()];
534
            int equalizationNegative = (int)laheNegative[getBandsToProcess().indexOf(band)][nElements - (intValue % (int)histogram.getNumValues())];
532 535

  
533 536
            int resValue = ((nElements - equalizationNegative) + equalizationPositive) / 2;
534 537
            return (int)resValue;
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/colortable/ColorTableOperation.java
23 23
package org.gvsig.raster.lib.legend.impl.operations.colortable;
24 24

  
25 25
import java.util.ArrayList;
26
import java.util.Iterator;
27 26
import java.util.List;
28 27

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

  
......
59 55
     *
60 56
     */
61 57
    public ColorTableOperation(OperationFactory factory) {
62
        this.factory = factory;
58
        super(factory);
63 59
    }
64 60

  
65 61
    @Override
......
69 65
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
70 66

  
71 67
        try {
72
            if (!colorInterpretation.isPalette()) {
68
            if (!getInputColorInterpretation().isPalette()) {
73 69
                throw new UnsupportedOperationException("The color interpretation of input buffer isn't Palette");
74 70
            }
75 71

  
76
            int bandType = this.buffer.getBand(colorInterpretation.getPaletteBand()).getDataType();
72
            int bandType = this.getInputBuffer().getBand(getInputColorInterpretation().getPaletteBand()).getDataType();
77 73
            switch (bandType) {
78 74
            case BufferManager.TYPE_BYTE:
79 75
                rowProcessor = new ByteRowProcessor();
......
94 90
                rowProcessor = new DoubleRowProcessor();
95 91
                break;
96 92
            default:
97
                throw new IllegalArgumentException("Unknow type of band '"+colorInterpretation.getPaletteBand()+"'");
93
                throw new IllegalArgumentException("Unknow type of band '"+getInputColorInterpretation().getPaletteBand()+"'");
98 94
            }
99 95

  
100 96

  
101
            int sourceBands = this.buffer.getBandCount();
102
            NoData[] sourceNoDatas = this.buffer.getBandNoData();
103
            int[] sourceTypes = this.buffer.getBandTypes();
97
            int sourceBands = this.getInputBuffer().getBandCount();
98
            NoData[] sourceNoDatas = this.getInputBuffer().getBandNoData();
99
//            int[] sourceTypes = this.getInputBuffer().getBandTypes();
104 100

  
105
            List<String> colorInterpretations = new ArrayList<String>();
106
            List<NoData> noDatas = new ArrayList<NoData>();
107
            List<Integer> types = new ArrayList<Integer>();
101
            List<String> colorInterpretations = new ArrayList<>();
102
            List<NoData> noDatas = new ArrayList<>();
103
            List<Integer> types = new ArrayList<>();
108 104

  
109 105
            colorInterpretations.add(ColorInterpretation.RED_BAND);
110 106
            colorInterpretations.add(ColorInterpretation.GREEN_BAND);
......
121 117
            noDatas.add(null);
122 118
            noDatas.add(null);
123 119

  
124
//            if (colorInterpretation.hasAlphaBand()) {
125
//                int alphaBand = colorInterpretation.getAlphaBand();
120
//            if (getInputColorInterpretation().hasAlphaBand()) {
121
//                int alphaBand = getInputColorInterpretation().getAlphaBand();
126 122
//                if(sourceTypes[alphaBand]!=BufferManager.TYPE_BYTE){
127 123
//                    throw new UnsupportedOperationException("The type of ALPHA band isn't BYTE");
128 124
//                }
......
131 127
//                noDatas.add(sourceNoDatas[alphaBand]);
132 128
//            }
133 129

  
134
            if (copyUnprocessedBands) {
130
            if (mustCopyUnprocessedBands()) {
135 131
                for (int band = 0; band < sourceBands; band++) {
136 132
                    if (!isProcessableBand(band)) {
137 133
                        colorInterpretations.add(ColorInterpretation.UNDEFINED_BAND);
138 134
                        noDatas.add(sourceNoDatas[band]);
139
                        types.add(this.buffer.getBandTypes()[band]);
135
                        types.add(this.getInputBuffer().getBandTypes()[band]);
140 136
                    }
141 137
                }
142 138
            }
143 139

  
144
            outputColorInterpretation =
145
                legendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
146
            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, outputColorInterpretation);
147
            int[] typesInt = new int[types.size()];
148
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
149
                int i = 0;
150
                Integer type = (Integer) iterator.next();
151
                typesInt[i] = type.intValue();
152
            }
140
            setOutputColorInterpretation(
141
                legendManager.createColorInterpretation(colorInterpretations));
142
            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getOutputColorInterpretation());
153 143

  
154
            this.outputBuffer =
155
                manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
156
                    noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
144
            this.setOutputBuffer(
145
                manager.createBuffer(
146
                        this.getInputBuffer().getRows(), 
147
                        this.getInputBuffer().getColumns(), 
148
                        this.getTypesAsArray(types),
149
                        this.getNoDatasAsArray(noDatas), 
150
                        this.getInputBuffer().getProjection(), 
151
                        this.getInputBuffer().getEnvelope()));
157 152
        } catch (LocatorException | BufferException | CreateEnvelopeException e) {
158 153
            throw new ProcessingOperationException(e);
159 154
        }
......
166 161

  
167 162
            // List<Integer> bandsToProcess = new ArrayList<Integer>();
168 163

  
169
            if (copyUnprocessedBands) {
170
                int bands = this.buffer.getBandCount();
171
                int outBand = 4; //colorInterpretation.hasAlphaBand() ? 4 : 3;
164
            if (mustCopyUnprocessedBands()) {
165
                int bands = this.getInputBuffer().getBandCount();
166
                int outBand = 4; //getInputColorInterpretation().hasAlphaBand() ? 4 : 3;
172 167
                for (int band = 0; band < bands; band++) {
173 168
                    if (!isProcessableBand(band)) {
174
                        outputBuffer.getBand(outBand).copyFrom(this.buffer.getBand(band));
169
                        getOutputBuffer().getBand(outBand).copyFrom(this.getInputBuffer().getBand(band));
175 170
                        outBand++;
176 171
                    }
177 172
                }
178 173
            }
179 174

  
180
            for (int row = 0; row < this.buffer.getRows(); row++) {
181
                Band bufferPaletteBand = buffer.getBand(colorInterpretation.getPaletteBand());
175
            for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
176
                Band bufferPaletteBand = getInputBuffer().getBand(getInputColorInterpretation().getPaletteBand());
182 177
                Object rowBandBuffer = bufferPaletteBand.createRowBuffer();
183 178
                bufferPaletteBand.fetchRow(row, rowBandBuffer);
184 179

  
185
                List<Object> outputRowBuffers = new ArrayList<Object>();
180
                List<Object> outputRowBuffers = new ArrayList<>();
186 181
                for (int band = 0; band < 4; band++) {
187
                    Band outputBufferBand = outputBuffer.getBand(band);
182
                    Band outputBufferBand = getOutputBuffer().getBand(band);
188 183
                    Object outputRowBuffer = outputBufferBand.createRowBuffer();
189 184
                    outputRowBuffers.add(outputRowBuffer);
190 185
                }
......
192 187
                rowProcessor.processRow(rowBandBuffer, outputRowBuffers);
193 188

  
194 189
                for (int band = 0; band < 4; band++) {
195
                    Band outputBufferBand = outputBuffer.getBand(band);
190
                    Band outputBufferBand = getOutputBuffer().getBand(band);
196 191
                    outputBufferBand.putRow(row, outputRowBuffers.get(band));
197 192
                }
198 193

  
......
212 207
     * @param band
213 208
     * @return
214 209
     */
215
    private boolean isProcessableBand(int band) {
210
    @Override
211
    protected boolean isProcessableBand(int band) {
216 212
        return isPaletteBand(band);
217 213
    }
218 214

  
219 215
    private boolean isPaletteBand(int band) {
220
        return (colorInterpretation.getPaletteBand() == band);
216
        return (getInputColorInterpretation().getPaletteBand() == band);
221 217
    }
222 218

  
223 219

  
......
231 227
        NoData noData;
232 228

  
233 229
        public AbstractRowProcessor() {
234
            noData = buffer.getBand(colorInterpretation.getPaletteBand()).getNoData();
230
            noData = getInputBuffer().getBand(getInputColorInterpretation().getPaletteBand()).getNoData();
235 231
        }
236 232
    }
237 233

  
......
265 261
                }
266 262
            }
267 263

  
268
            return colorInterpretation.getPalette().getRGBA(0xFF & (byte)value);
264
            return getInputColorInterpretation().getPalette().getRGBA(0xFF & (byte)value);
269 265
        }
270 266

  
271 267
    }
......
295 291
                return result;
296 292
            }
297 293

  
298
            return colorInterpretation.getPalette().getRGBA(value);
294
            return getInputColorInterpretation().getPalette().getRGBA(value);
299 295
        }
300 296

  
301 297
    }
......
325 321
                return result;
326 322
            }
327 323

  
328
            return colorInterpretation.getPalette().getRGBA(0xFFFF & (byte)value);
324
            return getInputColorInterpretation().getPalette().getRGBA(0xFFFF & (byte)value);
329 325
        }
330 326

  
331 327
    }
......
355 351
                return result;
356 352
            }
357 353

  
358
            return colorInterpretation.getPalette().getRGBA(value);
354
            return getInputColorInterpretation().getPalette().getRGBA(value);
359 355
        }
360 356

  
361 357
    }
......
384 380
                return result;
385 381
            }
386 382

  
387
            return colorInterpretation.getPalette().getRGBA(value);
383
            return getInputColorInterpretation().getPalette().getRGBA(value);
388 384
        }
389 385

  
390 386
    }
......
415 411
                return result;
416 412
            }
417 413

  
418
            return colorInterpretation.getPalette().getRGBA(value);
414
            return getInputColorInterpretation().getPalette().getRGBA(value);
419 415
        }
420 416

  
421 417
    }
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/brightness/BrightnessOperation.java
22 22
 */
23 23
package org.gvsig.raster.lib.legend.impl.operations.brightness;
24 24

  
25
import java.util.ArrayList;
26
import java.util.Iterator;
27
import java.util.List;
28 25

  
29 26
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
30 27
import org.gvsig.raster.lib.buffer.api.Band;
......
59 56
     *
60 57
     */
61 58
    public BrightnessOperation(OperationFactory factory) {
62
        this.factory = factory;
59
        super(factory);
63 60
    }
64 61

  
65 62
    @Override
......
68 65
        BufferManager manager = BufferLocator.getBufferManager();
69 66
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
70 67

  
71
        brightness = (Integer) this.parameters.getDynValue(BRIGHTNESS_PARAM);
68
        brightness = (Integer) this.getParameter(BRIGHTNESS_PARAM,0);
72 69

  
73
        int bands = this.buffer.getBandCount();
70
        int bands = this.getInputBuffer().getBandCount();
74 71
        NoData[] noData;
75
        if (copyUnprocessedBands) {
76
            this.parameters.setDynValue(OUTPUT_COLOR_INTERPRETATION_PARAM, colorInterpretation);
77
            noData = this.buffer.getBandNoData();
72
        if (mustCopyUnprocessedBands()) {
73
            this.setParameter(OUTPUT_COLOR_INTERPRETATION_PARAM, getInputColorInterpretation());
74
            noData = this.getInputBuffer().getBandNoData();
78 75
            try {
79
                this.outputBuffer =
80
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), this.buffer.getBandTypes(),
81
                        this.buffer.getBandNoData(), this.buffer.getProjection(), this.buffer.getEnvelope());
82
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
76
                this.setOutputBuffer(
77
                    manager.createBuffer(
78
                            this.getInputBuffer().getRows(), 
79
                            this.getInputBuffer().getColumns(), 
80
                            this.getInputBuffer().getBandTypes(),
81
                            this.getInputBuffer().getBandNoData(), 
82
                            this.getInputBuffer().getProjection(), 
83
                            this.getInputBuffer().getEnvelope()));
84
            } catch (Exception e) {
83 85
                throw new ProcessingOperationException(e);
84 86
            }
85 87
        } else {
86
            List<String> colorInterpretations = new ArrayList<String>();
87
            List<NoData> noDatas = new ArrayList<NoData>();
88
            List<Integer> types = new ArrayList<Integer>();
89
            for (int band = 0; band < bands; band++) {
90
                if (isProcessableBand(band)) {
91
                    colorInterpretations.add(colorInterpretation.get(band));
92
                    noDatas.add(this.buffer.getBandNoData()[band]);
93
                    types.add(this.buffer.getBandTypes()[band]);
94
                }
95
            }
96
            if (colorInterpretation.hasAlphaBand()) {
97
                colorInterpretations.add(ColorInterpretation.ALPHA_BAND);
98
            }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff