Search in sources :

Example 51 with Component

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");
    }
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) InstanceState(com.cburch.logisim.instance.InstanceState) Pin(com.cburch.logisim.std.wiring.Pin) TestException(com.cburch.logisim.data.TestException) Instance(com.cburch.logisim.instance.Instance) Component(com.cburch.logisim.comp.Component)

Example 52 with Component

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]);
        }
    }
}
Also used : Component(com.cburch.logisim.comp.Component)

Example 53 with Component

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);
}
Also used : Graphics(java.awt.Graphics) CustomHandles(com.cburch.logisim.tools.CustomHandles) Component(com.cburch.logisim.comp.Component) Location(com.cburch.logisim.data.Location)

Example 54 with Component

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);
}
Also used : Graphics(java.awt.Graphics) AttributeSet(com.cburch.logisim.data.AttributeSet) Component(com.cburch.logisim.comp.Component) Location(com.cburch.logisim.data.Location)

Example 55 with Component

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);
            }
        }
    }
}
Also used : Circuit(com.cburch.logisim.circuit.Circuit) Component(com.cburch.logisim.comp.Component)

Aggregations

Component (com.cburch.logisim.comp.Component)97 Location (com.cburch.logisim.data.Location)26 ArrayList (java.util.ArrayList)20 Circuit (com.cburch.logisim.circuit.Circuit)19 AttributeSet (com.cburch.logisim.data.AttributeSet)13 Wire (com.cburch.logisim.circuit.Wire)12 Bounds (com.cburch.logisim.data.Bounds)11 HashMap (java.util.HashMap)11 HashSet (java.util.HashSet)11 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)8 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)8 EndData (com.cburch.logisim.comp.EndData)8 InstanceComponent (com.cburch.logisim.instance.InstanceComponent)8 Project (com.cburch.logisim.proj.Project)7 Pin (com.cburch.logisim.std.wiring.Pin)7 Graphics (java.awt.Graphics)7 CircuitState (com.cburch.logisim.circuit.CircuitState)6 Splitter (com.cburch.logisim.circuit.Splitter)6 Selection (com.cburch.logisim.gui.main.Selection)6 InstanceState (com.cburch.logisim.instance.InstanceState)5