* Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, @version $Revision: 1401 $, by $Author: averbraeck $,
* initial version Oct 17, 2014
* @author Alexander Verbraeck
*/
public class N201IMB extends AbstractWrappableAnimation
{
/** */
private static final long serialVersionUID = 20161007L;
/** The model. */
private N201Model model;
/**
* Main program.
* @param args String[]; the command line arguments (not used)
* @throws SimRuntimeException should never happen
*/
public static void main(final String[] args) throws SimRuntimeException
{
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
try
{
N201IMB n201Model = new N201IMB();
// 1 hour simulation run for testing
n201Model.buildAnimator(Time.ZERO, Duration.ZERO, new Duration(10.0, DurationUnit.HOUR),
new ArrayList>(), null, true);
}
catch (SimRuntimeException | NamingException | OTSSimulationException | PropertyException exception)
{
exception.printStackTrace();
}
}
});
}
/** {@inheritDoc} */
@Override
public final String shortName()
{
return "Model N201";
}
/** {@inheritDoc} */
@Override
public final String description()
{
return "Model N201 - IMB";
}
/** {@inheritDoc} */
@Override
public final void stopTimersThreads()
{
super.stopTimersThreads();
}
/** {@inheritDoc} */
@Override
protected final OTSModelInterface makeModel(final GTUColorer colorer)
{
System.out.println("N201IMB.makeModel called");
this.model = new N201Model(getSavedUserModifiedProperties(), colorer, new OTSNetwork("N201 network"));
return this.model;
}
/**
* @return the saved user properties for a next run
*/
private List> getSavedUserModifiedProperties()
{
return this.savedUserModifiedProperties;
}
/** {@inheritDoc} */
@Override
protected void addAnimationToggles()
{
AnimationToggles.setTextAnimationTogglesStandard(this);
this.addToggleGISButtonText(" GIS Layers:", this.model.getGisMap(), "Turn GIS map layer on or off");
}
/** {@inheritDoc} */
@Override
protected final Double makeAnimationRectangle()
{
return new Rectangle2D.Double(103000, 478000, 5500, 5000);
}
/** {@inheritDoc} */
@Override
public final String toString()
{
return "N201 network - IMB []";
}
/**
* Model to test the XML parser.
*
* Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.
* All rights reserved. BSD-style license. See OpenTrafficSim
* License.
*
* $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, @version $Revision: 1401 $, by $Author: averbraeck $,
* initial version un 27, 2015
* @author Alexander Verbraeck
* @author Peter Knoppers
*/
class N201Model implements OTSModelInterface
{
/** */
private static final long serialVersionUID = 20141121L;
/** The simulator. */
private OTSDEVSSimulatorInterface simulator;
/** User settable properties. */
private List> modelProperties = null;
/** the network as created by the AbstractWrappableIMBAnimation. */
private final OTSNetwork network;
/** Connector to the IMB hub. */
OTSIMBConnector imbConnector;
/** the GIS map. */
private GisRenderable2D gisMap;
/**
* @param modelProperties ArrayList<AbstractProperty<?>>; the properties
* @param gtuColorer the default and initial GTUColorer, e.g. a DefaultSwitchableTUColorer.
* @param network Network; the network
*/
N201Model(final List> modelProperties, final GTUColorer gtuColorer, final OTSNetwork network)
{
this.modelProperties = modelProperties;
this.network = network;
}
/** {@inheritDoc} */
@Override
public final void constructModel(final SimulatorInterface