Statistics
| Revision:

gvsig-raster / org.gvsig.raster.ermapper / trunk / org.gvsig.raster.ermapper / org.gvsig.raster.ermapper.io / src / main / java / org / gvsig / raster / ermapper / io / ErmapperWriter.java @ 2449

History | View | Annotate | Download (19.7 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.raster.ermapper.io;
23

    
24
import java.awt.geom.AffineTransform;
25
import java.awt.geom.Point2D;
26
import java.io.File;
27
import java.io.IOException;
28

    
29
import org.cresques.cts.IProjection;
30
import org.gvsig.fmap.dal.coverage.RasterLibrary;
31
import org.gvsig.fmap.dal.coverage.RasterLocator;
32
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
33
import org.gvsig.fmap.dal.coverage.datastruct.Params;
34
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
35
import org.gvsig.fmap.dal.coverage.process.CancelEvent;
36
import org.gvsig.fmap.dal.coverage.process.TaskEventManager;
37
import org.gvsig.fmap.dal.coverage.store.DataServerWriter;
38
import org.gvsig.fmap.dal.coverage.store.ExternalCancellable;
39
import org.gvsig.raster.impl.store.ParamImpl;
40
import org.gvsig.raster.impl.store.WriteFileFormatFeatures;
41
import org.gvsig.raster.impl.store.writer.DefaultRasterWriter;
42
import org.gvsig.raster.util.DefaultProviderServices;
43
import org.gvsig.tools.ToolsLocator;
44
import org.gvsig.tools.extensionpoint.ExtensionPoint;
45
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
46

    
47
import es.gva.cit.jecwcompress.EcwException;
48
import es.gva.cit.jecwcompress.JniObject;
49
import es.gva.cit.jecwcompress.NCSEcwCompressClient;
50
import es.gva.cit.jecwcompress.ReadCallBack;
51
/**
52
 * Driver para la compresi?n en formato Ecw.
53
 *
54
 * Puede exportar un fichero desde un GeoRasterFile en cualquier formato soportado
55
 * por los drivers de lectura a uno en formato Ecw.
56
 *
57
 * Puede salvar a disco en formato Ecw obteniendo los datos que van siendo servidos
58
 * desde el cliente. Este cliente debe implementar un DataServerWriter o tener un objeto
59
 * que lo implemente. Inicialmente le pasar? los par?metros de la imagen de salida
60
 * y cuando el driver comience a escribir le ir? solicitando m?s a trav?s del m?todo
61
 * readData de DataServerWriter. El cliente ser? el que lleve el control de lo que va
62
 * sirviendo y lo que le queda por servir.
63
 * @author Nacho Brodin (brodin_ign@gva.es)
64
 */
65
public class ErmapperWriter extends DefaultRasterWriter {
66

    
67
        public static void register() {
68
                DefaultProviderServices pInfo = (DefaultProviderServices)RasterLocator.getManager().getProviderServices();
69
                ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
70
                ExtensionPoint point = extensionPoints.get("RasterWriter");
71
                WriteFileFormatFeatures features = null;
72

    
73
                String os = System.getProperties().getProperty("os.version");
74
                if (os.startsWith("2.4")){
75
                        point.append("ecw", "", ErmapperWriter.class);
76
                        features = new WriteFileFormatFeatures("Ecw", "ecw", new int[]{3}, null, ErmapperWriter.class);
77
                        pInfo.getFileFeature().put("ecw", features);
78
                }
79
                point.append("jp2", "", ErmapperWriter.class);
80
                features = new WriteFileFormatFeatures("Jpeg2000", "jp2", new int[]{3}, null, ErmapperWriter.class);
81
                pInfo.getFileFeature().put("jp2", features);
82
        }
83

    
84
        public final int                                 windowSizeX = 386;
85
        public final int                                 windowSizeY = 220;
86
        public final int                                 panelSizeX = 358;
87
        public final int                                 panelSizeY = 125;
88
        public final String                         panelLayout = "BorderLayout";
89
        private NCSEcwCompressClient         compressclient = null;
90
        private Reader                                         readerObj;
91
        private double                                         pixelSizeX;
92
        private double                                         pixelSizeY;
93
        private double                                         geoCoordOrigenX;
94
        private double                                         geoCoordOrigenY;
95
        private boolean                                 consulta = false;
96

    
97
        /**
98
         * Carga los par?metros de este driver.
99
         */
100
        public void loadParams() {
101
                WriteFileFormatFeatures wfff = new WriteFileFormatFeatures();
102
                wfff.loadParams();
103
                driverParams = wfff.getParams();
104

    
105
                driverParams.setParam(        "compression",
106
                                new Integer(10),
107
                                Params.SLIDER,
108
                                new String[]{ "1", "20", "10", "1", "5" }); //min, max, valor defecto, intervalo peque?o, intervalo grande;
109

    
110
                driverParams.setParam(        "format",
111
                                new Integer(4),
112
                                Params.CHOICE,
113
                                new String[]{ "NONE", "UINT8", "YUV", "MULTI", "RGB"});
114
        }
115
        
116
        /*
117
         * (non-Javadoc)
118
         * @see org.gvsig.fmap.dal.coverage.store.RasterWriter#getProviderName()
119
         */
120
        public String getProviderName() {
121
                return ErmapperProvider.NAME;
122
        }
123

    
124
        /**
125
         * Constructor para la obtenci?n de par?metros del driver.
126
         */
127
        public ErmapperWriter(String fileName) {
128
                DefaultProviderServices pInfo = (DefaultProviderServices)RasterLocator.getManager().getProviderServices();
129
                ident = fileUtil.getExtensionFromFileName(fileName);
130
                driver = ((WriteFileFormatFeatures)pInfo.getFileFeature().get(ident)).getDriverName();
131

    
132
                loadParams();
133

    
134
                consulta = true;
135
        }
136

    
137
        /**
138
         * Constructor para la lectura de datos desde el objeto cliente a partir de un
139
         * viewport dado.
140
         * @param dataWriter Objeto que sirve datos para el escritor
141
         * @param outFileName Fichero de salida
142
         * @param nBands N?mero de bandas
143
         * @param at
144
         * @param outSizeX
145
         * @param outSizeY
146
         * @param dataType
147
         * @param params
148
         * @param proj
149
         * @param geo
150
         * @throws EcwException
151
         * @throws IOException
152
         */
153
        public ErmapperWriter(        DataServerWriter dataWriter,
154
                        String outFileName,
155
                        Integer nBands,
156
                        AffineTransform at,
157
                        Integer outSizeX,
158
                        Integer outSizeY,
159
                        Integer dataType,
160
                        Params params,
161
                        IProjection proj,
162
                        Boolean geo) throws EcwException, IOException {
163
                DefaultProviderServices pInfo = (DefaultProviderServices)RasterLocator.getManager().getProviderServices();
164
                //La libreria de ECW no se traga caracteres raros al escribir. Los cambiamos por X de momento y ya se apa?a el usuario
165

    
166
                String ext = fileUtil.getExtensionFromFileName(outFileName);
167
                String fname = outFileName.substring(outFileName.lastIndexOf(File.separator) + 1, outFileName.lastIndexOf(".")).replaceAll("[^a-zA-Z0-9_]", "X");
168
                outFileName = outFileName.substring(0, outFileName.lastIndexOf(File.separator) + 1) + fname + "." + ext;
169

    
170
                this.proj = proj;
171
                ident = fileUtil.getExtensionFromFileName(outFileName);
172
                driver = ((WriteFileFormatFeatures)pInfo.getFileFeature().get(ident)).getDriverName();
173
                this.dataType = dataType.intValue();
174

    
175
                if (nBands.intValue() <= 0)
176
                        throw new EcwException("N?mero de bandas erroneo.");
177

    
178
                this.outFileName = outFileName;
179
                this.dataWriter = dataWriter;
180

    
181
                this.nBands = nBands.intValue();
182

    
183
                this.sizeWindowX = outSizeX.intValue();
184
                this.sizeWindowY = outSizeY.intValue();
185

    
186
                //Calculamos la georeferenciaci?n a partir del extend pasado por el cliente.
187
                geoCoordOrigenX = at.getTranslateX();
188
                geoCoordOrigenY = at.getTranslateY();
189

    
190
                pixelSizeX = (at.getScaleX() > 0) ? at.getScaleX() : -at.getScaleX();
191
                pixelSizeY = (at.getScaleY() < 0) ? at.getScaleY() : -at.getScaleY();
192

    
193
                String outRmf = fileUtil.getNameWithoutExtension(outFileName);
194
                if(geo.booleanValue())
195
                        rasterUtil.saveGeoInfo(outRmf, at, new Point2D.Double(sizeWindowX, sizeWindowY));
196

    
197
                if (pixelSizeX == 0)
198
                        pixelSizeX = 1.0;
199

    
200
                if (pixelSizeY == 0)
201
                        pixelSizeY = 1.0;
202

    
203
                if(params == null)
204
                        loadParams();
205
                else
206
                        driverParams = params;
207

    
208
                init();
209
        }
210

    
211
        /**
212
         * Inicializaci?n de los par?metros del compresor que ser?n obtenidos
213
         * de PxRaster.
214
         * @throws EcwException
215
         */
216
        private void init() throws EcwException {
217
                percent = 0;
218
                int comp = ((Integer)(((ParamImpl)driverParams.getParamById("compression"))).getDefaultValue()).intValue();
219
                ParamImpl param = (ParamImpl)driverParams.getParamById("format");
220
                String format = param.getList()[((Integer)param.getDefaultValue()).intValue()];
221
                if ( comp == 0 )
222
                        driverParams.changeParamValue("compression", "1");
223

    
224
                if (compressclient == null)
225
                        compressclient = new NCSEcwCompressClient();
226

    
227
                compressclient.setOutputFilename(outFileName);
228
                compressclient.setInputFilename(inFileName);
229
                compressclient.setTargetCompress(comp);
230
                compressclient.setInOutSizeX(sizeWindowX);
231
                compressclient.setInOutSizeY(sizeWindowY);
232
                compressclient.setInputBands(nBands);
233
                compressclient.setCompressFormat(convertFormatToInt(format));
234

    
235
                /* boolean georef = new Boolean(((Param)driverParams.getParamById("georef")).defaultValue).booleanValue();
236
                                if (georef) {*/
237
                compressclient.setCellIncrementX(pixelSizeX);
238
                compressclient.setCellIncrementY(pixelSizeY);
239
                compressclient.setOriginX(geoCoordOrigenX);
240
                compressclient.setOriginY(geoCoordOrigenY);
241
                //}
242

    
243
                compressclient.setCellSizeUnits(1);
244
                int blocksize = RasterLibrary.blockHeight;
245

    
246
                if (dataWriter != null)
247
                        readerObj = new Reader(dataWriter, compressclient, sizeWindowX,
248
                                        sizeWindowY, blocksize, nBands, this, dataType);
249
        }
250

    
251
        /**
252
         * Convierte la cadena que representa el formato en un valor n?merico
253
         * que entiende el driver.
254
         * @param format Cadena que representa el formato
255
         * @return Entero que representa a la cadena
256
         */
257
        private int convertFormatToInt(String format) {
258
                if(format.compareTo("NONE") == 0)
259
                        return 0;
260
                if(format.compareTo("UINT8") == 0)
261
                        return 1;
262
                if(format.compareTo("YUV") == 0)
263
                        return 2;
264
                if(format.compareTo("MULTI") == 0)
265
                        return 3;
266
                if(format.compareTo("RGB") == 0)
267
                        return 4;
268
                return -1;
269
        }
270
        /**
271
         * A partir de un elemento que contiene una propiedad y un valor
272
         * lo parsea y asigna el valor a su variable.
273
         * @param propValue        elemento con la forma propiedad=valor
274
         */
275
        private void readProperty(String propValue) {
276
                String prop = propValue.substring(0, propValue.indexOf("="));
277

    
278
                if (propValue.startsWith(prop)) {
279
                        String value = propValue.substring(propValue.indexOf("=") + 1, propValue.length());
280

    
281
                        if ((value != null) && !value.equals("")) {
282
                                if (prop.equals("BLOCKSIZE"))
283
                                        driverParams.changeParamValue("blocksize", value);
284
                                if (prop.equals("FORMAT"))
285
                                        driverParams.changeParamValue("format", value);
286
                                if (prop.equals("COMPRESSION"))
287
                                        driverParams.changeParamValue("compression", value);
288
                        }
289
                }
290
        }
291

    
292
        /**
293
         * Asigna propiedades al driver a partir de un vector de
294
         * strings donde cada elemento tiene la estructura de
295
         * propiedad=valor.
296
         * @param props        Propiedades
297
         */
298
        public void setProps(String[] props) {
299
                for (int iProps = 0; iProps < props.length; iProps++)
300
                        readProperty(props[iProps]);
301

    
302
                loadParams();
303

    
304
                try {
305
                        if (!consulta)
306
                                init();
307
                } catch (EcwException e) {
308
                        e.printStackTrace();
309
                }
310
        }
311

    
312
        /**
313
         * Realiza la funci?n de compresi?n a partir de un GeoRasterFile.
314
         * @throws IOException
315
         */
316
        public void fileWrite() throws IOException {
317
                /* try {
318
                                                compressclient.NCSEcwCompressOpen(false);
319
                                                compressclient.NCSEcwCompress(readerObj);
320
                                } catch (EcwException e) {
321
                                                e.printStackTrace();
322
                                }*/
323
                //TODO: FUNCIONALIDAD: Compresi?n a partir de un dataset. De momento no es necesario y es posible que nunca lo sea.
324
        }
325

    
326
        /**
327
         * Realiza la funci?n de compresi?n a partir de los datos pasados por el cliente.
328
         * @throws IOException
329
         */
330
        public void dataWrite() throws IOException, ProcessInterruptedException {
331
                if (dataWriter == null)
332
                        throw new IOException("No se ha obtenido un objeto para la lectura valido.");
333

    
334
                try {
335
                        compressclient.NCSEcwCompressOpen(false);
336
                        compressclient.NCSEcwCompress(readerObj);
337
                } catch (EcwException e) {
338
                        throw new IOException("Error en la compresi?n.");
339
                }
340
        }
341

    
342
        /**
343
         * Cierra el compresor ecw.
344
         */
345
        public void writeClose() {
346
                try {
347
                        compressclient.NCSEcwCompressClose();
348
                } catch (EcwException e) {
349
                        e.printStackTrace();
350
                }
351
        }
352

    
353
        /**
354
         * Cancela el compresor ecw.
355
         */
356
        public void writeCancel() {
357
                try {
358
                        if(readerObj != null)
359
                                readerObj.setWrite(false);
360
                        compressclient.NCSEcwCompressCancel();
361
                } catch (EcwException e) {
362
                        e.printStackTrace();
363
                }
364
        }
365

    
366
        /*
367
         * (non-Javadoc)
368
         * @see org.gvsig.raster.dataset.GeoRasterWriter#setWkt(java.lang.String)
369
         */
370
        public void setWkt(String wkt) {
371
                //TODO: FUNCIONALIDAD: La asignaci?n de proyecci?n en Ecw falla haciendo petar la aplicaci?n.
372
                /*if(compressclient != null && wkt != null && wkt.compareTo("unknown") != 0) {
373
                        WktUtils wktutil = new WktUtils(wkt);
374
                        compressclient.setProjection("EPSG:" + wktutil.getEPSG());
375
                }*/
376
        }
377
        
378
        /*
379
         * (non-Javadoc)
380
         * @see org.gvsig.raster.dataset.GeoRasterWriter#setCancellableRasterDriver(org.gvsig.raster.dataset.io.IExternalCancellable)
381
         */
382
        public void setCancellableRasterDriver(ExternalCancellable cancellable) {
383
                super.setCancellableRasterDriver(cancellable);
384
                if(readerObj != null)
385
                        readerObj.setCancellableRasterDriver(cancellable);
386
        }
387

    
388
}
389

    
390

    
391
/**
392
 * Clase que se encarga de la lectura de datos que ser?n escritos. Hereda de JniObject
393
 * para asegurar  para asegurar que el interfaz de la libreria tiene acceso a variables
394
 * necesarias para la petici?n de datos cuando vacia el buffer. Implementa ReadCallBack
395
 * para obligar escribir el m?todo loadBuffer encargado de servir los datos cuando el
396
 * buffer se vacia.
397
 *
398
 */
399
class Reader extends JniObject implements ReadCallBack {
400
        private NCSEcwCompressClient        compressclient = null;
401
        private int                                         width;
402
        //private int                                         height;
403
        //private int                                         ulX;
404
        //private int                                         ulY;
405
        private DataServerWriter        dataWriter = null;
406
        //private GdalRasterBand                         rband = null;
407
        private DefaultRasterWriter                        writer = null;
408
        private int                                         blockSizeRead = 1; //Alto del bloque leido de la imagen origen
409
        private int                                         countLine = 1; //Contador de l?neas procesadas en cada lectura de bloque
410
        byte[][]                                                 buf = null;
411
        byte[]                                                         bufband1 = null;
412
        byte[]                                                         bufband2 = null;
413
        byte[]                                                         bufband3 = null;
414
        byte[]                                                         bufband4 = null;
415
        byte[]                                                         bufband5 = null;
416
        byte[]                                                         bufband6 = null;
417
        int[]                                                         dataBuffer = null;
418
        byte[][]                                                 byteBuffer = null;
419
        private int                                         lineasBloqueFinal = 0; //N?mero de l?neas leidas del bloque final
420
        private int                                         nBlocks = 0; //N?mero de bloques completos
421
        private int                                         countBlock = 1; //Contador de bloques completos procesados
422
        private int                                         nBands = 0;
423
        private        boolean                                        write = true; //Cuando est? a true se puede escribir en la imagen de salida. Si est? a false el proceso es interrumpido
424
        private int                                                dataType = Buffer.TYPE_BYTE;
425
        protected ExternalCancellable  extCancellable = null;
426
        
427
        /**
428
         * Constructor para que los datos sean servidos desde el cliente a trav?s de un
429
         * DataServerWriter.
430
         * @param dataWriter        Objeto servidor de datos del driver
431
         * @param compressclient        Objeto que representa al compresor ecw
432
         * @param width        Ancho de la imagen
433
         * @param height        Alto de la imagen
434
         * @param blockSizeRead        Altura del bloque en la lectura
435
         * @param nBands        N?mero de bandas
436
         */
437
        public Reader(DataServerWriter dataWriter, NCSEcwCompressClient compressclient,
438
                        int width, int height, int blockSizeRead, int nBands,
439
                        DefaultRasterWriter writer, int dataType) {
440
                this.compressclient = compressclient;
441
                this.width = width;
442
                //this.height = height;
443
                this.dataWriter = dataWriter;
444
                this.nBands = nBands;
445
                this.writer = writer;
446
                this.dataType = dataType;
447

    
448
                if (blockSizeRead != 0)
449
                        this.blockSizeRead = blockSizeRead;
450

    
451
                nBlocks = (height / this.blockSizeRead);
452
                lineasBloqueFinal = height - (nBlocks * this.blockSizeRead);
453
        }
454

    
455
        /**
456
         * Lectura de bandas llamando al objeto cliente para que nos cargue el buffer
457
         * @param width        Ancho de la imagen
458
         * @param height        Alto de la imagen
459
         */
460
        /*private void readBands(int width, int height) {
461
                if(dataType == IBuffer.TYPE_IMAGE)
462
                        dataBuffer = dataWriter.readARGBData(width, height, 0);
463
                if(dataType == IBuffer.TYPE_BYTE) {
464
                        byte[][] b = dataWriter.readByteData(width, height);
465

466
                }
467
        }*/
468
        
469
        public void setCancellableRasterDriver(ExternalCancellable cancellable) {
470
                this.extCancellable = cancellable;
471
        }
472

    
473
        /**
474
         * M?todo obligado por el interfaz y que es llamado desde C cuando el
475
         * compresor necesita que le sirvan m?s datos.
476
         */
477
        public void loadBuffer() {
478
                TaskEventManager taskEventManager = RasterLocator.getManager().getRasterTask();
479
                if(taskEventManager.getEvent() != null) {
480
                        if (taskEventManager.getEvent() instanceof CancelEvent) {
481
                                try {
482
                                        if (extCancellable != null)
483
                                                extCancellable.processFinalize();
484
                                        compressclient.NCSEcwCompressCancel();
485
                                } catch (EcwException e1) {
486
                                }
487
                                return;
488
                        }
489
                }
490
                
491
                int lineasLeidas = 0;
492

    
493
                //si se leen bloques completos lineasLeidas es == al tama?o de bloque sino
494
                //es que es el ?ltimo con lo que ser? del tama?o del bloque final
495
                if (countBlock <= nBlocks)
496
                        lineasLeidas = blockSizeRead;
497
                else
498
                        lineasLeidas = lineasBloqueFinal;
499

    
500
                try {
501
                        // Leemos un bloque nuevo cuando se han procesado todas las l?neas
502
                        // del anterior
503
                        if ((nNextLine % blockSizeRead) == 0) {
504
                                if (dataWriter != null) {
505
                                        if (dataType == Buffer.TYPE_IMAGE)
506
                                                dataBuffer = dataWriter.readARGBData(width,
507
                                                                lineasLeidas, 0);
508
                                        if (dataType == Buffer.TYPE_BYTE)
509
                                                byteBuffer = dataWriter.readByteData(width,
510
                                                                lineasLeidas);
511
                                }
512

    
513
                                countLine = 0;
514
                                countBlock++;
515
                        }
516

    
517
                        if (dataType == Buffer.TYPE_IMAGE)
518
                                loadBufferFromImageDataType(dataBuffer);
519
                        if (dataType == Buffer.TYPE_BYTE)
520
                                loadBufferFromByteDataType(byteBuffer);
521
                } catch (ProcessInterruptedException e) {
522

    
523
                }
524

    
525
        }
526

    
527
        /**
528
         * Carga el buffer de datos desde elementos de tipo entero con contenido ARGB
529
         * @param data Array de datos enteros
530
         */
531
        private void loadBufferFromImageDataType(int[] data) {
532
                for (int iBand = 0; iBand < this.nBands; iBand++)
533
                        for (int pos = 0; pos < width; pos++) {
534
                                switch(iBand) {
535
                                case 0:
536
                                        compressclient.buffer[pos + (width * iBand)] =
537
                                                (byte) ((data[pos + (width * countLine)] & 0xff0000) >> 16);
538
                                        break;
539
                                case 1:
540
                                        compressclient.buffer[pos + (width * iBand)] =
541
                                                (byte) ((data[pos + (width * countLine)] & 0xff00) >> 8);
542
                                        break;
543
                                case 2:
544
                                        compressclient.buffer[pos + (width * iBand)] =
545
                                                (byte) (data[pos + (width * countLine)] & 0xff);
546
                                        break;
547
                                }
548
                                if ((pos == (width - 1)) && (iBand == (this.nBands - 1)))
549
                                        countLine++;
550
                        }
551
        }
552

    
553
        /**
554
         * Carga el buffer de datos a comprimir desde un buffer byte[][] donde la primera dimensi?n
555
         * es el n?mero de bandas y la segunda los elementos en lista (Ancho X Alto)
556
         * @param b Buffer de datos de tipo byte[][]
557
         */
558
        private void loadBufferFromByteDataType(byte[][] b) {
559
                for (int iBand = 0; iBand < this.nBands; iBand++)
560
                        for (int pos = 0; pos < width; pos++) {
561
                                compressclient.buffer[pos + (width * iBand)] = b[iBand][pos + (width * countLine)];
562
                                if ((pos == (width - 1)) && (iBand == (this.nBands - 1)))
563
                                        countLine++;
564
                        }
565
        }
566

    
567
        /**
568
         * M?todo obligado por el interfaz y que es llamado desde C cuando el
569
         * compresor actualiza el porcentaje de compresi?n
570
         */
571
        public void updatePercent() {
572
                writer.setPercent(compressclient.getPercent());
573
                //System.out.println(compressclient.getPercent() + "%");
574
        }
575

    
576
        /**
577
         * Obtiene el valor a la variable write que estar? a true cuando se est? escribiendo
578
         *  o puede escribirse la imagen de salida. El cancelar la operaci?n de escritura
579
         * pondr? esta variable a false deteniendose la escritura y cerrandose el dataset
580
         * de salida.
581
         * @return True si puede escribirse y false si no puede
582
         */
583
        public boolean isWrite() {
584
                return write;
585
        }
586

    
587
        /**
588
         * Asigna el valor a la variable write que estar? a true cuando se est? escribiendo
589
         *  o puede escribirse la imagen de salida. El cancelar la operaci?n de escritura
590
         * pondr? esta variable a false deteniendose la escritura y cerrandose el dataset
591
         * de salida.
592
         * @param write Variable booleana. True si puede escribirse y false si no puede
593
         */
594
        public void setWrite(boolean write) {
595
                this.write = write;
596
        }
597

    
598
}