Package java.awt.geom

Examples of java.awt.geom.CubicCurve2D$Double


  protected void basicMoveBy(int dx, int dy)
  {
    // Don't move the start and end point since they are connected
    for (Iterator it = segments.iterator(); it.hasNext();)
    {
      CubicCurve2D next = (CubicCurve2D) it.next();

      next.setCurve(next.getX1() + dx, next.getY1() + dy, next.getCtrlX1() + dx, next.getCtrlY1() + dy, next.getCtrlX2() + dx, next.getCtrlY2() + dy, next.getX2() + dx, next.getY2() + dy);
    }
  }
View Full Code Here


    Point2D target = new Point2D.Double(2f * center.getX() - p.getX(), 2f * center.getY() - p.getY());

    if (side == 0)
    {
      // We modify CtrlP1
      CubicCurve2D next = (CubicCurve2D) segments.get(index);

      next.setCurve(next.getP1(), target, next.getCtrlP2(), next.getP2());
    }
    else
    {
      // We modify CtrlP2
      CubicCurve2D prev = (CubicCurve2D) segments.get(index - 1);

      prev.setCurve(prev.getP1(), prev.getCtrlP1(), target, prev.getP2());
    }
  }
View Full Code Here

    dy = CommonUtil.rnd(target.getY() - p.getY());

    if (index > 0)
    {
      // if index is not the first segment, we adjust the endpoint of the previous segment
      CubicCurve2D prev = (CubicCurve2D) segments.get(index - 1);

      p = prev.getCtrlP2();

      p.setLocation(p.getX() + dx, p.getY() + dy);

      prev.setCurve(prev.getP1(), prev.getCtrlP1(), p, target);

      basicSetCtrlPoint(index, LEFT_CONTROLPOINT, p);
    }
    if (index < segments.size())
    {
      // likewise, if we are not the last segment, we adjust the position of the one after us

      CubicCurve2D next = (CubicCurve2D) segments.get(index);

      p = next.getCtrlP1();

      p.setLocation(p.getX() + dx, p.getY() + dy);

      next.setCurve(target, p, next.getCtrlP2(), next.getP2());

      basicSetCtrlPoint(index, RIGHT_CONTROLPOINT, p);
    }

    changed();
View Full Code Here

    target = constrainCtrlPoint(index, side, target);

    if (side != LEFT_CONTROLPOINT)
    {
      // We modify CtrlP1
      CubicCurve2D next = (CubicCurve2D) segments.get(index);
      next.setCurve(next.getP1(), target, next.getCtrlP2(), next.getP2());
    }
    else
    {
      // We modify CtrlP2
      CubicCurve2D prev = (CubicCurve2D) segments.get(index - 1);
      prev.setCurve(prev.getP1(), prev.getCtrlP1(), target, prev.getP2());
    }
  }
View Full Code Here

    {
      // - we remove the segment AFTER the given point
      // - we set the end point of the segment before the given point
      //   to the start point of the segment after the deleted segment

      CubicCurve2D removed = (CubicCurve2D) segments.remove(i);
      CubicCurve2D prev = (CubicCurve2D) segments.get(i - 1);

      prev.setCurve(prev.getP1(), prev.getCtrlP1(), removed.getCtrlP2(), removed.getP2());
    }

    changed();
    clearShapeCache();
  }
View Full Code Here

    // we normalize the position to the number of segments
    position = position * segments.size();

    // We get the appropriate segment
    CubicCurve2D curve = (CubicCurve2D) segments.get(Math.min(segments.size() - 1, (int) Math.floor(position)));

    position %= 1;

    double k1, k2, k3, k4;

    k1 = (1 - position) * (1 - position) * (1 - position);
    k2 = (1 - position) * (1 - position) * position * 3;
    k3 = (1 - position) * position * position * 3;
    k4 = position * position * position;

    ret.setLocation(k1 * curve.getX1() + k2 * curve.getCtrlX1() + k3 * curve.getCtrlX2() + k4 * curve.getX2(), k1 * curve.getY1() + k2 * curve.getCtrlY1() + k3 * curve.getCtrlY2() + k4 * curve.getY2());

    return ret;
  }
View Full Code Here

    // find the segment to this coordinates
    int i = findSegment(x, y);

    if (i != -1)
    {
      CubicCurve2D insert = new CubicCurve2D.Double();

      CubicCurve2D prev = ((CubicCurve2D) segments.get(i));

      prev.subdivide(prev, insert);

      segments.add(i + 1, insert);

      setPointAt(i + 1, new Point(x, y));
View Full Code Here

TOP

Related Classes of java.awt.geom.CubicCurve2D$Double

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.