package org.opentrafficsim.demo.geometry; import java.awt.Dimension; import java.rmi.RemoteException; import javax.naming.NamingException; import org.djunits.unit.util.UNITS; import org.djunits.value.vdouble.scalar.Duration; import org.djunits.value.vdouble.scalar.Time; import org.djutils.draw.bounds.Bounds2d; import org.djutils.event.TimedEvent; import org.opentrafficsim.core.animation.gtu.colorer.DefaultSwitchableGTUColorer; import org.opentrafficsim.core.dsol.OTSAnimator; import org.opentrafficsim.core.dsol.OTSModelInterface; import org.opentrafficsim.core.dsol.OTSReplication; import org.opentrafficsim.draw.core.OTSDrawingException; import org.opentrafficsim.draw.factory.DefaultAnimationFactory; import org.opentrafficsim.swing.gui.AnimationToggles; import org.opentrafficsim.swing.gui.OTSAnimationPanel; import org.opentrafficsim.swing.gui.OTSSwingApplication; import nl.tudelft.simulation.dsol.SimRuntimeException; import nl.tudelft.simulation.dsol.experiment.ReplicationInterface; import nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit; import nl.tudelft.simulation.dsol.swing.gui.DSOLApplication; import nl.tudelft.simulation.dsol.swing.gui.DSOLPanel; import nl.tudelft.simulation.dsol.swing.gui.control.RealTimeControlPanel; import nl.tudelft.simulation.language.DSOLException; /** *

* Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License. *

* $LastChangedDate: 2020-09-03 11:54:19 +0200 (Thu, 03 Sep 2020) $, @version $Revision: 6688 $, by $Author: averbraeck $, * initial version Oct 16, 2014
* @author Alexander Verbraeck */ public class TestGeometry extends DSOLApplication implements UNITS { /** */ private static final long serialVersionUID = 1L; /** * @param title String; t * @param panel DSOLPanel<Time,Duration,SimTimeDoubleUnit>; p */ public TestGeometry(final String title, final DSOLPanel panel) { super(panel, title); } /** * @param args String[]; args * @throws RemoteException if error * @throws SimRuntimeException if error * @throws NamingException if error * @throws OTSDrawingException if error * @throws DSOLException when the simulator does not implement AnimatorInterface */ public static void main(final String[] args) throws SimRuntimeException, NamingException, RemoteException, OTSDrawingException, DSOLException { OTSAnimator simulator = new OTSAnimator("TestGeometry"); OTSModelInterface model = new TestModel(simulator); OTSReplication replication = new OTSReplication("rep1", Time.ZERO, Duration.ZERO, new Duration(1800.0, SECOND)); simulator.initialize(model, replication); DSOLPanel panel = new DSOLPanel(new RealTimeControlPanel(model, simulator)); Bounds2d extent = new Bounds2d(-50, 250, -50, 50); Dimension size = new Dimension(1024, 768); OTSAnimationPanel animationPanel = new OTSAnimationPanel(extent, size, simulator, model, new DefaultSwitchableGTUColorer(), model.getNetwork()); panel.getTabbedPane().addTab(0, "animation", animationPanel); DefaultAnimationFactory.animateNetwork(model.getNetwork(), model.getSimulator(), OTSSwingApplication.DEFAULT_COLORER); AnimationToggles.setTextAnimationTogglesStandard(animationPanel); // tell the animation panel to update its statistics animationPanel.notify( new TimedEvent(ReplicationInterface.START_REPLICATION_EVENT, simulator, null, simulator.getSimulatorTime())); new TestGeometry("TestGeometry", panel); animationPanel.enableSimulationControlButtons(); } }