POC for detailed gallery view
This commit is contained in:
@@ -54,10 +54,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Controller
|
||||
@EnableAutoConfiguration
|
||||
@RequestMapping(path = "/api")
|
||||
@@ -91,22 +87,6 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
this.csvUploadHandler = csvUploadHandler;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/plots", //
|
||||
method = RequestMethod.GET, //
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE, //
|
||||
produces = MediaType.APPLICATION_JSON_VALUE //
|
||||
)
|
||||
@ResponseBody
|
||||
ResponseEntity<PlotResponse> createPlotGet(@RequestParam(name = "request") final String request)
|
||||
throws InternalPlottingException, InterruptedException, JsonParseException, JsonMappingException,
|
||||
IOException {
|
||||
|
||||
final ObjectMapper objectMapper = new ObjectMapper();
|
||||
final PlotRequest plotRequest = objectMapper.readValue(request, PlotRequest.class);
|
||||
|
||||
return createPlot(plotRequest);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/plots", //
|
||||
method = RequestMethod.POST, //
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE, //
|
||||
|
||||
@@ -6,8 +6,21 @@ public class DataSeriesStats {
|
||||
private final int values;
|
||||
private final long maxValue;
|
||||
private final double average;
|
||||
private final String name;
|
||||
private final StyleAndColor dashTypeAndColor;
|
||||
|
||||
public DataSeriesStats(final int values, final long maxValue, final double average) {
|
||||
this.name = "<noName>";
|
||||
this.dashTypeAndColor = new StyleAndColor("000", 0);
|
||||
this.values = values;
|
||||
this.maxValue = maxValue;
|
||||
this.average = average;
|
||||
}
|
||||
|
||||
public DataSeriesStats(final String name, final StyleAndColor dashTypeAndColor, final int values,
|
||||
final long maxValue, final double average) {
|
||||
this.name = name;
|
||||
this.dashTypeAndColor = dashTypeAndColor;
|
||||
this.values = values;
|
||||
this.maxValue = maxValue;
|
||||
this.average = average;
|
||||
@@ -22,6 +35,10 @@ public class DataSeriesStats {
|
||||
return values;
|
||||
}
|
||||
|
||||
public StyleAndColor getDashTypeAndColor() {
|
||||
return dashTypeAndColor;
|
||||
}
|
||||
|
||||
public long getMaxValue() {
|
||||
return maxValue;
|
||||
}
|
||||
@@ -30,9 +47,14 @@ public class DataSeriesStats {
|
||||
return average;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[values=" + values + ", maxValue=" + maxValue + ", average=" + average + "]";
|
||||
return "[name=" + name + ", dashTypeAndColor=" + dashTypeAndColor + ", values=" + values + ", maxValue="
|
||||
+ maxValue + ", average=" + average + "]";
|
||||
}
|
||||
|
||||
public static double average(final Collection<DataSeriesStats> stats) {
|
||||
|
||||
@@ -75,8 +75,11 @@ public class PlotResponseStats {
|
||||
values += dataSerie.getValues();
|
||||
maxValue = Math.max(maxValue, dataSerie.getMaxValue());
|
||||
|
||||
dataSeriesStats
|
||||
.add(new DataSeriesStats(dataSerie.getValues(), dataSerie.getMaxValue(), dataSerie.getAverage()));
|
||||
final StyleAndColor lineStyle = new StyleAndColor(dataSerie.getStyle().getColor().getColor(),
|
||||
dataSerie.getStyle().getPointType());
|
||||
|
||||
dataSeriesStats.add(new DataSeriesStats(dataSerie.getTitle(), lineStyle, dataSerie.getValues(),
|
||||
dataSerie.getMaxValue(), dataSerie.getAverage()));
|
||||
}
|
||||
|
||||
final double average = Math.round(DataSeriesStats.average(dataSeriesStats));
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
public class StyleAndColor {
|
||||
private String color;
|
||||
|
||||
private final int pointType;
|
||||
|
||||
public StyleAndColor(final String color, final int pointType) {
|
||||
super();
|
||||
this.color = color;
|
||||
this.pointType = pointType;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(final String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getPointType() {
|
||||
return pointType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("LineStyleAndColor [color=");
|
||||
builder.append(color);
|
||||
builder.append(", pointType=");
|
||||
builder.append(pointType);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user