Examples of CanvasObject


Examples of com.cburch.draw.model.CanvasObject

    // check that the anchor and all ports are in their proper places.
    List<CanvasObject> shapes = new ArrayList<CanvasObject>(shapesBase);
    int n = shapes.size();
    int ports = 0;
    for (int i = n - 1; i >= 0; i--) { // count ports, move anchor to end
      CanvasObject o = shapes.get(i);
      if (o instanceof AppearanceAnchor) {
        if (i != n - 1) {
          shapes.remove(i);
          shapes.add(o);
        }
      } else if (o instanceof AppearancePort) {
        ports++;
      }
    }
    for (int i = (n - ports - 1) - 1; i >= 0; i--) { // move ports to top
      CanvasObject o = shapes.get(i);
      if (o instanceof AppearancePort) {
        shapes.remove(i);
        shapes.add(n - ports - 1, o);
        i--;
      }
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

  public void mouseReleased(Canvas canvas, MouseEvent e) {
    if (active) {
      updateMouse(canvas, e.getX(), e.getY(), e.getModifiersEx());
      Location start = mouseStart;
      Location end = mouseEnd;
      CanvasObject add = null;
      if (!start.equals(end)) {
        active = false;
        CanvasModel model = canvas.getModel();
        Location[] ends = { start, end };
        List<Location> locs = UnmodifiableList.create(ends);
        add = attrs.applyTo(new Poly(false, locs));
        add.setValue(DrawAttr.PAINT_TYPE, DrawAttr.PAINT_STROKE);
        canvas.doAction(new ModelAddAction(model, add));
        repaintArea(canvas);
      }
      canvas.toolGestureComplete(this, add);
    }
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

      return null;
    } else {
      Set<CanvasObject> set = toSet(model.getObjectsOverlapping(query));
      ListIterator<CanvasObject> it = objs.listIterator(index);
      while (it.hasPrevious()) {
        CanvasObject o = it.previous();
        if (set.contains(o) && !ignore.contains(o)) return o;
      }
      return null;
    }
  }
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

      List<ReorderRequest> rs = reorder.getReorderRequests();
      List<ReorderRequest> mod = new ArrayList<ReorderRequest>(rs.size());
      boolean changed = false;
      boolean movedToMax = false;
      for (ReorderRequest r : rs) {
        CanvasObject o = r.getObject();
        if (o instanceof AppearanceElement) {
          changed = true;
        } else {
          if (r.getToIndex() > max) {
            int from = r.getFromIndex();
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

    return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
  }
 
  @Override
  public void toolDeselected(Canvas canvas) {
    CanvasObject add = commit(canvas);
    canvas.toolGestureComplete(this, add);
    repaintArea(canvas);
  }
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

      mx = canvas.snapX(mx);
      my = canvas.snapY(my);
    }

    if (active && e.getClickCount() > 1) {
      CanvasObject add = commit(canvas);
      canvas.toolGestureComplete(this, add);
      return;
    }

    Location loc = Location.create(mx, my);
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

      if (size >= 3) {
        Location first = locations.get(0);
        Location last = locations.get(size - 1);
        if (first.manhattanDistanceTo(last) <= CLOSE_TOLERANCE) {
          locations.remove(size - 1);
          CanvasObject add = commit(canvas);
          canvas.toolGestureComplete(this, add);
        }
      }
    }
  }
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

        active = false;
        locations.clear();
        repaintArea(canvas);
        canvas.toolGestureComplete(this, null);
      } else if (ch == '\n') { // enter key
        CanvasObject add = commit(canvas);
        canvas.toolGestureComplete(this, add);
      }
    }
  }
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

    }
  }
 
  private CanvasObject commit(Canvas canvas) {
    if (!active) return null;
    CanvasObject add = null;
    active = false;
    ArrayList<Location> locs = locations;
    for(int i = locs.size() - 2; i >= 0; i--) {
      if (locs.get(i).equals(locs.get(i + 1))) locs.remove(i);
    }
View Full Code Here

Examples of com.cburch.draw.model.CanvasObject

    if (active) {
      Bounds oldBounds = currentBounds;
      Bounds bds = computeBounds(canvas, e.getX(), e.getY(), e.getModifiersEx());
      currentBounds = Bounds.EMPTY_BOUNDS;
      active = false;
      CanvasObject add = null;
      if (bds.getWidth() != 0 && bds.getHeight() != 0) {
        CanvasModel model = canvas.getModel();
        add = createShape(bds.getX(), bds.getY(),
            bds.getWidth(), bds.getHeight());
        canvas.doAction(new ModelAddAction(model, add));
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.