CPD Results
The following document contains the results of PMD's CPD 7.0.0.
Duplications
| File | Line |
|---|---|
| org/opentrafficsim/core/dsol/OtsDevsRealTimeParallelMove.java | 299 |
| org/opentrafficsim/core/dsol/OtsDevsRealTimeParallelMove.java | 342 |
new SimEvent<>(this.simulatorTime, se.getTarget(), "movePrep", se.getArgs());
this.executor.execute(new Runnable()
{
@Override
public void run()
{
try
{
moveEvent.execute();
}
catch (Exception exception)
{
getLogger().always().error(exception);
if (OtsDevsRealTimeParallelMove.this.getErrorStrategy().equals(ErrorStrategy.WARN_AND_PAUSE))
{
try
{
OtsDevsRealTimeParallelMove.this.stop();
}
catch (SimRuntimeException exception1)
{
getLogger().always().error(exception1);
}
}
}
}
});
}
this.executor.shutdown();
try
{
this.executor.awaitTermination(1L, java.util.concurrent.TimeUnit.HOURS);
}
catch (InterruptedException exception)
{
//
}
this.executor = Executors.newFixedThreadPool(1);
for (int i = 0; i < moveEvents.size(); i++)
{
SimEvent<Duration> se = (SimEvent<Duration>) moveEvents.get(i);
final SimEventInterface<Duration> moveEvent =
new SimEvent<>(this.simulatorTime, se.getTarget(), "moveGenerate", se.getArgs()); | |
| File | Line |
|---|---|
| org/opentrafficsim/core/geometry/Flattener.java | 235 |
| org/opentrafficsim/core/geometry/Flattener.java | 331 |
result.put(medianT, medianPoint);
directions.put(medianT, line.getDirection(medianT));
iterationsAtSinglePoint++;
Throw.when(iterationsAtSinglePoint == 50, RuntimeException.class,
"Required a new point 50 times at the same point. Likely the reported direction of the point does "
+ "not match further points produced. Consider using the numerical approach in the "
+ "default getDirection(fraction) method of the FlattableLine.");
continue;
}
iterationsAtSinglePoint = 0;
// Check for an inflection point by creating additional points at one quarter and three quarters. If these
// are on opposite sides of the line from prevPoint to nextPoint; there must be an inflection point.
// https://stackoverflow.com/questions/1560492/how-to-tell-whether-a-point-is-to-the-right-or-left-side-of-a-line
Point2d quarter = line.get((prevT + medianT) / 2);
int sign1 = (int) Math.signum((nextPoint.x - prevPoint.x) * (quarter.y - prevPoint.y)
- (nextPoint.y - prevPoint.y) * (quarter.x - prevPoint.x));
Point2d threeQuarter = line.get((nextT + medianT) / 2);
int sign2 = (int) Math.signum((nextPoint.x - prevPoint.x) * (threeQuarter.y - prevPoint.y)
- (nextPoint.y - prevPoint.y) * (threeQuarter.x - prevPoint.x));
if (sign1 != sign2)
{ | |
| File | Line |
|---|---|
| org/opentrafficsim/core/geometry/Flattener.java | 185 |
| org/opentrafficsim/core/geometry/Flattener.java | 292 |
this.maxAngle = maxAngle;
}
/** {@inheritDoc} */
@Override
public PolyLine2d flatten(final FlattableLine line)
{
NavigableMap<Double, Point2d> result = new TreeMap<>();
result.put(0.0, line.get(0.0));
result.put(1.0, line.get(1.0));
Map<Double, Double> directions = new LinkedHashMap<>();
directions.put(0.0, line.getDirection(0.0));
directions.put(1.0, line.getDirection(1.0));
// Walk along all point pairs and see if additional points need to be inserted
double prevT = result.firstKey();
Point2d prevPoint = result.get(prevT);
Map.Entry<Double, Point2d> entry;
int iterationsAtSinglePoint = 0;
while ((entry = result.higherEntry(prevT)) != null)
{
double nextT = entry.getKey();
Point2d nextPoint = entry.getValue();
double medianT = (prevT + nextT) / 2; | |
| File | Line |
|---|---|
| org/opentrafficsim/core/dsol/OtsAnimator.java | 74 |
| org/opentrafficsim/core/dsol/OtsLoggingAnimator.java | 67 |
public void initialize(final Time startTime, final Duration warmupPeriod, final Duration runLength,
final OtsModelInterface model, final Map<String, StreamInterface> streams)
throws SimRuntimeException, NamingException
{
setErrorStrategy(ErrorStrategy.WARN_AND_PAUSE);
setAnimationDelay(20); // 50 Hz animation update
OtsReplication newReplication = new OtsReplication("rep" + ++this.lastReplication, startTime, warmupPeriod, runLength);
model.getStreams().putAll(streams);
super.initialize(model, newReplication);
}
/** {@inheritDoc} */
@Override
public void initialize(final Time startTime, final Duration warmupPeriod, final Duration runLength,
final OtsModelInterface model, final int replicationnr) throws SimRuntimeException, NamingException
{
setErrorStrategy(ErrorStrategy.WARN_AND_PAUSE);
setAnimationDelay(20); // 50 Hz animation update
OtsReplication newReplication = new OtsReplication("rep" + replicationnr, startTime, warmupPeriod, runLength);
super.initialize(model, newReplication);
}
/** {@inheritDoc} */
@Override | |
| File | Line |
|---|---|
| org/opentrafficsim/core/geometry/Flattener.java | 136 |
| org/opentrafficsim/core/geometry/Flattener.java | 249 |
Point2d quarter = line.get((prevT + medianT) / 2);
int sign1 = (int) Math.signum((nextPoint.x - prevPoint.x) * (quarter.y - prevPoint.y)
- (nextPoint.y - prevPoint.y) * (quarter.x - prevPoint.x));
Point2d threeQuarter = line.get((nextT + medianT) / 2);
int sign2 = (int) Math.signum((nextPoint.x - prevPoint.x) * (threeQuarter.y - prevPoint.y)
- (nextPoint.y - prevPoint.y) * (threeQuarter.x - prevPoint.x));
if (sign1 != sign2)
{
// There is an inflection point, inserting the halfway point should take care of this
result.put(medianT, medianPoint); | |
| File | Line |
|---|---|
| org/opentrafficsim/core/dsol/OtsDevsRealTimeParallelMove.java | 299 |
| org/opentrafficsim/core/dsol/OtsDevsRealTimeParallelMove.java | 342 |
| org/opentrafficsim/core/dsol/OtsDevsRealTimeParallelMove.java | 385 |
new SimEvent<>(this.simulatorTime, se.getTarget(), "movePrep", se.getArgs());
this.executor.execute(new Runnable()
{
@Override
public void run()
{
try
{
moveEvent.execute();
}
catch (Exception exception)
{
getLogger().always().error(exception);
if (OtsDevsRealTimeParallelMove.this.getErrorStrategy().equals(ErrorStrategy.WARN_AND_PAUSE))
{
try
{
OtsDevsRealTimeParallelMove.this.stop();
}
catch (SimRuntimeException exception1)
{
getLogger().always().error(exception1);
}
}
}
}
});
}
this.executor.shutdown();
try
{
this.executor.awaitTermination(1L, java.util.concurrent.TimeUnit.HOURS);
}
catch (InterruptedException exception)
{
//
} | |
| File | Line |
|---|---|
| org/opentrafficsim/core/geometry/Flattener.java | 136 |
| org/opentrafficsim/core/geometry/Flattener.java | 345 |
Point2d quarter = line.get((prevT + medianT) / 2);
int sign1 = (int) Math.signum((nextPoint.x - prevPoint.x) * (quarter.y - prevPoint.y)
- (nextPoint.y - prevPoint.y) * (quarter.x - prevPoint.x));
Point2d threeQuarter = line.get((nextT + medianT) / 2);
int sign2 = (int) Math.signum((nextPoint.x - prevPoint.x) * (threeQuarter.y - prevPoint.y)
- (nextPoint.y - prevPoint.y) * (threeQuarter.x - prevPoint.x));
if (sign1 != sign2)
{ | |
| File | Line |
|---|---|
| org/opentrafficsim/core/network/Node.java | 212 |
| org/opentrafficsim/core/network/Node.java | 273 |
}
// ------------------------------------------- make datasets if needed
if (this.connections == null)
{
this.connections = new LinkedHashMap<>();
}
if (!this.connections.containsKey(gtuType))
{
this.connections.put(gtuType, new LinkedHashMap<>());
}
Map<Link, Set<Link>> gtuMap = this.connections.get(gtuType);
if (!gtuMap.containsKey(incomingLink))
{
gtuMap.put(incomingLink, new LinkedHashSet<>());
}
// ------------------------------------------- add the connection
gtuMap.get(incomingLink).add(outgoingLink); | |
| File | Line |
|---|---|
| org/opentrafficsim/core/perception/collections/HistoricalHashMap.java | 41 |
| org/opentrafficsim/core/perception/collections/HistoricalLinkedHashMap.java | 41 |
public HistoricalHashMap(final HistoryManager historyManager, final Map<? extends K, ? extends V> m)
{
super(historyManager, new LinkedHashMap<>(m));
}
/** {@inheritDoc} */
@Override
public LinkedHashMap<K, V> get()
{
return getMap();
}
/** {@inheritDoc} */
@Override
public LinkedHashMap<K, V> get(final Time time)
{
if (isLastState(time))
{
return getMap();
}
return fill(time, new LinkedHashMap<>());
}
/** {@inheritDoc} */
@Override
public String toString()
{
return "HistoricalHashMap [current=" + getMap() + "]"; | |
