Search in sources :

Example 36 with CanvasObject

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

the class RevertAppearanceAction method doIt.

@Override
public void doIt(Project proj) {
    CircuitAppearance appear = circuit.getAppearance();
    wasDefault = appear.isDefaultAppearance();
    old = new ArrayList<CanvasObject>(appear.getObjectsFromBottom());
    appear.setDefaultAppearance(true);
}
Also used : CircuitAppearance(com.cburch.logisim.circuit.appear.CircuitAppearance) CanvasObject(com.cburch.draw.model.CanvasObject)

Example 37 with CanvasObject

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

the class Selection method setMovingShapes.

public void setMovingShapes(Collection<? extends CanvasObject> shapes, int dx, int dy) {
    for (CanvasObject o : shapes) {
        suppressed.put(o, TRANSLATING);
    }
    moveDx = dx;
    moveDy = dy;
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject)

Example 38 with CanvasObject

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

the class Selection method setSelected.

public void setSelected(Collection<CanvasObject> shapes, boolean value) {
    if (value) {
        List<CanvasObject> added;
        added = new ArrayList<CanvasObject>(shapes.size());
        for (CanvasObject shape : shapes) {
            if (selected.add(shape)) {
                added.add(shape);
            }
        }
        if (!added.isEmpty()) {
            fireChanged(SelectionEvent.ACTION_ADDED, added);
        }
    } else {
        List<CanvasObject> removed;
        removed = new ArrayList<CanvasObject>(shapes.size());
        for (CanvasObject shape : shapes) {
            if (selected.remove(shape)) {
                suppressed.remove(shape);
                Handle h = selectedHandle;
                if (h != null && h.getObject() == shape)
                    setHandleSelected(null);
                removed.add(shape);
            }
        }
        if (!removed.isEmpty()) {
            fireChanged(SelectionEvent.ACTION_REMOVED, removed);
        }
    }
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject) Handle(com.cburch.draw.model.Handle)

Example 39 with CanvasObject

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

the class Selection method toggleSelected.

public void toggleSelected(Collection<CanvasObject> shapes) {
    List<CanvasObject> added;
    added = new ArrayList<CanvasObject>(shapes.size());
    List<CanvasObject> removed;
    removed = new ArrayList<CanvasObject>(shapes.size());
    for (CanvasObject shape : shapes) {
        if (selected.contains(shape)) {
            selected.remove(shape);
            suppressed.remove(shape);
            Handle h = selectedHandle;
            if (h != null && h.getObject() == shape)
                setHandleSelected(null);
            removed.add(shape);
        } else {
            selected.add(shape);
            added.add(shape);
        }
    }
    if (!removed.isEmpty()) {
        fireChanged(SelectionEvent.ACTION_REMOVED, removed);
    }
    if (!added.isEmpty()) {
        fireChanged(SelectionEvent.ACTION_ADDED, added);
    }
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject) Handle(com.cburch.draw.model.Handle)

Example 40 with CanvasObject

use of com.cburch.draw.model.CanvasObject in project logisim-evolution by logisim-evolution.

the class PolyTool method commit.

private CanvasObject commit(Canvas canvas) {
    if (!active)
        return null;
    CanvasObject add = null;
    active = false;
    final var locs = locations;
    for (var i = locs.size() - 2; i >= 0; i--) {
        if (locs.get(i).equals(locs.get(i + 1)))
            locs.remove(i);
    }
    if (locs.size() > 1) {
        final var 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) Poly(com.cburch.draw.shapes.Poly)

Aggregations

CanvasObject (com.cburch.draw.model.CanvasObject)45 Location (com.cburch.logisim.data.Location)15 ArrayList (java.util.ArrayList)13 Handle (com.cburch.draw.model.Handle)9 Selection (com.cburch.draw.canvas.Selection)8 ModelAddAction (com.cburch.draw.actions.ModelAddAction)7 Direction (com.cburch.logisim.data.Direction)5 HandleGesture (com.cburch.draw.model.HandleGesture)4 Poly (com.cburch.draw.shapes.Poly)4 Instance (com.cburch.logisim.instance.Instance)4 Map (java.util.Map)4 Rectangle (com.cburch.draw.shapes.Rectangle)3 HashMap (java.util.HashMap)3 AbstractCanvasObject (com.cburch.draw.model.AbstractCanvasObject)2 CanvasModel (com.cburch.draw.model.CanvasModel)2 Circuit (com.cburch.logisim.circuit.Circuit)2 AppearanceElement (com.cburch.logisim.circuit.appear.AppearanceElement)2 AppearancePort (com.cburch.logisim.circuit.appear.AppearancePort)2 Attribute (com.cburch.logisim.data.Attribute)2 Bounds (com.cburch.logisim.data.Bounds)2