Revision 43867

View differences:

branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/pom.xml
58 58
        <module>org.gvsig.png.app</module>
59 59
        <module>org.gvsig.tiff.app</module>
60 60
        <module>org.gvsig.jp2.app</module>
61
        <module>org.gvsig.bsq.app</module>
61 62
    </modules>
62 63

  
63 64
</project>
64 65

  
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.mainplugin/src/main/java/org/gvsig/raster/tools/app/mainplugin/SaveRasterLayerExtension.java
69 69
                    if (buffer != null) {
70 70
                        Buffer filteredBuffer = null;
71 71
                        try {
72
                            filteredBuffer = filters.execute(buffer);
72
                            filteredBuffer = filters.execute(null,buffer);
73 73
                            RasterSwingBufferManager rasterSwingBufferManager =
74 74
                                RasterSwingBufferLocator.getSwingManager();
75 75
                            SaveBufferDialog saveBufferDialog = rasterSwingBufferManager.createSaveBufferDialog();
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.raster.app/org.gvsig.raster.app.mainplugin/src/main/java/org/gvsig/raster/app/mainplugin/StatisticsPage.java
91 91
                    updateStatisticsPanel();
92 92
                }
93 93
            });
94
            panel.set(this.layer.getStatistics(null));
94
            updateStatisticsPanel();
95
//            panel.set(this.layer.getStatistics(null));
95 96

  
96 97
            panel.addActionListener(new ActionListener() {
97 98

  
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.bsq.app/org.gvsig.bsq.app.mainplugin/buildNumber.properties
1
#Tue Feb 20 10:20:55 CET 2018
2
buildNumber=3000
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.bsq.app/org.gvsig.bsq.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
  <id>gvsig-plugin-package</id>
28
  <formats>
29
    <format>zip</format>
30
  </formats>
31
  <baseDirectory>${project.artifactId}</baseDirectory>
32
  <includeBaseDirectory>true</includeBaseDirectory>
33
  <files>
34
    <file>
35
      <source>target/${project.artifactId}-${project.version}.jar</source>
36
      <outputDirectory>lib</outputDirectory>
37
    </file>
38
    <file>
39
      <source>target/package.info</source>
40
    </file>
41
  </files>
42

  
43
  <fileSets>
44
    <fileSet>
45
      <directory>src/main/resources-plugin</directory>
46
      <outputDirectory>.</outputDirectory>
47
    </fileSet>
48
  </fileSets>
49

  
50

  
51
  <dependencySets>
52
    <dependencySet>
53
      <useProjectArtifact>false</useProjectArtifact>
54
      <useTransitiveDependencies>false</useTransitiveDependencies>
55
      <outputDirectory>lib</outputDirectory>
56
      <includes>
57
        <include>org.gvsig:org.gvsig.fmap.dal.file.bsq</include>
58
      </includes>
59
    </dependencySet>
60
  </dependencySets>
61

  
62
</assembly>
63

  
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.bsq.app/org.gvsig.bsq.app.mainplugin/src/main/java/org/gvsig/bsq/app/BSQExtension.java
1

  
2
package org.gvsig.bsq.app;
3

  
4
import org.gvsig.andami.plugins.Extension;
5

  
6

  
7
public class BSQExtension extends Extension {
8

  
9
    @Override
10
    public void initialize() {
11
//        DynClass metadataDefinition = BSQLibrary.getMatadataDefinition();
12
//        BSQGetLegend.register(metadataDefinition);
13
//        BSQGetColorInterpretation.register(metadataDefinition); 
14
//        BSQGetColorTable.register(metadataDefinition); 
15
    }
16

  
17
    @Override
18
    public void execute(String actionCommand) {
19
    }
20

  
21
    @Override
22
    public boolean isEnabled() {
23
        return false;
24
    }
25

  
26
    @Override
27
    public boolean isVisible() {
28
        return false;
29
    }
30
    
31
}
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.bsq.app/org.gvsig.bsq.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<plugin-config>
28
  <depends plugin-name="org.gvsig.app.mainplugin" />
29
  <libraries library-dir="lib"/>
30
  <resourceBundle name="text"/>
31
  <extensions>
32
    <extension class-name="org.gvsig.bsq.app.BSQExtension"
33
      description=""
34
      active="true">
35
    </extension>
36
  </extensions>
37

  
38
</plugin-config>
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.bsq.app/org.gvsig.bsq.app.mainplugin/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
    <modelVersion>4.0.0</modelVersion>
4
    <artifactId>org.gvsig.bsq.app.mainplugin</artifactId>
5
    <packaging>jar</packaging>
6
    <name>${project.artifactId}</name>
7
    <description>BSQ file format support</description>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.bsq.app</artifactId>
11
        <version>3.0.0-SNAPSHOT</version>
12
    </parent>
13
    <dependencies>
14

  
15
        <dependency>
16
            <groupId>org.gvsig</groupId>
17
            <artifactId>org.gvsig.fmap.dal.file.bsq</artifactId>
18
            <scope>compile</scope>
19
        </dependency>
20

  
21
        <dependency>
22
            <groupId>org.gvsig</groupId>
23
            <artifactId>org.gvsig.andami</artifactId>
24
            <scope>compile</scope>
25
        </dependency>
26
    </dependencies>
27

  
28
    <properties>
29
        <gvsig.package.info.name>Formats: BSQ raster file format support</gvsig.package.info.name>
30
        <gvsig.package.info.categories>Formats,Raster</gvsig.package.info.categories>
31
        <gvsig.package.info.official>true</gvsig.package.info.official>
32
    </properties>
33

  
34
</project>
35

  
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.bsq.app/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.bsq.app</artifactId>
6
    <name>${project.artifactId}</name>
7
    <packaging>pom</packaging>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.desktop.plugin</artifactId>
11
        <version>3.0.0-SNAPSHOT</version>
12
    </parent>
13
  
14
    <modules>
15
        <module>org.gvsig.bsq.app.mainplugin</module>
16
    </modules>
17
</project>
0 18

  
branches/org.gvsig.desktop-2018a/pom.xml
1252 1252
                <artifactId>org.gvsig.fmap.dal.file.tiff</artifactId>
1253 1253
                <version>3.0.0-SNAPSHOT</version>
1254 1254
            </dependency>
1255
            <dependency>
1256
                <groupId>org.gvsig</groupId>
1257
                <artifactId>org.gvsig.fmap.dal.file.bsq</artifactId>
1258
                <version>3.0.0-SNAPSHOT</version>
1259
            </dependency>
1255 1260

  
1256 1261
            <dependency>
1257 1262
                <groupId>org.gvsig</groupId>
......
2764 2769

  
2765 2770
        <jython.artifactId>jython-standalone</jython.artifactId>
2766 2771
        <!-- External project versions -->
2767
        <gvsig.tools.version>3.0.153</gvsig.tools.version>
2772
        <gvsig.tools.version>3.0.154</gvsig.tools.version>
2768 2773
        <gvsig.proj.version>1.0.4</gvsig.proj.version>
2769 2774
        <gvsig.projection.api.version>2.0.25</gvsig.projection.api.version>
2770 2775

  
2771 2776

  
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
30 30
import org.gvsig.tools.observer.WeakReferencingObservable;
31 31
import org.gvsig.tools.persistence.Persistent;
32 32
import org.gvsig.tools.lang.Cloneable;
33
import org.gvsig.tools.task.TaskStatus;
33
import org.gvsig.tools.task.SimpleTaskStatus;
34 34

  
35 35

  
36 36
/**
......
45 45
     * @return the buffer result of executing the operations list in chained fashion
46 46
     * @throws BufferOperationException
47 47
     */
48
    public Buffer execute(TaskStatus status, Buffer buffer) throws BufferOperationException;
48
    public Buffer execute(SimpleTaskStatus 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/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.task.SimpleTaskStatus;
28 29
import org.gvsig.tools.task.TaskStatus;
29 30

  
30 31

  
......
41 42
     * @return the buffer result of executing the operation
42 43
     * @throws BufferOperationException
43 44
     */
44
    public Buffer execute(TaskStatus status, Buffer buffer, DynObject parameters) throws BufferOperationException;
45
    public Buffer execute(SimpleTaskStatus status, Buffer buffer, DynObject parameters) throws BufferOperationException;
45 46

  
46 47
    /**
47 48
     * @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/statistics/Statistics.java
117 117
     * desde el principio del array ordenado y desde el final de ?l (m?nimo y m?ximo).
118 118
     *
119 119
     * @param percent Porcentaje de recorte
120
     * @param valueByBand array bidimensional de enteros o doubles. Depende del tipo de dato del raster.
121 120
     * @return El valor de recorte de colas para el porcentaje dado
122 121
     */
123 122
    public double[][] getTailTrimValue(double percent);
......
129 128
     * raster (o una muestra de ellos) y devolver el valor que corresponde al porcentaje comenzando
130 129
     * desde el principio del array ordenado y desde el final de ?l (m?nimo y m?ximo).
131 130
     * @param pos posici?n de recorte
132
     * @param valueByBand array bidimensional de enteros o doubles. Depende del tipo de dato del raster.
133 131
     * @return el valor de recorte de colas para la posici?n dada
134 132
     */
135 133
    public double[][] getTailTrimValue(int pos);
......
144 142
     * Throws the thread which figure out statistics
145 143
     * @param status
146 144
     * @param bands
147
     * @throws FileNotOpenException
148
     * @throws RasterDriverException
149
     * @throws ProcessInterruptedException
150 145
     */
151 146
    public void calculate(SimpleTaskStatus status, List<Band> bands); //??? scale ???
152 147

  
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
import org.gvsig.tools.task.SimpleTaskStatus;
34 34

  
35 35

  
36 36
/**
......
93 93
     * @return the buffer result of executing the operation
94 94
     * @throws BufferOperationException
95 95
     */
96
    public Buffer execute (TaskStatus status, String name, Buffer buffer, DynObject parameters) throws BufferOperationException;
96
    public Buffer execute (SimpleTaskStatus status, String name, Buffer buffer, DynObject parameters) throws BufferOperationException;
97 97

  
98 98

  
99 99
};
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
28 28
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
29 29
import org.gvsig.tools.ToolsLocator;
30 30
import org.gvsig.tools.dynobject.DynObject;
31
import org.gvsig.tools.task.TaskStatus;
31
import org.gvsig.tools.task.SimpleTaskStatus;
32 32
import org.gvsig.tools.task.TaskStatusManager;
33 33

  
34 34

  
......
44 44
    private DynObject parameters;
45 45
    private Buffer outputBuffer;
46 46
    private final OperationFactory factory;
47
    private TaskStatus taskStatus;
47
    private SimpleTaskStatus taskStatus;
48 48

  
49 49
    private boolean copyUnprocessedBands;
50 50

  
......
71 71
    }
72 72

  
73 73
    @Override
74
    public TaskStatus getTaskStatus() {
74
    public SimpleTaskStatus getTaskStatus() {
75 75
        if( this.taskStatus==null ) {
76 76
            TaskStatusManager taskStatusManager = ToolsLocator.getTaskStatusManager();
77 77
            this.taskStatus = taskStatusManager.createDefaultSimpleTaskStatus(
78 78
                this.getFactory().getName());
79
            this.taskStatus.setAutoremove(true);
80
            this.taskStatus.add();
79 81
        }
80 82
        return this.taskStatus;
81 83
    }
......
95 97
     * @see org.gvsig.raster.lib.buffer.api.Operation#execute(org.gvsig.raster.lib.buffer.api.Buffer, org.gvsig.tools.dynobject.DynObject)
96 98
     */
97 99
    @Override
98
    public Buffer execute(TaskStatus status, Buffer buffer, DynObject parameters) throws BufferOperationException {
100
    public Buffer execute(SimpleTaskStatus status, Buffer buffer, DynObject parameters) throws BufferOperationException {
99 101
        this.buffer = buffer;
100 102
        this.parameters = parameters;
101 103
        this.taskStatus = status;
102
        this.preProcess();
103
        this.process();
104
        this.postProcess();
105
        return this.getOutputBuffer();
104
        try {
105
            this.taskStatus.push();
106
            
107
            this.preProcess();
108
            this.process();
109
            this.postProcess();
110
            return this.getOutputBuffer();
111
        } finally {
112
            if( this.taskStatus.isRunning() ) {
113
                this.taskStatus.terminate();
114
            }
115
            this.taskStatus.pop();
116
        }
106 117
    }
107 118

  
108 119
    /* (non-Javadoc)
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/OperationServices.java
26 26
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
27 27
import org.gvsig.raster.lib.buffer.api.operations.Operation;
28 28
import org.gvsig.tools.dynobject.DynObject;
29
import org.gvsig.tools.task.SimpleTaskStatus;
29 30
import org.gvsig.tools.task.TaskStatus;
30 31

  
31 32

  
......
73 74
     */
74 75
    void postProcess() throws BufferOperationException;
75 76

  
76
    TaskStatus getTaskStatus();
77
    SimpleTaskStatus getTaskStatus();
77 78
}
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/AbstractSpecifiedBandsOperation.java
24 24

  
25 25
import java.util.ArrayList;
26 26
import java.util.List;
27
import org.gvsig.raster.lib.buffer.api.Buffer;
28 27
import org.gvsig.raster.lib.buffer.api.NoData;
29 28

  
30 29
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/BufferInterpolation.java
194 194
        } else {
195 195
            status.push();
196 196
        }
197
        status.add();
197 198
        try {
198 199
            int rows = target.getRows();
199 200
            int columns = target.getColumns();
......
201 202
            double pxSizeX = (double) source.getColumns() / (double) columns;
202 203
            double pxSizeY = (double) source.getRows() / (double) rows;
203 204

  
204
            status.setRangeOfValues(0, source.getBandCount() * source.getRows() * source.getColumns());
205
            status.message("Calculating interpolation");
206
            int count = 0;
207 205
            double posX, posY;
208 206
            double dx = 0D, dy = 0D;
209

  
210
            for (int iBand = 0; iBand < source.getBandCount(); iBand++) {
207
            int bandCount = source.getBandCount();
208
            for (int iBand = 0; iBand < bandCount; iBand++) {
209
                status.setRangeOfValues(0, source.getRows());
210
                status.message("Interpolating, band "+iBand+"/"+ bandCount);
211
                status.setCurValue(0);
211 212
                posY = pxSizeY / 2D;
212 213
                Band sourceBand = source.getBand(iBand);
213 214
                Band targetBand = target.getBand(iBand);
214 215
                for (int iRow = 0; iRow < rows; iRow++) {
216
                    status.setCurValue(iRow);
217
                    if (status.isCancelled()) {
218
                        status.abort();
219
                        return;
220
                    }
215 221
                    dy = posY - ((int) posY);
216 222
                    posX = pxSizeX / 2D;
217 223
                    for (int iCol = 0; iCol < columns; iCol++) {
218
                        status.setCurValue(count++);
219
                        if (status.isCancelled()) {
220
                            status.abort();
221
                            return;
222
                        }
223 224
                        dx = posX - ((int) posX);
224 225
                        try {
225 226
                            double[] kernel = getKernel((int) posY, (int) posX, sourceBand);
......
245 246
            status.abort();
246 247
            throw e;
247 248
        }
248
        return;
249 249
    }
250 250

  
251 251
    /**
......
374 374
            double pxSizeX = (double) source.getColumns() / (double) columns;
375 375
            double pxSizeY = (double) source.getRows() / (double) rows;
376 376

  
377
            status.setRangeOfValues(0, source.getBandCount() * source.getRows() * source.getColumns());
377
            status.setRangeOfValues(0, source.getRows()*source.getBandCount());
378 378
            status.message("Calculating interpolation");
379 379
            int count = 0;
380 380
            double posX, posY;
......
385 385
                Band sourceBand = source.getBand(iBand);
386 386
                Band targetBand = target.getBand(iBand);
387 387
                for (int iRow = 0; iRow < rows; iRow++) {
388
                    status.setCurValue(count++);
389
                    if (status.isCancelled()) {
390
                        status.abort();
391
                        return;
392
                    }
388 393
                    dy = posY - ((int) posY);
389 394
                    posX = pxSizeX / 2D;
390 395
                    for (int iCol = 0; iCol < columns; iCol++) {
391
                        status.setCurValue(count++);
392
                        if (status.isCancelled()) {
393
                            status.abort();
394
                            return;
395
                        }
396 396
                        dx = posX - ((int) posX);
397 397
                        try {
398 398
                            double[][] submatrix = get4x4Submatrix(((int) posY), ((int) posX), source, sourceBand);
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/linearstretchenhancement/LinearStretchEnhancementOperation.java
140 140
    @Override
141 141
    public void process() throws ProcessingOperationException {
142 142
        super.process();
143
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
143
        int bandCount = this.getInputBuffer().getBandCount();
144
        int rowCount = this.getInputBuffer().getRows();
145
        for (int band=0; band<bandCount; band++){
144 146
            if (this.getBandsToProcess().contains(band)) {
147
                this.getTaskStatus().setRangeOfValues(0, rowCount);
148
                this.getTaskStatus().setCurValue(0);
149
                this.getTaskStatus().message("LinearStretch band "+band+"/"+bandCount);
150

  
145 151
                Band bufferBand = this.getInputBuffer().getBand(band);
146 152
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
147 153

  
148
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
154
                for (int row = 0; row < rowCount; row++) {
155
                    this.getTaskStatus().setCurValue(row);
149 156
                    Object rowBuffer = bufferBand.createRowBuffer();
150 157
                    bufferBand.fetchRow(row, rowBuffer);
151 158

  
......
164 171
                }
165 172
            }
166 173
        }
174
        this.getTaskStatus().terminate();
167 175
    }
168 176

  
169 177
    @Override
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/DefaultOperationList.java
57 57
import org.gvsig.tools.persistence.PersistenceManager;
58 58
import org.gvsig.tools.persistence.PersistentState;
59 59
import org.gvsig.tools.persistence.exception.PersistenceException;
60
import org.gvsig.tools.task.TaskStatus;
60
import org.gvsig.tools.task.SimpleTaskStatus;
61 61

  
62 62

  
63 63
/**
......
249 249
    }
250 250

  
251 251
    @Override
252
    public Buffer execute(TaskStatus status, Buffer buffer) throws BufferOperationException {
252
    public Buffer execute(SimpleTaskStatus status, Buffer buffer) throws BufferOperationException {
253 253
        Buffer tmpBuffer1 = buffer;
254 254
        DisposeUtils.bind(tmpBuffer1);
255 255
        Buffer tmpBuffer2;
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/DefaultBufferManager.java
55 55
import org.gvsig.tools.dynobject.DynObject;
56 56
import org.gvsig.tools.folders.FoldersManager;
57 57
import org.gvsig.tools.locator.LocatorException;
58
import org.gvsig.tools.task.TaskStatus;
58
import org.gvsig.tools.task.SimpleTaskStatus;
59 59

  
60 60
/**
61 61
 * @author fdiaz
......
655 655
    }
656 656

  
657 657
    @Override
658
    public Buffer execute(TaskStatus status, String name, Buffer buffer, DynObject parameters) throws BufferOperationException {
658
    public Buffer execute(SimpleTaskStatus status, String name, Buffer buffer, DynObject parameters) throws BufferOperationException {
659 659
        OperationFactory factory = getOperationFactory(name);
660 660
        Operation operation = factory.create();
661 661
        return operation.execute(status, buffer, parameters);
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/statistics/DefaultStatistics.java
27 27
    double[][] varCov;
28 28

  
29 29
    /**
30
     * @param bands
31 30
     *
32 31
     */
33 32
    public DefaultStatistics() {
......
167 166
        }
168 167
        init(bands);
169 168
        try {
170
            status.setRangeOfValues(0, statisticsBands.length * 3);
169
            status.setIndeterminate();
171 170
            status.message("Calculating statistics");
172
            long cont = 0;
173

  
171
            int count = 1;
172
            int maxCount = statisticsBands.length*3;
174 173
            for (int i = 0; i < statisticsBands.length; i++) {
175
                status.setCurValue(cont++);
176
                if (status.isCancelled()) {
174
                status.message("Calculating statistics "+count++ +"/"+maxCount);
175
               if (status.isCancelled()) {
177 176
                    status.abort();
178 177
                    return;
179 178
                }
......
182 181
                }
183 182
            }
184 183
            for (int i = 0; i < statisticsBands.length; i++) {
185
                status.setCurValue(cont++);
184
                status.message("Calculating statistics "+count++ +"/"+maxCount);
186 185
                if (status.isCancelled()) {
187 186
                    status.abort();
188 187
                    return;
189 188
                }
190 189
                for (int j = i; j < statisticsBands.length; j++) {
191
                    this.varCov[i][j] = getCovariance(statisticsBands[i],bands.get(i), statisticsBands[j], bands.get(j));
190
                    this.varCov[i][j] = getCovariance(status,statisticsBands[i],bands.get(i), statisticsBands[j], bands.get(j));
192 191
                }
193 192
            }
194

  
193
            status.setIndeterminate();
195 194
            for (int i = 0; i < statisticsBands.length; i++) {
196
                status.setCurValue(cont++);
195
                status.message("Calculating statistics "+count++ +"/"+maxCount);
197 196
                if (status.isCancelled()) {
198 197
                    status.abort();
199 198
                    return;
......
214 213
        }
215 214
    }
216 215

  
217
    private double getCovariance(StatisticsBand statisticBand1, Band band1, StatisticsBand statisticBand2, Band band2) {
216
    private double getCovariance(SimpleTaskStatus  status, StatisticsBand statisticBand1, Band band1, StatisticsBand statisticBand2, Band band2) {
218 217

  
219 218
        double sigma = 0;
220 219
        int n = 0;
221

  
222
        for (int row = 0; row < band1.getRows(); row++) {
220
        int rowCount = band1.getRows();
221
        status.setRangeOfValues(0, rowCount);
222
        for (int row = 0; row < rowCount; row++) {
223
            status.setCurValue(row);
223 224
            for (int column = 0; column < band1.getColumns(); column++) {
224 225
                Double v1 = band1.getAsDouble(row, column);
225 226
                if (v1 != null) {
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/statistics/DefaultStatisticsBand.java
57 57
        if (status == null) {
58 58
            status = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus("Statistics");
59 59
            status.add();
60
            status.message("Calculating statistics band");
60 61
            isMyStatus = true;
61 62
        } else {
62 63
            status.push();
......
64 65
        try {
65 66
            calculated = false;
66 67
            status.setRangeOfValues(0, band.getRows() * 2);
67
            status.message("Calculating statistics band");
68 68
            long cont = 0;
69 69

  
70 70
            this.bandLenght = band.getRows() * band.getColumns();
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/AbstractPaginatedBand.java
30 30
    protected BandPageManager pageManager;
31 31
    private boolean loaded;
32 32

  
33
    protected static final int MAX_PREFERED_SIZE = 10485760; // 10MB;
33
    // protected static final int MAX_PREFERED_SIZE = 10485760; // 10MB;
34
    protected static final int MAX_PREFERED_SIZE = 2621440; // 2.5MB;
34 35

  
35 36
    /**
36 37
     * @param rows
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/raster/spi/AbstractRasterStoreProvider.java
66 66
 */
67 67
public abstract class AbstractRasterStoreProvider extends AbstractDisposable implements RasterStoreProvider{
68 68

  
69
    private static final Logger LOG =
69
    protected static final Logger LOG =
70 70
        LoggerFactory.getLogger(AbstractRasterStoreProvider.class);
71 71

  
72 72
    private RasterStoreProviderServices store;
......
258 258
        try {
259 259
            open();
260 260
        } catch (Exception e) {
261
            throw new RuntimeException();
261
            throw new RuntimeException(e);
262 262
        }
263 263
    }
264 264

  
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.tiff/src/main/java/org/gvsig/fmap/dal/file/tiff/TiffLibrary.java
98 98
                    new ImageIOFileSystemServerProviderFactory(
99 99
                            NAME,
100 100
                            DESCRIPTION,
101
                            FILE_EXTENSIONS
101
                            FILE_EXTENSIONS,
102
                            true
102 103
                    )
103 104
            );
104 105
        } catch (Exception e) {
105 106

  
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.imageio/src/main/java/org/gvsig/fmap/dal/file/imageio/ImageIOFileSystemServerProvider.java
22 22
 */
23 23
package org.gvsig.fmap.dal.file.imageio;
24 24

  
25
import java.awt.image.BufferedImage;
25 26
import java.io.File;
27
import java.io.FileOutputStream;
28
import java.io.IOException;
29
import java.lang.reflect.InvocationTargetException;
30
import java.lang.reflect.Method;
31
import java.util.logging.Level;
32
import java.util.logging.Logger;
33
import javax.imageio.IIOImage;
34
import javax.imageio.ImageIO;
35
import javax.imageio.ImageWriteParam;
36
import javax.imageio.ImageWriter;
26 37

  
27 38
import org.apache.commons.io.FilenameUtils;
39
import org.apache.commons.io.IOUtils;
28 40

  
29 41
import org.gvsig.fmap.dal.DataServerExplorer;
42
import org.gvsig.fmap.dal.NewDataStoreParameters;
43
import org.gvsig.fmap.dal.exception.CreateException;
44
import org.gvsig.fmap.dal.exception.DataException;
45
import org.gvsig.fmap.dal.raster.api.NewRasterStoreParameters;
46
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
30 47
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
31 48
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
49
import org.gvsig.raster.lib.buffer.api.Buffer;
50
import org.gvsig.tools.ToolsLocator;
51
import org.gvsig.tools.dataTypes.CoercionException;
52
import org.gvsig.tools.dataTypes.DataTypes;
53
import org.gvsig.tools.dataTypes.DataTypesManager;
54
import org.gvsig.tools.dynobject.DynField;
55
import org.gvsig.tools.dynobject.DynField_v2;
32 56

  
33 57
public class ImageIOFileSystemServerProvider extends AbstractFilesystemServerExplorerProvider {
34 58

  
35 59
    protected FilesystemServerExplorerProviderServices serverExplorer;
36 60

  
37 61
    protected String[] fileExtensions;
62
    protected boolean canCreate;
38 63

  
39 64
    public ImageIOFileSystemServerProvider(
40 65
            String name, 
41 66
            String description, 
42 67
            String[] fileExtensions
43 68
        ) {
69
        this(name, description, fileExtensions, false);
70
    }
71
    
72
    public ImageIOFileSystemServerProvider(
73
            String name, 
74
            String description, 
75
            String[] fileExtensions,
76
            boolean canCreate
77
        ) {
44 78
        super(name, description);
45 79
        this.fileExtensions = fileExtensions;
80
        this.canCreate = canCreate;
46 81
    }
47 82
    
48 83
    @Override
84
    public boolean canCreate() {
85
        return canCreate;
86
    }
87

  
88
    @Override
89
    public NewDataStoreParameters getCreateParameters() throws DataException {
90
        if( !this.canCreate() ) {
91
           throw new UnsupportedOperationException();
92
        }
93
        return null ; // TODO: Falta la creacion de los parametros 
94
    }
95

  
96
    @Override
97
    public void create(NewDataStoreParameters parameters, boolean overwrite) throws CreateException {
98
        if( !this.canCreate() ) {
99
           throw new UnsupportedOperationException();
100
        }
101
        File output = ((FilesystemStoreParameters)parameters).getFile();
102
        if( output==null ) {
103
            throw new IllegalArgumentException("Parameter 'file' can't be null.");
104
        }
105
        Buffer buffer = ((NewRasterStoreParameters)parameters).getBuffer();
106
        if( buffer==null ) {
107
            throw new IllegalArgumentException("Parameter 'buffer' can't be null.");
108
        }
109
        BufferedImage image = buffer.getBufferedImage();
110
        try {
111
            ImageIO.write(image, this.getName(), output);
112
        } catch (IOException ex) {
113
            throw new CreateException(output.getAbsolutePath(), ex);
114
        }
115
        
116
//        DataTypesManager dtm = ToolsLocator.getDataTypesManager();
117
//        ImageWriter writer = getImageWriter();
118
//        ImageWriteParam writerParams = writer.getDefaultWriteParam();
119
//        Class<? extends ImageWriteParam> writerParamsClass = writerParams.getClass();
120
//        for( DynField field : parameters.getDynClass().getDynFields() ) {
121
//            DynField_v2 field2 = (DynField_v2) field;
122
//            try {
123
//                String methodName = (String) field2.getTags().get(
124
//                    "ImageWriteParam", 
125
//                    DataTypes.STRING
126
//                );
127
//                if( methodName!=null ) {
128
//                    Method setter = writerParamsClass.getMethod(
129
//                        methodName, 
130
//                        dtm.getDefaultClass(field.getType())
131
//                    );
132
//                    setter.invoke(
133
//                        writerParams, 
134
//                        parameters.getDynValue(field.getName())
135
//                    );
136
//                }
137
//            } catch (Exception ex) {
138
//            }
139
//        }
140
//        FileOutputStream fos = null;
141
//        try {
142
//            fos = new FileOutputStream(output);
143
//            writer.setOutput(fos);
144
//            writer.write(null, new IIOImage(image, null, null), writerParams);
145
//        } catch (Exception ex) {
146
//            throw new CreateException(output.getAbsolutePath(), ex);
147
//        } finally {
148
//            IOUtils.closeQuietly(fos);
149
//        }
150
        
151
    }
152
    
153
//    private ImageWriter getImageWriter() {
154
//        return null;
155
//    }
156
    
157
    @Override
49 158
    public int getMode() {
50 159
        return DataServerExplorer.MODE_RASTER;
51 160
    }
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.imageio/src/main/java/org/gvsig/fmap/dal/file/imageio/ImageIOFileSystemServerProviderFactory.java
32 32
public class ImageIOFileSystemServerProviderFactory extends AbstractFilesystemServerExplorerProviderFactory {
33 33

  
34 34
    protected String[] fileExtensions;
35
    protected boolean canCreate;
35 36

  
36 37
    public ImageIOFileSystemServerProviderFactory(
37 38
            String name, 
38 39
            String description, 
39 40
            String[] fileExtensions
40 41
        ) {
42
        this(name, description, fileExtensions, false);
43
    }
44

  
45
    public ImageIOFileSystemServerProviderFactory(
46
            String name, 
47
            String description, 
48
            String[] fileExtensions,
49
            boolean canCreate
50
        ) {
41 51
        super(name, description);
42 52
        this.fileExtensions = fileExtensions;
53
        this.canCreate = canCreate;
43 54
    }
44 55

  
45 56
    @Override
......
47 58
        return new ImageIOFileSystemServerProvider(
48 59
                this.getName(),
49 60
                this.getDescription(),
50
                this.fileExtensions
61
                this.fileExtensions,
62
                this.canCreate
51 63
        );
52 64
    }
53 65

  
54 66

  
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.png/src/main/java/org/gvsig/fmap/dal/file/png/PngLibrary.java
99 99
                    new ImageIOFileSystemServerProviderFactory(
100 100
                            NAME,
101 101
                            DESCRIPTION,
102
                            FILE_EXTENSIONS
102
                            FILE_EXTENSIONS,
103
                            true
103 104
                    )
104 105
            );
105 106
        } catch (Exception e) {
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.bsq/src/main/java/org/gvsig/fmap/dal/file/bsq/BSQBandPageManager.java
1

  
2
package org.gvsig.fmap.dal.file.bsq;
3

  
4
import java.io.File;
5
import java.io.IOException;
6
import java.io.RandomAccessFile;
7
import java.nio.Buffer;
8
import java.nio.ByteBuffer;
9
import java.nio.DoubleBuffer;
10
import java.nio.FloatBuffer;
11
import java.nio.IntBuffer;
12
import java.nio.ShortBuffer;
13
import org.apache.commons.io.IOUtils;
14
import org.gvsig.raster.lib.buffer.api.BandInfo;
15
import org.gvsig.raster.lib.buffer.api.BandPageManager;
16
import org.gvsig.raster.lib.buffer.api.BufferLocator;
17
import org.gvsig.raster.lib.buffer.api.BufferManager;
18
import org.gvsig.tools.dispose.impl.AbstractDisposable;
19
import org.gvsig.tools.exception.BaseException;
20

  
21
public class BSQBandPageManager extends AbstractDisposable implements BandPageManager {
22

  
23
    private RandomAccessFile  raf;
24
    private final int rows;
25
    private final int columns;
26
    private final int dataType;
27
    private final File file;
28
    private final long startpos;
29

  
30
    /**
31
     * @param file
32
     * @param startpos
33
     * @param rows
34
     * @param columns
35
     * @param dataType
36
     * @throws IOException
37
     */
38
    public BSQBandPageManager(File file, long startpos, int rows, int columns, int dataType) throws IOException {
39
        this.rows = rows;
40
        this.columns = columns;
41
        this.dataType = dataType;
42
        this.file = file;
43
        this.startpos = startpos;
44

  
45
        this.raf = new RandomAccessFile(this.file, "rw");
46
        // BufferManager bufferManager = BufferLocator.getBufferManager();
47
        //raf.setLength(rows*columns*bufferManager.getDataTypeSize(dataType));
48

  
49
    }
50

  
51
    @Override
52
    public void load(Buffer buffer, int row, int rows, int dataType) throws IOException {
53

  
54
        long pos = row*this.columns + this.startpos;
55
        raf.seek(pos);
56
        BufferManager bufferManager = BufferLocator.getBufferManager();
57
        int dataTypeSize = bufferManager.getDataTypeSize(dataType);
58
        byte[] byteArray = new byte[buffer.capacity() * dataTypeSize];
59
        raf.read(byteArray);
60
        buffer.rewind();
61

  
62
        switch (dataType) {
63
        case BufferManager.TYPE_BYTE:
64
            //FIXME: Elegir cual de las dos siguientes maneras de hacerlo es la id?nea
65

  
66
            ((ByteBuffer) buffer).put(byteArray, 0, byteArray.length);
67
//            System.arraycopy(byteArray, 0, ((ByteBuffer) buffer).array(), 0, byteArray.length);
68
            break;
69
        case BufferManager.TYPE_SHORT:
70
        case BufferManager.TYPE_USHORT:
71
            for( int cell =0 ; cell<byteArray.length ; cell++ ) {
72
                ((ShortBuffer) buffer).put((int)(cell/dataTypeSize), byteArray[cell]);
73
            }
74
            break;
75
        case BufferManager.TYPE_INT:
76
            for( int cell =0 ; cell<byteArray.length ; cell++ ) {
77
                ((IntBuffer) buffer).put((int)(cell/dataTypeSize), byteArray[cell]);
78
            }
79
            break;
80
        case BufferManager.TYPE_FLOAT:
81
            for( int cell =0 ; cell<byteArray.length ; cell++ ) {
82
                ((FloatBuffer) buffer).put((int)(cell/dataTypeSize), byteArray[cell]);
83
            }
84
            break;
85

  
86
        case BufferManager.TYPE_DOUBLE:
87
            for( int cell =0 ; cell<byteArray.length ; cell++ ) {
88
                ((DoubleBuffer) buffer).put((int)(cell/dataTypeSize), byteArray[cell]);
89
            }
90
            break;
91

  
92
        default:
93
            throw new IllegalArgumentException("Data Type " + dataType + " not supported.");
94
        }
95
    }
96

  
97
    @Override
98
    public void save(Buffer buffer, int row, int rows, int dataType) throws IOException {
99

  
100
        long pos = row*this.columns + this.startpos;
101
        raf.seek(pos);
102

  
103
        BufferManager bufferManager = BufferLocator.getBufferManager();
104
        ByteBuffer byteBuffer = ByteBuffer.allocate(buffer.capacity() * bufferManager.getDataTypeSize(dataType));
105
        switch (dataType) {
106
        case BufferManager.TYPE_BYTE:
107
            byteBuffer.put(((ByteBuffer)buffer).array());
108
            break;
109
        case BufferManager.TYPE_SHORT:
110
        case BufferManager.TYPE_USHORT:
111
            ShortBuffer byteAsShortBuffer = byteBuffer.asShortBuffer();
112
            byteAsShortBuffer.put((short[]) buffer.array());
113
            break;
114
        case BufferManager.TYPE_INT:
115
            IntBuffer byteAsIntBuffer = byteBuffer.asIntBuffer();
116
            byteAsIntBuffer.put((int[]) buffer.array());
117
            break;
118
        case BufferManager.TYPE_FLOAT:
119
            FloatBuffer byteAsFloatBuffer = byteBuffer.asFloatBuffer();
120
            byteAsFloatBuffer.put((float[]) buffer.array());
121
            break;
122
        case BufferManager.TYPE_DOUBLE:
123
            DoubleBuffer byteAsDoubleBuffer = byteBuffer.asDoubleBuffer();
124
            byteAsDoubleBuffer.put((double[]) buffer.array());
125
            break;
126
        default:
127
            throw new IllegalArgumentException("Data Type " + dataType + " not supported.");
128
        }
129
        raf.write(byteBuffer.array());
130

  
131
    }
132

  
133
    @Override
134
    public boolean isSupportedSave() {
135
        return true;
136
    }
137

  
138
    @Override
139
    public BandInfo getBandInfo() {
140
        return null;
141
    }
142

  
143
    @Override
144
    protected void doDispose() throws BaseException {
145
        IOUtils.closeQuietly(this.raf);
146
        this.raf = null;
147
    }
148
}
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.bsq/src/main/java/org/gvsig/fmap/dal/file/bsq/FileOpenRasterStoreParameters.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 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.fmap.dal.file.bsq;
24

  
25
import java.io.File;
26

  
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

  
30
import org.gvsig.fmap.dal.FileHelper;
31
import org.gvsig.fmap.dal.raster.OpenRasterStoreParameters;
32
import org.gvsig.fmap.dal.raster.spi.AbstractOpenRasterStoreParameters;
33
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
34
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
35
import org.gvsig.tools.dynobject.DelegatedDynObject;
36

  
37

  
38
public class FileOpenRasterStoreParameters 
39
        extends 
40
            AbstractOpenRasterStoreParameters 
41
        implements
42
            OpenRasterStoreParameters, 
43
            FilesystemStoreParameters
44
    {
45

  
46
    protected static final Logger logger = LoggerFactory.getLogger(FileOpenRasterStoreParameters.class);
47

  
48
    public static final String FILE_PARAMTER_NAME = "file";
49

  
50
    protected DelegatedDynObject parameters;
51

  
52
    /**
53
     * Constructor
54
     * @param name
55
     */
56
    @SuppressWarnings("OverridableMethodCallInConstructor")
57
    public FileOpenRasterStoreParameters(String name) {
58
        super();
59
        this.parameters = (DelegatedDynObject) FileHelper.newParameters(name+"StoreProviderParameters");
60
        this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name);
61
    }
62

  
63
    @Override
64
    public boolean isValid() {
65
        return (this.getFile() != null);
66
    }
67

  
68
    @Override
69
    public File getFile() {
70
        return (File) this.getDynValue(FILE_PARAMTER_NAME);
71
    }
72

  
73
    @Override
74
    public void setFile(File file) {
75
        this.setDynValue(FILE_PARAMTER_NAME, file);
76
    }
77

  
78
    @Override
79
    protected DelegatedDynObject getDelegatedDynObject() {
80
        return parameters;
81
    }
82

  
83
}
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.bsq/src/main/java/org/gvsig/fmap/dal/file/bsq/BSQFileSystemServerProviderFactory.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2018 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.fmap.dal.file.bsq;
24

  
25
import java.io.File;
26

  
27
import org.apache.commons.io.FilenameUtils;
28
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProviderFactory;
29
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider;
30

  
31

  
32
public class BSQFileSystemServerProviderFactory extends AbstractFilesystemServerExplorerProviderFactory {
33

  
34
    protected String[] fileExtensions;
35
    protected boolean canCreate;
36

  
37
    public BSQFileSystemServerProviderFactory(
38
            String name, 
39
            String description, 
40
            String[] fileExtensions
41
        ) {
42
        this(name, description, fileExtensions, false);
43
    }
44

  
45
    public BSQFileSystemServerProviderFactory(
46
            String name, 
47
            String description, 
48
            String[] fileExtensions,
49
            boolean canCreate
50
        ) {
51
        super(name, description);
52
        this.fileExtensions = fileExtensions;
53
        this.canCreate = canCreate;
54
    }
55

  
56
    @Override
57
    public FilesystemServerExplorerProvider create() {
58
        return new BSQFileSystemServerProvider(
59
                this.getName(),
60
                this.getDescription(),
61
                this.fileExtensions,
62
                this.canCreate
63
        );
64
    }
65

  
66
    @Override
67
    public boolean accept(File pathname) {
68
        return FilenameUtils.isExtension(pathname.getName().toLowerCase(), this.fileExtensions);
69
    }
70

  
71
}
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.bsq/src/main/java/org/gvsig/fmap/dal/file/bsq/BSQStoreProviderFactory.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 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.fmap.dal.file.bsq;
24

  
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

  
28
import org.gvsig.fmap.dal.DataParameters;
29
import org.gvsig.fmap.dal.exception.InitializeException;
30
import org.gvsig.fmap.dal.raster.OpenRasterStoreParameters;
31
import org.gvsig.fmap.dal.raster.spi.AbstractRasterStoreProviderFactory;
32
import org.gvsig.fmap.dal.raster.spi.RasterStoreProvider;
33
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
34

  
35

  
36
public class BSQStoreProviderFactory extends AbstractRasterStoreProviderFactory {
37

  
38
    protected static final Logger logger = LoggerFactory.getLogger(BSQStoreProviderFactory.class);
39

  
40
    public BSQStoreProviderFactory(String name, String description) {
41
        super(name, description);
42
    }
43

  
44
    @Override
45
    public RasterStoreProvider createProvider(DataParameters parameters,
46
        DataStoreProviderServices providerServices) throws InitializeException {
47
        return new BSQStoreProvider(
48
                this.getName(), 
49
                this.getDescription(), 
50
                (OpenRasterStoreParameters)parameters, 
51
                providerServices
52
        );
53
    }
54

  
55
    @Override
56
    public OpenRasterStoreParameters createParameters() {
57
        return new FileOpenRasterStoreParameters(this.getName());
58
    }
59

  
60
}
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.bsq/src/main/java/org/gvsig/fmap/dal/file/bsq/BSQLibrary.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 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.fmap.dal.file.bsq;
24

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

  
28
import org.gvsig.fmap.dal.DALFileLibrary;
29
import org.gvsig.fmap.dal.DALFileLocator;
30
import org.gvsig.fmap.dal.DALLibrary;
31
import org.gvsig.fmap.dal.FileHelper;
32
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerManager;
33
import org.gvsig.fmap.dal.spi.DALSPILocator;
34
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
35
import org.gvsig.metadata.MetadataLocator;
36
import org.gvsig.metadata.MetadataManager;
37
import org.gvsig.metadata.exceptions.MetadataException;
38
import org.gvsig.tools.dynobject.DynClass;
39
import org.gvsig.tools.library.AbstractLibrary;
40
import org.gvsig.tools.library.LibraryException;
41

  
42
/**
43
 * BSQ, Band Sequential Format, Library to register provider components
44
 *
45
 */
46
public class BSQLibrary extends AbstractLibrary {
47

  
48
    public static String NAME = "BSQ";
49
    public static String DESCRIPTION = "BSQ provider";
50
    public static String[] FILE_EXTENSIONS = new String[]{"bsq"};
51

  
52
    @Override
53
    public void doRegistration() {
54
        registerAsServiceOf(DALLibrary.class);
55
        require(DALFileLibrary.class);
56

  
57
    }
58

  
59
    @Override
60
    protected void doInitialize() throws LibraryException {
61
    }
62

  
63
    @Override
64
    protected void doPostInitialize() throws LibraryException {
65
        List<Throwable> exs = new ArrayList<>();
66

  
67

  
68
        FileHelper.registerParametersDefinition(
69
                NAME + "StoreProviderParameters",
70
                FileOpenRasterStoreParameters.class,
71
                this.getClass().getClassLoader(),
72
                this.getClass().getResource(NAME + "Parameters.xml"));
73
        try {
74
            try {
75
                FileHelper.registerMetadataDefinition(
76
                        NAME,
77
                        BSQStoreProvider.class,
78
                        this.getClass().getClassLoader(),
79
                        this.getClass().getResource(NAME + "Metadata.xml"));
80
            } catch (MetadataException e) {
81
                exs.add(e);
82
            }
83
            
84
            DataManagerProviderServices datamanager = DALSPILocator.getDataManagerProviderServices();
85
            FilesystemServerExplorerManager explorerManager = DALFileLocator.getFilesystemServerExplorerManager();
86

  
87
            if (!datamanager.getStoreProviders().contains(NAME)) {
88
                datamanager.registerStoreProviderFactory(
89
                        new BSQStoreProviderFactory(
90
                                NAME,
91
                                DESCRIPTION));
92
            }
93
            explorerManager.registerProviderFactory(
94
                    new BSQFileSystemServerProviderFactory(
95
                            NAME,
96
                            DESCRIPTION,
97
                            FILE_EXTENSIONS,
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff