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