Search in sources :

Example 11 with Selection

use of com.cburch.draw.canvas.Selection in project logisim-evolution by reds-heig.

the class AppearanceEditHandler method delete.

@Override
public void delete() {
    Selection sel = canvas.getSelection();
    int n = sel.getSelected().size();
    List<CanvasObject> select = new ArrayList<CanvasObject>(n);
    List<CanvasObject> remove = new ArrayList<CanvasObject>(n);
    Location anchorLocation = null;
    Direction anchorFacing = null;
    for (CanvasObject o : sel.getSelected()) {
        if (o.canRemove()) {
            remove.add(o);
        } else {
            select.add(o);
            if (o instanceof AppearanceAnchor) {
                AppearanceAnchor anchor = (AppearanceAnchor) o;
                anchorLocation = anchor.getLocation();
                anchorFacing = anchor.getFacing();
            }
        }
    }
    if (!remove.isEmpty()) {
        canvas.getProject().doAction(new SelectionAction(canvas, Strings.getter("deleteSelectionAction"), remove, null, select, anchorLocation, anchorFacing));
    }
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject) Selection(com.cburch.draw.canvas.Selection) ArrayList(java.util.ArrayList) AppearanceAnchor(com.cburch.logisim.circuit.appear.AppearanceAnchor) Direction(com.cburch.logisim.data.Direction) Location(com.cburch.logisim.data.Location)

Example 12 with Selection

use of com.cburch.draw.canvas.Selection in project logisim-evolution by reds-heig.

the class AppearanceEditHandler method selectAll.

@Override
public void selectAll() {
    Selection sel = canvas.getSelection();
    sel.setSelected(canvas.getModel().getObjectsFromBottom(), true);
    canvas.repaint();
}
Also used : Selection(com.cburch.draw.canvas.Selection)

Example 13 with Selection

use of com.cburch.draw.canvas.Selection in project logisim-evolution by reds-heig.

the class AppearanceEditHandler method removeControlPoint.

@Override
public void removeControlPoint() {
    Selection sel = canvas.getSelection();
    Handle handle = sel.getSelectedHandle();
    canvas.doAction(new ModelDeleteHandleAction(canvas.getModel(), handle));
}
Also used : ModelDeleteHandleAction(com.cburch.draw.actions.ModelDeleteHandleAction) Selection(com.cburch.draw.canvas.Selection) Handle(com.cburch.draw.model.Handle)

Example 14 with Selection

use of com.cburch.draw.canvas.Selection in project logisim-evolution by reds-heig.

the class SelectionAction method undo.

@Override
public void undo(Project proj) {
    AppearanceAnchor anchor = findAnchor(canvasModel);
    if (anchor != null && anchorOldLocation != null) {
        anchor.translate(anchorOldLocation.getX() - anchorNewLocation.getX(), anchorOldLocation.getY() - anchorNewLocation.getY());
    }
    if (anchor != null && anchorOldFacing != null) {
        anchor.setValue(AppearanceAnchor.FACING, anchorOldFacing);
    }
    Selection sel = canvas.getSelection();
    sel.clearSelected();
    if (toAdd != null)
        canvasModel.removeObjects(toAdd);
    if (toRemove != null)
        canvasModel.addObjects(toRemove);
    sel.setSelected(oldSelection, true);
    canvas.repaint();
}
Also used : Selection(com.cburch.draw.canvas.Selection) AppearanceAnchor(com.cburch.logisim.circuit.appear.AppearanceAnchor)

Aggregations

Selection (com.cburch.draw.canvas.Selection)14 CanvasObject (com.cburch.draw.model.CanvasObject)9 Handle (com.cburch.draw.model.Handle)7 HandleGesture (com.cburch.draw.model.HandleGesture)3 AppearanceAnchor (com.cburch.logisim.circuit.appear.AppearanceAnchor)3 Location (com.cburch.logisim.data.Location)3 ArrayList (java.util.ArrayList)3 CanvasModel (com.cburch.draw.model.CanvasModel)2 ModelDeleteHandleAction (com.cburch.draw.actions.ModelDeleteHandleAction)1 ModelInsertHandleAction (com.cburch.draw.actions.ModelInsertHandleAction)1 ModelMoveHandleAction (com.cburch.draw.actions.ModelMoveHandleAction)1 ModelRemoveAction (com.cburch.draw.actions.ModelRemoveAction)1 ModelTranslateAction (com.cburch.draw.actions.ModelTranslateAction)1 Circuit (com.cburch.logisim.circuit.Circuit)1 AppearanceElement (com.cburch.logisim.circuit.appear.AppearanceElement)1 Bounds (com.cburch.logisim.data.Bounds)1 Direction (com.cburch.logisim.data.Direction)1 Project (com.cburch.logisim.proj.Project)1 Graphics (java.awt.Graphics)1 Graphics2D (java.awt.Graphics2D)1