List of usage examples for java.awt.geom Line2D ptSegDist
public double ptSegDist(Point2D pt)
From source file:org.tellervo.desktop.graph.SkeletonPlot.java
public boolean contact(GraphSettings gInfo, Graph g, Point p, int bottom) { // snap to year int yearWidth = gInfo.getYearWidth(); int firstYearIdx = (p.x / yearWidth) - 1; int nYears = 3; // Check three years' worth of data: the year prior to and after the year the mouse is inside Year startYear = gInfo.getDrawBounds().getStart().add(firstYearIdx); List<Point2D> points = this.getPointsFrom(gInfo, g, startYear, nYears, bottom); int nLines = points.size() - 1; for (int i = 0; i < nLines; i++) { Line2D line = new Line2D.Float(points.get(i), points.get(i + 1)); int distance = Math.round((float) line.ptSegDist(p)); if (distance <= NEAR) return true; }//from w w w.j a v a2 s .co m return false; }