Java examples for 2D Graphics:Line
length of Line2D
//package com.java2s; import java.awt.geom.*; public class Main { private static double length(Line2D segment) { double x = segment.getX1() - segment.getX2(); double y = segment.getY1() - segment.getY2(); return Math.sqrt(x * x + y * y); }/*ww w . ja v a 2 s. co m*/ }