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


Java Pin类代码示例

本文整理汇总了Java中com.cburch.logisim.std.wiring.Pin的典型用法代码示例。如果您正苦于以下问题:Java Pin类的具体用法?Java Pin怎么用?Java Pin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Pin类属于com.cburch.logisim.std.wiring包,在下文中一共展示了Pin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: propagate

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
@Override
public void propagate(InstanceState superState) {
	CircuitState subState = getSubstate(superState);

	CircuitAttributes attrs = (CircuitAttributes) superState.getAttributeSet();
	Instance[] pins = attrs.getPinInstances();
	for (int i = 0; i < pins.length; i++) {
		Instance pin = pins[i];
		InstanceState pinState = subState.getInstanceState(pin);
		if (Pin.FACTORY.isInputPin(pin)) {
			Value newVal = superState.getPort(i);
			Value oldVal = Pin.FACTORY.getValue(pinState);
			if (!newVal.equals(oldVal)) {
				Pin.FACTORY.setValue(pinState, newVal);
				Pin.FACTORY.propagate(pinState);
			}
		} else { // it is output-only
			Value val = pinState.getPort(0);
			superState.setPort(i, val, 1);
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:SubcircuitFactory.java

示例2: propagateComponents

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
private static void propagateComponents(ExpressionMap expressionMap,
		Collection<Component> components) throws AnalyzeException {
	for (Component comp : components) {
		ExpressionComputer computer = (ExpressionComputer) comp
				.getFeature(ExpressionComputer.class);
		if (computer != null) {
			try {
				expressionMap.currentCause = comp;
				computer.computeExpression(expressionMap);
			} catch (UnsupportedOperationException e) {
				throw new AnalyzeException.CannotHandle(comp.getFactory()
						.getDisplayName());
			}
		} else if (comp.getFactory() instanceof Pin) {
			; // pins are handled elsewhere
		} else {
			// pins are handled elsewhere
			throw new AnalyzeException.CannotHandle(comp.getFactory()
					.getDisplayName());
		}
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:23,代码来源:Analyze.java

示例3: propagate

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
@Override
public void propagate(InstanceState superState) {
	CircuitState subState = getSubstate(superState);

	CircuitAttributes attrs = (CircuitAttributes) superState
			.getAttributeSet();
	Instance[] pins = attrs.getPinInstances();
	for (int i = 0; i < pins.length; i++) {
		Instance pin = pins[i];
		InstanceState pinState = subState.getInstanceState(pin);
		if (Pin.FACTORY.isInputPin(pin)) {
			Value newVal = superState.getPortValue(i);
			Value oldVal = Pin.FACTORY.getValue(pinState);
			if (!newVal.equals(oldVal)) {
				Pin.FACTORY.setValue(pinState, newVal);
				Pin.FACTORY.propagate(pinState);
			}
		} else { // it is output-only
			Value val = pinState.getPortValue(0);
			superState.setPort(i, val, 1);
		}
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:24,代码来源:SubcircuitFactory.java

示例4: GetAnnotationName

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
private static String GetAnnotationName(Component comp) {
	String ComponentName;
	/* Pins are treated specially */
	if (comp.getFactory() instanceof Pin) {
		if (comp.getEnd(0).isOutput()) {
			if (comp.getEnd(0).getWidth().getWidth() > 1) {
				ComponentName = "Input_bus";
			} else {
				ComponentName = "Input";
			}
		} else {
			if (comp.getEnd(0).getWidth().getWidth() > 1) {
				ComponentName = "Output_bus";
			} else {
				ComponentName = "Output";
			}
		}
	} else {
		ComponentName = comp.getFactory().getHDLName(
				comp.getAttributeSet());
	}
	return ComponentName;
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:24,代码来源:Circuit.java

示例5: propagateComponents

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
private static void propagateComponents(ExpressionMap expressionMap,
		Collection<Component> components) throws AnalyzeException {
	for (Component comp : components) {
		ExpressionComputer computer
			= (ExpressionComputer) comp.getFeature(ExpressionComputer.class);
		if (computer != null) {
			try {
				expressionMap.currentCause = comp;
				computer.computeExpression(expressionMap);
			} catch (UnsupportedOperationException e) {
				throw new AnalyzeException.CannotHandle(comp.getFactory().getDisplayName());
			}
		} else if (comp.getFactory() instanceof Pin) {
			; // pins are handled elsewhere
		} else {
			// pins are handled elsewhere
			throw new AnalyzeException.CannotHandle(comp.getFactory().getDisplayName());
		}
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:21,代码来源:Analyze.java

示例6: addPins

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
private void addPins(Location[] locations, int x, String name,
		AttributeSet attrs, Location[] endPorts) {
	Location aux = locations[0];
	if (aux == null)
		return;
	int y = aux.getY();
	for (int i = MAX_LOGICAL_BITS - 1; i >= 0; i--) {
		if (locations[i] == null)
			continue;
		Location loc = Location.create(x, y + i * 40);
		AttributeSet newAttrs = (AttributeSet) attrs.clone();
		newAttrs.setValue(StdAttr.LABEL, name + i);
		Component pin = Pin.FACTORY.createComponent(loc, newAttrs);
		endPorts[i] = pin.getEnd(0).getLocation();
		mutation.add(pin);
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:18,代码来源:MainSubcircuit.java

示例7: placeOutput

import com.cburch.logisim.std.wiring.Pin; //导入依赖的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

示例8: loadAppearance

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
private void loadAppearance(Element appearElt, CircuitData circData, String context) {
	Map<Location, Instance> pins = new HashMap<Location, Instance>();
	for (Component comp : circData.knownComponents.values()) {
		if (comp.getFactory() == Pin.FACTORY) {
			Instance instance = Instance.getInstanceFor(comp);
			pins.put(comp.getLocation(), instance);
		}
	}

	List<AbstractCanvasObject> shapes = new ArrayList<AbstractCanvasObject>();
	for (Element sub : XmlIterator.forChildElements(appearElt)) {
		try {
			AbstractCanvasObject m = AppearanceSvgReader.createShape(sub, pins);
			if (m == null) {
				addError(Strings.get("fileAppearanceNotFound", sub.getTagName()),
						context + "." + sub.getTagName());
			} else {
				shapes.add(m);
			}
		} catch (RuntimeException e) {
			addError(Strings.get("fileAppearanceError", sub.getTagName()), context + "." + sub.getTagName());
		}
	}
	if (!shapes.isEmpty()) {
		if (circData.appearance == null) {
			circData.appearance = shapes;
		} else {
			circData.appearance.addAll(shapes);
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:32,代码来源:XmlReader.java

示例9: doAnalyze

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
public static void doAnalyze(Project proj, Circuit circuit) {
	Map<Instance, String> pinNames = Analyze.getPinLabels(circuit);
	ArrayList<String> inputNames = new ArrayList<String>();
	ArrayList<String> outputNames = new ArrayList<String>();
	for (Map.Entry<Instance, String> entry : pinNames.entrySet()) {
		Instance pin = entry.getKey();
		boolean isInput = Pin.FACTORY.isInputPin(pin);
		if (isInput) {
			inputNames.add(entry.getValue());
		} else {
			outputNames.add(entry.getValue());
		}
		if (pin.getAttributeValue(StdAttr.WIDTH).getWidth() > 1) {
			if (isInput) {
				analyzeError(proj, Strings.get("analyzeMultibitInputError"));
			} else {
				analyzeError(proj, Strings.get("analyzeMultibitOutputError"));
			}
			return;
		}
	}
	if (inputNames.size() > AnalyzerModel.MAX_INPUTS) {
		analyzeError(proj,
				StringUtil.format(Strings.get("analyzeTooManyInputsError"), "" + AnalyzerModel.MAX_INPUTS));
		return;
	}
	if (outputNames.size() > AnalyzerModel.MAX_OUTPUTS) {
		analyzeError(proj,
				StringUtil.format(Strings.get("analyzeTooManyOutputsError"), "" + AnalyzerModel.MAX_OUTPUTS));
		return;
	}

	Analyzer analyzer = AnalyzerManager.getAnalyzer();
	analyzer.getModel().setCurrentCircuit(proj, circuit);
	configureAnalyzer(proj, circuit, analyzer, pinNames, inputNames, outputNames);
	analyzer.setVisible(true);
	analyzer.toFront();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:39,代码来源:ProjectCircuitActions.java

示例10: attributeValueChanged

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
@Override
public void attributeValueChanged(AttributeEvent e) {
	Attribute<?> attr = e.getAttribute();
	if (attr == StdAttr.FACING || attr == StdAttr.LABEL || attr == Pin.ATTR_TYPE) {
		appearanceManager.updatePorts();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:CircuitPins.java

示例11: computePorts

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
void computePorts(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	Map<Location, Instance> portLocs = source.getAppearance().getPortOffsets(facing);
	Port[] ports = new Port[portLocs.size()];
	Instance[] pins = new Instance[portLocs.size()];
	int i = -1;
	for (Map.Entry<Location, Instance> portLoc : portLocs.entrySet()) {
		i++;
		Location loc = portLoc.getKey();
		Instance pin = portLoc.getValue();
		String type = Pin.FACTORY.isInputPin(pin) ? Port.INPUT : Port.OUTPUT;
		BitWidth width = pin.getAttributeValue(StdAttr.WIDTH);
		ports[i] = new Port(loc.getX(), loc.getY(), type, width);
		pins[i] = pin;

		String label = pin.getAttributeValue(StdAttr.LABEL);
		if (label != null && label.length() > 0) {
			ports[i].setToolTip(StringUtil.constantGetter(label));
		}
	}

	CircuitAttributes attrs = (CircuitAttributes) instance.getAttributeSet();
	attrs.setPinInstances(pins);
	instance.setPorts(ports);
	instance.recomputeBounds();
	configureLabel(instance); // since this affects the circuit's bounds
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:28,代码来源:SubcircuitFactory.java

示例12: processDirtyComponents

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
void processDirtyComponents() {
	if (!dirtyComponents.isEmpty()) {
		// This seeming wasted copy is to avoid ConcurrentModifications
		// if we used an iterator instead.
		Object[] toProcess;
		RuntimeException firstException = null;
		for (int tries = 4; true; tries--) {
			try {
				toProcess = dirtyComponents.toArray();
				break;
			} catch (RuntimeException e) {
				if (firstException == null)
					firstException = e;
				if (tries == 0) {
					toProcess = new Object[0];
					dirtyComponents = new CopyOnWriteArrayList<Component>();
					throw firstException;
				}
			}
		}
		dirtyComponents.clear();
		for (Object compObj : toProcess) {
			if (compObj instanceof Component) {
				Component comp = (Component) compObj;
				comp.propagate(this);
				if (comp.getFactory() instanceof Pin && parentState != null) {
					// should be propagated in superstate
					parentComp.propagate(parentState);
				}
			}
		}
	}

	CircuitState[] subs = new CircuitState[substates.size()];
	for (CircuitState substate : substates.toArray(subs)) {
		substate.processDirtyComponents();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:39,代码来源:CircuitState.java

示例13: placeOutput

import com.cburch.logisim.std.wiring.Pin; //导入依赖的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:reds-heig,项目名称:logisim-evolution,代码行数:11,代码来源:CircuitBuilder.java

示例14: loadAppearance

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
private void loadAppearance(Element appearElt, CircuitData circData,
		String context) {
	Map<Location, Instance> pins = new HashMap<Location, Instance>();
	for (Component comp : circData.knownComponents.values()) {
		if (comp.getFactory() == Pin.FACTORY) {
			Instance instance = Instance.getInstanceFor(comp);
			pins.put(comp.getLocation(), instance);
		}
	}

	List<AbstractCanvasObject> shapes = new ArrayList<AbstractCanvasObject>();
	for (Element sub : XmlIterator.forChildElements(appearElt)) {
		try {
			AbstractCanvasObject m = AppearanceSvgReader.createShape(
					sub, pins);
			if (m == null) {
				addError(
						Strings.get("fileAppearanceNotFound",
								sub.getTagName()),
						context + "." + sub.getTagName());
			} else {
				shapes.add(m);
			}
		} catch (RuntimeException e) {
			addError(Strings.get("fileAppearanceError",
					sub.getTagName()), context + "." + sub.getTagName());
		}
	}
	if (!shapes.isEmpty()) {
		if (circData.appearance == null) {
			circData.appearance = shapes;
		} else {
			circData.appearance.addAll(shapes);
		}
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:37,代码来源:XmlReader.java

示例15: attributeValueChanged

import com.cburch.logisim.std.wiring.Pin; //导入依赖的package包/类
public void attributeValueChanged(AttributeEvent e) {
	Attribute<?> attr = e.getAttribute();
	if (attr == StdAttr.FACING || attr == StdAttr.LABEL
			|| attr == Pin.ATTR_TYPE) {
		appearanceManager.updatePorts();
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:8,代码来源:CircuitPins.java


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