* Copyright (c) 2013-2018 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 Dec 06, 2016
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
*/
public class TrafCODDemo2 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
{
TrafCODDemo2 model = new TrafCODDemo2();
// 1 hour simulation run for testing
model.buildAnimator(Time.ZERO, Duration.ZERO, new Duration(60.0, DurationUnit.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 2";
}
/** {@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(TrafCODDemo2.this.controllerDisplayPanel);
JPanel wrapper = new JPanel(new BorderLayout());
wrapper.add(scrollPane);
addTab(getTabCount() - 1, this.trafCOD.getId(), wrapper);
}
/** {@inheritDoc} */
@Override
protected final OTSModelInterface makeModel() throws OTSSimulationException
{
return new TrafCODModel();
}
/** {@inheritDoc} */
@Override
protected final void addAnimationToggles()
{
AnimationToggles.setTextAnimationTogglesStandard(this);
}
/** {@inheritDoc} */
@Override
protected final Double makeAnimationRectangle()
{
return new Rectangle2D.Double(-200, -200, 400, 400);
}
/**
* The simulation model.
*/
class TrafCODModel extends EventProducer implements OTSModelInterface, EventListenerInterface
{
/** */
private static final long serialVersionUID = 20161020L;
/** The network. */
private OTSNetwork network;
@SuppressWarnings("synthetic-access")
@Override
public void constructModel(final SimulatorInterface