Package com.cburch.draw.model

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.decorate(Arrays.asList(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


        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

            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

            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

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

    private CanvasObject commit(Canvas canvas) {
        if (!active) {
            return null;
        }

        CanvasObject add = null;
        active = false;
        List<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

            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;
                }

            }
View Full Code Here

    public static ModelReorderAction createRaise(CanvasModel model,
            Collection<? extends CanvasObject> objects) {
        List<ReorderRequest> reqs = new ArrayList<ReorderRequest>();
        Map<CanvasObject, Integer> zmap = ZOrder.getZIndex(objects, model);
        for(Map.Entry<CanvasObject, Integer> entry : zmap.entrySet()) {
            CanvasObject obj = entry.getKey();
            int from = entry.getValue().intValue();
            CanvasObject above = ZOrder.getObjectAbove(obj, model, objects);
            if (above != null) {
                int to = ZOrder.getZIndex(above, model);
                if (objects.contains(above)) {
                    to--;
                }
View Full Code Here

    public static ModelReorderAction createLower(CanvasModel model,
            Collection<? extends CanvasObject> objects) {
        List<ReorderRequest> reqs = new ArrayList<ReorderRequest>();
        Map<CanvasObject, Integer> zmap = ZOrder.getZIndex(objects, model);
        for(Map.Entry<CanvasObject, Integer> entry : zmap.entrySet()) {
            CanvasObject obj = entry.getKey();
            int from = entry.getValue().intValue();
            CanvasObject above = ZOrder.getObjectBelow(obj, model, objects);
            if (above != null) {
                int to = ZOrder.getZIndex(above, model);
                if (objects.contains(above)) {
                    to++;
                }
View Full Code Here

            Collection<? extends CanvasObject> objects) {
        List<ReorderRequest> reqs = new ArrayList<ReorderRequest>();
        Map<CanvasObject, Integer> zmap = ZOrder.getZIndex(objects, model);
        int to = model.getObjectsFromBottom().size() - 1;
        for(Map.Entry<CanvasObject, Integer> entry : zmap.entrySet()) {
            CanvasObject obj = entry.getKey();
            int from = entry.getValue().intValue();
            reqs.add(new ReorderRequest(obj, from, to));
        }
        if (reqs.isEmpty()) {
            return null;
View Full Code Here

TOP

Related Classes of com.cburch.draw.model.CanvasObject

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.