@Override
public void renderDynamic(GC gc, ViewPort vp, long time) {
helper.adapt(gc, vp);
if (showRelativeSpeedDynamic) {
final Set<Connection<? extends ConnectionData>> set =
ImmutableSet.copyOf(updatedConnections);
for (final Connection<? extends ConnectionData> e : set) {
final double dist = Point.distance(e.from(), e.to());
final Point f = PointUtil.on(e, dist * ARROW_REL_FROM_TO.x);
final Point t = PointUtil.on(e, dist * ARROW_REL_FROM_TO.y);
final MultiAttributeData data = (MultiAttributeData) e.data().get();
final double ratio =
data.getMaxSpeed().get()
/ Double.parseDouble((String) data.getAttributes().get("ts"));
final Color color =
new Color(gc.getDevice(),
(int) Math.max(Math.min(-510 * ratio + 510, 255), 0),
(int) Math.max(Math.min(510 * ratio, 255), 0), 0);
helper.setBackgroundSysCol(color);
helper.drawArrow(f, t, ARROW_HEAD_SIZE, ARROW_HEAD_SIZE);
color.dispose();
}
}
}