本文整理汇总了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);
}
}
}
示例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());
}
}
}
示例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);
}
}
}
示例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;
}
示例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());
}
}
}
示例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);
}
}
示例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));
}
示例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);
}
}
}
示例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();
}
示例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();
}
}
示例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
}
示例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();
}
}
示例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));
}
示例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);
}
}
}
示例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();
}
}