The following document contains the results of PMD's CPD 5.3.5.
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistDoubleScalar.java | 166 |
org\opentrafficsim\core\units\distributions\DiscreteDistDoubleScalar.java | 166 |
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(getDistribution().draw(), (AccelerationUnit) getUnit()); case "AngleUnit": return (T) new Angle(getDistribution().draw(), (AngleUnit) getUnit()); case "AngleSolidUnit": return (T) new AngleSolid(getDistribution().draw(), (AngleSolidUnit) getUnit()); case "AreaUnit": return (T) new Area(getDistribution().draw(), (AreaUnit) getUnit()); case "DensityUnit": return (T) new Density(getDistribution().draw(), (DensityUnit) getUnit()); case "DimensionlessUnit": return (T) new Dimensionless(getDistribution().draw(), (DimensionlessUnit) getUnit()); case "ElectricalChargeUnit": return (T) new ElectricalCharge(getDistribution().draw(), (ElectricalChargeUnit) getUnit()); case "ElectricalCurrentUnit": return (T) new ElectricalCurrent(getDistribution().draw(), (ElectricalCurrentUnit) getUnit()); case "ElectricalPotentialUnit": return (T) new ElectricalPotential(getDistribution().draw(), (ElectricalPotentialUnit) getUnit()); case "ElectricalResistanceUnit": return (T) new ElectricalResistance(getDistribution().draw(), (ElectricalResistanceUnit) getUnit()); case "EnergyUnit": return (T) new Energy(getDistribution().draw(), (EnergyUnit) getUnit()); case "FlowMassUnit": return (T) new FlowMass(getDistribution().draw(), (FlowMassUnit) getUnit()); case "FlowVolumeUnit": return (T) new FlowVolume(getDistribution().draw(), (FlowVolumeUnit) getUnit()); case "ForceUnit": return (T) new Force(getDistribution().draw(), (ForceUnit) getUnit()); case "FrequencyUnit": return (T) new Frequency(getDistribution().draw(), (FrequencyUnit) getUnit()); case "LengthUnit": return (T) new Length(getDistribution().draw(), (LengthUnit) getUnit()); case "LinearDensityUnit": return (T) new LinearDensity(getDistribution().draw(), (LinearDensityUnit) getUnit()); case "MassUnit": return (T) new Mass(getDistribution().draw(), (MassUnit) getUnit()); case "PowerUnit": return (T) new Power(getDistribution().draw(), (PowerUnit) getUnit()); case "PressureUnit": return (T) new Pressure(getDistribution().draw(), (PressureUnit) getUnit()); case "SpeedUnit": return (T) new Speed(getDistribution().draw(), (SpeedUnit) getUnit()); case "TemperatureUnit": return (T) new Temperature(getDistribution().draw(), (TemperatureUnit) getUnit()); case "TimeUnit": return (T) new Duration(getDistribution().draw(), (TimeUnit) getUnit()); case "TorqueUnit": return (T) new Torque(getDistribution().draw(), (TorqueUnit) getUnit()); case "VolumeUnit": return (T) new Volume(getDistribution().draw(), (VolumeUnit) getUnit()); default: return (T) new DoubleScalar.Rel(getDistribution().draw(), getUnit()); } } /** {@inheritDoc} */ @Override public final String toString() { return "ContinuousDistDoubleScalar.Rel [T=" + getUnit().getClass().getSimpleName() + "]"; |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistFloatScalar.java | 195 |
org\opentrafficsim\core\units\distributions\DiscreteDistFloatScalar.java | 194 |
return (T) new FloatDimensionless((float) getDistribution().draw(), (DimensionlessUnit) getUnit()); case "ElectricalChargeUnit": return (T) new FloatElectricalCharge((float) getDistribution().draw(), (ElectricalChargeUnit) getUnit()); case "ElectricalCurrentUnit": return (T) new FloatElectricalCurrent((float) getDistribution().draw(), (ElectricalCurrentUnit) getUnit()); case "ElectricalPotentialUnit": return (T) new FloatElectricalPotential((float) getDistribution().draw(), (ElectricalPotentialUnit) getUnit()); case "ElectricalResistanceUnit": return (T) new FloatElectricalResistance((float) getDistribution().draw(), (ElectricalResistanceUnit) getUnit()); case "EnergyUnit": return (T) new FloatEnergy((float) getDistribution().draw(), (EnergyUnit) getUnit()); case "FlowMassUnit": return (T) new FloatFlowMass((float) getDistribution().draw(), (FlowMassUnit) getUnit()); case "FlowVolumeUnit": return (T) new FloatFlowVolume((float) getDistribution().draw(), (FlowVolumeUnit) getUnit()); case "ForceUnit": return (T) new FloatForce((float) getDistribution().draw(), (ForceUnit) getUnit()); case "FrequencyUnit": return (T) new FloatFrequency((float) getDistribution().draw(), (FrequencyUnit) getUnit()); case "LengthUnit": return (T) new FloatLength((float) getDistribution().draw(), (LengthUnit) getUnit()); case "LinearDensityUnit": return (T) new FloatLinearDensity((float) getDistribution().draw(), (LinearDensityUnit) getUnit()); case "MassUnit": return (T) new FloatMass((float) getDistribution().draw(), (MassUnit) getUnit()); case "PowerUnit": return (T) new FloatPower((float) getDistribution().draw(), (PowerUnit) getUnit()); case "PressureUnit": return (T) new FloatPressure((float) getDistribution().draw(), (PressureUnit) getUnit()); case "SpeedUnit": return (T) new FloatSpeed((float) getDistribution().draw(), (SpeedUnit) getUnit()); case "TemperatureUnit": return (T) new FloatTemperature((float) getDistribution().draw(), (TemperatureUnit) getUnit()); case "TimeUnit": return (T) new FloatDuration((float) getDistribution().draw(), (TimeUnit) getUnit()); case "TorqueUnit": return (T) new FloatTorque((float) getDistribution().draw(), (TorqueUnit) getUnit()); case "VolumeUnit": return (T) new FloatVolume((float) getDistribution().draw(), (VolumeUnit) getUnit()); default: return (T) new FloatScalar.Rel((float) getDistribution().draw(), getUnit()); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\OTSBufferingJTS.java | 492 |
org\opentrafficsim\core\geometry\OTSLine3D.java | 302 |
OTSLine3D offsetLineAtEnd = offsetLine(referenceLine, offsetAtEnd); // System.out.println(OTSGeometry.printCoordinates("#offset line at end: \nc0.7,0.7,0.7\n#", offsetLineAtEnd, "\n ")); Geometry startGeometry = offsetLineAtStart.getLineString(); Geometry endGeometry = offsetLineAtEnd.getLineString(); LengthIndexedLine first = new LengthIndexedLine(startGeometry); double firstLength = startGeometry.getLength(); LengthIndexedLine second = new LengthIndexedLine(endGeometry); double secondLength = endGeometry.getLength(); ArrayList<Coordinate> out = new ArrayList<Coordinate>(); Coordinate[] firstCoordinates = startGeometry.getCoordinates(); Coordinate[] secondCoordinates = endGeometry.getCoordinates(); int firstIndex = 0; int secondIndex = 0; Coordinate prevCoordinate = null; final double tooClose = 0.05; // 5 cm while (firstIndex < firstCoordinates.length && secondIndex < secondCoordinates.length) { double firstRatio = firstIndex < firstCoordinates.length ? first.indexOf(firstCoordinates[firstIndex]) / firstLength : Double.MAX_VALUE; double secondRatio = secondIndex < secondCoordinates.length ? second.indexOf(secondCoordinates[secondIndex]) / secondLength : Double.MAX_VALUE; double ratio; if (firstRatio < secondRatio) { ratio = firstRatio; firstIndex++; } else { ratio = secondRatio; secondIndex++; } Coordinate firstCoordinate = first.extractPoint(ratio * firstLength); Coordinate secondCoordinate = second.extractPoint(ratio * secondLength); Coordinate resultCoordinate = new Coordinate((1 - ratio) * firstCoordinate.x + ratio * secondCoordinate.x, (1 - ratio) * firstCoordinate.y + ratio * secondCoordinate.y); if (null == prevCoordinate || resultCoordinate.distance(prevCoordinate) > tooClose) { out.add(resultCoordinate); prevCoordinate = resultCoordinate; } } Coordinate[] resultCoordinates = new Coordinate[out.size()]; for (int index = 0; index < out.size(); index++) { resultCoordinates[index] = out.get(index); } return new OTSLine3D(resultCoordinates); } /** * @param args args * @throws NetworkException on error * @throws OTSGeometryException on error */ public static void main(final String[] args) throws NetworkException, OTSGeometryException |
File | Line |
---|---|
org\opentrafficsim\core\geometry\OTSBufferingJTS.java | 294 |
org\opentrafficsim\core\geometry\OTSPoint3D.java | 166 |
private static OTSPoint3D intersectionOfLineSegments(final OTSPoint3D line1P1, final OTSPoint3D line1P2, final OTSPoint3D line2P1, final OTSPoint3D line2P2) { double denominator = (line2P2.y - line2P1.y) * (line1P2.x - line1P1.x) - (line2P2.x - line2P1.x) * (line1P2.y - line1P1.y); if (denominator == 0f) { return null; // lines are parallel (they might even be on top of each other, but we don't check that) } double uA = ((line2P2.x - line2P1.x) * (line1P1.y - line2P1.y) - (line2P2.y - line2P1.y) * (line1P1.x - line2P1.x)) / denominator; if ((uA < 0f) || (uA > 1f)) { return null; // intersection outside line 1 } double uB = ((line1P2.x - line1P1.x) * (line1P1.y - line2P1.y) - (line1P2.y - line1P1.y) * (line1P1.x - line2P1.x)) / denominator; if (uB < 0 || uB > 1) { return null; // intersection outside line 2 } return new OTSPoint3D(line1P1.x + uA * (line1P2.x - line1P1.x), line1P1.y + uA * (line1P2.y - line1P1.y), 0); } |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistFloatScalar.java | 166 |
org\opentrafficsim\core\units\distributions\DiscreteDistFloatScalar.java | 165 |
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 FloatAcceleration((float) getDistribution().draw(), (AccelerationUnit) getUnit()); case "AngleUnit": return (T) new FloatAngle((float) getDistribution().draw(), (AngleUnit) getUnit()); case "AngleSolidUnit": return (T) new FloatAngleSolid((float) getDistribution().draw(), (AngleSolidUnit) getUnit()); case "AreaUnit": return (T) new FloatArea((float) getDistribution().draw(), (AreaUnit) getUnit()); case "DensityUnit": return (T) new FloatDensity((float) getDistribution().draw(), (DensityUnit) getUnit()); case "DimensionlessUnit": return (T) new FloatDimensionless((float) getDistribution().draw(), (DimensionlessUnit) getUnit()); |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistDoubleScalar.java | 103 |
org\opentrafficsim\core\units\distributions\DiscreteDistDoubleScalar.java | 103 |
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 "AngleUnit": return (T) new Direction(getDistribution().draw(), (AngleUnit) getUnit()); case "LengthUnit": return (T) new Position(getDistribution().draw(), (LengthUnit) getUnit()); case "TemperatureUnit": return (T) new AbsoluteTemperature(getDistribution().draw(), (TemperatureUnit) getUnit()); case "TimeUnit": return (T) new Time(getDistribution().draw(), (TimeUnit) getUnit()); default: return (T) new DoubleScalar.Abs(getDistribution().draw(), getUnit()); } } /** {@inheritDoc} */ @Override public final String toString() { return "ContinuousDistDoubleScalar.Abs [T=" + getUnit().getClass().getSimpleName() + "]"; |
File | Line |
---|---|
org\opentrafficsim\core\geometry\OTSBufferingJTS.java | 507 |
org\opentrafficsim\core\geometry\OTSLine3D.java | 317 |
org\opentrafficsim\core\geometry\OTSLine3D.java | 391 |
while (firstIndex < firstCoordinates.length && secondIndex < secondCoordinates.length) { double firstRatio = firstIndex < firstCoordinates.length ? first.indexOf(firstCoordinates[firstIndex]) / firstLength : Double.MAX_VALUE; double secondRatio = secondIndex < secondCoordinates.length ? second.indexOf(secondCoordinates[secondIndex]) / secondLength : Double.MAX_VALUE; double ratio; if (firstRatio < secondRatio) { ratio = firstRatio; firstIndex++; } else { ratio = secondRatio; secondIndex++; } Coordinate firstCoordinate = first.extractPoint(ratio * firstLength); Coordinate secondCoordinate = second.extractPoint(ratio * secondLength); Coordinate resultCoordinate = new Coordinate((1 - ratio) * firstCoordinate.x + ratio * secondCoordinate.x, (1 - ratio) * firstCoordinate.y + ratio * secondCoordinate.y); if (null == prevCoordinate || resultCoordinate.distance(prevCoordinate) > tooClose) { out.add(resultCoordinate); prevCoordinate = resultCoordinate; } } |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistFloatScalar.java | 103 |
org\opentrafficsim\core\units\distributions\DiscreteDistFloatScalar.java | 103 |
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 "AngleUnit": return (T) new FloatDirection((float) getDistribution().draw(), (AngleUnit) getUnit()); case "LengthUnit": return (T) new FloatPosition((float) getDistribution().draw(), (LengthUnit) getUnit()); case "TemperatureUnit": return (T) new FloatAbsoluteTemperature((float) getDistribution().draw(), (TemperatureUnit) getUnit()); case "TimeUnit": return (T) new FloatTime((float) getDistribution().draw(), (TimeUnit) getUnit()); default: return (T) new FloatScalar.Abs((float) getDistribution().draw(), getUnit()); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 177 |
org\opentrafficsim\core\geometry\Test.java | 783 |
reference = new OTSLine3D(new OTSPoint3D(10, 10, 0), new OTSPoint3D(9.999, 8, 0), new OTSPoint3D(9.996, 7.99, 0), new OTSPoint3D(9.999, 7.98, 0), new OTSPoint3D(10.03, 7.95, 0), new OTSPoint3D(10.01, 7.94, 0), new OTSPoint3D(10.0, 7.94, 0), new OTSPoint3D(10, 6, 0), new OTSPoint3D(9.999, 6, 0), new OTSPoint3D( 9.996, 5.99, 0), new OTSPoint3D(9.999, 5.98, 0), new OTSPoint3D(10.03, 5.95, 0), new OTSPoint3D(10.01, 5.94, 0), new OTSPoint3D(10.0, 5.94, 0), new OTSPoint3D(10, 2, 0)); System.out.println("AV line2: " + checkAll(reference, 1.625)); |
File | Line |
---|---|
org\opentrafficsim\core\gtu\animation\AccelerationGTUColorer.java | 88 |
org\opentrafficsim\core\gtu\animation\SpeedGTUColorer.java | 59 |
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\core\network\OTSNetwork.java | 399 |
org\opentrafficsim\core\network\OTSNetwork.java | 446 |
for (LinkEdge<Link> link : path.getPathEdgeList()) { if (!link.getLink().getEndNode().equals(route.destinationNode()) && route.destinationNode().isDirectionallyConnectedTo(gtuType, link.getLink().getEndNode())) { route.addNode(link.getLink().getEndNode()); } else if (!link.getLink().getStartNode().equals(route.destinationNode()) && route.destinationNode().isDirectionallyConnectedTo(gtuType, link.getLink().getStartNode())) { route.addNode(link.getLink().getStartNode()); } else { throw new NetworkException("Cannot connect two links when calculating shortest route"); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 820 |
org\opentrafficsim\core\geometry\Test2.java | 41 |
System.out.println(OTSGeometryUtil.printCoordinates("#left:\nc0,0,1\n#", left, "\n ")); reference = new OTSLine3D(new OTSPoint3D(10, 0.5, 0), new OTSPoint3D(10, -2, 0), new OTSPoint3D(9.9, -2.01, 0), new OTSPoint3D(10.1, -2.03, 0), new OTSPoint3D(10, -2.04, 0), new OTSPoint3D(10, -6, 0), new OTSPoint3D(9.9, -6.01, 0), new OTSPoint3D(10.1, -6.03, 0), new OTSPoint3D(10, -6.04, 0), new OTSPoint3D(10, -8.54, 0)); System.out.println(OTSGeometryUtil.printCoordinates("#reference:\nc1,0,0\n#", reference, "\n ")); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 156 |
org\opentrafficsim\core\geometry\Test.java | 810 |
reference = new OTSLine3D(new OTSPoint3D(5, -1, 0), new OTSPoint3D(5, -2, 0), new OTSPoint3D(4.9, -2.01, 0), new OTSPoint3D(5.1, -2.03, 0), new OTSPoint3D(5, -2.04, 0), new OTSPoint3D(5, -6, 0), new OTSPoint3D( 4.9, -6.01, 0), new OTSPoint3D(5.1, -6.03, 0), new OTSPoint3D(5, -6.04, 0), new OTSPoint3D(5, -7.04, 0)); System.out.println("Straight reference with noise near ends: " + checkAll(reference, 2)); |
File | Line |
---|---|
org\opentrafficsim\gui\OTSAnimationPanel.java | 250 |
org\opentrafficsim\gui\OTSControlPanel.java | 221 |
public DisposeOnCloseThread(final OTSAnimationPanel panel) { super(); this.panel = panel; } /** {@inheritDoc} */ @Override public final void run() { Container root = this.panel; while (!(root instanceof JFrame)) { try { Thread.sleep(10); } catch (InterruptedException exception) { // nothing to do } // Search towards the root of the Swing components until we find a JFrame root = this.panel; while (null != root.getParent() && !(root instanceof JFrame)) { root = root.getParent(); } } JFrame frame = (JFrame) root; frame.addWindowListener(this.panel); this.panel.closeHandlerRegistered = true; } /** {@inheritDoc} */ @Override public final String toString() { return "DisposeOnCloseThread of OTSAnimationPanel [panel=" + this.panel + "]"; |
File | Line |
---|---|
org\opentrafficsim\simulationengine\SimpleAnimator.java | 53 |
org\opentrafficsim\simulationengine\SimpleSimulator.java | 50 |
setAnimationDelay(20); // 50 Hz animation update initialize(new OTSReplication("rep" + ++this.lastReplication, new OTSSimTimeDouble(startTime), warmupPeriod, runLength, model), ReplicationMode.TERMINATING); } /** * {@inheritDoc} */ public final SimEvent<OTSSimTimeDouble> scheduleEvent(final Time 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(executionTime.getSI(), TimeUnit.SECOND)), priority, source, target, method, args); scheduleEvent(result); return result; } } |
File | Line |
---|---|
org\opentrafficsim\core\geometry\OTSBufferingJTS.java | 207 |
org\opentrafficsim\core\geometry\OTSOffsetLinePK.java | 143 |
for (int additionalPoint = 1; additionalPoint < numSegments; additionalPoint++) { double intermediateAngle = (additionalPoint * angle + (numSegments - additionalPoint) * prevAngle) / numSegments; if (prevAngle * angle < 0 && Math.abs(prevAngle) > Math.PI / 2 && Math.abs(angle) > Math.PI / 2) { intermediateAngle += Math.PI; } OTSPoint3D intermediatePoint = new OTSPoint3D(prevPoint.x - Math.sin(intermediateAngle) * offset, prevPoint.y + Math.cos(intermediateAngle) * offset); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 146 |
org\opentrafficsim\core\geometry\Test.java | 169 |
System.out.println("Closely spaced points on large circle: " + checkAll(reference, 2)); // Straight design line with some <i>noise</i> (sufficiently far from the end points). reference = new OTSLine3D(new OTSPoint3D(10, 10, 0), new OTSPoint3D(9.999, 8, 0), new OTSPoint3D(9.996, 7.99, 0), new OTSPoint3D(9.999, 7.98, 0), new OTSPoint3D(10.03, 7.95, 0), new OTSPoint3D(10.01, 7.94, 0), new OTSPoint3D(10.0, 7.94, 0), new OTSPoint3D(10, 6, 0), new OTSPoint3D(10, 2, 0)); System.out.println("Straight reference with noise far from ends: " + checkAll(reference, 2)); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 762 |
org\opentrafficsim\core\geometry\Test.java | 780 |
public static void test6() throws OTSGeometryException { System.out.println("O0,-10"); OTSLine3D reference = new OTSLine3D(new OTSPoint3D(10, 10, 0), new OTSPoint3D(9.999, 8, 0), new OTSPoint3D(9.996, 7.99, 0), new OTSPoint3D(9.999, 7.98, 0), new OTSPoint3D(10.03, 7.95, 0), new OTSPoint3D(10.01, 7.94, 0), new OTSPoint3D(10.0, 7.94, 0), new OTSPoint3D(10, 6, 0), new OTSPoint3D(10, 2, 0)); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 149 |
org\opentrafficsim\core\geometry\Test.java | 171 |
org\opentrafficsim\core\geometry\Test.java | 765 |
reference = new OTSLine3D(new OTSPoint3D(10, 10, 0), new OTSPoint3D(9.999, 8, 0), new OTSPoint3D(9.996, 7.99, 0), new OTSPoint3D(9.999, 7.98, 0), new OTSPoint3D(10.03, 7.95, 0), new OTSPoint3D(10.01, 7.94, 0), new OTSPoint3D(10.0, 7.94, 0), new OTSPoint3D(10, 6, 0), new OTSPoint3D(10, 2, 0)); System.out.println("Straight reference with noise far from ends: " + checkAll(reference, 2)); |
File | Line |
---|---|
org\opentrafficsim\core\network\OTSNode.java | 184 |
org\opentrafficsim\core\network\OTSNode.java | 246 |
} // ------------------------------------------- make datasets if needed if (this.connections == null) { this.connections = new HashMap<>(); } if (!this.connections.containsKey(gtuType)) { this.connections.put(gtuType, new HashMap<>()); } Map<Link, Set<Link>> gtuMap = this.connections.get(gtuType); if (!gtuMap.containsKey(incomingLink)) { gtuMap.put(incomingLink, new HashSet<>()); } // ------------------------------------------- add the connection gtuMap.get(incomingLink).add(outgoingLink); |