remove old way of rendering images
This commit is contained in:
@@ -93,7 +93,7 @@ public class BarChartAggregatorForIntervals implements CustomAggregator, Indexed
|
||||
}
|
||||
|
||||
private boolean showLabel(final int index, final int numberOfBuckets) {
|
||||
final int width = settings.getWidth();
|
||||
final int width = settings.getMaxWidth();
|
||||
final int widthInPx = width - GnuplotSettings.GNUPLOT_LEFT_RIGHT_MARGIN;
|
||||
|
||||
final long maxLabels = Math.max(1, widthInPx / (GnuplotSettings.TICKS_FONT_SIZE * 8));
|
||||
|
||||
@@ -63,7 +63,7 @@ public class HistogramAggregator implements CustomAggregator {
|
||||
final char separator = ',';
|
||||
final char newline = '\n';
|
||||
|
||||
final int numBins = plotSettings.getWidth() / 8;
|
||||
final int numBins = plotSettings.getMaxWidth() / 8;
|
||||
final int binWidth = Math.max((int) (max) / numBins, 1);
|
||||
|
||||
final ToBins toBins = new ToBins(numBins, binWidth);
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.lucares.pdb.api.DateTimeRange;
|
||||
import org.lucares.recommind.logs.GnuplotAxis;
|
||||
import org.lucares.recommind.logs.GnuplotSettings;
|
||||
import org.lucares.utils.Preconditions;
|
||||
|
||||
public class PlotSettings {
|
||||
@@ -20,14 +21,6 @@ public class PlotSettings {
|
||||
|
||||
private String query;
|
||||
|
||||
private int height;
|
||||
|
||||
private int width;
|
||||
|
||||
private int thumbnailMaxWidth = 0;
|
||||
|
||||
private int thumbnailMaxHeight = 0;
|
||||
|
||||
private List<String> groupBy;
|
||||
|
||||
private Limit limitBy;
|
||||
@@ -41,10 +34,6 @@ public class PlotSettings {
|
||||
|
||||
private AggregateHandlerCollection aggregates;
|
||||
|
||||
private boolean keyOutside;
|
||||
|
||||
private boolean generateThumbnail;
|
||||
|
||||
private Interval interval;
|
||||
|
||||
private boolean renderBarChartTickLabels;
|
||||
@@ -67,38 +56,6 @@ public class PlotSettings {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(final int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(final int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public int getThumbnailMaxWidth() {
|
||||
return thumbnailMaxWidth;
|
||||
}
|
||||
|
||||
public void setThumbnailMaxWidth(final int thumbnailMaxWidth) {
|
||||
this.thumbnailMaxWidth = thumbnailMaxWidth;
|
||||
}
|
||||
|
||||
public int getThumbnailMaxHeight() {
|
||||
return thumbnailMaxHeight;
|
||||
}
|
||||
|
||||
public void setThumbnailMaxHeight(final int thumbnailMaxHeight) {
|
||||
this.thumbnailMaxHeight = thumbnailMaxHeight;
|
||||
}
|
||||
|
||||
public List<String> getGroupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
@@ -145,11 +102,9 @@ public class PlotSettings {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlotSettings [query=" + query + ", height=" + height + ", width=" + width + ", thumbnailMaxWidth="
|
||||
+ thumbnailMaxWidth + ", thumbnailMaxHeight=" + thumbnailMaxHeight + ", groupBy=" + groupBy
|
||||
+ ", limitBy=" + limitBy + ", limit=" + limit + ", dateRangeAsString=" + dateRangeAsString + ", y1="
|
||||
+ y1 + " y2=" + y2 + ", aggregates=" + aggregates + ", keyOutside=" + keyOutside
|
||||
+ ", generateThumbnail=" + generateThumbnail + "]";
|
||||
return "PlotSettings [query=" + query + ", groupBy=" + groupBy + ", limitBy=" + limitBy + ", limit=" + limit
|
||||
+ ", dateRangeAsString=" + dateRangeAsString + ", y1=" + y1 + " y2=" + y2 + ", aggregates=" + aggregates
|
||||
+ ", renders=" + renders + "]";
|
||||
}
|
||||
|
||||
public void setAggregates(final AggregateHandlerCollection aggregates) {
|
||||
@@ -160,22 +115,6 @@ public class PlotSettings {
|
||||
return aggregates;
|
||||
}
|
||||
|
||||
public void setKeyOutside(final boolean keyOutside) {
|
||||
this.keyOutside = keyOutside;
|
||||
}
|
||||
|
||||
public boolean isKeyOutside() {
|
||||
return keyOutside;
|
||||
}
|
||||
|
||||
public void setGenerateThumbnail(final boolean generateThumbnail) {
|
||||
this.generateThumbnail = generateThumbnail;
|
||||
}
|
||||
|
||||
public boolean isGenerateThumbnail() {
|
||||
return generateThumbnail;
|
||||
}
|
||||
|
||||
public YAxisDefinition getY1() {
|
||||
return y1;
|
||||
}
|
||||
@@ -219,4 +158,32 @@ public class PlotSettings {
|
||||
this.renderBarChartTickLabels = renderBarChartTickLabels;
|
||||
}
|
||||
|
||||
public int getMaxWidth() {
|
||||
int maxWidth = 1;
|
||||
|
||||
for (final RenderOptions renderOptions : renders.values()) {
|
||||
int width = renderOptions.getWidth();
|
||||
if (renderOptions.isRenderLabels()) {
|
||||
width -= GnuplotSettings.GNUPLOT_LEFT_RIGHT_MARGIN;
|
||||
}
|
||||
maxWidth = Math.max(maxWidth, width);
|
||||
}
|
||||
|
||||
return maxWidth;
|
||||
}
|
||||
|
||||
public int getMaxHeight() {
|
||||
int maxHeight = 1;
|
||||
|
||||
for (final RenderOptions renderOptions : renders.values()) {
|
||||
int height = renderOptions.getHeight();
|
||||
if (renderOptions.isRenderLabels()) {
|
||||
height -= GnuplotSettings.GNUPLOT_TOP_BOTTOM_MARGIN;
|
||||
}
|
||||
maxHeight = Math.max(maxHeight, height);
|
||||
}
|
||||
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.lucares.collections.Sparse2DLongArray;
|
||||
import org.lucares.pdb.api.RuntimeIOException;
|
||||
import org.lucares.recommind.logs.GnuplotAxis;
|
||||
import org.lucares.recommind.logs.GnuplotSettings;
|
||||
import org.lucares.recommind.logs.LambdaFriendlyWriter;
|
||||
import org.lucares.recommind.logs.LongUtils;
|
||||
|
||||
@@ -38,8 +37,8 @@ public class ScatterAggregator implements CustomAggregator {
|
||||
|
||||
this.tmpDir = tmpDir;
|
||||
useMillis = (toEpochMilli - fromEpochMilli) < TimeUnit.MINUTES.toMillis(5);
|
||||
plotAreaWidthInPx = plotSettings.getWidth() - GnuplotSettings.GNUPLOT_LEFT_RIGHT_MARGIN;
|
||||
plotAreaHeightInPx = plotSettings.getHeight() - GnuplotSettings.GNUPLOT_TOP_BOTTOM_MARGIN;
|
||||
plotAreaWidthInPx = plotSettings.getMaxWidth();
|
||||
plotAreaHeightInPx = plotSettings.getMaxHeight();
|
||||
epochMillisPerPixel = Math.max(1, (toEpochMilli - fromEpochMilli) / plotAreaWidthInPx);
|
||||
|
||||
final YAxisDefinition yAxisDefinition = plotSettings.getyAxisDefinition(yAxis);
|
||||
|
||||
@@ -5,17 +5,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlotResult {
|
||||
private final Path imagePath;
|
||||
private final List<DataSeries> dataSeries;
|
||||
private final Path thumbnail;
|
||||
private final Map<String, Path> renderedImages;
|
||||
|
||||
public PlotResult(final Path imagePath, final List<DataSeries> dataSeries, final Path thumbnail,
|
||||
final Map<String, Path> renderedImages) {
|
||||
super();
|
||||
this.imagePath = imagePath;
|
||||
public PlotResult(final List<DataSeries> dataSeries, final Map<String, Path> renderedImages) {
|
||||
|
||||
this.dataSeries = dataSeries;
|
||||
this.thumbnail = thumbnail;
|
||||
|
||||
this.renderedImages = renderedImages;
|
||||
}
|
||||
|
||||
@@ -23,22 +19,6 @@ public class PlotResult {
|
||||
return renderedImages;
|
||||
}
|
||||
|
||||
public Path getImageName() {
|
||||
return imagePath.getFileName();
|
||||
}
|
||||
|
||||
public Path getImagePath() {
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
public Path getThumbnailName() {
|
||||
return thumbnail.getFileName();
|
||||
}
|
||||
|
||||
public Path getThumbnailPath() {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public List<DataSeries> getDataSeries() {
|
||||
return dataSeries;
|
||||
}
|
||||
|
||||
@@ -73,8 +73,6 @@ public class Plotter {
|
||||
|
||||
final String query = plotSettings.getQuery();
|
||||
final List<String> groupBy = plotSettings.getGroupBy();
|
||||
final int height = plotSettings.getHeight();
|
||||
final int width = plotSettings.getWidth();
|
||||
final DateTimeRange dateRange = plotSettings.dateRange();
|
||||
final OffsetDateTime dateFrom = dateRange.getStart();
|
||||
final OffsetDateTime dateTo = dateRange.getEnd();
|
||||
@@ -114,41 +112,6 @@ public class Plotter {
|
||||
DataSeries.sortAndLimit(dataSeries, limitBy, limit);
|
||||
DataSeries.setColors(dataSeries);
|
||||
|
||||
final Path outputFile = Files.createTempFile(outputDir, "", ".png");
|
||||
{
|
||||
final Gnuplot gnuplot = new Gnuplot(tmpBaseDir);
|
||||
final GnuplotSettings gnuplotSettings = new GnuplotSettings(outputFile);
|
||||
gnuplotSettings.setHeight(height);
|
||||
gnuplotSettings.setWidth(width);
|
||||
gnuplotSettings.setDateTimeRange(plotSettings.dateRange());
|
||||
|
||||
gnuplotSettings.setY1(plotSettings.getY1());
|
||||
gnuplotSettings.setY2(plotSettings.getY2());
|
||||
|
||||
gnuplotSettings.setAggregates(plotSettings.getAggregates());
|
||||
gnuplotSettings.setKeyOutside(plotSettings.isKeyOutside());
|
||||
gnuplotSettings.setRenderBarChartTickLabels(plotSettings.isRenderBarChartTickLabels());
|
||||
gnuplot.plot(gnuplotSettings, dataSeries);
|
||||
}
|
||||
|
||||
final Path thumbnail;
|
||||
if (plotSettings.isGenerateThumbnail()) {
|
||||
thumbnail = Files.createTempFile(outputDir, "", ".png");
|
||||
final Gnuplot gnuplot = new Gnuplot(tmpBaseDir);
|
||||
final GnuplotSettings gnuplotSettings = new GnuplotSettings(thumbnail);
|
||||
gnuplotSettings.setHeight(plotSettings.getThumbnailMaxHeight());
|
||||
gnuplotSettings.setWidth(plotSettings.getThumbnailMaxWidth());
|
||||
gnuplotSettings.setDateTimeRange(plotSettings.dateRange());
|
||||
gnuplotSettings.setY1(plotSettings.getY1());
|
||||
gnuplotSettings.setY2(plotSettings.getY2());
|
||||
gnuplotSettings.setAggregates(plotSettings.getAggregates());
|
||||
gnuplotSettings.setKeyOutside(false);
|
||||
gnuplotSettings.renderLabels(false);
|
||||
gnuplot.plot(gnuplotSettings, dataSeries);
|
||||
} else {
|
||||
thumbnail = null;
|
||||
}
|
||||
|
||||
final Map<String, Path> renderedImages = new HashMap<>();
|
||||
for (final Entry<String, RenderOptions> renders : plotSettings.getRenders().entrySet()) {
|
||||
final Path file = Files.createTempFile(outputDir, "", ".png");
|
||||
@@ -168,7 +131,7 @@ public class Plotter {
|
||||
gnuplot.plot(gnuplotSettings, dataSeries);
|
||||
}
|
||||
|
||||
return new PlotResult(outputFile, dataSeries, thumbnail, renderedImages);
|
||||
return new PlotResult(dataSeries, renderedImages);
|
||||
} catch (final InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new AbortException();
|
||||
|
||||
Reference in New Issue
Block a user