use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.
the class LayoutEditHandler method duplicate.
@Override
public void duplicate() {
Project proj = frame.getProject();
Selection sel = frame.getCanvas().getSelection();
proj.doAction(SelectionActions.duplicate(sel));
}
use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.
the class LayoutEditHandler method paste.
@Override
public void paste() {
Project proj = frame.getProject();
Selection sel = frame.getCanvas().getSelection();
selectSelectTool(proj);
Action action = SelectionActions.pasteMaybe(proj, sel);
if (action != null) {
proj.doAction(action);
}
}
use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.
the class SelectionAttributes method isReadOnly.
@Override
public boolean isReadOnly(Attribute<?> attr) {
Project proj = canvas.getProject();
Circuit circ = canvas.getCircuit();
if (!proj.getLogisimFile().contains(circ)) {
return true;
} else if (selected.isEmpty() && circ != null) {
return circ.getStaticAttributes().isReadOnly(attr);
} else {
int i = findIndex(attr);
boolean[] ro = readOnly;
return i >= 0 && i < ro.length ? ro[i] : true;
}
}
use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.
the class AppearanceEditHandler method computeEnabled.
@Override
public void computeEnabled() {
Project proj = canvas.getProject();
Circuit circ = canvas.getCircuit();
Selection sel = canvas.getSelection();
boolean selEmpty = sel.isEmpty();
boolean canChange = proj.getLogisimFile().contains(circ);
boolean clipExists = !Clipboard.isEmpty();
boolean selHasRemovable = false;
for (CanvasObject o : sel.getSelected()) {
if (!(o instanceof AppearanceElement)) {
selHasRemovable = true;
}
}
boolean canRaise;
boolean canLower;
if (!selEmpty && canChange) {
Map<CanvasObject, Integer> zs = ZOrder.getZIndex(sel.getSelected(), canvas.getModel());
int zmin = Integer.MAX_VALUE;
int zmax = Integer.MIN_VALUE;
int count = 0;
for (Map.Entry<CanvasObject, Integer> entry : zs.entrySet()) {
if (!(entry.getKey() instanceof AppearanceElement)) {
count++;
int z = entry.getValue().intValue();
if (z < zmin)
zmin = z;
if (z > zmax)
zmax = z;
}
}
int maxPoss = AppearanceCanvas.getMaxIndex(canvas.getModel());
if (count > 0 && count <= maxPoss) {
canRaise = zmin <= maxPoss - count;
canLower = zmax >= count;
} else {
canRaise = false;
canLower = false;
}
} else {
canRaise = false;
canLower = false;
}
boolean canAddCtrl = false;
boolean canRemCtrl = false;
Handle handle = sel.getSelectedHandle();
if (handle != null && canChange) {
CanvasObject o = handle.getObject();
canAddCtrl = o.canInsertHandle(handle.getLocation()) != null;
canRemCtrl = o.canDeleteHandle(handle.getLocation()) != null;
}
setEnabled(LogisimMenuBar.CUT, selHasRemovable && canChange);
setEnabled(LogisimMenuBar.COPY, !selEmpty);
setEnabled(LogisimMenuBar.PASTE, canChange && clipExists);
setEnabled(LogisimMenuBar.DELETE, selHasRemovable && canChange);
setEnabled(LogisimMenuBar.DUPLICATE, !selEmpty && canChange);
setEnabled(LogisimMenuBar.SELECT_ALL, true);
setEnabled(LogisimMenuBar.RAISE, canRaise);
setEnabled(LogisimMenuBar.LOWER, canLower);
setEnabled(LogisimMenuBar.RAISE_TOP, canRaise);
setEnabled(LogisimMenuBar.LOWER_BOTTOM, canLower);
setEnabled(LogisimMenuBar.ADD_CONTROL, canAddCtrl);
setEnabled(LogisimMenuBar.REMOVE_CONTROL, canRemCtrl);
}
use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.
the class ProjectExplorerModel method setProject.
public void setProject(Project value) {
Project old = proj;
if (old != null) {
old.removeProjectListener(this);
}
setLogisimFile(null);
proj = value;
if (value != null) {
value.addProjectListener(this);
setLogisimFile(value.getLogisimFile());
}
}
Aggregations