Search in sources :

Example 6 with Project

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));
}
Also used : Project(com.cburch.logisim.proj.Project)

Example 7 with Project

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);
    }
}
Also used : Project(com.cburch.logisim.proj.Project) Action(com.cburch.logisim.proj.Action)

Example 8 with Project

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;
    }
}
Also used : Project(com.cburch.logisim.proj.Project) Circuit(com.cburch.logisim.circuit.Circuit)

Example 9 with Project

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);
}
Also used : Project(com.cburch.logisim.proj.Project) CanvasObject(com.cburch.draw.model.CanvasObject) Selection(com.cburch.draw.canvas.Selection) Circuit(com.cburch.logisim.circuit.Circuit) AppearanceElement(com.cburch.logisim.circuit.appear.AppearanceElement) Map(java.util.Map) Handle(com.cburch.draw.model.Handle)

Example 10 with Project

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());
    }
}
Also used : Project(com.cburch.logisim.proj.Project)

Aggregations

Project (com.cburch.logisim.proj.Project)26 Circuit (com.cburch.logisim.circuit.Circuit)11 Component (com.cburch.logisim.comp.Component)7 Location (com.cburch.logisim.data.Location)5 Action (com.cburch.logisim.proj.Action)5 AttributeSet (com.cburch.logisim.data.AttributeSet)3 Bounds (com.cburch.logisim.data.Bounds)3 Selection (com.cburch.logisim.gui.main.Selection)3 Wire (com.cburch.logisim.circuit.Wire)2 ComponentUserEvent (com.cburch.logisim.comp.ComponentUserEvent)2 LoadFailedException (com.cburch.logisim.file.LoadFailedException)2 Loader (com.cburch.logisim.file.Loader)2 ToolAttributeAction (com.cburch.logisim.gui.main.ToolAttributeAction)2 MoveGesture (com.cburch.logisim.tools.move.MoveGesture)2 MoveResult (com.cburch.logisim.tools.move.MoveResult)2 File (java.io.File)2 IOException (java.io.IOException)2 Map (java.util.Map)2 Selection (com.cburch.draw.canvas.Selection)1 CanvasObject (com.cburch.draw.model.CanvasObject)1