Package research.figure

Examples of research.figure.PolyLineFigure


      FigureEnumeration fe = getAffectedFigures();
      if (!fe.hasMoreElements()) {
        return false;
      }

      PolyLineFigure figure = (PolyLineFigure)fe.nextFigure();
      Point backupPoint = figure.pointAt(getPointIndex());
      figure.setPointAt(getOldPoint(), getPointIndex());
      setOldPoint(backupPoint);
      return true;
    }
View Full Code Here


  public PolyLineLocator(int index) {
    fIndex = index;
  }

  public Point locate(Figure owner) {
    PolyLineFigure plf = (PolyLineFigure)owner;
    // guard against changing PolyLineFigures -> temporary hack
    if (fIndex < plf.pointCount()) {
      return ((PolyLineFigure)owner).pointAt(fIndex);
    }
    return new Point(0, 0);
  }
View Full Code Here

  public PolyLineConnector(Figure owner) {
    super(owner);
  }

  protected Point chop(Figure target, Point from) {
    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;
View Full Code Here

TOP

Related Classes of research.figure.PolyLineFigure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.