Example usage for java.awt.geom Line2D ptLineDist

List of usage examples for java.awt.geom Line2D ptLineDist

Introduction

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

Prototype

public double ptLineDist(double px, double py) 

Source Link

Document

Returns the distance from a point to this line.

Usage

From source file:net.sourceforge.processdash.ev.ui.chart.RangeXYItemRenderer.java

private Point2D gradientStart(double x0, double y0, double x1, double y1, double x2, double y2, double x3,
        double y3) {
    double dy = x0 - x1;
    double dx = y1 - y0;
    double startLen = Math.sqrt(dy * dy + dx * dx);
    if (startLen == 0)
        throw new IllegalArgumentException();

    Line2D line = new Line2D.Double(x0, y0, x1, y1);
    double len2 = line.ptLineDist(x2, y2);
    double len3 = line.ptLineDist(x3, y3);
    double len = 10;
    len = Math.max(len, len2);//from   www .  java  2s . co  m
    len = Math.max(len, len3);

    double fraction = len / startLen;

    return new Point2D.Double(x1 + dx * fraction, y1 + dy * fraction);
}