Search in sources :

Example 1 with AppearanceAnchor

use of com.cburch.logisim.circuit.appear.AppearanceAnchor in project logisim-evolution by reds-heig.

the class SelectionAction method doIt.

@Override
public void doIt(Project proj) {
    Selection sel = canvas.getSelection();
    sel.clearSelected();
    if (toRemove != null)
        canvasModel.removeObjects(toRemove.keySet());
    int dest = AppearanceCanvas.getMaxIndex(canvasModel) + 1;
    if (toAdd != null)
        canvasModel.addObjects(dest, toAdd);
    AppearanceAnchor anchor = findAnchor(canvasModel);
    if (anchor != null && anchorNewLocation != null) {
        anchorOldLocation = anchor.getLocation();
        anchor.translate(anchorNewLocation.getX() - anchorOldLocation.getX(), anchorNewLocation.getY() - anchorOldLocation.getY());
    }
    if (anchor != null && anchorNewFacing != null) {
        anchorOldFacing = anchor.getFacing();
        anchor.setValue(AppearanceAnchor.FACING, anchorNewFacing);
    }
    sel.setSelected(newSelection, true);
    canvas.repaint();
}
Also used : Selection(com.cburch.draw.canvas.Selection) AppearanceAnchor(com.cburch.logisim.circuit.appear.AppearanceAnchor)

Example 2 with AppearanceAnchor

use of com.cburch.logisim.circuit.appear.AppearanceAnchor 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 3 with AppearanceAnchor

use of com.cburch.logisim.circuit.appear.AppearanceAnchor 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)3 AppearanceAnchor (com.cburch.logisim.circuit.appear.AppearanceAnchor)3 CanvasObject (com.cburch.draw.model.CanvasObject)1 Direction (com.cburch.logisim.data.Direction)1 Location (com.cburch.logisim.data.Location)1 ArrayList (java.util.ArrayList)1