public QSimDensityDrawer(Scenario sc) { for (Link l : sc.getNetwork().getLinks().values()) { if (l.getId().toString().contains("jps") || l.getId().toString().contains("el") || l.getAllowedModes().contains("walk2d") || l.getCapacity() >= 100000 || l.getFreespeed() > 100 || l.getId().toString().contains("el")) { continue; } float width = (float) (l.getCapacity() / sc.getNetwork().getCapacityPeriod() / 1.3); boolean isCar = false; if (l.getFreespeed() > 1.35) { width = (float) (l.getNumberOfLanes() * 3.5); isCar = true; } else { width = (float) (width); } double dx = l.getToNode().getCoord().getX() - l.getFromNode().getCoord().getX(); double dy = l.getToNode().getCoord().getY() - l.getFromNode().getCoord().getY(); double length = Math.sqrt(dx * dx + dy * dy); dx /= length; dy /= length; LinkInfo info = new LinkInfo(); info.id = l.getId(); info.cap = (l.getLength() / ((NetworkImpl) sc.getNetwork()).getEffectiveCellSize()) * l.getNumberOfLanes(); double x0 = l.getFromNode().getCoord().getX(); double y0 = l.getFromNode().getCoord().getY(); double x1 = l.getToNode().getCoord().getX(); double y1 = l.getToNode().getCoord().getY(); x0 += dy * width / 2; x1 += dy * width / 2; y0 -= dx * width / 2; y1 -= dx * width / 2; info.width = width; info.x0 = x0; info.x1 = x1; info.y0 = y0; info.y1 = y1; double tan = dx / dy; double atan = Math.atan(tan); if (atan > 0) { atan -= Math.PI / 2; } else { atan += Math.PI / 2; } double offsetX = dy * .075; double offsetY = -dx * .075; if (dx > 0) { offsetX *= -1; offsetY *= -1; } info.tx = (x0 + x1) / 2 + offsetX; info.ty = (y0 + y1) / 2 + offsetY; info.text = "0"; info.atan = atan; info.isCar = isCar; if (isCar) { info.cap = l.getLength() / 7.5 * l.getNumberOfLanes(); } this.links.add(info); this.map.put(l.getId(), info); } }