* @param nodeViews
* @param scrolledLocalCenter
* @return the nearest node to a given point
*/
public static NodeModel getNearestNode(List<NodeView> nodeViews, Point2D scrolledLocalCenter){
NodeView nearestNodeTodropPoint = nodeViews.get(0);
double nearestNodeDistance = Point2DUtils.distance(scrolledLocalCenter, nearestNodeTodropPoint.getPosition());
for (NodeView node : nodeViews){
double nodeDistance = Point2DUtils.distance(scrolledLocalCenter, node.getPosition());
if (nodeDistance < nearestNodeDistance){
nearestNodeTodropPoint = node;
nearestNodeDistance = nodeDistance;
}
}
return nearestNodeTodropPoint.getModelElement();
}