Search in sources :

Example 1 with CanvasModel

use of com.cburch.draw.model.CanvasModel in project logisim-evolution by reds-heig.

the class AppearanceCanvas method setModel.

@Override
public void setModel(CanvasModel value, ActionDispatcher dispatcher) {
    CanvasModel oldModel = super.getModel();
    if (oldModel != null) {
        oldModel.removeCanvasModelListener(listener);
    }
    super.setModel(value, dispatcher);
    if (value != null) {
        value.addCanvasModelListener(listener);
    }
}
Also used : CanvasModel(com.cburch.draw.model.CanvasModel)

Example 2 with CanvasModel

use of com.cburch.draw.model.CanvasModel in project logisim-evolution by reds-heig.

the class CurveTool method mouseReleased.

@Override
public void mouseReleased(Canvas canvas, MouseEvent e) {
    Curve c = updateMouse(canvas, e.getX(), e.getY(), e.getModifiersEx());
    mouseDown = false;
    if (state == CONTROL_DRAG) {
        if (c != null) {
            attrs.applyTo(c);
            CanvasModel model = canvas.getModel();
            canvas.doAction(new ModelAddAction(model, c));
            canvas.toolGestureComplete(this, c);
        }
        state = BEFORE_CREATION;
    }
    repaintArea(canvas);
}
Also used : ModelAddAction(com.cburch.draw.actions.ModelAddAction) Curve(com.cburch.draw.shapes.Curve) CanvasModel(com.cburch.draw.model.CanvasModel)

Example 3 with CanvasModel

use of com.cburch.draw.model.CanvasModel in project logisim-evolution by reds-heig.

the class PolyTool method commit.

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);
    }
    if (locs.size() > 1) {
        CanvasModel model = canvas.getModel();
        add = new Poly(closed, locs);
        canvas.doAction(new ModelAddAction(model, add));
        repaintArea(canvas);
    }
    locs.clear();
    return add;
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject) ModelAddAction(com.cburch.draw.actions.ModelAddAction) CanvasModel(com.cburch.draw.model.CanvasModel) Poly(com.cburch.draw.shapes.Poly) Location(com.cburch.logisim.data.Location)

Example 4 with CanvasModel

use of com.cburch.draw.model.CanvasModel in project logisim-evolution by reds-heig.

the class RectangularTool method mouseReleased.

@Override
public void mouseReleased(Canvas canvas, MouseEvent e) {
    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));
            repaintArea(canvas, oldBounds.add(bds));
        }
        canvas.toolGestureComplete(this, add);
    }
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject) Bounds(com.cburch.logisim.data.Bounds) ModelAddAction(com.cburch.draw.actions.ModelAddAction) CanvasModel(com.cburch.draw.model.CanvasModel)

Example 5 with CanvasModel

use of com.cburch.draw.model.CanvasModel in project logisim-evolution by reds-heig.

the class SelectTool method keyTyped.

@Override
public void keyTyped(Canvas canvas, KeyEvent e) {
    char ch = e.getKeyChar();
    Selection selected = canvas.getSelection();
    if ((ch == '\u0008' || ch == '\u007F') && !selected.isEmpty()) {
        ArrayList<CanvasObject> toRemove = new ArrayList<CanvasObject>();
        for (CanvasObject shape : selected.getSelected()) {
            if (shape.canRemove()) {
                toRemove.add(shape);
            }
        }
        if (!toRemove.isEmpty()) {
            e.consume();
            CanvasModel model = canvas.getModel();
            canvas.doAction(new ModelRemoveAction(model, toRemove));
            selected.clearSelected();
            repaintArea(canvas);
        }
    } else if (ch == '\u001b' && !selected.isEmpty()) {
        selected.clearSelected();
        repaintArea(canvas);
    }
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject) Selection(com.cburch.draw.canvas.Selection) ArrayList(java.util.ArrayList) ModelRemoveAction(com.cburch.draw.actions.ModelRemoveAction) CanvasModel(com.cburch.draw.model.CanvasModel)

Aggregations

CanvasModel (com.cburch.draw.model.CanvasModel)11 CanvasObject (com.cburch.draw.model.CanvasObject)6 ModelAddAction (com.cburch.draw.actions.ModelAddAction)4 Location (com.cburch.logisim.data.Location)3 Selection (com.cburch.draw.canvas.Selection)2 Poly (com.cburch.draw.shapes.Poly)2 Bounds (com.cburch.logisim.data.Bounds)2 ModelChangeAttributeAction (com.cburch.draw.actions.ModelChangeAttributeAction)1 ModelMoveHandleAction (com.cburch.draw.actions.ModelMoveHandleAction)1 ModelRemoveAction (com.cburch.draw.actions.ModelRemoveAction)1 ModelTranslateAction (com.cburch.draw.actions.ModelTranslateAction)1 AttributeMapKey (com.cburch.draw.model.AttributeMapKey)1 Handle (com.cburch.draw.model.Handle)1 HandleGesture (com.cburch.draw.model.HandleGesture)1 Curve (com.cburch.draw.shapes.Curve)1 AttributeSet (com.cburch.logisim.data.AttributeSet)1 Graphics (java.awt.Graphics)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1