use of com.cburch.draw.model.CanvasObject in project logisim-evolution by logisim-evolution.
the class CanvasListener method handlePopupTrigger.
private void handlePopupTrigger(MouseEvent e) {
final var loc = Location.create(e.getX(), e.getY());
final var objects = canvas.getModel().getObjectsFromTop();
CanvasObject clicked = null;
for (final var o : objects) {
if (o.contains(loc, false)) {
clicked = o;
break;
}
}
if (clicked == null) {
for (final var o : objects) {
if (o.contains(loc, true)) {
clicked = o;
break;
}
}
}
canvas.showPopupMenu(e, clicked);
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by logisim-evolution.
the class AttrTableSelectionModel method getTitle.
@Override
public String getTitle() {
final var sel = canvas.getSelection();
Class<? extends CanvasObject> commonClass = null;
var commonCount = 0;
CanvasObject firstObject = null;
var totalCount = 0;
for (final var obj : sel.getSelected()) {
if (firstObject == null) {
firstObject = obj;
commonClass = obj.getClass();
commonCount = 1;
} else if (obj.getClass() == commonClass) {
commonCount++;
} else {
commonClass = null;
}
totalCount++;
}
if (firstObject == null) {
return null;
} else if (commonClass == null) {
return S.get("selectionVarious", "" + totalCount);
} else if (commonCount == 1) {
return firstObject.getDisplayNameAndLabel();
} else {
return S.get("selectionMultiple", firstObject.getDisplayName(), "" + commonCount);
}
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by reds-heig.
the class AttrTableSelectionModel method getTitle.
@Override
public String getTitle() {
final var sel = canvas.getSelection();
Class<? extends CanvasObject> commonClass = null;
var commonCount = 0;
CanvasObject firstObject = null;
var totalCount = 0;
for (final var obj : sel.getSelected()) {
if (firstObject == null) {
firstObject = obj;
commonClass = obj.getClass();
commonCount = 1;
} else if (obj.getClass() == commonClass) {
commonCount++;
} else {
commonClass = null;
}
totalCount++;
}
if (firstObject == null) {
return null;
} else if (commonClass == null) {
return S.get("selectionVarious", "" + totalCount);
} else if (commonCount == 1) {
return firstObject.getDisplayNameAndLabel();
} else {
return S.get("selectionMultiple", firstObject.getDisplayName(), "" + commonCount);
}
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by reds-heig.
the class CanvasListener method handlePorts.
private void handlePorts(MouseEvent e) {
final var loc = Location.create(e.getX(), e.getY());
final var objects = canvas.getModel().getObjectsFromTop();
final var ports = new ArrayList<CanvasObject>();
CanvasObject newSelectedPort = null;
for (final var object : objects) {
if (object instanceof AppearancePort)
ports.add(object);
}
for (final var port : ports) {
if (port.contains(loc, false) || port.contains(loc, true)) {
newSelectedPort = port;
}
}
if (newSelectedPort != selectedPort) {
if (newSelectedPort == null) {
canvas.setTooltip(null, null);
canvas.repaint(canvas.getVisibleRect());
} else {
canvas.setTooltip(loc, newSelectedPort.getDisplayNameAndLabel());
canvas.repaint(canvas.getVisibleRect());
}
selectedPort = newSelectedPort;
}
}
use of com.cburch.draw.model.CanvasObject 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;
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;
}
Aggregations