Package com.cburch.logisim.instance

Examples of com.cburch.logisim.instance.Instance


    void setPin(Instance value) {
        pin = value;
    }

    private boolean isInput() {
        Instance p = pin;
        return p == null || Pin.FACTORY.isInputPin(p);
    }
View Full Code Here


        Set<Instance> adds = new HashSet<Instance>();
        Set<Instance> removes = new HashSet<Instance>();
        Map<Instance, Instance> replaces = new HashMap<Instance, Instance>();
        for (Component comp : repl.getAdditions()) {
            if (comp.getFactory() instanceof Pin) {
                Instance in = Instance.getInstanceFor(comp);
                boolean added = pins.add(in);
                if (added) {
                    comp.addComponentListener(myComponentListener);
                    in.getAttributeSet().addAttributeListener(myComponentListener);
                    adds.add(in);
                }
            }
        }
        for (Component comp : repl.getRemovals()) {
            if (comp.getFactory() instanceof Pin) {
                Instance in = Instance.getInstanceFor(comp);
                boolean removed = pins.remove(in);
                if (removed) {
                    comp.removeComponentListener(myComponentListener);
                    in.getAttributeSet().removeAttributeListener(myComponentListener);
                    Collection<Component> rs = repl.getComponentsReplacing(comp);
                    if (rs.isEmpty()) {
                        removes.add(in);
                    } else {
                        Component r = rs.iterator().next();
                        Instance rin = Instance.getInstanceFor(r);
                        adds.remove(rin);
                        replaces.put(in, rin);
                    }
                }
            }
View Full Code Here

        } else if (name.equals("circ-port")) {
            Location loc = getLocation(elt);
            String[] pinStr = elt.getAttribute("pin").split(",");
            Location pinLoc = Location.create(Integer.parseInt(pinStr[0].trim()),
                    Integer.parseInt(pinStr[1].trim()));
            Instance pin = pins.get(pinLoc);
            if (pin == null) {
                return null;
            } else {
                return new AppearancePort(loc, pin);
            }
View Full Code Here

        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>();
View Full Code Here

        BitWidth dataBits = state.getAttributeValue(DATA_ATTR);

        RamState myState = (RamState) state.getData();
        if (myState == null) {
            MemContents contents = MemContents.create(addrBits.getWidth(), dataBits.getWidth());
            Instance instance = state.getInstance();
            myState = new RamState(instance, contents, new MemListener(instance));
            state.setData(myState);
        } else {
            myState.setRam(state.getInstance());
        }
View Full Code Here

        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));
            }
        }
View Full Code Here

        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)) {
View Full Code Here

        g.setFont(attrs.getFont());
        FontMetrics fm = g.getFontMetrics();
        Bounds bds = computeBounds(attrs, fm.stringWidth(label),
                fm.getAscent() + fm.getDescent(), g, label);
        if (attrs.setOffsetBounds(bds)) {
            Instance instance = painter.getInstance();
            if (instance != null) {
                instance.recomputeBounds();
            }

        }

        int x0 = bds.getX();
View Full Code Here

            if (b == null) {
                b = ret.createBundleAt(loc);
                b.points.add(loc);
                ret.setBundleAt(loc, b);
            }
            Instance instance = Instance.getInstanceFor(comp);
            b.addPullValue(PullResistor.getPullValue(instance));
        }
    }
View Full Code Here

    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, getFromLocale("analyzeMultibitInputError"));
                } else {
                    analyzeError(proj, getFromLocale("analyzeMultibitOutputError"));
                }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.instance.Instance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.