Example usage for java.awt.geom Line2D.Double intersects

List of usage examples for java.awt.geom Line2D.Double intersects

Introduction

In this page you can find the example usage for java.awt.geom Line2D.Double intersects.

Prototype

public boolean intersects(Rectangle2D r) 

Source Link

Usage

From source file:uk.ac.ebi.cysbgn.methods.ArcSegmentationAlgorithm.java

public void checkGlyphIntersection(List<SegmentationPoint> segmentPoints, SegmentationPoint point) {

    for (int i = 0; i < (segmentPoints.size() - 1); i++) {
        SegmentationPoint startSegmentPoint = segmentPoints.get(i);
        SegmentationPoint endSegmentPoint = segmentPoints.get((i + 1));

        Rectangle2D.Double glyphBBox = new Rectangle2D.Double(((Glyph) point.getPoint()).getBbox().getX(),
                ((Glyph) point.getPoint()).getBbox().getY(),
                ((Glyph) point.getPoint()).getBbox().getW() + SAFETY_DISTANCE_NODE_ARC_INTERSECTION,
                ((Glyph) point.getPoint()).getBbox().getH() + SAFETY_DISTANCE_NODE_ARC_INTERSECTION);

        Point2D.Double startPoint = new Point2D.Double(startSegmentPoint.getX(), startSegmentPoint.getY());
        Point2D.Double endPoint = new Point2D.Double(endSegmentPoint.getX(), endSegmentPoint.getY());
        Line2D.Double segmentLine = new Line2D.Double(startPoint, endPoint);

        if (segmentLine.intersects(glyphBBox)) {

            double portDistance = point.calculateDistance(startSegmentPoint);
            portDistance += startSegmentPoint.getDistance();

            point.setDistance(portDistance);

            segmentPoints.add(point);//from   ww  w . jav  a  2 s.c om

            return;
        }
    }

}