当前位置: 首页>>代码示例>>Java>>正文


Java CircuitMutation类代码示例

本文整理汇总了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();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:25,代码来源:SetAttributeAction.java

示例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;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:WiringTool.java

示例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();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:19,代码来源:SelectionBase.java

示例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;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:17,代码来源:SelectionActions.java

示例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;
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:22,代码来源:WiringTool.java

示例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));
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:24,代码来源:AttrTableToolModel.java

示例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();
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:25,代码来源:SetAttributeAction.java

示例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;
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:21,代码来源:WiringTool.java

示例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();
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:18,代码来源:SelectionBase.java

示例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));
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:10,代码来源:CircuitBuilder.java

示例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);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:14,代码来源:MenuTool.java

示例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();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:16,代码来源:SelectionBase.java

示例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();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:9,代码来源:SelectionBase.java

示例14: dropAll

import com.cburch.logisim.circuit.CircuitMutation; //导入依赖的package包/类
void dropAll(CircuitMutation xn) {
	if (!lifted.isEmpty()) {
		xn.addAll(lifted);
		selected.addAll(lifted);
		lifted.clear();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:SelectionBase.java

示例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();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:SelectionBase.java


注:本文中的com.cburch.logisim.circuit.CircuitMutation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。