The following document contains the results of PMD's CPD 5.1.2.
File | Line |
---|---|
org\opentrafficsim\core\gtu2\RelativePosition.java | 19 |
org\opentrafficsim\core\gtu\RelativePosition.java | 19 |
public class RelativePosition implements Serializable, OTS_SCALAR { /** */ private static final long serialVersionUID = 20141231L; /** positive x is in the normal direction of movement. */ private final Length.Rel dx; /** positive y is left compared to the normal direction of movement (seen from the top). */ private final Length.Rel dy; /** positive z is up. */ private final Length.Rel dz; /** type of relative position (FRONT, BACK, etc.). */ private final TYPE type; /** Standard relative position type FRONT. */ public static final TYPE FRONT = new TYPE("FRONT"); /** Standard relative position type BACK. */ public static final TYPE REAR = new TYPE("REAR"); /** Standard relative position type CENTER. */ public static final TYPE CENTER = new TYPE("CENTER"); /** Standard relative position type REFERENCE. */ public static final TYPE REFERENCE = new TYPE("REFERENCE"); /** Standard relative position type DRIVER. */ public static final TYPE DRIVER = new TYPE("DRIVER"); /** the reference position (always 0, 0, 0). */ public static final RelativePosition REFERENCE_POSITION = new RelativePosition(new Length.Rel(0.0d, METER), new Length.Rel(0.0d, METER), new Length.Rel(0.0d, METER), RelativePosition.REFERENCE); /** * @param dx positive x is in the normal direction of movement. * @param dy positive y is left compared to the normal direction of movement (seen from the top). * @param dz positive z is up. * @param type type of relative position (FRONT, BACK, etc.). */ public RelativePosition(final Length.Rel dx, final Length.Rel dy, final Length.Rel dz, final TYPE type) { super(); this.dx = dx; this.dy = dy; this.dz = dz; this.type = type; } /** * @param p a relative position to make a deep copy of. */ public RelativePosition(final RelativePosition p) { super(); this.dx = p.getDx(); this.dy = p.getDy(); this.dz = p.getDz(); this.type = p.getType(); } /** * @return dx. */ public final Length.Rel getDx() { return this.dx; } /** * @return dy. */ public final Length.Rel getDy() { return this.dy; } /** * @return dz. */ public final Length.Rel getDz() { return this.dz; } /** * @return type. */ public final TYPE getType() { return this.type; } /** {@inheritDoc} */ @Override public final String toString() { return "(" + this.dx + ", " + this.dy + ", " + this.dz + "): " + this.type; } /** {@inheritDoc} */ @Override @SuppressWarnings("checkstyle:designforextension") public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.dx == null) ? 0 : this.dx.hashCode()); result = prime * result + ((this.dy == null) ? 0 : this.dy.hashCode()); result = prime * result + ((this.dz == null) ? 0 : this.dz.hashCode()); result = prime * result + ((this.type == null) ? 0 : this.type.hashCode()); return result; } /** {@inheritDoc} */ @Override @SuppressWarnings({"checkstyle:designforextension", "checkstyle:needbraces"}) public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; RelativePosition other = (RelativePosition) obj; if (this.dx == null) { if (other.dx != null) return false; } else if (!this.dx.equals(other.dx)) return false; if (this.dy == null) { if (other.dy != null) return false; } else if (!this.dy.equals(other.dy)) return false; if (this.dz == null) { if (other.dz != null) return false; } else if (!this.dz.equals(other.dz)) return false; if (this.type == null) { if (other.type != null) return false; } else if (!this.type.equals(other.type)) return false; return true; } /** * The type of relative position, e.g., Front, Back, etc. * <p> * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. <br> * All rights reserved. <br> * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. * <p> * $LastChangedDate: 2015-07-28 17:11:47 +0200 (Tue, 28 Jul 2015) $, @version $Revision: 1165 $, by $Author: averbraeck $, * initial version ec 31, 2014 <br> * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> */ public static class TYPE implements Serializable { /** */ private static final long serialVersionUID = 20141231L; /** the type name. */ private final String name; /** * @param name the type name. */ public TYPE(final String name) { super(); this.name = name; } /** * @return name. */ public final String getName() { return this.name; } /** {@inheritDoc} */ @Override public final String toString() { return this.name; } /** {@inheritDoc} */ @Override @SuppressWarnings("checkstyle:designforextension") public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.name == null) ? 0 : this.name.hashCode()); return result; } /** {@inheritDoc} */ @Override @SuppressWarnings({"checkstyle:designforextension", "checkstyle:needbraces"}) public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; TYPE other = (TYPE) obj; if (this.name == null) { if (other.name != null) return false; } else if (!this.name.equals(other.name)) return false; return true; } } } |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistFloatScalar.java | 68 |
org\opentrafficsim\core\units\distributions\DiscreteDistFloatScalar.java | 68 |
public Abs(final float constant, final U unit) { super(constant, unit); } /** * @return a drawn number from the distribution in the given unit. */ @SuppressWarnings({"unchecked", "rawtypes"}) public final T draw() { switch (getUnit().getClass().getSimpleName()) { case "AccelerationUnit": return (T) new Acceleration.Abs((float) getDistribution().draw(), (AccelerationUnit) getUnit()); case "AnglePlaneUnit": return (T) new AnglePlane.Abs((float) getDistribution().draw(), (AnglePlaneUnit) getUnit()); case "AngleSlopeUnit": return (T) new AngleSlope.Abs((float) getDistribution().draw(), (AngleSlopeUnit) getUnit()); case "AngleSolidUnit": return (T) new AngleSolid.Abs((float) getDistribution().draw(), (AngleSolidUnit) getUnit()); case "AreaUnit": return (T) new Area.Abs((float) getDistribution().draw(), (AreaUnit) getUnit()); case "DensityUnit": return (T) new Density.Abs((float) getDistribution().draw(), (DensityUnit) getUnit()); case "DimensionlessUnit": return (T) new Dimensionless.Abs((float) getDistribution().draw(), (DimensionlessUnit) getUnit()); case "ElectricalChargeUnit": return (T) new ElectricalCharge.Abs((float) getDistribution().draw(), (ElectricalChargeUnit) getUnit()); case "ElectricalCurrentUnit": return (T) new ElectricalCurrent.Abs((float) getDistribution().draw(), (ElectricalCurrentUnit) getUnit()); case "ElectricalPotentialUnit": return (T) new ElectricalPotential.Abs((float) getDistribution().draw(), (ElectricalPotentialUnit) getUnit()); case "ElectricalResistanceUnit": return (T) new ElectricalResistance.Abs((float) getDistribution().draw(), (ElectricalResistanceUnit) getUnit()); case "EnergyUnit": return (T) new Energy.Abs((float) getDistribution().draw(), (EnergyUnit) getUnit()); case "FlowMassUnit": return (T) new FlowMass.Abs((float) getDistribution().draw(), (FlowMassUnit) getUnit()); case "FlowVolumeUnit": return (T) new FlowVolume.Abs((float) getDistribution().draw(), (FlowVolumeUnit) getUnit()); case "ForceUnit": return (T) new Force.Abs((float) getDistribution().draw(), (ForceUnit) getUnit()); case "FrequencyUnit": return (T) new Frequency.Abs((float) getDistribution().draw(), (FrequencyUnit) getUnit()); case "LengthUnit": return (T) new Length.Abs((float) getDistribution().draw(), (LengthUnit) getUnit()); case "LinearDensityUnit": return (T) new LinearDensity.Abs((float) getDistribution().draw(), (LinearDensityUnit) getUnit()); case "MassUnit": return (T) new Mass.Abs((float) getDistribution().draw(), (MassUnit) getUnit()); case "PowerUnit": return (T) new Power.Abs((float) getDistribution().draw(), (PowerUnit) getUnit()); case "PressureUnit": return (T) new Pressure.Abs((float) getDistribution().draw(), (PressureUnit) getUnit()); case "SpeedUnit": return (T) new Speed.Abs((float) getDistribution().draw(), (SpeedUnit) getUnit()); case "TemperatureUnit": return (T) new Temperature.Abs((float) getDistribution().draw(), (TemperatureUnit) getUnit()); case "TimeUnit": return (T) new Time.Abs((float) getDistribution().draw(), (TimeUnit) getUnit()); case "TorqueUnit": return (T) new Torque.Abs((float) getDistribution().draw(), (TorqueUnit) getUnit()); case "VolumeUnit": return (T) new Volume.Abs((float) getDistribution().draw(), (VolumeUnit) getUnit()); default: return (T) new FloatScalar.Abs((float) getDistribution().draw(), getUnit()); |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistFloatScalar.java | 188 |
org\opentrafficsim\core\units\distributions\DiscreteDistFloatScalar.java | 188 |
public Rel(final float constant, final U unit) { super(constant, unit); } /** * @return a drawn number from the distribution in the given unit. */ @SuppressWarnings({"unchecked", "rawtypes"}) public final T draw() { switch (getUnit().getClass().getSimpleName()) { case "AccelerationUnit": return (T) new Acceleration.Rel((float) getDistribution().draw(), (AccelerationUnit) getUnit()); case "AnglePlaneUnit": return (T) new AnglePlane.Rel((float) getDistribution().draw(), (AnglePlaneUnit) getUnit()); case "AngleSlopeUnit": return (T) new AngleSlope.Rel((float) getDistribution().draw(), (AngleSlopeUnit) getUnit()); case "AngleSolidUnit": return (T) new AngleSolid.Rel((float) getDistribution().draw(), (AngleSolidUnit) getUnit()); case "AreaUnit": return (T) new Area.Rel((float) getDistribution().draw(), (AreaUnit) getUnit()); case "DensityUnit": return (T) new Density.Rel((float) getDistribution().draw(), (DensityUnit) getUnit()); case "DimensionlessUnit": return (T) new Dimensionless.Rel((float) getDistribution().draw(), (DimensionlessUnit) getUnit()); case "ElectricalChargeUnit": return (T) new ElectricalCharge.Rel((float) getDistribution().draw(), (ElectricalChargeUnit) getUnit()); case "ElectricalCurrentUnit": return (T) new ElectricalCurrent.Rel((float) getDistribution().draw(), (ElectricalCurrentUnit) getUnit()); case "ElectricalPotentialUnit": return (T) new ElectricalPotential.Rel((float) getDistribution().draw(), (ElectricalPotentialUnit) getUnit()); case "ElectricalResistanceUnit": return (T) new ElectricalResistance.Rel((float) getDistribution().draw(), (ElectricalResistanceUnit) getUnit()); case "EnergyUnit": return (T) new Energy.Rel((float) getDistribution().draw(), (EnergyUnit) getUnit()); case "FlowMassUnit": return (T) new FlowMass.Rel((float) getDistribution().draw(), (FlowMassUnit) getUnit()); case "FlowVolumeUnit": return (T) new FlowVolume.Rel((float) getDistribution().draw(), (FlowVolumeUnit) getUnit()); case "ForceUnit": return (T) new Force.Rel((float) getDistribution().draw(), (ForceUnit) getUnit()); case "FrequencyUnit": return (T) new Frequency.Rel((float) getDistribution().draw(), (FrequencyUnit) getUnit()); case "LengthUnit": return (T) new Length.Rel((float) getDistribution().draw(), (LengthUnit) getUnit()); case "LinearDensityUnit": return (T) new LinearDensity.Rel((float) getDistribution().draw(), (LinearDensityUnit) getUnit()); case "MassUnit": return (T) new Mass.Rel((float) getDistribution().draw(), (MassUnit) getUnit()); case "PowerUnit": return (T) new Power.Rel((float) getDistribution().draw(), (PowerUnit) getUnit()); case "PressureUnit": return (T) new Pressure.Rel((float) getDistribution().draw(), (PressureUnit) getUnit()); case "SpeedUnit": return (T) new Speed.Rel((float) getDistribution().draw(), (SpeedUnit) getUnit()); case "TemperatureUnit": return (T) new Temperature.Rel((float) getDistribution().draw(), (TemperatureUnit) getUnit()); case "TimeUnit": return (T) new Time.Rel((float) getDistribution().draw(), (TimeUnit) getUnit()); case "TorqueUnit": return (T) new Torque.Rel((float) getDistribution().draw(), (TorqueUnit) getUnit()); case "VolumeUnit": return (T) new Volume.Rel((float) getDistribution().draw(), (VolumeUnit) getUnit()); default: return (T) new FloatScalar.Rel((float) getDistribution().draw(), getUnit()); |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistDoubleScalar.java | 68 |
org\opentrafficsim\core\units\distributions\DiscreteDistDoubleScalar.java | 94 |
public Abs(final double constant, final U unit) { super(constant, unit); } /** * @return a drawn number from the distribution in the given unit. */ @SuppressWarnings({"unchecked", "rawtypes"}) public final T draw() { switch (getUnit().getClass().getSimpleName()) { case "AccelerationUnit": return (T) new Acceleration.Abs(getDistribution().draw(), (AccelerationUnit) getUnit()); case "AnglePlaneUnit": return (T) new AnglePlane.Abs(getDistribution().draw(), (AnglePlaneUnit) getUnit()); case "AngleSlopeUnit": return (T) new AngleSlope.Abs(getDistribution().draw(), (AngleSlopeUnit) getUnit()); case "AngleSolidUnit": return (T) new AngleSolid.Abs(getDistribution().draw(), (AngleSolidUnit) getUnit()); case "AreaUnit": return (T) new Area.Abs(getDistribution().draw(), (AreaUnit) getUnit()); case "DensityUnit": return (T) new Density.Abs(getDistribution().draw(), (DensityUnit) getUnit()); case "DimensionlessUnit": return (T) new Dimensionless.Abs(getDistribution().draw(), (DimensionlessUnit) getUnit()); case "ElectricalChargeUnit": return (T) new ElectricalCharge.Abs(getDistribution().draw(), (ElectricalChargeUnit) getUnit()); case "ElectricalCurrentUnit": return (T) new ElectricalCurrent.Abs(getDistribution().draw(), (ElectricalCurrentUnit) getUnit()); case "ElectricalPotentialUnit": return (T) new ElectricalPotential.Abs(getDistribution().draw(), (ElectricalPotentialUnit) getUnit()); case "ElectricalResistanceUnit": return (T) new ElectricalResistance.Abs(getDistribution().draw(), (ElectricalResistanceUnit) getUnit()); case "EnergyUnit": return (T) new Energy.Abs(getDistribution().draw(), (EnergyUnit) getUnit()); case "FlowMassUnit": return (T) new FlowMass.Abs(getDistribution().draw(), (FlowMassUnit) getUnit()); case "FlowVolumeUnit": return (T) new FlowVolume.Abs(getDistribution().draw(), (FlowVolumeUnit) getUnit()); case "ForceUnit": return (T) new Force.Abs(getDistribution().draw(), (ForceUnit) getUnit()); case "FrequencyUnit": return (T) new Frequency.Abs(getDistribution().draw(), (FrequencyUnit) getUnit()); case "LengthUnit": return (T) new Length.Abs(getDistribution().draw(), (LengthUnit) getUnit()); case "LinearDensityUnit": return (T) new LinearDensity.Abs(getDistribution().draw(), (LinearDensityUnit) getUnit()); case "MassUnit": return (T) new Mass.Abs(getDistribution().draw(), (MassUnit) getUnit()); case "PowerUnit": return (T) new Power.Abs(getDistribution().draw(), (PowerUnit) getUnit()); case "PressureUnit": return (T) new Pressure.Abs(getDistribution().draw(), (PressureUnit) getUnit()); case "SpeedUnit": return (T) new Speed.Abs(getDistribution().draw(), (SpeedUnit) getUnit()); case "TemperatureUnit": return (T) new Temperature.Abs(getDistribution().draw(), (TemperatureUnit) getUnit()); case "TimeUnit": return (T) new Time.Abs(getDistribution().draw(), (TimeUnit) getUnit()); case "TorqueUnit": return (T) new Torque.Abs(getDistribution().draw(), (TorqueUnit) getUnit()); case "VolumeUnit": return (T) new Volume.Abs(getDistribution().draw(), (VolumeUnit) getUnit()); default: return (T) new DoubleScalar.Abs(getDistribution().draw(), getUnit()); } } } /** * Relative value. * @param <T> The absolute DoubleScalar type * @param <U> The unit type used */ public static class Rel<T extends DoubleScalar.Rel<U>, U extends Unit<U>> extends AbstractContinuousDistScalar implements |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistDoubleScalar.java | 186 |
org\opentrafficsim\core\units\distributions\DiscreteDistDoubleScalar.java | 212 |
public Rel(final double constant, final U unit) { super(constant, unit); } /** * @return a drawn number from the distribution in the given unit. */ @SuppressWarnings({"unchecked", "rawtypes"}) public final T draw() { switch (getUnit().getClass().getSimpleName()) { case "AccelerationUnit": return (T) new Acceleration.Rel(getDistribution().draw(), (AccelerationUnit) getUnit()); case "AnglePlaneUnit": return (T) new AnglePlane.Rel(getDistribution().draw(), (AnglePlaneUnit) getUnit()); case "AngleSlopeUnit": return (T) new AngleSlope.Rel(getDistribution().draw(), (AngleSlopeUnit) getUnit()); case "AngleSolidUnit": return (T) new AngleSolid.Rel(getDistribution().draw(), (AngleSolidUnit) getUnit()); case "AreaUnit": return (T) new Area.Rel(getDistribution().draw(), (AreaUnit) getUnit()); case "DensityUnit": return (T) new Density.Rel(getDistribution().draw(), (DensityUnit) getUnit()); case "DimensionlessUnit": return (T) new Dimensionless.Rel(getDistribution().draw(), (DimensionlessUnit) getUnit()); case "ElectricalChargeUnit": return (T) new ElectricalCharge.Rel(getDistribution().draw(), (ElectricalChargeUnit) getUnit()); case "ElectricalCurrentUnit": return (T) new ElectricalCurrent.Rel(getDistribution().draw(), (ElectricalCurrentUnit) getUnit()); case "ElectricalPotentialUnit": return (T) new ElectricalPotential.Rel(getDistribution().draw(), (ElectricalPotentialUnit) getUnit()); case "ElectricalResistanceUnit": return (T) new ElectricalResistance.Rel(getDistribution().draw(), (ElectricalResistanceUnit) getUnit()); case "EnergyUnit": return (T) new Energy.Rel(getDistribution().draw(), (EnergyUnit) getUnit()); case "FlowMassUnit": return (T) new FlowMass.Rel(getDistribution().draw(), (FlowMassUnit) getUnit()); case "FlowVolumeUnit": return (T) new FlowVolume.Rel(getDistribution().draw(), (FlowVolumeUnit) getUnit()); case "ForceUnit": return (T) new Force.Rel(getDistribution().draw(), (ForceUnit) getUnit()); case "FrequencyUnit": return (T) new Frequency.Rel(getDistribution().draw(), (FrequencyUnit) getUnit()); case "LengthUnit": return (T) new Length.Rel(getDistribution().draw(), (LengthUnit) getUnit()); case "LinearDensityUnit": return (T) new LinearDensity.Rel(getDistribution().draw(), (LinearDensityUnit) getUnit()); case "MassUnit": return (T) new Mass.Rel(getDistribution().draw(), (MassUnit) getUnit()); case "PowerUnit": return (T) new Power.Rel(getDistribution().draw(), (PowerUnit) getUnit()); case "PressureUnit": return (T) new Pressure.Rel(getDistribution().draw(), (PressureUnit) getUnit()); case "SpeedUnit": return (T) new Speed.Rel(getDistribution().draw(), (SpeedUnit) getUnit()); case "TemperatureUnit": return (T) new Temperature.Rel(getDistribution().draw(), (TemperatureUnit) getUnit()); case "TimeUnit": return (T) new Time.Rel(getDistribution().draw(), (TimeUnit) getUnit()); case "TorqueUnit": return (T) new Torque.Rel(getDistribution().draw(), (TorqueUnit) getUnit()); case "VolumeUnit": return (T) new Volume.Rel(getDistribution().draw(), (VolumeUnit) getUnit()); default: return (T) new DoubleScalar.Rel(getDistribution().draw(), getUnit()); } } } } |
File | Line |
---|---|
org\opentrafficsim\core\dsol\OTSDEVSAnimator.java | 32 |
org\opentrafficsim\core\dsol\OTSDEVSRealTimeClock.java | 33 |
public OTSDEVSAnimator() { super(); } /** {@inheritDoc} */ @Override public final void initialize( final Replication<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> initReplication, final ReplicationMode replicationMode) throws SimRuntimeException { try { super.initialize(initReplication, replicationMode); } catch (RemoteException exception) { throw new SimRuntimeException(exception); } } /** {@inheritDoc} */ @Override public final void scheduleEventRel(final Time.Rel relativeDelay, final short priority, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventRel(relativeDelay, priority, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventRel(final Time.Rel relativeDelay, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventRel(relativeDelay, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventAbs(final Time.Abs absoluteTime, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventAbs(absoluteTime, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventAbs(final Time.Abs absoluteTime, final short priority, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventAbs(absoluteTime, priority, source, target, method, args); } /** {@inheritDoc} */ @Override public final void runUpTo(final Time.Abs when) throws SimRuntimeException { super.runUpTo(when); } |
File | Line |
---|---|
org\opentrafficsim\core\dsol\OTSDEVSAnimator.java | 38 |
org\opentrafficsim\core\dsol\OTSDEVSSimulator.java | 31 |
@Override public final void initialize( final Replication<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> initReplication, final ReplicationMode replicationMode) throws SimRuntimeException { try { super.initialize(initReplication, replicationMode); } catch (RemoteException exception) { throw new SimRuntimeException(exception); } } /** {@inheritDoc} */ @Override public final void scheduleEventRel(final Time.Rel relativeDelay, final short priority, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventRel(relativeDelay, priority, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventRel(final Time.Rel relativeDelay, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventRel(relativeDelay, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventAbs(final Time.Abs absoluteTime, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventAbs(absoluteTime, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventAbs(final Time.Abs absoluteTime, final short priority, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventAbs(absoluteTime, priority, source, target, method, args); } /** {@inheritDoc} */ @Override public final void runUpTo(final Time.Abs when) throws SimRuntimeException { super.runUpTo(when); } } |
File | Line |
---|---|
org\opentrafficsim\core\dsol\OTSDEVSRealTimeClock.java | 39 |
org\opentrafficsim\core\dsol\OTSDEVSSimulator.java | 31 |
@Override public final void initialize( final Replication<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> initReplication, final ReplicationMode replicationMode) throws SimRuntimeException { try { super.initialize(initReplication, replicationMode); } catch (RemoteException exception) { throw new SimRuntimeException(exception); } } /** {@inheritDoc} */ @Override public final void scheduleEventRel(final Time.Rel relativeDelay, final short priority, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventRel(relativeDelay, priority, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventRel(final Time.Rel relativeDelay, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventRel(relativeDelay, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventAbs(final Time.Abs absoluteTime, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventAbs(absoluteTime, source, target, method, args); } /** {@inheritDoc} */ @Override public final void scheduleEventAbs(final Time.Abs absoluteTime, final short priority, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { super.scheduleEventAbs(absoluteTime, priority, source, target, method, args); } /** {@inheritDoc} */ @Override public final void runUpTo(final Time.Abs when) throws SimRuntimeException { super.runUpTo(when); } |
File | Line |
---|---|
org\opentrafficsim\simulationengine\SimpleAnimator.java | 142 |
org\opentrafficsim\simulationengine\SimpleAnimator.java | 260 |
this.simulatorTime.add(r1); } } } synchronized (super.semaphore) { this.simulatorTime = event.getAbsoluteExecutionTime(); this.fireTimedEvent(SimulatorInterface.TIME_CHANGED_EVENT, this.simulatorTime, this.simulatorTime); // carry out all events scheduled on this simulation time, as long as we are still running. while (this.isRunning() && !this.eventList.isEmpty() && event.getAbsoluteExecutionTime().eq(this.simulatorTime)) { event = this.eventList.removeFirst(); try { event.execute(); } catch (Exception exception) { exception.printStackTrace(); System.err.println(event.toString()); if (this.isPauseOnError()) { this.stop(); } } if (!this.eventList.isEmpty()) { // peek at next event for while loop. event = this.eventList.first(); } } } } this.fireTimedEvent(SimulatorInterface.TIME_CHANGED_EVENT, this.simulatorTime, this.simulatorTime); updateAnimation(); animationThread.stopAnimation(); } |
File | Line |
---|---|
org\opentrafficsim\simulationengine\SimpleAnimator.java | 44 |
org\opentrafficsim\simulationengine\SimpleSimulator.java | 42 |
public SimpleAnimator(final Time.Abs startTime, final Time.Rel warmupPeriod, final Time.Rel runLength, final OTSModelInterface model) throws SimRuntimeException, NamingException { setPauseOnError(true); initialize(new OTSReplication("rep" + ++this.lastReplication, new OTSSimTimeDouble(startTime), warmupPeriod, runLength, model), ReplicationMode.TERMINATING); } /** * {@inheritDoc} */ public final SimEvent<OTSSimTimeDouble> scheduleEvent(final Time.Abs executionTime, final short priority, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { SimEvent<OTSSimTimeDouble> result = new SimEvent<OTSSimTimeDouble>(new OTSSimTimeDouble(new Time.Abs(executionTime.getSI(), SECOND)), priority, source, target, method, args); scheduleEvent(result); return result; } |
File | Line |
---|---|
org\opentrafficsim\core\gtu\animation\AccelerationGTUColorer.java | 87 |
org\opentrafficsim\core\gtu\animation\VelocityGTUColorer.java | 54 |
if (ratio <= 0) { return this.legend.get(0).getColor(); } if (ratio >= this.legend.size() - 1) { return this.legend.get(this.legend.size() - 1).getColor(); } // Interpolate int floor = (int) Math.floor(ratio); return ColorInterpolator.interpolateColor(this.legend.get(floor).getColor(), this.legend.get(floor + 1).getColor(), ratio - floor); } /** {@inheritDoc} */ @Override public final List<LegendEntry> getLegend() { return Collections.unmodifiableList(this.legend); } /** {@inheritDoc} */ @Override public final String toString() { return "Acceleration"; |
File | Line |
---|---|
org\opentrafficsim\simulationengine\SimpleAnimator.java | 89 |
org\opentrafficsim\simulationengine\SimpleAnimator.java | 205 |
r1 = this.relativeMillis(factor); } // peek at the first event and determine the time difference relative to RT speed. SimEventInterface<OTSSimTimeDouble> event = this.eventList.first(); double simTimeDiffMillis = (event.getAbsoluteExecutionTime().minus(simTime0)).doubleValue() / (msec1 * factor); /* * simTimeDiff gives the number of milliseconds between the last event and this event. if speed == 1, this is the * number of milliseconds we have to wait. if speed == 10, we have to wait 1/10 of that. If the speed == 0.1, we * have to wait 10 times that amount. We might also be behind. */ if (simTimeDiffMillis < (System.currentTimeMillis() - clockTime0)) { // we are behind. if (!isCatchup()) { // if no catch-up: re-baseline. clockTime0 = System.currentTimeMillis(); simTime0 = this.simulatorTime; } else { // if catch-up: indicate we were behind. this.fireTimedEvent(BACKLOG_EVENT, this.simulatorTime, null); } } else { while (simTimeDiffMillis > System.currentTimeMillis() - clockTime0) { try { Thread.sleep(1); |