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);
}
}
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;
}
}
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());
}
}
}
}
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;
}
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;
}
Aggregations