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

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

Introduction

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

Prototype

public abstract double getX2();

Source Link

Document

Returns the X coordinate of the end point in double precision.

Usage

From source file:org.fhcrc.cpl.viewer.mrm.Utils.java

public static XYLineAnnotation line2Annotation(Line2D.Double l2dd, Stroke s, Paint p) {
    return new XYLineAnnotation(l2dd.getX1(), l2dd.getY1(), l2dd.getX2(), l2dd.getY2(), s, p);
}

From source file:com.joliciel.jochre.graphics.RowOfShapesImpl.java

Point2D.Double getIntersectionPoint(Line2D.Double line1, Line2D.Double line2) {
    //if (! line1.intersectsLine(line2) ) return null;

    double px = line1.getX1(), py = line1.getY1(), rx = line1.getX2() - px, ry = line1.getY2() - py;
    double qx = line2.getX1(), qy = line2.getY1(), sx = line2.getX2() - qx, sy = line2.getY2() - qy;

    double det = sx * ry - sy * rx;
    if (det == 0) {
        return null;
    } else {/* w  w  w .  j a v a  2  s.co m*/
        double z = (sx * (qy - py) + sy * (px - qx)) / det;
        //if (z==0 ||  z==1) return null;  // intersection at end point!
        return new Point2D.Double((double) (px + z * rx), (double) (py + z * ry));
    }
}