本文整理汇总了Java中com.cburch.logisim.circuit.CircuitMutation类的典型用法代码示例。如果您正苦于以下问题:Java CircuitMutation类的具体用法?Java CircuitMutation怎么用?Java CircuitMutation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CircuitMutation类属于com.cburch.logisim.circuit包,在下文中一共展示了CircuitMutation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doIt
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
@Override
public void doIt(Project proj) {
CircuitMutation xn = new CircuitMutation(circuit);
int len = values.size();
oldValues.clear();
for (int i = 0; i < len; i++) {
Component comp = comps.get(i);
Attribute<Object> attr = attrs.get(i);
Object value = values.get(i);
if (circuit.contains(comp)) {
oldValues.add(null);
xn.set(comp, attr, value);
} else {
AttributeSet compAttrs = comp.getAttributeSet();
oldValues.add(compAttrs.getValue(attr));
compAttrs.setValue(attr, value);
}
}
if (!xn.isEmpty()) {
CircuitTransactionResult result = xn.execute();
xnReverse = result.getReverseTransaction();
}
}
示例2: performShortening
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
private boolean performShortening(Canvas canvas, Location drag0, Location drag1) {
Wire shorten = willShorten(drag0, drag1);
if (shorten == null) {
return false;
} else {
CircuitMutation xn = new CircuitMutation(canvas.getCircuit());
StringGetter actName;
Wire result = getShortenResult(shorten, drag0, drag1);
if (result == null) {
xn.remove(shorten);
actName = Strings.getter("removeComponentAction", shorten.getFactory().getDisplayGetter());
} else {
xn.replace(shorten, result);
actName = Strings.getter("shortenWireAction");
}
canvas.getProject().doAction(xn.toAction(actName));
return true;
}
}
示例3: remove
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
void remove(CircuitMutation xn, Component comp) {
boolean removed = selected.remove(comp);
if (lifted.contains(comp)) {
if (xn == null) {
throw new IllegalStateException("cannot remove");
} else {
lifted.remove(comp);
removed = true;
xn.add(comp);
}
}
if (removed) {
if (shouldSnapComponent(comp))
computeShouldSnap();
fireSelectionChanged();
}
}
示例4: doIt
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
@Override
public void doIt(Project proj) {
Clipboard clip = Clipboard.get();
Circuit circuit = proj.getCurrentCircuit();
CircuitMutation xn = new CircuitMutation(circuit);
Collection<Component> comps = clip.getComponents();
Collection<Component> toAdd = computeAdditions(comps);
if (toAdd.size() > 0) {
sel.pasteHelper(xn, toAdd);
CircuitTransactionResult result = xn.execute();
xnReverse = result.getReverseTransaction();
after = SelectionSave.create(sel);
} else {
xnReverse = null;
}
}
示例5: performShortening
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
private boolean performShortening(Canvas canvas, Location drag0,
Location drag1) {
Wire shorten = willShorten(drag0, drag1);
if (shorten == null) {
return false;
} else {
CircuitMutation xn = new CircuitMutation(canvas.getCircuit());
StringGetter actName;
Wire result = getShortenResult(shorten, drag0, drag1);
if (result == null) {
xn.remove(shorten);
actName = Strings.getter("removeComponentAction", shorten
.getFactory().getDisplayGetter());
} else {
xn.replace(shorten, result);
actName = Strings.getter("shortenWireAction");
}
canvas.getProject().doAction(xn.toAction(actName));
return true;
}
}
示例6: 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));
}
示例7: doIt
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
@Override
public void doIt(Project proj) {
CircuitMutation xn = new CircuitMutation(circuit);
int len = values.size();
oldValues.clear();
for (int i = 0; i < len; i++) {
Component comp = comps.get(i);
Attribute<Object> attr = attrs.get(i);
Object value = values.get(i);
if (circuit.contains(comp)) {
oldValues.add(null);
xn.set(comp, attr, value);
} else {
AttributeSet compAttrs = comp.getAttributeSet();
oldValues.add(compAttrs.getValue(attr));
compAttrs.setValue(attr, value);
}
}
if (!xn.isEmpty()) {
CircuitTransactionResult result = xn.execute();
xnReverse = result.getReverseTransaction();
}
}
示例8: performShortening
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
private boolean performShortening(Canvas canvas, Location drag0, Location drag1) {
Wire shorten = willShorten(drag0, drag1);
if (shorten == null) {
return false;
} else {
CircuitMutation xn = new CircuitMutation(canvas.getCircuit());
StringGetter actName;
Wire result = getShortenResult(shorten, drag0, drag1);
if (result == null) {
xn.remove(shorten);
actName = Strings.getter("removeComponentAction",
shorten.getFactory().getDisplayGetter());
} else {
xn.replace(shorten, result);
actName = Strings.getter("shortenWireAction");
}
canvas.getProject().doAction(xn.toAction(actName));
return true;
}
}
示例9: remove
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
void remove(CircuitMutation xn, Component comp) {
boolean removed = selected.remove(comp);
if (lifted.contains(comp)) {
if (xn == null) {
throw new IllegalStateException("cannot remove");
} else {
lifted.remove(comp);
removed = true;
xn.add(comp);
}
}
if (removed) {
if (shouldSnapComponent(comp)) computeShouldSnap();
fireSelectionChanged();
}
}
示例10: placeOutput
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
private static void placeOutput(CircuitMutation result, Location loc, String name) {
ComponentFactory factory = Pin.FACTORY;
AttributeSet attrs = factory.createAttributeSet();
attrs.setValue(StdAttr.FACING, Direction.WEST);
attrs.setValue(Pin.ATTR_TYPE, Boolean.TRUE);
attrs.setValue(StdAttr.LABEL, name);
attrs.setValue(Pin.ATTR_LABEL_LOC, Direction.NORTH);
result.add(factory.createComponent(loc, attrs));
}
示例11: actionPerformed
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
if (src == del) {
Circuit circ = proj.getCurrentCircuit();
CircuitMutation xn = new CircuitMutation(circ);
xn.remove(comp);
proj.doAction(
xn.toAction(Strings.getter("removeComponentAction", comp.getFactory().getDisplayGetter())));
} else if (src == attrs) {
proj.getFrame().viewComponentAttributes(circ, comp);
}
}
示例12: clear
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
void clear(CircuitMutation xn, boolean dropLifted) {
if (selected.isEmpty() && lifted.isEmpty())
return;
if (dropLifted && !lifted.isEmpty()) {
xn.addAll(lifted);
}
selected.clear();
lifted.clear();
shouldSnap = false;
bounds = Bounds.EMPTY_BOUNDS;
fireSelectionChanged();
}
示例13: deleteAllHelper
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
void deleteAllHelper(CircuitMutation xn) {
for (Component comp : selected) {
xn.remove(comp);
}
selected.clear();
lifted.clear();
fireSelectionChanged();
}
示例14: dropAll
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
void dropAll(CircuitMutation xn) {
if (!lifted.isEmpty()) {
xn.addAll(lifted);
selected.addAll(lifted);
lifted.clear();
}
}
示例15: pasteHelper
import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
void pasteHelper(CircuitMutation xn, Collection<Component> comps) {
clear(xn);
Map<Component, Component> newLifted = copyComponents(comps);
lifted.addAll(newLifted.values());
fireSelectionChanged();
}