org.tigris.gef.presentation
Class AnnotationHelper

java.lang.Object
  extended by org.tigris.gef.presentation.AnnotationHelper

public class AnnotationHelper
extends java.lang.Object

Contains utility methods for solving std geometry problems. The original class had several bugs and/or performance problems that were fixed. The new AnnotationHelper can handle FigPolys, ie, lines with bend points. Improvement can be made by improving FigPoly's method for getting all points.

Version:
2.0
Author:
unknown, jesco.von.voss@gentleware.de

Method Summary
static java.awt.Point getClosestPoint(java.awt.Point from, FigEdgePoly to)
          Returns the closest point on an edge with several points.
static java.awt.Point getClosestPointOnEdge(java.awt.Point p, java.awt.Point begin, java.awt.Point end)
          Standard geometry here.
static int getNormOffset(java.awt.Point p0, java.awt.Point p1, java.awt.Point p2)
          Unmodified method.
static java.awt.Point getNormPointOnEdge(java.awt.Point r1, java.awt.Point r0, java.awt.Point r2)
           
static float getRatio(java.awt.Point from, java.awt.Point begin, java.awt.Point end)
          Calculates the point (as relative length) where the perpendicular hits the line.
static AnnotationHelper instance()
           
static int sqr_distance(java.awt.Point p1, java.awt.Point p2)
          sqr distance of two points; unmodified method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static AnnotationHelper instance()

getNormOffset

public static final int getNormOffset(java.awt.Point p0,
                                      java.awt.Point p1,
                                      java.awt.Point p2)
Unmodified method.


getRatio

public static final float getRatio(java.awt.Point from,
                                   java.awt.Point begin,
                                   java.awt.Point end)
Calculates the point (as relative length) where the perpendicular hits the line. It's final so that no one can damage the implementation (and for speed).

Parameters:
from - The point that sits in space.
begin - The start point of the edge.
end - The end point of the edge.
Returns:
A double: if 0, then the point 'from' sits on the perpendicular through the point 'begin', if 1, it is on the perpendicular through 'end'. You figure out the rest.

getClosestPoint

public static final java.awt.Point getClosestPoint(java.awt.Point from,
                                                   FigEdgePoly to)
Returns the closest point on an edge with several points. It's final so that no one can damage the implementation (and for speed).


getClosestPointOnEdge

public static final java.awt.Point getClosestPointOnEdge(java.awt.Point p,
                                                         java.awt.Point begin,
                                                         java.awt.Point end)
Standard geometry here. It's final so that no one can damage the implementation (and for speed).

Parameters:
p - The point that is somewhere near the edge.
begin - The begin point of the edge.
end - The end point of the edge.

sqr_distance

public static final int sqr_distance(java.awt.Point p1,
                                     java.awt.Point p2)
sqr distance of two points; unmodified method


getNormPointOnEdge

public static java.awt.Point getNormPointOnEdge(java.awt.Point r1,
                                                java.awt.Point r0,
                                                java.awt.Point r2)