本文整理汇总了Java中com.cburch.logisim.circuit.CircuitMutation.setForCircuit方法的典型用法代码示例。如果您正苦于以下问题:Java CircuitMutation.setForCircuit方法的具体用法?Java CircuitMutation.setForCircuit怎么用?Java CircuitMutation.setForCircuit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cburch.logisim.circuit.CircuitMutation
的用法示例。
在下文中一共展示了CircuitMutation.setForCircuit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValueRequested
import com.cburch.logisim.circuit.CircuitMutation; //导入方法依赖的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));
}
示例2: setValueRequested
import com.cburch.logisim.circuit.CircuitMutation; //导入方法依赖的package包/类
@Override
public void setValueRequested(Attribute<Object> attr, Object value) throws AttrTableSetException {
if (!proj.getLogisimFile().contains(circ)) {
String msg = Strings.get("cannotModifyCircuitError");
throw new AttrTableSetException(msg);
} else {
CircuitMutation xn = new CircuitMutation(circ);
xn.setForCircuit(attr, value);
proj.doAction(xn.toAction(Strings.getter("changeCircuitAttrAction")));
}
}
示例3: setValueRequested
import com.cburch.logisim.circuit.CircuitMutation; //导入方法依赖的package包/类
@Override
public void setValueRequested(Attribute<Object> attr, Object value)
throws AttrTableSetException {
if (!proj.getLogisimFile().contains(circ)) {
String msg = Strings.get("cannotModifyCircuitError");
throw new AttrTableSetException(msg);
} else {
CircuitMutation xn = new CircuitMutation(circ);
xn.setForCircuit(attr, value);
proj.doAction(xn.toAction(Strings.getter("changeCircuitAttrAction")));
}
}
示例4: setValueRequested
import com.cburch.logisim.circuit.CircuitMutation; //导入方法依赖的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);
}
}