use of com.cburch.draw.model.CanvasObject in project logisim-evolution by reds-heig.
the class ZOrder method sortXFirst.
private static <E extends CanvasObject> List<E> sortXFirst(Collection<E> objects, CanvasModel model, Collection<CanvasObject> objs) {
Set<E> set = toSet(objects);
List<E> ret = new ArrayList<E>(objects.size());
for (CanvasObject o : objs) {
if (set.contains(o)) {
@SuppressWarnings("unchecked") E toAdd = (E) o;
ret.add(toAdd);
}
}
return ret;
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by reds-heig.
the class ZOrder method getZIndex.
public static Map<CanvasObject, Integer> getZIndex(Collection<? extends CanvasObject> query, CanvasModel model) {
// from the bottom up.
if (query == null)
return Collections.emptyMap();
Set<? extends CanvasObject> querySet = toSet(query);
Map<CanvasObject, Integer> ret;
ret = new LinkedHashMap<CanvasObject, Integer>(query.size());
int z = -1;
for (CanvasObject o : model.getObjectsFromBottom()) {
z++;
if (querySet.contains(o)) {
ret.put(o, Integer.valueOf(z));
}
}
return ret;
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by reds-heig.
the class Main method main.
public static void main(String[] args) {
DrawingAttributeSet attrs = new DrawingAttributeSet();
Drawing model = new Drawing();
CanvasObject rect = attrs.applyTo(new Rectangle(25, 25, 50, 50));
model.addObjects(0, Collections.singleton(rect));
showFrame(model, "Drawing 1");
showFrame(model, "Drawing 2");
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by reds-heig.
the class Selection method setHandleSelected.
public void setHandleSelected(Handle handle) {
Handle cur = selectedHandle;
boolean same = cur == null ? handle == null : cur.equals(handle);
if (!same) {
selectedHandle = handle;
curHandleGesture = null;
Collection<CanvasObject> objs;
if (handle == null) {
objs = Collections.emptySet();
} else {
objs = Collections.singleton(handle.getObject());
}
fireChanged(SelectionEvent.ACTION_HANDLE, objs);
}
}
use of com.cburch.draw.model.CanvasObject in project logisim-evolution by logisim-evolution.
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;
}
}
Aggregations