本文整理汇总了Java中com.cburch.logisim.circuit.SubcircuitFactory类的典型用法代码示例。如果您正苦于以下问题:Java SubcircuitFactory类的具体用法?Java SubcircuitFactory怎么用?Java SubcircuitFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubcircuitFactory类属于com.cburch.logisim.circuit包,在下文中一共展示了SubcircuitFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: libraryChanged
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void libraryChanged(LibraryEvent event) {
int action = event.getAction();
if (action == LibraryEvent.REMOVE_LIBRARY) {
Library unloaded = (Library) event.getData();
if (tool != null && unloaded.containsFromSource(tool)) {
setTool(null);
}
} else if (action == LibraryEvent.REMOVE_TOOL) {
Object data = event.getData();
if (data instanceof AddTool) {
Object factory = ((AddTool) data).getFactory();
if (factory instanceof SubcircuitFactory) {
SubcircuitFactory fact = (SubcircuitFactory) factory;
if (fact.getSubcircuit() == getCurrentCircuit()) {
setCurrentCircuit(file.getMainCircuit());
}
}
}
}
}
示例2: getTotal
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
private static Count getTotal(List<Count> counts, Set<Circuit> exclude) {
Count ret = new Count(null);
for (Count count : counts) {
ComponentFactory factory = count.getFactory();
Circuit factoryCirc = null;
if (factory instanceof SubcircuitFactory) {
factoryCirc = ((SubcircuitFactory) factory).getSubcircuit();
}
if (exclude == null || !exclude.contains(factoryCirc)) {
ret.simpleCount += count.simpleCount;
ret.uniqueCount += count.uniqueCount;
ret.recursiveCount += count.recursiveCount;
}
}
return ret;
}
示例3: removeCircuit
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public void removeCircuit(Circuit circuit) {
if (tools.size() <= 1) {
throw new RuntimeException("Cannot remove last circuit");
}
int index = getCircuits().indexOf(circuit);
if (index >= 0) {
Tool circuitTool = tools.remove(index);
if (main == circuit) {
AddTool dflt_tool = tools.get(0);
SubcircuitFactory factory = (SubcircuitFactory) dflt_tool.getFactory();
setMainCircuit(factory.getSubcircuit());
}
fireEvent(LibraryEvent.REMOVE_TOOL, circuitTool);
}
}
示例4: mousePressed
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
// verify the addition would be valid
Circuit circ = canvas.getCircuit();
if (!canvas.getProject().getLogisimFile().contains(circ)) {
canvas.setErrorMessage(Strings.getter("cannotModifyError"));
return;
}
if (factory instanceof SubcircuitFactory) {
SubcircuitFactory circFact = (SubcircuitFactory) factory;
Dependencies depends = canvas.getProject().getDependencies();
if (!depends.canAdd(circ, circFact.getSubcircuit())) {
canvas.setErrorMessage(Strings.getter("circularError"));
return;
}
}
if (shouldSnap)
Canvas.snapToGrid(e);
moveTo(canvas, g, e.getX(), e.getY());
setState(canvas, SHOW_ADD);
}
示例5: findComponentFactory
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
private static ComponentFactory findComponentFactory(ComponentFactory factory, ArrayList<Library> libs,
boolean acceptNameMatch) {
String name = factory.getName();
for (Library lib : libs) {
for (Tool tool : lib.getTools()) {
if (tool instanceof AddTool) {
AddTool addTool = (AddTool) tool;
if (name.equals(addTool.getName())) {
ComponentFactory fact = addTool.getFactory(true);
if (acceptNameMatch) {
return fact;
} else if (fact == factory) {
return fact;
} else if (fact.getClass() == factory.getClass() && !(fact instanceof SubcircuitFactory)) {
return fact;
}
}
}
}
}
return null;
}
示例6: doubleClicked
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void doubleClicked(ProjectExplorer.Event event) {
Object clicked = event.getTarget();
if (clicked instanceof AddTool) {
AddTool tool = (AddTool) clicked;
ComponentFactory source = tool.getFactory();
if (source instanceof SubcircuitFactory) {
SubcircuitFactory circFact = (SubcircuitFactory) source;
proj.setCurrentCircuit(circFact.getSubcircuit());
proj.getFrame().setEditorView(Frame.EDIT_LAYOUT);
proj.getFrame().getCanvas().autoZoomCenter();
if (lastSelected != null)
proj.setTool(lastSelected);
}
}
}
示例7: menuRequested
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public JPopupMenu menuRequested(ProjectExplorer.Event event) {
Object clicked = event.getTarget();
if (clicked instanceof AddTool) {
AddTool tool = (AddTool) clicked;
ComponentFactory source = tool.getFactory();
if (source instanceof SubcircuitFactory) {
Circuit circ = ((SubcircuitFactory) source).getSubcircuit();
return Popups.forCircuit(proj, tool, circ);
} else {
return null;
}
} else if (clicked instanceof Tool) {
return null;
} else if (clicked == proj.getLogisimFile()) {
return Popups.forProject(proj);
} else if (clicked instanceof Library) {
boolean is_top = event.getTreePath().getPathCount() <= 2;
return Popups.forLibrary(proj, (Library) clicked, is_top);
} else {
return null;
}
}
示例8: selectionChanged
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void selectionChanged(ProjectExplorer.Event event) {
Object selected = event.getTarget();
if (selected instanceof Tool) {
if (selected instanceof AddTool) {
AddTool addTool = (AddTool) selected;
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;
}
}
}
lastSelected = proj.getTool();
Tool tool = (Tool) selected;
proj.setTool(tool);
proj.getFrame().viewAttributes(tool);
}
}
示例9: SelectionItem
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public SelectionItem(Model model, Component[] path, Component comp, Object option) {
this.model = model;
this.path = path;
this.comp = comp;
this.option = option;
computeDescriptors();
if (path != null) {
model.getCircuitState().getCircuit().addCircuitListener(this);
for (int i = 0; i < path.length; i++) {
path[i].getAttributeSet().addAttributeListener(this);
SubcircuitFactory circFact = (SubcircuitFactory) path[i].getFactory();
circFact.getSubcircuit().addCircuitListener(this);
}
}
comp.getAttributeSet().addAttributeListener(this);
}
示例10: libraryChanged
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public void libraryChanged(LibraryEvent event) {
int action = event.getAction();
if (action == LibraryEvent.REMOVE_LIBRARY) {
Library unloaded = (Library) event.getData();
if (tool != null && unloaded.containsFromSource(tool)) {
setTool(null);
}
} else if (action == LibraryEvent.REMOVE_TOOL) {
Object data = event.getData();
if (data instanceof AddTool) {
Object factory = ((AddTool) data).getFactory();
if (factory instanceof SubcircuitFactory) {
SubcircuitFactory fact = (SubcircuitFactory) factory;
if (fact.getSubcircuit() == getCurrentCircuit()) {
setCurrentCircuit(file.getMainCircuit());
}
}
}
}
}
示例11: removeCircuit
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public void removeCircuit(Circuit circuit) {
if (tools.size() <= 1) {
throw new RuntimeException("Cannot remove last circuit");
}
int index = getCircuits().indexOf(circuit);
if (index >= 0) {
Tool circuitTool = tools.remove(index);
if (main == circuit) {
AddTool dflt_tool = tools.get(0);
SubcircuitFactory factory = (SubcircuitFactory) dflt_tool
.getFactory();
setMainCircuit(factory.getSubcircuit());
}
fireEvent(LibraryEvent.REMOVE_TOOL, circuitTool);
}
}
示例12: setValueRequested
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
@Override
public void setValueRequested(Attribute<Object> attr, Object value) {
if (tool instanceof AddTool) {
AddTool mytool = (AddTool) tool;
if (mytool.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory fac = (SubcircuitFactory) mytool.getFactory();
if (attr.equals(CircuitAttributes.NAMED_CIRCUIT_BOX)||
attr.equals(CircuitAttributes.NAME_ATTR)) {
try {
CircuitMutation mutation = new CircuitMutation(fac.getSubcircuit());
mutation.setForCircuit(attr, value);
Action action = mutation.toAction(null);
proj.doAction(action);
} catch (CircuitException ex) {
JOptionPane.showMessageDialog(proj.getFrame(),
ex.getMessage());
}
return;
}
}
}
proj.doAction(ToolAttributeAction.create(tool, attr, value));
}
示例13: findComponentFactory
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
private static ComponentFactory findComponentFactory(
ComponentFactory factory, ArrayList<Library> libs,
boolean acceptNameMatch) {
String name = factory.getName();
for (Library lib : libs) {
for (Tool tool : lib.getTools()) {
if (tool instanceof AddTool) {
AddTool addTool = (AddTool) tool;
if (name.equals(addTool.getName())) {
ComponentFactory fact = addTool.getFactory(true);
if (acceptNameMatch) {
return fact;
} else if (fact == factory) {
return fact;
} else if (fact.getClass() == factory.getClass()
&& !(fact instanceof SubcircuitFactory)) {
return fact;
}
}
}
}
}
return null;
}
示例14: deleteRequested
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
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());
}
}
}
}
示例15: doubleClicked
import com.cburch.logisim.circuit.SubcircuitFactory; //导入依赖的package包/类
public void doubleClicked(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) {
SubcircuitFactory circFact = (SubcircuitFactory) source;
proj.setCurrentCircuit(circFact.getSubcircuit());
proj.getFrame().setEditorView(Frame.EDIT_LAYOUT);
if (lastSelected != null){
proj.setTool(lastSelected);
} else {
Library base = proj.getLogisimFile().getLibrary("Base");
if (base != null)
proj.setTool(base.getTool("Edit Tool"));
}
}
}
}
}