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();
}
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));
}
}
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();
}
Aggregations