put y axis definition into its own object
This commit is contained in:
@@ -9,9 +9,8 @@ import org.lucares.pdb.plot.api.HistogramHandler;
|
||||
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.pdb.plot.api.TimeRangeUnit;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.TimeRangeUnit;
|
||||
|
||||
class PlotSettingsTransformer {
|
||||
static PlotSettings toSettings(final PlotRequest request) {
|
||||
@@ -25,40 +24,40 @@ class PlotSettingsTransformer {
|
||||
result.setLimit(request.getLimit());
|
||||
result.setLimitBy(request.getLimitBy());
|
||||
result.setDateRange(request.getDateRange());
|
||||
result.setYAxisScale(request.getAxisScale());
|
||||
result.setYAxisScale(request.getY1().getAxisScale());
|
||||
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.setYRangeMin(request.getY1().getyRangeMin());
|
||||
result.setYRangeMax(request.getY1().getyRangeMax());
|
||||
result.setYRangeUnit(toTimeRangeUnitInternal(request.getY1().getyRangeUnit()));
|
||||
result.setAggregates(
|
||||
toAggregateInternal(result.getYRangeUnit(), result.getYAxisScale(), request.getAggregates()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static TimeRangeUnitInternal toTimeRangeUnitInternal(final TimeRangeUnit yRangeUnit) {
|
||||
private static TimeRangeUnit toTimeRangeUnitInternal(final TimeRangeUnit yRangeUnit) {
|
||||
switch (yRangeUnit) {
|
||||
case AUTOMATIC:
|
||||
return TimeRangeUnitInternal.AUTOMATIC;
|
||||
return TimeRangeUnit.AUTOMATIC;
|
||||
case MILLISECONDS:
|
||||
return TimeRangeUnitInternal.MILLISECONDS;
|
||||
return TimeRangeUnit.MILLISECONDS;
|
||||
case SECONDS:
|
||||
return TimeRangeUnitInternal.SECONDS;
|
||||
return TimeRangeUnit.SECONDS;
|
||||
case MINUTES:
|
||||
return TimeRangeUnitInternal.MINUTES;
|
||||
return TimeRangeUnit.MINUTES;
|
||||
case HOURS:
|
||||
return TimeRangeUnitInternal.HOURS;
|
||||
return TimeRangeUnit.HOURS;
|
||||
case DAYS:
|
||||
return TimeRangeUnitInternal.DAYS;
|
||||
return TimeRangeUnit.DAYS;
|
||||
}
|
||||
throw new IllegalStateException("unhandled enum value: " + yRangeUnit);
|
||||
}
|
||||
|
||||
static AggregateHandlerCollection toAggregateInternal(final TimeRangeUnitInternal yRangeUnit,
|
||||
final AxisScale yAxisScale, final Iterable<Aggregate> aggregates) {
|
||||
static AggregateHandlerCollection toAggregateInternal(final TimeRangeUnit yRangeUnit, final AxisScale yAxisScale,
|
||||
final Iterable<Aggregate> aggregates) {
|
||||
final AggregateHandlerCollection aggregateHandlerCollection = new AggregateHandlerCollection();
|
||||
|
||||
for (final Aggregate aggregate : aggregates) {
|
||||
@@ -71,7 +70,7 @@ class PlotSettingsTransformer {
|
||||
aggregateHandlerCollection.addAggregateHandler(new ParallelRequestsAggregate());
|
||||
break;
|
||||
case SCATTER:
|
||||
if (yRangeUnit == TimeRangeUnitInternal.AUTOMATIC && yAxisScale == AxisScale.LINEAR) {
|
||||
if (yRangeUnit == TimeRangeUnit.AUTOMATIC && yAxisScale == AxisScale.LINEAR) {
|
||||
// TODO need a second ScatterAggregateHandler for YRangeUnit() ==
|
||||
// TimeRangeUnitInternal.AUTOMATIC
|
||||
throw new UnsupportedOperationException(
|
||||
|
||||
@@ -4,8 +4,8 @@ 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;
|
||||
import org.lucares.pdb.plot.api.YAxisDefinition;
|
||||
|
||||
public class PlotRequest {
|
||||
private String query;
|
||||
@@ -22,18 +22,15 @@ public class PlotRequest {
|
||||
|
||||
private Limit limitBy = Limit.NO_LIMIT;
|
||||
|
||||
private AxisScale yAxisScale = AxisScale.LINEAR;
|
||||
|
||||
private int limit = Integer.MAX_VALUE;
|
||||
|
||||
private YAxisDefinition y1 = new YAxisDefinition();
|
||||
private YAxisDefinition y2 = new YAxisDefinition();
|
||||
|
||||
private String dateRange;
|
||||
|
||||
private List<Aggregate> aggregates = new ArrayList<>();
|
||||
|
||||
private int yRangeMin;
|
||||
private int yRangeMax;
|
||||
private TimeRangeUnit yRangeUnit = TimeRangeUnit.AUTOMATIC;
|
||||
|
||||
private boolean keyOutside;
|
||||
|
||||
private boolean generateThumbnail;
|
||||
@@ -115,14 +112,6 @@ public class PlotRequest {
|
||||
this.dateRange = dateRange;
|
||||
}
|
||||
|
||||
public AxisScale getAxisScale() {
|
||||
return yAxisScale;
|
||||
}
|
||||
|
||||
public void setAxisScale(final AxisScale yAxis) {
|
||||
this.yAxisScale = yAxis;
|
||||
}
|
||||
|
||||
public void setAggregate(final List<Aggregate> aggregates) {
|
||||
this.aggregates = aggregates;
|
||||
}
|
||||
@@ -147,27 +136,19 @@ public class PlotRequest {
|
||||
this.generateThumbnail = generateThumbnail;
|
||||
}
|
||||
|
||||
public int getyRangeMin() {
|
||||
return yRangeMin;
|
||||
public YAxisDefinition getY1() {
|
||||
return y1;
|
||||
}
|
||||
|
||||
public void setyRangeMin(final int yRangeMin) {
|
||||
this.yRangeMin = yRangeMin;
|
||||
public void setY1(final YAxisDefinition y1) {
|
||||
this.y1 = y1;
|
||||
}
|
||||
|
||||
public int getyRangeMax() {
|
||||
return yRangeMax;
|
||||
public YAxisDefinition getY2() {
|
||||
return y2;
|
||||
}
|
||||
|
||||
public void setyRangeMax(final int yRangeMax) {
|
||||
this.yRangeMax = yRangeMax;
|
||||
}
|
||||
|
||||
public TimeRangeUnit getyRangeUnit() {
|
||||
return yRangeUnit;
|
||||
}
|
||||
|
||||
public void setyRangeUnit(final TimeRangeUnit yRangeUnit) {
|
||||
this.yRangeUnit = yRangeUnit;
|
||||
public void setY2(final YAxisDefinition y2) {
|
||||
this.y2 = y2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
public enum TimeRangeUnit {
|
||||
AUTOMATIC, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS
|
||||
}
|
||||
Reference in New Issue
Block a user