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

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

Introduction

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

Prototype

public abstract double getX1();

Source Link

Document

Returns the X coordinate of the start 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 {//from w ww .  j a va 2s  .  com
        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));
    }
}