Statistics
| Revision:

svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.library / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.buffer.spi / src / main / java / org / gvsig / raster / lib / buffer / spi / operations / AbstractOperation.java @ 43803

History | View | Annotate | Download (3.7 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.raster.lib.buffer.spi.operations;
24

    
25
import org.gvsig.raster.lib.buffer.api.Buffer;
26
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
27
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
28
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
29
import org.gvsig.tools.dynobject.DynObject;
30
import org.gvsig.tools.persistence.PersistentState;
31
import org.gvsig.tools.persistence.exception.PersistenceException;
32

    
33

    
34
/**
35
 * @author fdiaz
36
 *
37
 */
38
public abstract class AbstractOperation implements OperationServices {
39

    
40
    static public String COPY_UNPROCESSED_BANDS_PARAM = "copy_unprocessed_bands";
41

    
42
    protected Buffer buffer;
43
    protected DynObject parameters;
44
    protected Buffer outputBuffer;
45
    protected OperationFactory factory;
46
    protected boolean copyUnprocessedBands;
47

    
48

    
49
    /**
50
     *
51
     */
52
    public AbstractOperation() {
53
        // Nothing to do
54
    }
55

    
56
    @Override
57
    public void preProcess() throws BufferOperationException {
58
        if (this.parameters.getDynClass().getDynField(COPY_UNPROCESSED_BANDS_PARAM) != null
59
            && this.parameters.hasDynValue(COPY_UNPROCESSED_BANDS_PARAM)) {
60
            copyUnprocessedBands = (Boolean) this.parameters.getDynValue(COPY_UNPROCESSED_BANDS_PARAM);
61
        } else {
62
            copyUnprocessedBands = true;
63
        }
64
    }
65

    
66
    @Override
67
    public void process() throws ProcessingOperationException {
68
        //Nothing to do
69
    }
70

    
71
    @Override
72
    public void postProcess() throws BufferOperationException {
73
        //Nothing to do
74
    }
75

    
76

    
77
    /* (non-Javadoc)
78
     * @see org.gvsig.raster.lib.buffer.api.Operation#execute(org.gvsig.raster.lib.buffer.api.Buffer, org.gvsig.tools.dynobject.DynObject)
79
     */
80
    @Override
81
    public Buffer execute(Buffer buffer, DynObject parameters) throws BufferOperationException {
82
        this.buffer = buffer;
83
        this.parameters = parameters;
84
        this.preProcess();
85
        this.process();
86
        this.postProcess();
87
        return this.getOutputBuffer();
88
    }
89

    
90
    /* (non-Javadoc)
91
     * @see org.gvsig.raster.lib.buffer.api.Operation#getFactory()
92
     */
93
    @Override
94
    public OperationFactory getFactory() {
95
        return factory;
96
    }
97

    
98
    /* (non-Javadoc)
99
     * @see org.gvsig.raster.lib.buffer.spi.OperationServices#getParameters()
100
     */
101
    @Override
102
    public DynObject getParameters() {
103
        return parameters;
104
    }
105

    
106
    /* (non-Javadoc)
107
     * @see org.gvsig.raster.lib.buffer.spi.OperationServices#getInputBuffer()
108
     */
109
    @Override
110
    public Buffer getInputBuffer() {
111
        return this.buffer;
112
    }
113

    
114
    /* (non-Javadoc)
115
     * @see org.gvsig.raster.lib.buffer.spi.OperationServices#getOutputBuffer()
116
     */
117
    @Override
118
    public Buffer getOutputBuffer() {
119
        return outputBuffer;
120
    }
121
}