本文整理汇总了Java中com.cburch.logisim.std.wiring.Pin.FACTORY属性的典型用法代码示例。如果您正苦于以下问题:Java Pin.FACTORY属性的具体用法?Java Pin.FACTORY怎么用?Java Pin.FACTORY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.cburch.logisim.std.wiring.Pin
的用法示例。
在下文中一共展示了Pin.FACTORY属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: placeOutput
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));
}
示例2: loadAppearance
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);
}
}
}
示例3: placeOutput
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));
}
示例4: loadAppearance
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);
}
}
}
示例5: loadAppearance
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);
}
}
}
示例6: addClock
private void addClock(){ // en verdad se agrega un pin que representa un reloj
Pin factory = Pin.FACTORY;
AttributeSet attrs = factory.createAttributeSet();
attrs.setValue(StdAttr.FACING, Direction.NORTH);
attrs.setValue(StdAttr.LABEL, "Clock");
Component clockPin = factory.createComponent(Location.create(registerClockPort.getX(), yClock), attrs);
this.mutation.add(clockPin);
clockPort = clockPin.getEnd(0).getLocation();
}
示例7: placeInputs
private static void placeInputs(CircuitMutation result, InputData inputData) {
ArrayList<Location> forbiddenYs = new ArrayList<Location>();
Comparator<Location> compareYs = new CompareYs();
int curX = 40;
int curY = 30;
for (int i = 0; i < inputData.names.length; i++) {
String name = inputData.names[i];
SingleInput singleInput = inputData.inputs.get(name);
// determine point where we can intersect with spine
int spineX = singleInput.spineX;
Location spineLoc = Location.create(spineX, curY);
if (singleInput.ys.size() > 0) {
// search for a Y that won't intersect with others
// (we needn't bother if the pin doesn't connect
// with anything anyway.)
Collections.sort(forbiddenYs, compareYs);
while (Collections.binarySearch(forbiddenYs, spineLoc, compareYs) >= 0) {
curY += 10;
spineLoc = Location.create(spineX, curY);
}
singleInput.ys.add(spineLoc);
}
Location loc = Location.create(curX, curY);
// now create the pin
ComponentFactory factory = Pin.FACTORY;
AttributeSet attrs = factory.createAttributeSet();
attrs.setValue(StdAttr.FACING, Direction.EAST);
attrs.setValue(Pin.ATTR_TYPE, Boolean.FALSE);
attrs.setValue(Pin.ATTR_TRISTATE, Boolean.FALSE);
attrs.setValue(StdAttr.LABEL, name);
attrs.setValue(Pin.ATTR_LABEL_LOC, Direction.NORTH);
result.add(factory.createComponent(loc, attrs));
ArrayList<Location> spine = singleInput.ys;
if (spine.size() > 0) {
// create wire connecting pin to spine
/*
* This should no longer matter - the wires will be repaired anyway by the
* circuit's WireRepair class. if (spine.size() == 2 &&
* spine.get(0).equals(spine.get(1))) { // a freak accident where the input is
* used just once, // and it happens that the pin is placed where no // spine is
* necessary Iterator<Wire> it = circuit.getWires(spineLoc).iterator(); Wire
* existing = it.next(); Wire replace = Wire.create(loc, existing.getEnd1());
* result.replace(existing, replace); } else {
*/
result.add(Wire.create(loc, spineLoc));
// }
// create spine
Collections.sort(spine, compareYs);
Location prev = spine.get(0);
for (int k = 1, n = spine.size(); k < n; k++) {
Location cur = spine.get(k);
if (!cur.equals(prev)) {
result.add(Wire.create(prev, cur));
prev = cur;
}
}
}
// advance y and forbid spine intersections for next pin
forbiddenYs.addAll(singleInput.ys);
curY += 50;
}
}
示例8: placeInputs
private static void placeInputs(CircuitMutation result, InputData inputData) {
ArrayList<Location> forbiddenYs = new ArrayList<Location>();
Comparator<Location> compareYs = new CompareYs();
int curX = 40;
int curY = 30;
for (int i = 0; i < inputData.names.length; i++) {
String name = inputData.names[i];
SingleInput singleInput = inputData.inputs.get(name);
// determine point where we can intersect with spine
int spineX = singleInput.spineX;
Location spineLoc = Location.create(spineX, curY);
if (singleInput.ys.size() > 0) {
// search for a Y that won't intersect with others
// (we needn't bother if the pin doesn't connect
// with anything anyway.)
Collections.sort(forbiddenYs, compareYs);
while (Collections.binarySearch(forbiddenYs, spineLoc,
compareYs) >= 0) {
curY += 10;
spineLoc = Location.create(spineX, curY);
}
singleInput.ys.add(spineLoc);
}
Location loc = Location.create(curX, curY);
// now create the pin
ComponentFactory factory = Pin.FACTORY;
AttributeSet attrs = factory.createAttributeSet();
attrs.setValue(StdAttr.FACING, Direction.EAST);
attrs.setValue(Pin.ATTR_TYPE, Boolean.FALSE);
attrs.setValue(Pin.ATTR_TRISTATE, Boolean.FALSE);
attrs.setValue(StdAttr.LABEL, name);
attrs.setValue(Pin.ATTR_LABEL_LOC, Direction.NORTH);
result.add(factory.createComponent(loc, attrs));
ArrayList<Location> spine = singleInput.ys;
if (spine.size() > 0) {
// create wire connecting pin to spine
/*
* This should no longer matter - the wires will be repaired
* anyway by the circuit's WireRepair class. if (spine.size() ==
* 2 && spine.get(0).equals(spine.get(1))) { // a freak accident
* where the input is used just once, // and it happens that the
* pin is placed where no // spine is necessary Iterator<Wire>
* it = circuit.getWires(spineLoc).iterator(); Wire existing =
* it.next(); Wire replace = Wire.create(loc,
* existing.getEnd1()); result.replace(existing, replace); }
* else {
*/
result.add(Wire.create(loc, spineLoc));
// }
// create spine
Collections.sort(spine, compareYs);
Location prev = spine.get(0);
for (int k = 1, n = spine.size(); k < n; k++) {
Location cur = spine.get(k);
if (!cur.equals(prev)) {
result.add(Wire.create(prev, cur));
prev = cur;
}
}
}
// advance y and forbid spine intersections for next pin
forbiddenYs.addAll(singleInput.ys);
curY += 50;
}
}
示例9: placeInputs
private static void placeInputs(CircuitMutation result, InputData inputData) {
ArrayList<Location> forbiddenYs = new ArrayList<Location>();
Comparator<Location> compareYs = new CompareYs();
int curX = 40;
int curY = 30;
for (int i = 0; i < inputData.names.length; i++) {
String name = inputData.names[i];
SingleInput singleInput = inputData.inputs.get(name);
// determine point where we can intersect with spine
int spineX = singleInput.spineX;
Location spineLoc = Location.create(spineX, curY);
if (singleInput.ys.size() > 0) {
// search for a Y that won't intersect with others
// (we needn't bother if the pin doesn't connect
// with anything anyway.)
Collections.sort(forbiddenYs, compareYs);
while (Collections.binarySearch(forbiddenYs, spineLoc, compareYs) >= 0) {
curY += 10;
spineLoc = Location.create(spineX, curY);
}
singleInput.ys.add(spineLoc);
}
Location loc = Location.create(curX, curY);
// now create the pin
ComponentFactory factory = Pin.FACTORY;
AttributeSet attrs = factory.createAttributeSet();
attrs.setValue(StdAttr.FACING, Direction.EAST);
attrs.setValue(Pin.ATTR_TYPE, Boolean.FALSE);
attrs.setValue(Pin.ATTR_TRISTATE, Boolean.FALSE);
attrs.setValue(StdAttr.LABEL, name);
attrs.setValue(Pin.ATTR_LABEL_LOC, Direction.NORTH);
result.add(factory.createComponent(loc, attrs));
ArrayList<Location> spine = singleInput.ys;
if (spine.size() > 0) {
// create wire connecting pin to spine
/* This should no longer matter - the wires will be repaired
* anyway by the circuit's WireRepair class.
if (spine.size() == 2 && spine.get(0).equals(spine.get(1))) {
// a freak accident where the input is used just once,
// and it happens that the pin is placed where no
// spine is necessary
Iterator<Wire> it = circuit.getWires(spineLoc).iterator();
Wire existing = it.next();
Wire replace = Wire.create(loc, existing.getEnd1());
result.replace(existing, replace);
} else {
*/
result.add(Wire.create(loc, spineLoc));
// }
// create spine
Collections.sort(spine, compareYs);
Location prev = spine.get(0);
for (int k = 1, n = spine.size(); k < n; k++) {
Location cur = spine.get(k);
if (!cur.equals(prev)) {
result.add(Wire.create(prev, cur));
prev = cur;
}
}
}
// advance y and forbid spine intersections for next pin
forbiddenYs.addAll(singleInput.ys);
curY += 50;
}
}
示例10: createPin
private Component createPin(AttributeSet attrs, Location loc){
Pin factory = Pin.FACTORY;
Component pin = factory.createComponent(loc, attrs);
this.mutation.add(pin);
return pin;
}