本文整理汇总了Java中com.cburch.logisim.circuit.SubcircuitFactory.getSubcircuit方法的典型用法代码示例。如果您正苦于以下问题:Java SubcircuitFactory.getSubcircuit方法的具体用法?Java SubcircuitFactory.getSubcircuit怎么用?Java SubcircuitFactory.getSubcircuit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cburch.logisim.circuit.SubcircuitFactory
的用法示例。
在下文中一共展示了SubcircuitFactory.getSubcircuit方法的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: 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);
}
}
示例3: 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());
}
}
}
}
}
示例4: 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));
}
示例5: selectionChanged
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
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);
}
}
示例6: selectionChanged
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
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);
}
}
示例7: contains
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
public boolean contains(Circuit circ) {
for (AddTool tool : tools) {
SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
if (factory.getSubcircuit() == circ)
return true;
}
return false;
}
示例8: getAddTool
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
public AddTool getAddTool(Circuit circ) {
for (AddTool tool : tools) {
SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
if (factory.getSubcircuit() == circ) {
return tool;
}
}
return null;
}
示例9: getCircuit
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
public Circuit getCircuit(String name) {
if (name == null)
return null;
for (AddTool tool : tools) {
SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
if (name.equals(factory.getName()))
return factory.getSubcircuit();
}
return null;
}
示例10: circuitChanged
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
@Override
public void circuitChanged(CircuitEvent event) {
int action = event.getAction();
if (action == CircuitEvent.ACTION_CLEAR || action == CircuitEvent.ACTION_REMOVE) {
Circuit circ = event.getCircuit();
Component circComp = null;
if (circ == model.getCircuitState().getCircuit()) {
circComp = path != null && path.length > 0 ? path[0] : comp;
} else if (path != null) {
for (int i = 0; i < path.length; i++) {
SubcircuitFactory circFact = (SubcircuitFactory) path[i].getFactory();
if (circ == circFact.getSubcircuit()) {
circComp = i + 1 < path.length ? path[i + 1] : comp;
}
}
}
if (circComp == null)
return;
if (action == CircuitEvent.ACTION_REMOVE && event.getData() != circComp) {
return;
}
int index = model.getSelection().indexOf(this);
if (index < 0)
return;
model.getSelection().remove(index);
}
}
示例11: circuitChanged
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
public void circuitChanged(CircuitEvent event) {
int action = event.getAction();
if (action == CircuitEvent.ACTION_CLEAR
|| action == CircuitEvent.ACTION_REMOVE) {
Circuit circ = event.getCircuit();
Component circComp = null;
if (circ == model.getCircuitState().getCircuit()) {
circComp = path != null && path.length > 0 ? path[0] : comp;
} else if (path != null) {
for (int i = 0; i < path.length; i++) {
SubcircuitFactory circFact = (SubcircuitFactory) path[i]
.getFactory();
if (circ == circFact.getSubcircuit()) {
circComp = i + 1 < path.length ? path[i + 1] : comp;
}
}
}
if (circComp == null)
return;
if (action == CircuitEvent.ACTION_REMOVE
&& event.getData() != circComp) {
return;
}
int index = model.getSelection().indexOf(this);
if (index < 0)
return;
model.getSelection().remove(index);
}
}
示例12: getCircuit
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
public Circuit getCircuit(String name) {
if (name == null) return null;
for (AddTool tool : tools) {
SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
if (name.equals(factory.getName())) return factory.getSubcircuit();
}
return null;
}
示例13: contains
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
public boolean contains(Circuit circ) {
for (AddTool tool : tools) {
SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
if (factory.getSubcircuit() == circ) return true;
}
return false;
}
示例14: circuitChanged
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
public void circuitChanged(CircuitEvent event) {
int action = event.getAction();
if (action == CircuitEvent.ACTION_CLEAR
|| action == CircuitEvent.ACTION_REMOVE) {
Circuit circ = event.getCircuit();
Component circComp = null;
if (circ == model.getCircuitState().getCircuit()) {
circComp = path != null && path.length > 0 ? path[0] : comp;
} else if (path != null) {
for (int i = 0; i < path.length; i++) {
SubcircuitFactory circFact = (SubcircuitFactory) path[i].getFactory();
if (circ == circFact.getSubcircuit()) {
circComp = i + 1 < path.length ? path[i + 1] : comp;
}
}
}
if (circComp == null) return;
if (action == CircuitEvent.ACTION_REMOVE
&& event.getData() != circComp) {
return;
}
int index = model.getSelection().indexOf(this);
if (index < 0) return;
model.getSelection().remove(index);
}
}
示例15: setValueRequested
import com.cburch.logisim.circuit.SubcircuitFactory; //导入方法依赖的package包/类
@Override
public void setValueRequested(Attribute<Object> attr, Object value)
throws AttrTableSetException {
Selection selection = frame.getCanvas().getSelection();
Circuit circuit = frame.getCanvas().getCircuit();
if (selection.isEmpty() && circuit != null) {
AttrTableCircuitModel circuitModel = new AttrTableCircuitModel(
project, circuit);
circuitModel.setValueRequested(attr, value);
} else {
SetAttributeAction act = new SetAttributeAction(circuit,
Strings.getter("selectionAttributeAction"));
AutoLabel labler = null;
if (attr.equals(StdAttr.LABEL)) {
labler = new AutoLabel((String)value,circuit);
}
SortedSet<Component> comps = new TreeSet<Component>(new PositionComparator());
comps.addAll(selection.getComponents());
for (Component comp : comps) {
if (!(comp instanceof Wire)) {
if (comp.getFactory() instanceof SubcircuitFactory) {
SubcircuitFactory fac = (SubcircuitFactory) comp.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);
project.doAction(action);
} catch (CircuitException ex) {
JOptionPane.showMessageDialog(project.getFrame(),
ex.getMessage());
}
return;
}
}
if (attr.equals(StdAttr.LABEL)) {
if (labler.hasNext(circuit)) {
if (comps.size()>1) {
act.set(comp, attr , labler.GetNext(circuit, comp.getFactory()));
} else {
if (getAttributeSet().getValue(StdAttr.LABEL).equals((String)value))
return;
else
act.set(comp, attr, labler.GetCurrent(circuit, comp.getFactory()));
}
} else act.set(comp, attr, "");
} else
act.set(comp, attr, value);
}
}
project.doAction(act);
}
}