Skip to content
Snippets Groups Projects
Commit 72d028e4 authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Reporting QoL changes.

parent 1c1b5d7e
Branches
No related tags found
No related merge requests found
package azgracompress.compression; package azgracompress.compression;
import azgracompress.compression.exception.ImageCompressionException;
import azgracompress.compression.listeners.IProgressListener; import azgracompress.compression.listeners.IProgressListener;
import azgracompress.compression.listeners.IStatusListener; import azgracompress.compression.listeners.IStatusListener;
import azgracompress.io.InputData;
import azgracompress.compression.exception.ImageCompressionException;
import azgracompress.huffman.Huffman; import azgracompress.huffman.Huffman;
import azgracompress.io.InputData;
import azgracompress.io.OutBitStream; import azgracompress.io.OutBitStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
...@@ -40,6 +40,11 @@ public abstract class CompressorDecompressorBase { ...@@ -40,6 +40,11 @@ public abstract class CompressorDecompressorBase {
this.progressListeners.add(listener); this.progressListeners.add(listener);
} }
public void clearAllListeners() {
this.statusListeners.clear();
this.progressListeners.clear();
}
protected void duplicateAllListeners(IListenable other) { protected void duplicateAllListeners(IListenable other) {
if (other == this) if (other == this)
return; return;
......
...@@ -17,4 +17,9 @@ public interface IListenable { ...@@ -17,4 +17,9 @@ public interface IListenable {
* @param listener Progress listener. * @param listener Progress listener.
*/ */
void addProgressListener(IProgressListener listener); void addProgressListener(IProgressListener listener);
/**
* Remove all active listeners.
*/
void clearAllListeners();
} }
...@@ -5,7 +5,6 @@ import azgracompress.compression.exception.ImageCompressionException; ...@@ -5,7 +5,6 @@ import azgracompress.compression.exception.ImageCompressionException;
import azgracompress.data.Range; import azgracompress.data.Range;
import azgracompress.fileformat.QCMPFileHeader; import azgracompress.fileformat.QCMPFileHeader;
import azgracompress.io.InputData; import azgracompress.io.InputData;
import org.scijava.util.ArrayUtils;
import java.io.*; import java.io.*;
import java.util.Arrays; import java.util.Arrays;
...@@ -112,6 +111,7 @@ public class ImageCompressor extends CompressorDecompressorBase { ...@@ -112,6 +111,7 @@ public class ImageCompressor extends CompressorDecompressorBase {
if (imageCompressor == null) { if (imageCompressor == null) {
return false; return false;
} }
duplicateAllListeners(imageCompressor);
long[] planeDataSizes = null; long[] planeDataSizes = null;
......
...@@ -91,6 +91,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -91,6 +91,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
if (!cacheManager.doesVQCacheExists(options.getInputDataInfo().getCacheFileName(), if (!cacheManager.doesVQCacheExists(options.getInputDataInfo().getCacheFileName(),
getCodebookSize(), getCodebookSize(),
options.getQuantizationVector())) { options.getQuantizationVector())) {
reportStatusToListeners("Quantization file doesn't exist");
trainAndSaveCodebook(); trainAndSaveCodebook();
} }
...@@ -183,10 +184,11 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -183,10 +184,11 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
for (final int planeIndex : planeIndices) { for (final int planeIndex : planeIndices) {
stopwatch.restart(); stopwatch.restart();
reportStatusToListeners(String.format("Loading plane %d.", planeIndex));
final int[][] planeVectors = planeLoader.loadVectorsFromPlaneRange(options, Utils.singlePlaneRange(planeIndex)); final int[][] planeVectors = planeLoader.loadVectorsFromPlaneRange(options, Utils.singlePlaneRange(planeIndex));
if (!hasGeneralQuantizer) { if (!hasGeneralQuantizer) {
reportStatusToListeners(String.format("Training vector quantizer from plane %d.", planeIndex)); reportStatusToListeners(String.format("Training vector quantizer from plane %d.", planeIndex));
quantizer = trainVectorQuantizerFromPlaneVectors(planeVectors); quantizer = trainVectorQuantizerFromPlaneVectors(planeVectors);
...@@ -206,6 +208,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -206,6 +208,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
stopwatch.stop(); stopwatch.stop();
if (options.isConsoleApplication()) { if (options.isConsoleApplication()) {
System.out.println("Is console app, whyy");
reportStatusToListeners("Finished compression of plane %d in %s.", planeIndex, stopwatch.getElapsedTimeString()); reportStatusToListeners("Finished compression of plane %d in %s.", planeIndex, stopwatch.getElapsedTimeString());
} else { } else {
reportProgressToListeners(planeIndex, planeIndices.length, reportProgressToListeners(planeIndex, planeIndices.length,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment