Search in sources :

Example 16 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class ToolboxManip method selectionChanged.

public void selectionChanged(ProjectExplorerEvent event) {
    Object selected = event.getTarget();
    if (selected instanceof ProjectExplorerToolNode) {
        Tool tool = ((ProjectExplorerToolNode) selected).getValue();
        if (selected instanceof AddTool) {
            AddTool addTool = (AddTool) tool;
            ComponentFactory source = addTool.getFactory();
            if (source instanceof SubcircuitFactory) {
                SubcircuitFactory circFact = (SubcircuitFactory) source;
                Circuit circ = circFact.getSubcircuit();
                if (proj.getCurrentCircuit() == circ) {
                    AttrTableModel m = new AttrTableCircuitModel(proj, circ);
                    proj.getFrame().setAttrTableModel(m);
                    return;
                }
            }
        }
        // This was causing the selection to lag behind double-clicks,
        // commented-out
        // lastSelected = proj.getTool();
        proj.setTool(tool);
        proj.getFrame().viewAttributes(tool);
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) AttrTableModel(com.cburch.logisim.gui.generic.AttrTableModel) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 17 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class ToolboxManip method menuRequested.

public JPopupMenu menuRequested(ProjectExplorerEvent event) {
    Object clicked = event.getTarget();
    if (clicked instanceof ProjectExplorerToolNode) {
        Tool baseTool = ((ProjectExplorerToolNode) clicked).getValue();
        if (baseTool instanceof AddTool) {
            AddTool tool = (AddTool) baseTool;
            ComponentFactory source = tool.getFactory();
            if (source instanceof SubcircuitFactory) {
                Circuit circ = ((SubcircuitFactory) source).getSubcircuit();
                return Popups.forCircuit(proj, tool, circ);
            } else {
                return null;
            }
        } else {
            return null;
        }
    } else if (clicked instanceof ProjectExplorerLibraryNode) {
        Library lib = ((ProjectExplorerLibraryNode) clicked).getValue();
        if (lib == proj.getLogisimFile()) {
            return Popups.forProject(proj);
        } else {
            boolean is_top = event.getTreePath().getPathCount() <= 2;
            return Popups.forLibrary(proj, lib, is_top);
        }
    } else {
        return null;
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool) ProjectExplorerLibraryNode(com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode) Library(com.cburch.logisim.tools.Library) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 18 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class ToolboxManip method deleteRequested.

public void deleteRequested(ProjectExplorerEvent event) {
    Object request = event.getTarget();
    if (request instanceof ProjectExplorerLibraryNode) {
        Library lib = ((ProjectExplorerLibraryNode) request).getValue();
        ProjectLibraryActions.doUnloadLibrary(proj, lib);
    } else if (request instanceof ProjectExplorerToolNode) {
        Tool tool = ((ProjectExplorerToolNode) request).getValue();
        if (tool instanceof AddTool) {
            ComponentFactory factory = ((AddTool) tool).getFactory();
            if (factory instanceof SubcircuitFactory) {
                SubcircuitFactory circFact = (SubcircuitFactory) factory;
                ProjectCircuitActions.doRemoveCircuit(proj, circFact.getSubcircuit());
            }
        }
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) ProjectExplorerLibraryNode(com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode) Library(com.cburch.logisim.tools.Library) AddTool(com.cburch.logisim.tools.AddTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 19 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class FileStatistics method doSimpleCount.

private static Map<ComponentFactory, Count> doSimpleCount(Circuit circuit) {
    Map<ComponentFactory, Count> counts;
    counts = new HashMap<ComponentFactory, Count>();
    for (Component comp : circuit.getNonWires()) {
        ComponentFactory factory = comp.getFactory();
        Count count = counts.get(factory);
        if (count == null) {
            count = new Count(factory);
            counts.put(factory, count);
        }
        count.simpleCount++;
    }
    return counts;
}
Also used : ComponentFactory(com.cburch.logisim.comp.ComponentFactory) Component(com.cburch.logisim.comp.Component)

Example 20 with ComponentFactory

use of com.cburch.logisim.comp.ComponentFactory in project logisim-evolution by reds-heig.

the class FileStatistics method sortCounts.

private static List<Count> sortCounts(Map<ComponentFactory, Count> counts, LogisimFile file) {
    List<Count> ret = new ArrayList<Count>();
    for (AddTool tool : file.getTools()) {
        ComponentFactory factory = tool.getFactory();
        Count count = counts.get(factory);
        if (count != null) {
            count.library = file;
            ret.add(count);
        }
    }
    for (Library lib : file.getLibraries()) {
        for (Tool tool : lib.getTools()) {
            if (tool instanceof AddTool) {
                ComponentFactory factory = ((AddTool) tool).getFactory();
                Count count = counts.get(factory);
                if (count != null) {
                    count.library = lib;
                    ret.add(count);
                }
            }
        }
    }
    return ret;
}
Also used : ComponentFactory(com.cburch.logisim.comp.ComponentFactory) ArrayList(java.util.ArrayList) AddTool(com.cburch.logisim.tools.AddTool) Library(com.cburch.logisim.tools.Library) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Aggregations

ComponentFactory (com.cburch.logisim.comp.ComponentFactory)37 AttributeSet (com.cburch.logisim.data.AttributeSet)16 AddTool (com.cburch.logisim.tools.AddTool)9 Tool (com.cburch.logisim.tools.Tool)9 Circuit (com.cburch.logisim.circuit.Circuit)8 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)8 Component (com.cburch.logisim.comp.Component)8 Library (com.cburch.logisim.tools.Library)8 ArrayList (java.util.ArrayList)6 Wire (com.cburch.logisim.circuit.Wire)4 Location (com.cburch.logisim.data.Location)4 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)4 HashSet (java.util.HashSet)4 Attribute (com.cburch.logisim.data.Attribute)3 Bounds (com.cburch.logisim.data.Bounds)3 ToolAttributeAction (com.cburch.logisim.gui.main.ToolAttributeAction)3 Action (com.cburch.logisim.proj.Action)3 HashMap (java.util.HashMap)3 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)2 Direction (com.cburch.logisim.data.Direction)2