Skip to content

Commit

Permalink
Adding the plotGreenLengthThresholdVehicle
Browse files Browse the repository at this point in the history
  • Loading branch information
computate committed Mar 16, 2023
1 parent bfb1cb2 commit df004a9
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,56 @@ public static String staticSearchFqPlotPerformance(SiteRequestEnUS siteRequest_,
return SimulationReportPage.staticSearchStrPlotPerformance(siteRequest_, SimulationReportPage.staticSearchPlotPerformance(siteRequest_, SimulationReportPage.staticSetPlotPerformance(siteRequest_, o)));
}

/////////////////////////////////////
// plotGreenLengthThresholdVehicle //
/////////////////////////////////////


/** The entity plotGreenLengthThresholdVehicle
* is defined as null before being initialized.
*/
@JsonProperty
@JsonInclude(Include.NON_NULL)
protected String plotGreenLengthThresholdVehicle;

/** <br> The entity plotGreenLengthThresholdVehicle
* is defined as null before being initialized.
* <br><a href="https://solr-solr.apps-crc.testing/solr/computate/select?q=*:*&fq=partEstEntite_indexed_boolean:true&fq=classeNomCanonique_enUS_indexed_string:org.computate.smartvillageview.enus.model.traffic.simulation.report.SimulationReportPage&fq=entiteVar_enUS_indexed_string:plotGreenLengthThresholdVehicle">Find the entity plotGreenLengthThresholdVehicle in Solr</a>
* <br>
* @param w is for wrapping a value to assign to this entity during initialization.
**/
protected abstract void _plotGreenLengthThresholdVehicle(Wrap<String> w);

public String getPlotGreenLengthThresholdVehicle() {
return plotGreenLengthThresholdVehicle;
}
public void setPlotGreenLengthThresholdVehicle(String o) {
this.plotGreenLengthThresholdVehicle = SimulationReportPage.staticSetPlotGreenLengthThresholdVehicle(siteRequest_, o);
}
public static String staticSetPlotGreenLengthThresholdVehicle(SiteRequestEnUS siteRequest_, String o) {
return o;
}
protected SimulationReportPage plotGreenLengthThresholdVehicleInit() {
Wrap<String> plotGreenLengthThresholdVehicleWrap = new Wrap<String>().var("plotGreenLengthThresholdVehicle");
if(plotGreenLengthThresholdVehicle == null) {
_plotGreenLengthThresholdVehicle(plotGreenLengthThresholdVehicleWrap);
setPlotGreenLengthThresholdVehicle(plotGreenLengthThresholdVehicleWrap.o);
}
return (SimulationReportPage)this;
}

public static String staticSearchPlotGreenLengthThresholdVehicle(SiteRequestEnUS siteRequest_, String o) {
return o;
}

public static String staticSearchStrPlotGreenLengthThresholdVehicle(SiteRequestEnUS siteRequest_, String o) {
return o == null ? null : o.toString();
}

public static String staticSearchFqPlotGreenLengthThresholdVehicle(SiteRequestEnUS siteRequest_, String o) {
return SimulationReportPage.staticSearchStrPlotGreenLengthThresholdVehicle(siteRequest_, SimulationReportPage.staticSearchPlotGreenLengthThresholdVehicle(siteRequest_, SimulationReportPage.staticSetPlotGreenLengthThresholdVehicle(siteRequest_, o)));
}

//////////////
// initDeep //
//////////////
Expand Down Expand Up @@ -193,6 +243,7 @@ public Future<Void> promiseSimulationReportPage(Promise<Void> promise) {
Promise<Void> promise2 = Promise.promise();
try {
plotPerformanceInit();
plotGreenLengthThresholdVehicleInit();
promise2.complete();
} catch(Exception ex) {
promise2.fail(ex);
Expand Down Expand Up @@ -248,6 +299,8 @@ public Object obtainSimulationReportPage(String var) {
switch(var) {
case "plotPerformance":
return oSimulationReportPage.plotPerformance;
case "plotGreenLengthThresholdVehicle":
return oSimulationReportPage.plotGreenLengthThresholdVehicle;
default:
return super.obtainSimulationReportGenPage(var);
}
Expand Down Expand Up @@ -289,6 +342,8 @@ public static Object staticSetSimulationReportPage(String entityVar, SiteRequest
switch(entityVar) {
case "plotPerformance":
return SimulationReportPage.staticSetPlotPerformance(siteRequest_, o);
case "plotGreenLengthThresholdVehicle":
return SimulationReportPage.staticSetPlotGreenLengthThresholdVehicle(siteRequest_, o);
default:
return SimulationReportGenPage.staticSetSimulationReportGenPage(entityVar, siteRequest_, o);
}
Expand All @@ -305,6 +360,8 @@ public static Object staticSearchSimulationReportPage(String entityVar, SiteRequ
switch(entityVar) {
case "plotPerformance":
return SimulationReportPage.staticSearchPlotPerformance(siteRequest_, (String)o);
case "plotGreenLengthThresholdVehicle":
return SimulationReportPage.staticSearchPlotGreenLengthThresholdVehicle(siteRequest_, (String)o);
default:
return SimulationReportGenPage.staticSearchSimulationReportGenPage(entityVar, siteRequest_, o);
}
Expand All @@ -321,6 +378,8 @@ public static String staticSearchStrSimulationReportPage(String entityVar, SiteR
switch(entityVar) {
case "plotPerformance":
return SimulationReportPage.staticSearchStrPlotPerformance(siteRequest_, (String)o);
case "plotGreenLengthThresholdVehicle":
return SimulationReportPage.staticSearchStrPlotGreenLengthThresholdVehicle(siteRequest_, (String)o);
default:
return SimulationReportGenPage.staticSearchStrSimulationReportGenPage(entityVar, siteRequest_, o);
}
Expand All @@ -337,6 +396,8 @@ public static String staticSearchFqSimulationReportPage(String entityVar, SiteRe
switch(entityVar) {
case "plotPerformance":
return SimulationReportPage.staticSearchFqPlotPerformance(siteRequest_, o);
case "plotGreenLengthThresholdVehicle":
return SimulationReportPage.staticSearchFqPlotGreenLengthThresholdVehicle(siteRequest_, o);
default:
return SimulationReportGenPage.staticSearchFqSimulationReportGenPage(entityVar, siteRequest_, o);
}
Expand All @@ -350,13 +411,16 @@ public static String staticSearchFqSimulationReportPage(String entityVar, SiteRe
StringBuilder sb = new StringBuilder();
sb.append(super.toString());
sb.append(Optional.ofNullable(plotPerformance).map(v -> "plotPerformance: \"" + v + "\"\n" ).orElse(""));
sb.append(Optional.ofNullable(plotGreenLengthThresholdVehicle).map(v -> "plotGreenLengthThresholdVehicle: \"" + v + "\"\n" ).orElse(""));
return sb.toString();
}

public static final String CLASS_SIMPLE_NAME = "SimulationReportPage";
public static final String VAR_plotPerformance = "plotPerformance";
public static final String VAR_plotGreenLengthThresholdVehicle = "plotGreenLengthThresholdVehicle";

public static final String DISPLAY_NAME_plotPerformance = "";
public static final String DISPLAY_NAME_plotGreenLengthThresholdVehicle = "";

public static String displayNameForClass(String var) {
return SimulationReportPage.displayNameSimulationReportPage(var);
Expand All @@ -365,6 +429,8 @@ public static String displayNameSimulationReportPage(String var) {
switch(var) {
case VAR_plotPerformance:
return DISPLAY_NAME_plotPerformance;
case VAR_plotGreenLengthThresholdVehicle:
return DISPLAY_NAME_plotGreenLengthThresholdVehicle;
default:
return SimulationReportGenPage.displayNameSimulationReportGenPage(var);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
**/
public class SimulationReportPage extends SimulationReportPageGen<SimulationReportGenPage> {

/**
/**
* {@inheritDoc}
* Stored: true
*/
Expand All @@ -61,17 +61,6 @@ protected void _plotPerformance(Wrap<String> w) {
}
dataset.addSeries(series3);

// JFreeChart chart = ChartFactory.createXYLineChart(
// "Performance" // chart title
// , "iterations" // x axis label
// , "average waiting time(s)" // y axis label
// , dataset // data
// , PlotOrientation.VERTICAL
// , true // include legend
// , true // tooltips
// , false // urls
// );

// create plot...
NumberAxis xAxis = new NumberAxis("iterations");
xAxis.setAutoRangeIncludesZero(false);
Expand Down Expand Up @@ -115,6 +104,81 @@ protected void _plotPerformance(Wrap<String> w) {
}
}

/**
* {@inheritDoc}
* Stored: true
*/
protected void _plotGreenLengthThresholdVehicle(Wrap<String> w) {
try {
JsonArray updatedParameters = simulationReport_.getUpdatedParameters();
JsonArray updatedPerformance = simulationReport_.getUpdatedPerformance();
if(updatedParameters != null && updatedParameters.size() >= 4 && simulationReport_ != null && updatedParameters != null && updatedPerformance != null) {
Integer size = updatedPerformance.size();

XYSeries series = new XYSeries("θ_1^min");
for(int i = 0; i < updatedParameters.getJsonArray(0).size(); i++) {
series.add(i + 1, updatedParameters.getJsonArray(0).getDouble(i));
}
XYSeriesCollection dataset = new XYSeriesCollection(series);
XYSeries series2 = new XYSeries("θ_1^max");
for(int i = 0; i < updatedParameters.getJsonArray(0).size(); i++) {
series2.add(i + 1, updatedParameters.getJsonArray(1).getDouble(i));
}
dataset.addSeries(series2);
XYSeries series3 = new XYSeries("θ_2^min");
for(int i = 0; i < updatedParameters.getJsonArray(0).size(); i++) {
series3.add(i + 1, updatedParameters.getJsonArray(2).getDouble(i));
}
dataset.addSeries(series3);
XYSeries series4 = new XYSeries("θ_2^max");
for(int i = 0; i < updatedParameters.getJsonArray(0).size(); i++) {
series4.add(i + 1, updatedParameters.getJsonArray(3).getDouble(i));
}
dataset.addSeries(series4);

// create plot...
NumberAxis xAxis = new NumberAxis("iterations");
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis("GREEN length threshold");
yAxis.setAutoRangeIncludesZero(false);

XYItemRenderer renderer1 = new XYLineAndShapeRenderer();
renderer1.setSeriesPaint(0, Color.yellow);
renderer1.setSeriesPaint(1, Color.red);
renderer1.setSeriesPaint(2, Color.pink);

XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer1);
// XYPlot plot = (XYPlot)chart.getPlot();
// plot.setBackgroundPaint(Color.WHITE);
// plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
// plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
plot.setDomainPannable(true);
plot.setRangePannable(false);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));

// create and return the chart panel...
JFreeChart chart = new JFreeChart("Green Length Threshold", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
ChartUtils.applyCurrentTheme(chart);

ChartRenderingInfo chartRenderingInfo = new ChartRenderingInfo(new StandardEntityCollection());
BufferedImage image = chart.createBufferedImage(600, 400, chartRenderingInfo);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "png", baos);
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close();

String imageStr = new String(Base64.getEncoder().encode(imageInByte), Charset.forName("UTF-8"));
w.o(imageStr);
}
} catch (IOException ex) {
ExceptionUtils.rethrow(ex);
}
}

@Override
public Future<Void> promiseDeepSimulationReportPage() {
Promise<Void> promise = Promise.promise();
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/templates/enUS/SimulationReportPage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ async function websocketSimulationReportInner2(apiRequest) {
var $fragment = $(fragment);
$fragment.replaceWith($response.find(".plotPerformance"));
});
$('.plotGreenLengthThresholdVehicle').each(function(index, fragment) {
var $fragment = $(fragment);
$fragment.replaceWith($response.find(".plotGreenLengthThresholdVehicle"));
});
}, 'html');
addGlow($('.plotPerformance'));
Expand Down Expand Up @@ -73,5 +77,8 @@ async function websocketSimulationReportInner2(apiRequest) {
<div>
<img class="plotPerformance" class="plotPerformance " src="data:image/png;base64,{{ plotPerformance }}"/>
</div>
<div>
<img class="plotGreenLengthThresholdVehicle" class="plotGreenLengthThresholdVehicle " src="data:image/png;base64,{{ plotGreenLengthThresholdVehicle }}"/>
</div>
{{/partial}}
{{> SimulationReportGenPage}}

0 comments on commit df004a9

Please sign in to comment.