* Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* @version $Revision$, $LastChangedDate$, by $Author$, initial version Nov 18, 2016
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
*/
public class TrafCODDemo extends AbstractWrappableAnimation
{
/** */
private static final long serialVersionUID = 20161118L;
/**
* 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
{
TrafCODDemo model = new TrafCODDemo();
// 1 hour simulation run for testing
model.buildAnimator(new Time(0.0, TimeUnit.SECOND), new Duration(0.0, TimeUnit.SECOND), new Duration(60.0,
TimeUnit.MINUTE), new ArrayList>(), null, true);
}
catch (SimRuntimeException | NamingException | OTSSimulationException | PropertyException exception)
{
exception.printStackTrace();
}
}
});
}
/** TrafCOD controller display. */
private JPanel controllerDisplayPanel = new JPanel(new BorderLayout());
/** The TrafCOD controller. */
private TrafCOD trafCOD;
/** {@inheritDoc} */
@Override
public final String shortName()
{
return "TrafCOD demonstration 1";
}
/** {@inheritDoc} */
@Override
public final String description()
{
return "TrafCOD demonstration";
}
/** {@inheritDoc} */
@Override
protected final void addTabs(final SimpleSimulatorInterface simulator) throws OTSSimulationException, PropertyException
{
JScrollPane scrollPane = new JScrollPane(TrafCODDemo.this.controllerDisplayPanel);
JPanel wrapper = new JPanel(new BorderLayout());
wrapper.add(scrollPane);
addTab(getTabCount() - 1, this.trafCOD.getId(), wrapper);
}
/** {@inheritDoc} */
@Override
protected final OTSModelInterface makeModel(final GTUColorer colorer) throws OTSSimulationException
{
return new TrafCODModel();
}
/** {@inheritDoc} */
@Override
protected final void addAnimationToggles()
{
AnimationToggles.setTextAnimationTogglesStandard(this);
}
/**
* The simulation model.
*/
class TrafCODModel extends EventProducer implements OTSModelInterface, EventListenerInterface
{
/** */
private static final long serialVersionUID = 20161020L;
/** the model. */
private OTSNetwork network;
@SuppressWarnings("synthetic-access")
@Override
public void constructModel(final SimulatorInterface