use of com.chrisali.javaflightsim.swing.plotting.PlotConfiguration.SubPlotOptions in project j6dof-flight-sim by chris-ali.
the class SimulationPlot method createPlots.
/**
* Populates the {@link plotLists} List with {@link XYPlot} objects created from the logsOut ArrayList
* argument. It first creates {@link XYSeries} objects with data from logsOut, adds those to
* {@link XYSeriesCollection}, adds those series collections to {@link XYPlot} objects, and finally
* puts the XYPlot objects into {@link plotList}. The types of {@link XYPlot} objects generated
* comes from settings in {@link SubPlotBundle}
*
* @param logsOut
* @param bundle
*/
private void createPlots(List<Map<SimOuts, Double>> logsOut, SubPlotBundle bundle) {
for (SubPlotOptions option : bundle.getSubPlots()) {
XYSeriesCollection collection = new XYSeriesCollection();
for (SimOuts simout : option.getyData()) {
XYSeries series = new XYSeries(simout.toString());
xySeriesData.put(simout, series);
collection.addSeries(series);
}
domainAxis = new NumberAxis(option.getxAxisName());
rangeAxes.put(option.getTitle(), new NumberAxis(option.getyAxisName()));
xyCollections.put(option.getTitle(), collection);
}
combinedDomPlot = new CombinedDomainXYPlot(domainAxis);
updateXYSeriesData(logsOut, bundle);
for (Map.Entry<String, XYSeriesCollection> entry : xyCollections.entrySet()) {
logger.debug("Creating a subplot called: " + entry.getKey() + "...");
XYPlot subPlot = new XYPlot(entry.getValue(), domainAxis, rangeAxes.get(entry.getKey()), new StandardXYItemRenderer());
plotList.add(subPlot);
}
}
use of com.chrisali.javaflightsim.swing.plotting.PlotConfiguration.SubPlotOptions in project j6dof-flight-sim by chris-ali.
the class ReadWriteJsonTest method WriteThenReadPlotConfigurationTest.
@Test
public void WriteThenReadPlotConfigurationTest() {
PlotConfiguration plots = FileUtilities.readPlotConfiguration();
String assertion = "Deserialized property should not be null";
assertNotNull(assertion, plots);
assertNotNull(assertion, plots.getSubPlotBundles());
assertTrue("There should be at least one bundle in configuration", plots.getSubPlotBundles().size() > 0);
for (Map.Entry<String, SubPlotBundle> entry : plots.getSubPlotBundles().entrySet()) {
SubPlotBundle bundle = entry.getValue();
assertNotNull(assertion, bundle);
assertNotNull(assertion, bundle.getSizeXPixels());
assertNotNull(assertion, bundle.getSizeYPixels());
assertNotNull(assertion, bundle.getTitle());
assertNotNull(assertion, bundle.getSubPlots());
assertTrue("There should be at least one subplot in this bundle", bundle.getSubPlots().size() > 0);
for (SubPlotOptions subplot : bundle.getSubPlots()) {
assertNotNull(assertion, subplot);
assertNotNull(assertion, subplot.getTitle());
assertNotNull(assertion, subplot.getxAxisName());
assertNotNull(assertion, subplot.getyAxisName());
assertNotNull(assertion, subplot.getxData());
assertNotNull(assertion, subplot.getyData());
assertTrue("There should be at least one y data in this bundle", subplot.getyData().size() > 0);
for (SimOuts simout : subplot.getyData()) {
assertNotNull(assertion, simout);
}
}
}
plots.save();
PlotConfiguration readPlots = FileUtilities.readPlotConfiguration();
assertion = "Deserialized property should not be null";
assertNotNull(assertion, readPlots);
assertNotNull(assertion, readPlots.getSubPlotBundles());
assertTrue("There should be at least one bundle in configuration", readPlots.getSubPlotBundles().size() > 0);
for (Map.Entry<String, SubPlotBundle> entry : readPlots.getSubPlotBundles().entrySet()) {
SubPlotBundle bundle = entry.getValue();
assertNotNull(assertion, bundle);
assertNotNull(assertion, bundle.getSizeXPixels());
assertNotNull(assertion, bundle.getSizeYPixels());
assertNotNull(assertion, bundle.getTitle());
assertNotNull(assertion, bundle.getSubPlots());
assertTrue("There should be at least one subplot in this bundle", bundle.getSubPlots().size() > 0);
for (SubPlotOptions subplot : bundle.getSubPlots()) {
assertNotNull(assertion, subplot);
assertNotNull(assertion, subplot.getTitle());
assertNotNull(assertion, subplot.getxAxisName());
assertNotNull(assertion, subplot.getyAxisName());
assertNotNull(assertion, subplot.getxData());
assertNotNull(assertion, subplot.getyData());
assertTrue("There should be at least one y data in this bundle", subplot.getyData().size() > 0);
for (SimOuts simout : subplot.getyData()) {
assertNotNull(assertion, simout);
}
}
}
}
Aggregations