use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class TestThread method matchPins.
void matchPins() throws TestException {
int n = vector.columnName.length;
pin = new Instance[n];
CircuitState state = new CircuitState(this.project, this.circuit);
for (int i = 0; i < n; i++) {
String columnName = vector.columnName[i];
for (Component comp : circuit.getNonWires()) {
if (!(comp.getFactory() instanceof Pin))
continue;
Instance inst = Instance.getInstanceFor(comp);
InstanceState pinState = state.getInstanceState(comp);
String label = pinState.getAttributeValue(StdAttr.LABEL);
if (label == null || !label.equals(columnName))
continue;
if (Pin.FACTORY.getWidth(inst).getWidth() != vector.columnWidth[i].getWidth())
throw new TestException("test vector column '" + columnName + "' has width " + vector.columnWidth[i] + ", but pin has width " + Pin.FACTORY.getWidth(inst));
pin[i] = inst;
break;
}
if (pin[i] == null)
throw new TestException("test vector column '" + columnName + "' has no matching pin");
}
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class AssemblyWindow method fillCombo.
@SuppressWarnings("unchecked")
private void fillCombo() {
Set<Component> comps = curCircuit.getNonWires();
Iterator<Component> iter = comps.iterator();
entry.clear();
while (iter.hasNext()) {
Component comp = iter.next();
if (comp.getFactory().getName().equals("Register")) {
if (!comp.getAttributeSet().getValue(StdAttr.LABEL).equals("")) {
entry.put(comp.getAttributeSet().getValue(StdAttr.LABEL), comp);
}
}
}
combo.removeAllItems();
if (entry.isEmpty()) {
status.setText("No labeled registers found.");
combo.setEnabled(false);
} else {
status.setText("");
combo.setEnabled(true);
Object[] objArr = entry.keySet().toArray();
Arrays.sort(objArr);
for (int i = 0; i < objArr.length; i++) {
combo.addItem(objArr[i]);
}
}
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class Selection method draw.
//
// graphics methods
//
public void draw(ComponentDrawContext context, Set<Component> hidden) {
Graphics g = context.getGraphics();
for (Component c : lifted) {
if (!hidden.contains(c)) {
Location loc = c.getLocation();
Graphics g_new = g.create();
context.setGraphics(g_new);
c.getFactory().drawGhost(context, Color.GRAY, loc.getX(), loc.getY(), c.getAttributeSet());
g_new.dispose();
}
}
for (Component comp : unionSet) {
if (!suppressHandles.contains(comp) && !hidden.contains(comp)) {
Graphics g_new = g.create();
context.setGraphics(g_new);
CustomHandles handler = (CustomHandles) comp.getFeature(CustomHandles.class);
if (handler == null) {
context.drawHandles(comp);
} else {
handler.drawHandles(context);
}
g_new.dispose();
}
}
context.setGraphics(g);
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class Selection method drawGhostsShifted.
public void drawGhostsShifted(ComponentDrawContext context, int dx, int dy) {
if (shouldSnap()) {
dx = Canvas.snapXToGrid(dx);
dy = Canvas.snapYToGrid(dy);
}
Graphics g = context.getGraphics();
for (Component comp : unionSet) {
AttributeSet attrs = comp.getAttributeSet();
Location loc = comp.getLocation();
int x = loc.getX() + dx;
int y = loc.getY() + dy;
context.setGraphics(g.create());
comp.getFactory().drawGhost(context, Color.gray, x, y, attrs);
context.getGraphics().dispose();
}
context.setGraphics(g);
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class SelectionAttributes method setValue.
@Override
public <V> void setValue(Attribute<V> attr, V value) {
Circuit circ = canvas.getCircuit();
if (selected.isEmpty() && circ != null) {
circ.getStaticAttributes().setValue(attr, value);
} else {
int i = findIndex(attr);
Object[] vs = values;
if (i >= 0 && i < vs.length) {
vs[i] = value;
for (Component comp : selected) {
comp.getAttributeSet().setValue(attr, value);
}
}
}
}
Aggregations