Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.Circuit


        }
    }

    private void buildCircuit(XmlReader.CircuitData circData, CircuitMutator mutator) {
        Element elt = circData.circuitElement;
        Circuit dest = circData.circuit;
        Map<Element, Component> knownComponents = circData.knownComponents;
        if (knownComponents == null) {
            knownComponents = Collections.emptyMap();
        }

        try {
            reader.initAttributeSet(circData.circuitElement, dest.getStaticAttributes(), null);
        } catch (XmlReaderException e) {
            reader.addErrors(e, circData.circuit.getName() + ".static");
        }

        for (Element sub_elt : XmlIterator.forChildElements(elt)) {
            String sub_elt_name = sub_elt.getTagName();
            if (sub_elt_name.equals("comp")) {
                try {
                    Component comp = knownComponents.get(sub_elt);
                    if (comp == null) {
                        comp = getComponent(sub_elt, reader);
                    }
                    mutator.add(dest, comp);
                } catch (XmlReaderException e) {
                    reader.addErrors(e, circData.circuit.getName() + "." + toComponentString(sub_elt));
                }
            } else if (sub_elt_name.equals("wire")) {
                try {
                    addWire(dest, mutator, sub_elt);
                } catch (XmlReaderException e) {
                    reader.addErrors(e, circData.circuit.getName() + "." + toWireString(sub_elt));
                }
            }
        }

        List<AbstractCanvasObject> appearance = circData.appearance;
        if (appearance != null && !appearance.isEmpty()) {
            dest.getAppearance().setObjectsForce(appearance);
            dest.getAppearance().setDefaultAppearance(false);
        }
    }
View Full Code Here


    private static Count getTotal(List<Count> counts, Set<Circuit> exclude) {
        Count ret = new Count(null);
        for (Count count : counts) {
            ComponentFactory factory = count.getFactory();
            Circuit factoryCirc = null;
            if (factory instanceof SubcircuitFactory) {
                factoryCirc = ((SubcircuitFactory) factory).getSubcircuit();
            }
            if (exclude == null || !exclude.contains(factoryCirc)) {
                ret.simpleCount += count.simpleCount;
View Full Code Here

    public String getDisplayName() {
        return getFromLocale("pokeTool");
    }

    private void removeCaret(boolean normal) {
        Circuit circ = pokedCircuit;
        Caret caret = pokeCaret;
        if (caret != null) {
            if (normal) {
                caret.stopEditing();
            }
            else {
              caret.cancelEditing();
            }

            circ.removeCircuitListener(listener);
            pokedCircuit = null;
            pokedComponent = null;
            pokeCaret = null;
        }
    }
View Full Code Here

            dirty = true;
            removeCaret(true);
        }
        if (pokeCaret == null) {
            ComponentUserEvent event = new ComponentUserEvent(canvas, x, y);
            Circuit circ = canvas.getCircuit();
            for (Component c : circ.getAllContaining(loc, g)) {
                if (pokeCaret != null) {
                    break;
                }


                if (c instanceof Wire) {
                    Caret caret = new WireCaret(canvas, (Wire) c, x, y,
                        canvas.getProject().getOptions().getAttributeSet());
                    setPokedComponent(circ, c, caret);
                    canvas.setHighlightedWires(circ.getWireSet((Wire) c));
                } else {
                    Pokable p = (Pokable) c.getFeature(Pokable.class);
                    if (p != null) {
                        Caret caret = p.getPokeCaret(event);
                        setPokedComponent(circ, c, caret);
View Full Code Here

    }

    private class Listener implements CircuitListener {
        @Override
        public void circuitChanged(CircuitEvent event) {
            Circuit circ = pokedCircuit;
            if (event.getCircuit() == circ && circ != null
                    && (event.getAction() == CircuitEvent.ACTION_REMOVE
                            || event.getAction() == CircuitEvent.ACTION_CLEAR)
                    && !circ.contains(pokedComponent)) {
                removeCaret(false);
            }
        }
View Full Code Here

        if (format == 0) {
            System.exit(0);
        }

        Project proj = new Project(file);
        Circuit circuit = file.getMainCircuit();
        Map<Instance, String> pinNames = Analyze.getPinLabels(circuit);
        ArrayList<Instance> outputPins = new ArrayList<Instance>();
        Instance haltPin = null;
        for (Map.Entry<Instance, String> entry : pinNames.entrySet()) {
            Instance pin = entry.getKey();
View Full Code Here

            case LibraryEvent.REMOVE_TOOL:
                if (e.getData() instanceof AddTool) {
                    ComponentFactory factory = ((AddTool) e.getData()).getFactory();
                    if (factory instanceof SubcircuitFactory) {
                        SubcircuitFactory circFact = (SubcircuitFactory) factory;
                        Circuit circ = circFact.getSubcircuit();
                        depends.removeNode(circ);
                        circ.removeCircuitListener(this);
                    }
                }
                break;
            }
        }
View Full Code Here

        } else {
            toolbox.setHaloedTool(null);
            layoutToolbarModel.setHaloedTool(null);
        }
        if (value instanceof AttrTableComponentModel) {
            Circuit circ = ((AttrTableComponentModel) value).getCircuit();
            Component comp = ((AttrTableComponentModel) value).getComponent();
            layoutCanvas.setHaloedComponent(circ, comp);
        } else {
            layoutCanvas.setHaloedComponent(null, null);
        }
View Full Code Here

        return layoutCanvas;
    }

    private void computeTitle() {
        String s;
        Circuit circuit = proj.getCurrentCircuit();
        String name = proj.getLogisimFile().getName();
        if (circuit != null) {
            s = getFromLocale("titleCircFileKnown", circuit.getName(), name);
        } else {
            s = getFromLocale("titleFileKnown", name);
        }
        this.setTitle(s);
        myProjectListener.enableSave();
View Full Code Here

            if (!force && !same && !(oldModel instanceof AttrTableCircuitModel)) {
                return;
            }
        }
        if (newAttrs == null) {
            Circuit circ = proj.getCurrentCircuit();
            if (circ != null) {
                setAttrTableModel(new AttrTableCircuitModel(proj, circ));
            } else if (force) {
                setAttrTableModel(null);
            }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.circuit.Circuit

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.