make it possible to draw the legend outside of the plot area
This commit is contained in:
@@ -1,68 +1,69 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggreateInternal;
|
||||
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.LimitBy;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.YAxis;
|
||||
|
||||
class PlotSettingsTransformer {
|
||||
static PlotSettings toSettings(final PlotRequest request) {
|
||||
|
||||
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(toLimit(request.getLimitBy()));
|
||||
result.setDateFrom(request.getDateFrom());
|
||||
result.setDateRange(request.getDateRange());
|
||||
result.setYAxisScale(toAxisScale(request.getAxisScale()));
|
||||
result.setAggregate(toAggregateInternal(request.getAggregate()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static AggreateInternal toAggregateInternal(Aggregate aggregate) {
|
||||
switch (aggregate) {
|
||||
case NONE:return AggreateInternal.NONE;
|
||||
case MEAN:return AggreateInternal.MEAN;
|
||||
}
|
||||
throw new IllegalStateException("unhandled enum: " + aggregate);
|
||||
}
|
||||
|
||||
private static AxisScale toAxisScale(final YAxis yAxis) {
|
||||
switch (yAxis) {
|
||||
case LINEAR:
|
||||
return AxisScale.LINEAR;
|
||||
case LOG10:
|
||||
return AxisScale.LOG10;
|
||||
case LOG2:
|
||||
return AxisScale.LOG2;
|
||||
default:
|
||||
throw new IllegalStateException("unhandled enum: " + yAxis);
|
||||
}
|
||||
}
|
||||
|
||||
private static Limit toLimit(final LimitBy limitBy) {
|
||||
switch (limitBy) {
|
||||
case NO_LIMIT:
|
||||
return Limit.NO_LIMIT;
|
||||
case FEWEST_VALUES:
|
||||
return Limit.FEWEST_VALUES;
|
||||
case MOST_VALUES:
|
||||
return Limit.MOST_VALUES;
|
||||
case MAX_VALUE:
|
||||
return Limit.MAX_VALUE;
|
||||
case MIN_VALUE:
|
||||
return Limit.MIN_VALUE;
|
||||
default:
|
||||
throw new IllegalStateException("unhandled enum: " + limitBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggreateInternal;
|
||||
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.LimitBy;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.YAxis;
|
||||
|
||||
class PlotSettingsTransformer {
|
||||
static PlotSettings toSettings(final PlotRequest request) {
|
||||
|
||||
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(toLimit(request.getLimitBy()));
|
||||
result.setDateFrom(request.getDateFrom());
|
||||
result.setDateRange(request.getDateRange());
|
||||
result.setYAxisScale(toAxisScale(request.getAxisScale()));
|
||||
result.setAggregate(toAggregateInternal(request.getAggregate()));
|
||||
result.setKeyOutside(request.isKeyOutside());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static AggreateInternal toAggregateInternal(Aggregate aggregate) {
|
||||
switch (aggregate) {
|
||||
case NONE:return AggreateInternal.NONE;
|
||||
case MEAN:return AggreateInternal.MEAN;
|
||||
}
|
||||
throw new IllegalStateException("unhandled enum: " + aggregate);
|
||||
}
|
||||
|
||||
private static AxisScale toAxisScale(final YAxis yAxis) {
|
||||
switch (yAxis) {
|
||||
case LINEAR:
|
||||
return AxisScale.LINEAR;
|
||||
case LOG10:
|
||||
return AxisScale.LOG10;
|
||||
case LOG2:
|
||||
return AxisScale.LOG2;
|
||||
default:
|
||||
throw new IllegalStateException("unhandled enum: " + yAxis);
|
||||
}
|
||||
}
|
||||
|
||||
private static Limit toLimit(final LimitBy limitBy) {
|
||||
switch (limitBy) {
|
||||
case NO_LIMIT:
|
||||
return Limit.NO_LIMIT;
|
||||
case FEWEST_VALUES:
|
||||
return Limit.FEWEST_VALUES;
|
||||
case MOST_VALUES:
|
||||
return Limit.MOST_VALUES;
|
||||
case MAX_VALUE:
|
||||
return Limit.MAX_VALUE;
|
||||
case MIN_VALUE:
|
||||
return Limit.MIN_VALUE;
|
||||
default:
|
||||
throw new IllegalStateException("unhandled enum: " + limitBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,113 +1,123 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlotRequest {
|
||||
private String query;
|
||||
|
||||
private int height = 1000;
|
||||
|
||||
private int width = 1000;
|
||||
|
||||
private List<String> groupBy;
|
||||
|
||||
private LimitBy limitBy = LimitBy.NO_LIMIT;
|
||||
|
||||
private YAxis yAxis = YAxis.LINEAR;
|
||||
|
||||
private int limit = Integer.MAX_VALUE;
|
||||
|
||||
private String dateFrom;
|
||||
|
||||
private String dateRange;
|
||||
|
||||
private Aggregate aggregate = Aggregate.NONE;
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(final String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return query + ":" + height + "x" + width;
|
||||
}
|
||||
|
||||
public List<String> getGroupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
|
||||
public void setGroupBy(final List<String> groupBy) {
|
||||
this.groupBy = groupBy;
|
||||
}
|
||||
|
||||
public LimitBy getLimitBy() {
|
||||
return limitBy;
|
||||
}
|
||||
|
||||
public void setLimitBy(final LimitBy limitBy) {
|
||||
this.limitBy = limitBy;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(final int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public String getDateFrom() {
|
||||
return dateFrom;
|
||||
}
|
||||
|
||||
public void setDateFrom(final String dateFrom) {
|
||||
this.dateFrom = dateFrom;
|
||||
}
|
||||
|
||||
public String getDateRange() {
|
||||
return dateRange;
|
||||
}
|
||||
|
||||
public void setDateRange(final String dateRange) {
|
||||
if (!dateRange.matches("\\d+ (second|minute|hour|day|week|month)s?")) {
|
||||
throw new IllegalArgumentException(dateRange + " is not a valid range");
|
||||
}
|
||||
this.dateRange = dateRange;
|
||||
}
|
||||
|
||||
public YAxis getAxisScale() {
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
public void setAxisScale(final YAxis yAxis) {
|
||||
this.yAxis = yAxis;
|
||||
}
|
||||
|
||||
public void setAggregate(Aggregate aggregate) {
|
||||
this.aggregate = aggregate;
|
||||
}
|
||||
|
||||
public Aggregate getAggregate() {
|
||||
return aggregate;
|
||||
}
|
||||
}
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlotRequest {
|
||||
private String query;
|
||||
|
||||
private int height = 1000;
|
||||
|
||||
private int width = 1000;
|
||||
|
||||
private List<String> groupBy;
|
||||
|
||||
private LimitBy limitBy = LimitBy.NO_LIMIT;
|
||||
|
||||
private YAxis yAxis = YAxis.LINEAR;
|
||||
|
||||
private int limit = Integer.MAX_VALUE;
|
||||
|
||||
private String dateFrom;
|
||||
|
||||
private String dateRange;
|
||||
|
||||
private Aggregate aggregate = Aggregate.NONE;
|
||||
|
||||
private boolean keyOutside;
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(final String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return query + ":" + height + "x" + width;
|
||||
}
|
||||
|
||||
public List<String> getGroupBy() {
|
||||
return groupBy;
|
||||
}
|
||||
|
||||
public void setGroupBy(final List<String> groupBy) {
|
||||
this.groupBy = groupBy;
|
||||
}
|
||||
|
||||
public LimitBy getLimitBy() {
|
||||
return limitBy;
|
||||
}
|
||||
|
||||
public void setLimitBy(final LimitBy limitBy) {
|
||||
this.limitBy = limitBy;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(final int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public String getDateFrom() {
|
||||
return dateFrom;
|
||||
}
|
||||
|
||||
public void setDateFrom(final String dateFrom) {
|
||||
this.dateFrom = dateFrom;
|
||||
}
|
||||
|
||||
public String getDateRange() {
|
||||
return dateRange;
|
||||
}
|
||||
|
||||
public void setDateRange(final String dateRange) {
|
||||
if (!dateRange.matches("\\d+ (second|minute|hour|day|week|month)s?")) {
|
||||
throw new IllegalArgumentException(dateRange + " is not a valid range");
|
||||
}
|
||||
this.dateRange = dateRange;
|
||||
}
|
||||
|
||||
public YAxis getAxisScale() {
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
public void setAxisScale(final YAxis yAxis) {
|
||||
this.yAxis = yAxis;
|
||||
}
|
||||
|
||||
public void setAggregate(Aggregate aggregate) {
|
||||
this.aggregate = aggregate;
|
||||
}
|
||||
|
||||
public Aggregate getAggregate() {
|
||||
return aggregate;
|
||||
}
|
||||
|
||||
public void setKeyOutside(boolean keyOutside) {
|
||||
this.keyOutside = keyOutside;
|
||||
}
|
||||
|
||||
public boolean isKeyOutside() {
|
||||
return keyOutside;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user