make it possible to render any combination of plots
This commit is contained in:
@@ -6,6 +6,7 @@ import java.io.OutputStream;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -20,10 +21,10 @@ import org.lucares.pdb.api.DateTimeRange;
|
||||
import org.lucares.pdb.api.QueryWithCaretMarker;
|
||||
import org.lucares.pdb.api.QueryWithCaretMarker.ResultMode;
|
||||
import org.lucares.pdb.datastore.Proposal;
|
||||
import org.lucares.pdb.plot.api.Aggregate;
|
||||
import org.lucares.pdb.plot.api.AxisScale;
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdbui.domain.Aggregate;
|
||||
import org.lucares.pdbui.domain.AutocompleteProposal;
|
||||
import org.lucares.pdbui.domain.AutocompleteProposalByValue;
|
||||
import org.lucares.pdbui.domain.AutocompleteResponse;
|
||||
@@ -158,7 +159,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
@RequestParam(name = "limitBy.selected", defaultValue = "NO_LIMIT") final Limit limitBy,
|
||||
@RequestParam(name = "dateRange") final String dateRange,
|
||||
@RequestParam(name = "axisScale", defaultValue = "LINEAR") final AxisScale axisScale,
|
||||
@RequestParam(name = "aggregate", defaultValue = "NONE") final Aggregate aggregate,
|
||||
@RequestParam(name = "aggregates") final EnumSet<Aggregate>aggregate,
|
||||
@RequestParam(name = "keyOutside", defaultValue = "false") final boolean keyOutside,
|
||||
@RequestParam(name = "width", defaultValue = "1920") final int hidth,
|
||||
@RequestParam(name = "height", defaultValue = "1080") final int height) {
|
||||
@@ -181,7 +182,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
plotSettings.setLimitBy(limitBy);
|
||||
plotSettings.setDateRange(dateRange);
|
||||
plotSettings.setYAxisScale(axisScale);
|
||||
plotSettings.setAggregate(PlotSettingsTransformer.toAggregateInternal(aggregate));
|
||||
plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(aggregate));
|
||||
plotSettings.setKeyOutside(keyOutside);
|
||||
plotSettings.setGenerateThumbnail(false);
|
||||
|
||||
|
||||
@@ -1,70 +1,78 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggregateHandler;
|
||||
import org.lucares.pdb.plot.api.NullAggregate;
|
||||
import org.lucares.pdb.plot.api.ParallelRequestsAggregate;
|
||||
import org.lucares.pdb.plot.api.Aggregate;
|
||||
import org.lucares.pdb.plot.api.AggregateHandlerCollection;
|
||||
import org.lucares.pdb.plot.api.CumulativeDistributionHandler;
|
||||
import org.lucares.pdb.plot.api.ParallelRequestsAggregate;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdb.plot.api.ScatterAggregateHandler;
|
||||
import org.lucares.pdb.plot.api.TimeRangeUnitInternal;
|
||||
import org.lucares.pdbui.domain.Aggregate;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.TimeRangeUnit;
|
||||
|
||||
class PlotSettingsTransformer {
|
||||
static PlotSettings toSettings(final PlotRequest request) {
|
||||
static PlotSettings toSettings(final PlotRequest request) {
|
||||
|
||||
final PlotSettings result = new PlotSettings();
|
||||
final PlotSettings result = new PlotSettings();
|
||||
|
||||
result.setQuery(request.getQuery());
|
||||
result.setGroupBy(request.getGroupBy());
|
||||
result.setHeight(request.getHeight());
|
||||
result.setWidth(request.getWidth());
|
||||
result.setLimit(request.getLimit());
|
||||
result.setLimitBy(request.getLimitBy());
|
||||
result.setDateRange(request.getDateRange());
|
||||
result.setYAxisScale(request.getAxisScale());
|
||||
result.setAggregate(toAggregateInternal(request.getAggregate()));
|
||||
result.setKeyOutside(request.isKeyOutside());
|
||||
result.setThumbnailMaxWidth(request.getThumbnailMaxWidth());
|
||||
result.setThumbnailMaxHeight(request.getThumbnailMaxHeight());
|
||||
result.setGenerateThumbnail(request.isGenerateThumbnail());
|
||||
result.setYRangeMin(request.getyRangeMin());
|
||||
result.setYRangeMax(request.getyRangeMax());
|
||||
result.setYRangeUnit(toTimeRangeUnitInternal(request.getyRangeUnit()));
|
||||
result.setQuery(request.getQuery());
|
||||
result.setGroupBy(request.getGroupBy());
|
||||
result.setHeight(request.getHeight());
|
||||
result.setWidth(request.getWidth());
|
||||
result.setLimit(request.getLimit());
|
||||
result.setLimitBy(request.getLimitBy());
|
||||
result.setDateRange(request.getDateRange());
|
||||
result.setYAxisScale(request.getAxisScale());
|
||||
result.setAggregates(toAggregateInternal(request.getAggregates()));
|
||||
result.setKeyOutside(request.isKeyOutside());
|
||||
result.setThumbnailMaxWidth(request.getThumbnailMaxWidth());
|
||||
result.setThumbnailMaxHeight(request.getThumbnailMaxHeight());
|
||||
result.setGenerateThumbnail(request.isGenerateThumbnail());
|
||||
result.setYRangeMin(request.getyRangeMin());
|
||||
result.setYRangeMax(request.getyRangeMax());
|
||||
result.setYRangeUnit(toTimeRangeUnitInternal(request.getyRangeUnit()));
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static TimeRangeUnitInternal toTimeRangeUnitInternal(final TimeRangeUnit yRangeUnit) {
|
||||
switch (yRangeUnit) {
|
||||
case AUTOMATIC:
|
||||
return TimeRangeUnitInternal.AUTOMATIC;
|
||||
case MILLISECONDS:
|
||||
return TimeRangeUnitInternal.MILLISECONDS;
|
||||
case SECONDS:
|
||||
return TimeRangeUnitInternal.SECONDS;
|
||||
case MINUTES:
|
||||
return TimeRangeUnitInternal.MINUTES;
|
||||
case HOURS:
|
||||
return TimeRangeUnitInternal.HOURS;
|
||||
case DAYS:
|
||||
return TimeRangeUnitInternal.DAYS;
|
||||
}
|
||||
throw new IllegalStateException("unhandled enum value: " + yRangeUnit);
|
||||
}
|
||||
private static TimeRangeUnitInternal toTimeRangeUnitInternal(final TimeRangeUnit yRangeUnit) {
|
||||
switch (yRangeUnit) {
|
||||
case AUTOMATIC:
|
||||
return TimeRangeUnitInternal.AUTOMATIC;
|
||||
case MILLISECONDS:
|
||||
return TimeRangeUnitInternal.MILLISECONDS;
|
||||
case SECONDS:
|
||||
return TimeRangeUnitInternal.SECONDS;
|
||||
case MINUTES:
|
||||
return TimeRangeUnitInternal.MINUTES;
|
||||
case HOURS:
|
||||
return TimeRangeUnitInternal.HOURS;
|
||||
case DAYS:
|
||||
return TimeRangeUnitInternal.DAYS;
|
||||
}
|
||||
throw new IllegalStateException("unhandled enum value: " + yRangeUnit);
|
||||
}
|
||||
|
||||
static AggregateHandler toAggregateInternal(final Aggregate aggregate) {
|
||||
switch (aggregate) {
|
||||
case NONE:
|
||||
return new NullAggregate();
|
||||
case CUM_DISTRIBUTION:
|
||||
return new CumulativeDistributionHandler();
|
||||
case PARALLEL:
|
||||
return new ParallelRequestsAggregate();
|
||||
case SCATTER:
|
||||
return new ScatterAggregateHandler();
|
||||
}
|
||||
throw new IllegalStateException("unhandled enum: " + aggregate);
|
||||
}
|
||||
static AggregateHandlerCollection toAggregateInternal(final Iterable<Aggregate> aggregates) {
|
||||
final AggregateHandlerCollection aggregateHandlerCollection = new AggregateHandlerCollection();
|
||||
|
||||
for (Aggregate aggregate : aggregates) {
|
||||
|
||||
switch (aggregate) {
|
||||
case CUM_DISTRIBUTION:
|
||||
aggregateHandlerCollection.add(new CumulativeDistributionHandler());
|
||||
break;
|
||||
case PARALLEL:
|
||||
aggregateHandlerCollection.add(new ParallelRequestsAggregate());
|
||||
break;
|
||||
case SCATTER:
|
||||
aggregateHandlerCollection.add(new ScatterAggregateHandler());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("unhandled enum: " + aggregate);
|
||||
}
|
||||
}
|
||||
|
||||
return aggregateHandlerCollection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
/**
|
||||
* Note: The order in this enum defines the order in which the aggregates are drawn.
|
||||
*/
|
||||
public enum Aggregate {
|
||||
NONE,
|
||||
|
||||
PARALLEL,
|
||||
|
||||
SCATTER,
|
||||
|
||||
/**
|
||||
* Empirical cumulative distribution functions
|
||||
*
|
||||
* @see https://serialmentor.com/dataviz/ecdf-qq.html
|
||||
*/
|
||||
CUM_DISTRIBUTION,
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lucares.pdb.plot.api.Aggregate;
|
||||
import org.lucares.pdb.plot.api.AxisScale;
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
|
||||
@@ -26,7 +28,7 @@ public class PlotRequest {
|
||||
|
||||
private String dateRange;
|
||||
|
||||
private Aggregate aggregate = Aggregate.NONE;
|
||||
private List<Aggregate> aggregates = new ArrayList<>();
|
||||
|
||||
private int yRangeMin;
|
||||
private int yRangeMax;
|
||||
@@ -121,12 +123,12 @@ public class PlotRequest {
|
||||
this.yAxis = yAxis;
|
||||
}
|
||||
|
||||
public void setAggregate(final Aggregate aggregate) {
|
||||
this.aggregate = aggregate;
|
||||
public void setAggregate(final List<Aggregate> aggregates) {
|
||||
this.aggregates = aggregates;
|
||||
}
|
||||
|
||||
public Aggregate getAggregate() {
|
||||
return aggregate;
|
||||
public List<Aggregate> getAggregates() {
|
||||
return aggregates;
|
||||
}
|
||||
|
||||
public void setKeyOutside(final boolean keyOutside) {
|
||||
|
||||
Reference in New Issue
Block a user