use of com.cburch.draw.model.CanvasObject 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());
final var start = mouseStart;
final var end = mouseEnd;
CanvasObject add = null;
if (!start.equals(end)) {
active = false;
final var model = canvas.getModel();
Location[] ends = { start, end };
final var 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);
}
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by logisim-evolution.
the class PolyTool method commit.
private CanvasObject commit(Canvas canvas) {
if (!active)
return null;
CanvasObject add = null;
active = false;
final var locs = locations;
for (var i = locs.size() - 2; i >= 0; i--) {
if (locs.get(i).equals(locs.get(i + 1)))
locs.remove(i);
}
if (locs.size() > 1) {
final var 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.CanvasObject in project logisim-evolution by logisim-evolution.
the class RectangularTool method mouseReleased.
@Override
public void mouseReleased(Canvas canvas, MouseEvent e) {
if (active) {
final var oldBounds = currentBounds;
final var 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) {
final var 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.CanvasObject in project logisim-evolution by logisim-evolution.
the class DrawingAttributeSet method applyTo.
public <E extends CanvasObject> E applyTo(E drawable) {
AbstractCanvasObject d = (AbstractCanvasObject) drawable;
// use a for(i...) loop since the attribute list may change as we go on
for (var i = 0; i < d.getAttributes().size(); i++) {
Attribute<?> attr = d.getAttributes().get(i);
@SuppressWarnings("unchecked") Attribute<Object> a = (Attribute<Object>) attr;
if (attr == DrawAttr.FILL_COLOR && this.containsAttribute(DrawAttr.TEXT_DEFAULT_FILL)) {
d.setValue(a, this.getValue(DrawAttr.TEXT_DEFAULT_FILL));
} else if (this.containsAttribute(a)) {
d.setValue(a, this.getValue(a));
}
}
return drawable;
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by logisim-evolution.
the class LineTool method mouseReleased.
@Override
public void mouseReleased(Canvas canvas, MouseEvent e) {
if (active) {
updateMouse(canvas, e.getX(), e.getY(), e.getModifiersEx());
final var start = mouseStart;
final var end = mouseEnd;
CanvasObject add = null;
if (!start.equals(end)) {
active = false;
final var model = canvas.getModel();
Location[] ends = { start, end };
final var 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);
}
}
Aggregations