}
return;
case Flow:
// Get the map element below the mouse
RoadNetworkElement elementBelowMouse = roadNetwork.PointHitTest(transformedPoint);
// If we are in the middle of creating a new flow and the user right
// clicks or clicks somewhere that is not an edge cancel the
// operation
if ((creatingNewElement) && ((e.getButton() == MouseEvent.BUTTON3) || (elementBelowMouse == null) || !(elementBelowMouse instanceof Edge))) {
creatingNewElement = false;
newElement = null;
repaint();
return;
}
if ((elementBelowMouse != null) && (elementBelowMouse instanceof Edge)) {
// Set the flow's ending point and add it to the traffic layer
if (creatingNewElement) {
((Flow) newElement).setTo(new Point2D.Double(elementBelowMouse.getBounds().getCenterX(), elementBelowMouse.getBounds().getCenterY()));
((Flow) newElement).setEnd((Edge) elementBelowMouse);
((Flow) newElement).SetDependencies();
currentTrafficLayer.AddTrafficElement(newElement);
creatingNewElement = false;
newElement = null;
repaint();
}
// Start creating the flow
else {
newElement = new Flow();
((Flow) newElement).setStart((Edge) elementBelowMouse);
((Flow) newElement).setFrom(new Point2D.Float((float) elementBelowMouse.getBounds().getCenterX(), (float) elementBelowMouse.getBounds().getCenterY()));
creatingNewElement = true;
}
}
return;
case Accident:
// Get the map element below the mouse
RoadNetworkElement elementBelowMouse2 = roadNetwork.PointHitTest(transformedPoint);
if ((elementBelowMouse2 != null) && (elementBelowMouse2 instanceof Edge) && (e.getButton() == MouseEvent.BUTTON1)) {
currentTrafficLayer.AddTrafficElement(new Accident((Edge) elementBelowMouse2, transformedPoint));
}