Back to index

moin  1.9.0~rc2
Public Member Functions | Protected Member Functions | Static Private Attributes
CH.ifa.draw.figures.PolyLineConnector Class Reference

PolyLineConnector finds connection points on a PolyLineFigure. More...

List of all members.

Public Member Functions

 PolyLineConnector ()
 PolyLineConnector (Figure owner)
 Constructs a connector with the given owner figure.

Protected Member Functions

Point chop (Figure target, Point from)

Static Private Attributes

static final long serialVersionUID = 6018435940519102865L

Detailed Description

PolyLineConnector finds connection points on a PolyLineFigure.

See also:
PolyLineFigure

Definition at line 20 of file PolyLineConnector.java.


Constructor & Destructor Documentation

Definition at line 27 of file PolyLineConnector.java.

                               {
        super();
    }

Constructs a connector with the given owner figure.

Definition at line 34 of file PolyLineConnector.java.

                                           {
        super(owner);
    }

Member Function Documentation

Point CH.ifa.draw.figures.PolyLineConnector.chop ( Figure  target,
Point  from 
) [inline, protected]

Definition at line 38 of file PolyLineConnector.java.

                                                    {
        PolyLineFigure p = (PolyLineFigure)owner();
        // *** based on PolygonFigure's heuristic
        Point ctr = p.center();
        int cx = -1;
        int cy = -1;
        long len = Long.MAX_VALUE;

        // Try for points along edge

        for (int i = 0; i < p.pointCount()-1; i++) {
            Point p1 = p.pointAt(i);
            Point p2 = p.pointAt(i+1);
            Point chop = Geom.intersect(p1.x,
                                 p1.y,
                                 p2.x,
                                 p2.y,
                                 from.x,
                                 from.y,
                                 ctr.x,
                                 ctr.y);
            if (chop != null) {
                long cl = Geom.length2(chop.x, chop.y, from.x, from.y);
                if (cl < len) {
                    len = cl;
                    cx = chop.x;
                    cy = chop.y;
                }
            }
        }
        // if none found, pick closest vertex
        //if (len ==  Long.MAX_VALUE) {
        { // try anyway
            for (int i = 0; i < p.pointCount(); i++) {
                Point pp = p.pointAt(i);
                long l = Geom.length2(pp.x, pp.y, from.x, from.y);
                if (l < len) {
                    len = l;
                    cx = pp.x;
                    cy = pp.y;
                }
            }
        }
        return new Point(cx, cy);
    }

Here is the call graph for this function:


Member Data Documentation

final long CH.ifa.draw.figures.PolyLineConnector.serialVersionUID = 6018435940519102865L [static, private]

Definition at line 25 of file PolyLineConnector.java.


The documentation for this class was generated from the following file: