Search in sources :

Example 1 with PlotConfiguration

use of com.chrisali.javaflightsim.swing.plotting.PlotConfiguration in project j6dof-flight-sim by chris-ali.

the class FileUtilities method readPlotConfiguration.

/**
 * Creates a {@link PlotConfiguration} object by deserializing a JSON file in the SimConfig directory
 * called PlotConfiguration.json
 *
 * @return deserialized {@link PlotConfiguration}
 */
public static PlotConfiguration readPlotConfiguration() {
    PlotConfiguration configuration = new PlotConfiguration();
    configuration = deserializeJson(PlotConfiguration.class.getSimpleName(), SimDirectories.SIM_CONFIG.toString(), PlotConfiguration.class);
    return configuration;
}
Also used : PlotConfiguration(com.chrisali.javaflightsim.swing.plotting.PlotConfiguration)

Example 2 with PlotConfiguration

use of com.chrisali.javaflightsim.swing.plotting.PlotConfiguration 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);
            }
        }
    }
}
Also used : SubPlotBundle(com.chrisali.javaflightsim.swing.plotting.PlotConfiguration.SubPlotBundle) PlotConfiguration(com.chrisali.javaflightsim.swing.plotting.PlotConfiguration) SimOuts(com.chrisali.javaflightsim.simulation.integration.SimOuts) Map(java.util.Map) SubPlotOptions(com.chrisali.javaflightsim.swing.plotting.PlotConfiguration.SubPlotOptions) Test(org.junit.Test)

Aggregations

PlotConfiguration (com.chrisali.javaflightsim.swing.plotting.PlotConfiguration)2 SimOuts (com.chrisali.javaflightsim.simulation.integration.SimOuts)1 SubPlotBundle (com.chrisali.javaflightsim.swing.plotting.PlotConfiguration.SubPlotBundle)1 SubPlotOptions (com.chrisali.javaflightsim.swing.plotting.PlotConfiguration.SubPlotOptions)1 Map (java.util.Map)1 Test (org.junit.Test)1