show plotted images

This commit is contained in:
2019-10-27 07:53:23 +01:00
parent 3190074ce3
commit 5a7cde7815
19 changed files with 117 additions and 35 deletions

View File

@@ -3,7 +3,7 @@ package org.lucares.pdbui;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "BadRequest")
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public class BadRequest extends RuntimeException {
private static final long serialVersionUID = 694206253376122420L;

View File

@@ -3,7 +3,7 @@ package org.lucares.pdbui;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Not Found")
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public class NotFoundException extends RuntimeException {
private static final long serialVersionUID = 694206253376122420L;

View File

@@ -143,7 +143,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
return ResponseEntity.ok().body(plotResponse);
} catch (final NoDataPointsException e) {
throw new NotFoundException(e);
throw new NotFoundException("No data was found. Try another query, or change the date range.",e);
} finally {
plotterLock.unlock();
}
@@ -186,7 +186,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
plotSettings.setLimitBy(limitBy);
plotSettings.setDateRange(dateRange);
plotSettings.setYAxisScale(axisScale);
plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(aggregate));
plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(plotSettings.getYRangeUnit(), plotSettings.getYAxisScale(), aggregate));
plotSettings.setKeyOutside(keyOutside);
plotSettings.setGenerateThumbnail(false);

View File

@@ -2,6 +2,7 @@ package org.lucares.pdbui;
import org.lucares.pdb.plot.api.Aggregate;
import org.lucares.pdb.plot.api.AggregateHandlerCollection;
import org.lucares.pdb.plot.api.AxisScale;
import org.lucares.pdb.plot.api.CumulativeDistributionHandler;
import org.lucares.pdb.plot.api.ParallelRequestsAggregate;
import org.lucares.pdb.plot.api.PlotSettings;
@@ -22,8 +23,7 @@ class PlotSettingsTransformer {
result.setLimit(request.getLimit());
result.setLimitBy(request.getLimitBy());
result.setDateRange(request.getDateRange());
result.setYAxisScale(request.getAxisScale());
result.setAggregates(toAggregateInternal(request.getAggregates()));
result.setYAxisScale(request.getYAxisScale());
result.setKeyOutside(request.isKeyOutside());
result.setThumbnailMaxWidth(request.getThumbnailMaxWidth());
result.setThumbnailMaxHeight(request.getThumbnailMaxHeight());
@@ -31,6 +31,7 @@ class PlotSettingsTransformer {
result.setYRangeMin(request.getyRangeMin());
result.setYRangeMax(request.getyRangeMax());
result.setYRangeUnit(toTimeRangeUnitInternal(request.getyRangeUnit()));
result.setAggregates(toAggregateInternal(result.getYRangeUnit(), result.getYAxisScale(), request.getAggregates()));
return result;
}
@@ -53,7 +54,8 @@ class PlotSettingsTransformer {
throw new IllegalStateException("unhandled enum value: " + yRangeUnit);
}
static AggregateHandlerCollection toAggregateInternal(final Iterable<Aggregate> aggregates) {
static AggregateHandlerCollection toAggregateInternal(TimeRangeUnitInternal yRangeUnit, AxisScale yAxisScale,
final Iterable<Aggregate> aggregates) {
final AggregateHandlerCollection aggregateHandlerCollection = new AggregateHandlerCollection();
for (Aggregate aggregate : aggregates) {
@@ -66,7 +68,12 @@ class PlotSettingsTransformer {
aggregateHandlerCollection.add(new ParallelRequestsAggregate());
break;
case SCATTER:
aggregateHandlerCollection.add(new ScatterAggregateHandler());
if (yRangeUnit == TimeRangeUnitInternal.AUTOMATIC && yAxisScale == AxisScale.LINEAR) {
// TODO need a second ScatterAggregateHandler for YRangeUnit() == TimeRangeUnitInternal.AUTOMATIC
throw new UnsupportedOperationException("linear axis with automatic y range does not work, use logarthmic y-axis, or define a y-axis range");
}else {
aggregateHandlerCollection.add(new ScatterAggregateHandler());
}
break;
default:
throw new IllegalStateException("unhandled enum: " + aggregate);

View File

@@ -22,7 +22,7 @@ public class PlotRequest {
private Limit limitBy = Limit.NO_LIMIT;
private AxisScale yAxis = AxisScale.LINEAR;
private AxisScale yAxisScale = AxisScale.LINEAR;
private int limit = Integer.MAX_VALUE;
@@ -115,12 +115,12 @@ public class PlotRequest {
this.dateRange = dateRange;
}
public AxisScale getAxisScale() {
return yAxis;
public AxisScale getYAxisScale() {
return yAxisScale;
}
public void setAxisScale(final AxisScale yAxis) {
this.yAxis = yAxis;
public void setYAxisScale(final AxisScale yAxis) {
this.yAxisScale = yAxis;
}
public void setAggregate(final List<Aggregate> aggregates) {