remove old way of rendering images

This commit is contained in:
2023-03-04 10:56:05 +01:00
parent bc3b6ec3e9
commit 8f369d9943
15 changed files with 52 additions and 264 deletions

View File

@@ -77,12 +77,6 @@ export class DashboardComponent implements OnInit {
const fullHeight = window.innerHeight-30;
const request = new PlotRequest(
height,
width,
600, // thumbnailMaxWidth
500, // thumbnailMaxHeight
false, // keyOutside
false, // generateThumbnail
(<any>window).submitterId+crypto.randomUUID(),
plotWidget.config,
{

View File

@@ -1,6 +1,6 @@
import { Component, OnInit, Input, Output, ViewChild, EventEmitter } from '@angular/core';
import { MatLegacySnackBar as MatSnackBar } from '@angular/material/legacy-snack-bar';
import { PlotService, PlotRequest, PlotResponse, PlotResponseStats, DashTypeAndColor } from '../plot.service';
import { PlotService, PlotRequest, PlotResponse, PlotResponseStats, DashTypeAndColor, RenderedImages } from '../plot.service';
import { UtilService } from '../utils.service';
export class GalleryFilterData {
@@ -242,8 +242,6 @@ export class GalleryViewComponent implements OnInit {
this.galleryItems.length = 0;
this.splitByValuesQueue.length = 0;
request.generateThumbnail = true;
this.plotService.splitQuery(request.config.query, splitByField).subscribe({
next: function(valuesForSplitBy){
console.log("valuesForSplitBy: " + JSON.stringify(valuesForSplitBy));
@@ -283,8 +281,8 @@ export class GalleryViewComponent implements OnInit {
that.progress = 100 * (that.totalNumberImages - that.splitByValuesQueue.length) / that.totalNumberImages;
plotResponse.thumbnailUrl = "//"+window.location.hostname+':'+window.location.port+'/'+plotResponse.rendered['thumbnail'];
plotResponse.imageUrl = "//"+window.location.hostname+':'+window.location.port+'/'+plotResponse.rendered['main'];
//plotResponse.thumbnailUrl = "//"+window.location.hostname+':'+window.location.port+'/'+plotResponse.rendered['thumbnail'];
//plotResponse.imageUrl = "//"+window.location.hostname+':'+window.location.port+'/'+plotResponse.rendered['main'];
let galleryItem = new GalleryItem(splitByValue, plotResponse);
that.galleryItems.push(galleryItem);
that.sortAndFilterGallery();
@@ -342,16 +340,16 @@ export class GalleryItemView {
export class GalleryItem {
thumbnailUrl: string;
imageUrl: string;
stats: PlotResponseStats;
splitByValue : string;
imageUrl: string;
thumbnailUrl :string;
show : boolean = false;
constructor(splitByValue: string, plotResponse: PlotResponse){
this.thumbnailUrl = plotResponse.thumbnailUrl;
this.imageUrl = plotResponse.imageUrl;
this.splitByValue = splitByValue;
this.stats = plotResponse.stats;
this.thumbnailUrl = "//"+window.location.hostname+':'+window.location.port+'/'+plotResponse.rendered['thumbnail'];
this.imageUrl = "//"+window.location.hostname+':'+window.location.port+'/'+plotResponse.rendered['main'];
}
}

View File

@@ -275,12 +275,6 @@ export class PlotViewComponent implements OnInit {
const actualDimension = typeof dimension === "function" ? dimension() : dimension;
const request = new PlotRequest(
actualDimension.height,
actualDimension.width,
300, // thumbnailMaxWidth
200, // thumbnailMaxHeight
false, // keyOutside
false, // generateThumbnail
(<any>window).submitterId,
this.config!,
{

View File

@@ -215,12 +215,6 @@ export type RenderedImages = {
export class PlotRequest {
constructor(
public height : number,
public width : number,
public thumbnailMaxWidth : number = 300,
public thumbnailMaxHeight : number = 200,
public keyOutside : boolean = false,
public generateThumbnail : boolean,
public submitterId: string,
public config: PlotConfig,
public renders: RenderOptionsMap
@@ -264,9 +258,7 @@ export class YAxisDefinition {
export class PlotResponse {
constructor(
public imageUrl : string,
public stats : PlotResponseStats,
public thumbnailUrl : string,
public rendered: RenderedImages){}
}

View File

@@ -198,12 +198,6 @@ export class VisualizationPageComponent implements OnInit {
};
const request = new PlotRequest(
results != null ? results.offsetHeight-1: 1024,
results != null ? results.offsetWidth-1 : 1024,
300, // thumbnailMaxWidth
200, // thumbnailMaxHeight
false, // keyOutside
this.enableGallery, // generateThumbnail
(<any>window).submitterId,
config,
renderOptions

View File

@@ -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));

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -117,13 +117,6 @@ public class PdbController implements HardcodedValues, PropertyKeys {
try {
final PlotResult result = plotter.plot(plotSettings);
final String imageUrl = WEB_IMAGE_OUTPUT_PATH + "/" + result.getImageName();
LOGGER.trace("image url: {}", imageUrl);
final String thumbnailUrl = result.getThumbnailPath() != null
? WEB_IMAGE_OUTPUT_PATH + "/" + result.getThumbnailName()
: "img/no-thumbnail.png";
final Map<String, String> rendered = new HashMap<>();
for (final Entry<String, Path> renderedImageEntry : result.getRenderedImages().entrySet()) {
final String url = WEB_IMAGE_OUTPUT_PATH + "/"
@@ -133,7 +126,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
}
final PlotResponseStats stats = PlotResponseStats.fromDataSeries(result.getDataSeries());
final PlotResponse plotResponse = new PlotResponse(stats, imageUrl, thumbnailUrl, rendered);
final PlotResponse plotResponse = new PlotResponse(stats, rendered);
return ResponseEntity.ok().body(plotResponse);
} catch (final NoDataPointsException e) {

View File

@@ -23,16 +23,10 @@ class PlotSettingsTransformer {
final PlotConfig config = request.getConfig();
result.setQuery(config.getQuery());
result.setGroupBy(config.getGroupBy());
result.setHeight(request.getHeight());
result.setWidth(request.getWidth());
result.setLimit(config.getLimit());
result.setLimitBy(config.getLimitBy());
result.setDateRange(config.getDateRange());
result.setKeyOutside(request.isKeyOutside());
result.setThumbnailMaxWidth(request.getThumbnailMaxWidth());
result.setThumbnailMaxHeight(request.getThumbnailMaxHeight());
result.setGenerateThumbnail(request.isGenerateThumbnail());
result.setY1(config.getY1());
result.setY2(config.getY2());
result.setAggregates(toAggregateInternal(config.getY1(), config.getY2(), config.getAggregates()));

View File

@@ -6,17 +6,6 @@ import java.util.TreeMap;
import org.lucares.pdb.plot.api.RenderOptions;
public class PlotRequest {
private int height = 1000;
private int width = 1000;
private int thumbnailMaxWidth = 0;
private int thumbnailMaxHeight = 0;
private boolean generateThumbnail;
private boolean keyOutside;
private String submitterId;
private PlotConfig config;
@@ -39,54 +28,6 @@ public class PlotRequest {
this.config = config;
}
public int getWidth() {
return width;
}
public void setWidth(final int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(final int height) {
this.height = height;
}
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 void setKeyOutside(final boolean keyOutside) {
this.keyOutside = keyOutside;
}
public boolean isKeyOutside() {
return keyOutside;
}
public boolean isGenerateThumbnail() {
return generateThumbnail;
}
public void setGenerateThumbnail(final boolean generateThumbnail) {
this.generateThumbnail = generateThumbnail;
}
public String getSubmitterId() {
return submitterId;
}
@@ -97,7 +38,7 @@ public class PlotRequest {
@Override
public String toString() {
return (config != null ? config.getQuery() : "<no query>") + ":" + height + "x" + width;
return (config != null ? config.getQuery() : "<no query>");
}
}

View File

@@ -3,16 +3,11 @@ package org.lucares.pdbui.domain;
import java.util.Map;
public class PlotResponse {
private String imageUrl = "";
private PlotResponseStats stats;
private String thumbnailUrl;
private final Map<String, String> rendered;
public PlotResponse(final PlotResponseStats stats, final String imageUrl, final String thumbnailUrl,
final Map<String, String> rendered) {
public PlotResponse(final PlotResponseStats stats, final Map<String, String> rendered) {
this.stats = stats;
this.imageUrl = imageUrl;
this.thumbnailUrl = thumbnailUrl;
this.rendered = rendered;
}
@@ -20,18 +15,6 @@ public class PlotResponse {
return rendered;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(final String imageUrl) {
this.imageUrl = imageUrl;
}
public String getThumbnailUrl() {
return thumbnailUrl;
}
public PlotResponseStats getStats() {
return stats;
}
@@ -40,13 +23,9 @@ public class PlotResponse {
this.stats = stats;
}
public void setThumbnailUrl(final String thumbnailUrl) {
this.thumbnailUrl = thumbnailUrl;
}
@Override
public String toString() {
return "PlotResponse [imageUrl=" + imageUrl + ", stats=" + stats + ", thumbnailUrl=" + thumbnailUrl + "]";
return "PlotResponse [stats=" + stats + ", rendered=" + rendered + "]";
}
}