add dashboard
This commit is contained in:
@@ -101,7 +101,7 @@ public class PercentilePlot implements ConcretePlotter {
|
||||
gnuplotSettings.setKeyOutside(plotSettings.isKeyOutside());
|
||||
gnuplot.plot(gnuplotSettings, dataSeries);
|
||||
|
||||
return new PlotResult(outputFile, dataSeries);
|
||||
return new PlotResult(outputFile, dataSeries, null); // TODO thumbail
|
||||
} catch (final InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("Plotting was interrupted.");
|
||||
|
||||
@@ -6,11 +6,13 @@ import java.util.List;
|
||||
public class PlotResult {
|
||||
private final Path imagePath;
|
||||
private final List<DataSeries> dataSeries;
|
||||
private final Path thumbnail;
|
||||
|
||||
public PlotResult(final Path imagePath, final List<DataSeries> dataSeries) {
|
||||
public PlotResult(final Path imagePath, final List<DataSeries> dataSeries, final Path thumbnail) {
|
||||
super();
|
||||
this.imagePath = imagePath;
|
||||
this.dataSeries = dataSeries;
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
public Path getImageName() {
|
||||
@@ -21,6 +23,14 @@ public class PlotResult {
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
public Path getThumbnailName() {
|
||||
return thumbnail.getFileName();
|
||||
}
|
||||
|
||||
public Path getThumbnailPath() {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public List<DataSeries> getDataSeries() {
|
||||
return dataSeries;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.lucares.recommind.logs;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -21,6 +23,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.lucares.pdb.api.Entry;
|
||||
import org.lucares.pdb.api.GroupResult;
|
||||
import org.lucares.pdb.api.Result;
|
||||
@@ -118,7 +122,10 @@ public class ScatterPlot implements ConcretePlotter {
|
||||
gnuplotSettings.setKeyOutside(plotSettings.isKeyOutside());
|
||||
gnuplot.plot(gnuplotSettings, dataSeries);
|
||||
|
||||
return new PlotResult(outputFile, dataSeries);
|
||||
final Path thumbnail = createOptionalThumbnail(outputFile, plotSettings.getThumbnailMaxWidth(),
|
||||
plotSettings.getThumbnailMaxHeight());
|
||||
|
||||
return new PlotResult(outputFile, dataSeries, thumbnail);
|
||||
} catch (final InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("Plotting was interrupted.");
|
||||
@@ -130,6 +137,44 @@ public class ScatterPlot implements ConcretePlotter {
|
||||
}
|
||||
}
|
||||
|
||||
private static BufferedImage resizeImage(final BufferedImage originalImage, final Integer img_width,
|
||||
final Integer img_height) {
|
||||
final int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
|
||||
final BufferedImage resizedImage = new BufferedImage(img_width, img_height, type);
|
||||
final Graphics2D g = resizedImage.createGraphics();
|
||||
g.drawImage(originalImage, 0, 0, img_width, img_height, null);
|
||||
g.dispose();
|
||||
|
||||
return resizedImage;
|
||||
}
|
||||
|
||||
private Path createOptionalThumbnail(final Path originalImage, final int thumbnailMaxWidth,
|
||||
final int thumbnailMaxHeight) {
|
||||
|
||||
Path result;
|
||||
if (thumbnailMaxWidth > 0 && thumbnailMaxHeight > 0) {
|
||||
try {
|
||||
final long start = System.nanoTime();
|
||||
final BufferedImage image = ImageIO.read(originalImage.toFile());
|
||||
|
||||
final BufferedImage thumbnail = resizeImage(image, thumbnailMaxWidth, thumbnailMaxHeight);
|
||||
final Path thumbnailPath = originalImage.getParent()
|
||||
.resolve(originalImage.getFileName() + ".thumbnail.jpg");
|
||||
|
||||
ImageIO.write(thumbnail, "JPG", thumbnailPath.toFile());
|
||||
LOGGER.info("thumbnail creation: " + (System.nanoTime() - start) / 1_000_000.0 + "ms");
|
||||
result = thumbnailPath;
|
||||
} catch (final IOException e) {
|
||||
LOGGER.warn("failed to scale image", e);
|
||||
result = null;
|
||||
}
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void defineXAxis(final GnuplotSettings gnuplotSettings, final OffsetDateTime minDate,
|
||||
final OffsetDateTime maxDate) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user