Search in sources :

Example 1 with ComponentEvent

use of com.cburch.logisim.comp.ComponentEvent in project logisim-evolution by reds-heig.

the class Splitter method configureComponent.

private synchronized void configureComponent() {
    SplitterAttributes attrs = (SplitterAttributes) getAttributeSet();
    SplitterParameters parms = attrs.getParameters();
    int fanout = attrs.fanout;
    byte[] bit_end = attrs.bit_end;
    // compute width of each end
    bit_thread = new byte[bit_end.length];
    byte[] end_width = new byte[fanout + 1];
    end_width[0] = (byte) bit_end.length;
    for (int i = 0; i < bit_end.length; i++) {
        byte thr = bit_end[i];
        if (thr > 0) {
            bit_thread[i] = end_width[thr];
            end_width[thr]++;
        } else {
            bit_thread[i] = -1;
        }
    }
    // compute end positions
    Location origin = getLocation();
    int x = origin.getX() + parms.getEnd0X();
    int y = origin.getY() + parms.getEnd0Y();
    int dx = parms.getEndToEndDeltaX();
    int dy = parms.getEndToEndDeltaY();
    EndData[] ends = new EndData[fanout + 1];
    ends[0] = new EndData(origin, BitWidth.create(bit_end.length), EndData.INPUT_OUTPUT);
    for (int i = 0; i < fanout; i++) {
        ends[i + 1] = new EndData(Location.create(x, y), BitWidth.create(end_width[i + 1]), EndData.INPUT_OUTPUT);
        x += dx;
        y += dy;
    }
    wire_data = new CircuitWires.SplitterData(fanout);
    setEnds(ends);
    recomputeBounds();
    fireComponentInvalidated(new ComponentEvent(this));
}
Also used : EndData(com.cburch.logisim.comp.EndData) ComponentEvent(com.cburch.logisim.comp.ComponentEvent) Location(com.cburch.logisim.data.Location)

Aggregations

ComponentEvent (com.cburch.logisim.comp.ComponentEvent)1 EndData (com.cburch.logisim.comp.EndData)1 Location (com.cburch.logisim.data.Location)1