Search in sources :

Example 6 with ModelAddAction

use of com.cburch.draw.actions.ModelAddAction in project logisim-evolution by reds-heig.

the class LineTool method mouseReleased.

@Override
public void mouseReleased(Canvas canvas, MouseEvent e) {
    if (active) {
        updateMouse(canvas, e.getX(), e.getY(), e.getModifiersEx());
        Location start = mouseStart;
        Location end = mouseEnd;
        CanvasObject add = null;
        if (!start.equals(end)) {
            active = false;
            CanvasModel model = canvas.getModel();
            Location[] ends = { start, end };
            List<Location> locs = UnmodifiableList.create(ends);
            add = attrs.applyTo(new Poly(false, locs));
            add.setValue(DrawAttr.PAINT_TYPE, DrawAttr.PAINT_STROKE);
            canvas.doAction(new ModelAddAction(model, add));
            repaintArea(canvas);
        }
        canvas.toolGestureComplete(this, add);
    }
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject) ModelAddAction(com.cburch.draw.actions.ModelAddAction) CanvasModel(com.cburch.draw.model.CanvasModel) Poly(com.cburch.draw.shapes.Poly) Location(com.cburch.logisim.data.Location)

Aggregations

ModelAddAction (com.cburch.draw.actions.ModelAddAction)6 CanvasModel (com.cburch.draw.model.CanvasModel)4 CanvasObject (com.cburch.draw.model.CanvasObject)4 Poly (com.cburch.draw.shapes.Poly)2 Location (com.cburch.logisim.data.Location)2 ModelEditTextAction (com.cburch.draw.actions.ModelEditTextAction)1 ModelRemoveAction (com.cburch.draw.actions.ModelRemoveAction)1 ModelReorderAction (com.cburch.draw.actions.ModelReorderAction)1 ReorderRequest (com.cburch.draw.model.ReorderRequest)1 Curve (com.cburch.draw.shapes.Curve)1 Text (com.cburch.draw.shapes.Text)1 Circuit (com.cburch.logisim.circuit.Circuit)1 AppearanceElement (com.cburch.logisim.circuit.appear.AppearanceElement)1 Bounds (com.cburch.logisim.data.Bounds)1 ArrayList (java.util.ArrayList)1