Examples of Handle


Examples of com.cburch.draw.model.Handle

    return true;
  }
 
  @Override
  public Handle moveHandle(HandleGesture gesture) {
    Handle h = gesture.getHandle();
    int dx = gesture.getDeltaX();
    int dy = gesture.getDeltaY();
    Handle ret = null;
    if (h.isAt(x0, y0)) {
      x0 += dx;
      y0 += dy;
      ret = new Handle(this, x0, y0);
    }
    if (h.isAt(x1, y1)) {
      x1 += dx;
      y1 += dy;
      ret = new Handle(this, x1, y1);
    }
    bounds = Bounds.create(x0, y0, 0, 0).add(x1, y1);
    return ret;
  }
View Full Code Here

Examples of com.cburch.draw.model.Handle

    if (setForStroke(g)) {
      int x0 = this.x0;
      int y0 = this.y0;
      int x1 = this.x1;
      int y1 = this.y1;
      Handle h = gesture.getHandle();
      if (h.isAt(x0, y0)) {
        x0 += gesture.getDeltaX();
        y0 += gesture.getDeltaY();
      }
      if (h.isAt(x1, y1)) {
        x1 += gesture.getDeltaX();
        y1 += gesture.getDeltaY();
      }
      g.drawLine(x0, y0, x1, y1);
    }
View Full Code Here

Examples of com.cburch.draw.model.Handle

  public Poly(boolean closed, List<Location> locations) {
    Handle[] hs = new Handle[locations.size()];
    int i = -1;
    for (Location loc : locations) {
      i++;
      hs[i] = new Handle(this, loc.getX(), loc.getY());
    }
   
    this.closed = closed;
    handles = hs;
    recomputeBounds();
View Full Code Here

Examples of com.cburch.draw.model.Handle

      lens = ls;
    }
    double pos = ls[ls.length - 1] * rand.nextDouble();
    for (int i = 0; true; i++) {
      if (pos < ls[i]) {
        Handle p = hs[i];
        Handle q = hs[(i + 1) % hs.length];
        double u = Math.random();
        int x = (int) Math.round(p.getX() + u * (q.getX() - p.getX()));
        int y = (int) Math.round(p.getY() + u * (q.getY() - p.getY()));
        return Location.create(x, y);
      }
    }
  }
View Full Code Here

Examples of com.cburch.draw.model.Handle

  @Override
  public void translate(int dx, int dy) {
    Handle[] hs = handles;
    Handle[] is = new Handle[hs.length];
    for(int i = 0; i < hs.length; i++) {
      is[i] = new Handle(this, hs[i].getX() + dx, hs[i].getY() + dy);
    }
    setHandles(is);
  }
View Full Code Here

Examples of com.cburch.draw.model.Handle

  public List<Handle> getHandles(HandleGesture gesture) {
    Handle[] hs = handles;
    if (gesture == null) {
      return UnmodifiableList.create(hs);
    } else {
      Handle g = gesture.getHandle();
      Handle[] ret = new Handle[hs.length];
      for (int i = 0, n = hs.length; i < n; i++) {
        Handle h = hs[i];
        if (h.equals(g)) {
          int x = h.getX() + gesture.getDeltaX();
          int y = h.getY() + gesture.getDeltaY();
          Location r;
          if (gesture.isShiftDown()) {
            Location prev = hs[(i + n - 1) % n].getLocation();
            Location next = hs[(i + 1) % n].getLocation();
            if (!closed) {
              if (i == 0) prev = null;
              if (i == n - 1) next = null;
            }
            if (prev == null) {
              r = LineUtil.snapTo8Cardinals(next, x, y);
            } else if (next == null) {
              r = LineUtil.snapTo8Cardinals(prev, x, y);
            } else {
              Location to = Location.create(x, y);
              Location a = LineUtil.snapTo8Cardinals(prev, x, y);
              Location b = LineUtil.snapTo8Cardinals(next, x, y);
              int ad = a.manhattanDistanceTo(to);
              int bd = b.manhattanDistanceTo(to);
              r = ad < bd ? a : b;
            }
          } else {
            r = Location.create(x, y);
          }
          ret[i] = new Handle(this, r);
        } else {
          ret[i] = h;
        }
      }
      return UnmodifiableList.create(ret);
View Full Code Here

Examples of com.cburch.draw.model.Handle

  @Override
  public Handle moveHandle(HandleGesture gesture) {
    List<Handle> hs = getHandles(gesture);
    Handle[] is = new Handle[hs.size()];
    Handle ret = null;
    int i = -1;
    for (Handle h : hs) {
      i++;
      is[i] = h;
    }
View Full Code Here

Examples of com.cburch.draw.model.Handle

      Location resLoc = result.getLocation();
      if (result.getPreviousHandle().isAt(resLoc)
          || result.getNextHandle().isAt(resLoc)) {
        return null;
      } else {
        return new Handle(this, result.getLocation());
      }
    } else {
      return null;
    }
  }
View Full Code Here

Examples of com.cburch.draw.model.Handle

 
  @Override
  public void insertHandle(Handle desired, Handle previous) {
    Location loc = desired.getLocation();
    Handle[] hs = handles;
    Handle prev;
    if (previous == null) {
      PolyUtil.ClosestResult result = PolyUtil.getClosestPoint(loc,
          closed, hs);
      prev = result.getPreviousHandle();
    } else {
View Full Code Here

Examples of com.cburch.draw.model.Handle

  @Override
  public Handle deleteHandle(Handle handle) {
    Handle[] hs = handles;
    int n = hs.length;
    Handle[] is = new Handle[n - 1];
    Handle previous = null;
    boolean deleted = false;
    for (int i = 0; i < n; i++) {
      if (deleted) {
        is[i - 1] = hs[i];
      } else if (hs[i].equals(handle)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.