Package com.cburch.logisim.comp

Examples of com.cburch.logisim.comp.ComponentFactory


                return;
            }


            wires.add(c);
            ComponentFactory factory = c.getFactory();
            if (factory instanceof Clock) {
                clocks.add(c);
            } else if (factory instanceof SubcircuitFactory) {
                SubcircuitFactory subcirc = (SubcircuitFactory) factory;
                subcirc.getSubcircuit().circuitsUsingThis.put(c, this);
View Full Code Here


        if (c instanceof Wire) {
            wires.remove(c);
        } else {
            wires.remove(c);
            comps.remove(c);
            ComponentFactory factory = c.getFactory();
            if (factory instanceof Clock) {
                clocks.remove(c);
            } else if (factory instanceof SubcircuitFactory) {
                SubcircuitFactory subcirc = (SubcircuitFactory) factory;
                subcirc.getSubcircuit().circuitsUsingThis.remove(c);
View Full Code Here

                throw new XmlReaderException(getFromLocale("compUnknownError", name));
            } else {
                throw new XmlReaderException(getFromLocale("compAbsentError", name, libName));
            }
        }
        ComponentFactory source = ((AddTool) tool).getFactory();

        // Determine attributes
        String loc_str = elt.getAttribute("loc");
        AttributeSet attrs = source.createAttributeSet();
        reader.initAttributeSet(elt, attrs, source);

        // Create component if location known
        if (loc_str == null || loc_str.equals("")) {
            throw new XmlReaderException(getFromLocale("compLocMissingError", source.getName()));
        } else {
            try {
                Location loc = Location.parse(loc_str);
                return source.createComponent(loc, attrs);
            } catch (NumberFormatException e) {
                throw new XmlReaderException(getFromLocale("compLocInvalidError",
                    source.getName(), loc_str));
            }
        }
    }
View Full Code Here

            if (counts.containsKey(subFactory)) {
                int multiplier = counts.get(subFactory).simpleCount;
                Map<ComponentFactory,Count> subCount;
                subCount = doRecursiveCount(sub, include, countMap);
                for (Count subcount : subCount.values()) {
                    ComponentFactory subfactory = subcount.factory;
                    Count supercount = counts.get(subfactory);
                    if (supercount == null) {
                        supercount = new Count(subfactory);
                        counts.put(subfactory, supercount);
                    }
View Full Code Here

    private static Map<ComponentFactory,Count> doSimpleCount(Circuit circuit) {
        Map<ComponentFactory,Count> counts;
        counts = new HashMap<ComponentFactory,Count>();
        for (Component comp : circuit.getNonWires()) {
            ComponentFactory factory = comp.getFactory();
            Count count = counts.get(factory);
            if (count == null) {
                count = new Count(factory);
                counts.put(factory, count);
            }
View Full Code Here

    }

    private static void doUniqueCounts(Map<ComponentFactory,Count> counts,
            Map<Circuit,Map<ComponentFactory,Count>> circuitCounts) {
        for (Count count : counts.values()) {
            ComponentFactory factory = count.getFactory();
            int unique = 0;
            for (Circuit circ : circuitCounts.keySet()) {
                Count subcount = circuitCounts.get(circ).get(factory);
                if (subcount != null) {
                    unique += subcount.simpleCount;
View Full Code Here

    private static List<Count> sortCounts(Map<ComponentFactory,Count> counts,
            LogisimFile file) {
        List<Count> ret = new ArrayList<Count>();
        for (AddTool tool : file.getTools()) {
            ComponentFactory factory = tool.getFactory();
            Count count = counts.get(factory);
            if (count != null) {
                count.library = file;
                ret.add(count);
            }
        }
        for (Library lib : file.getLibraries()) {
            for (Tool tool : lib.getTools()) {
                if (tool instanceof AddTool) {
                    ComponentFactory factory = ((AddTool) tool).getFactory();
                    Count count = counts.get(factory);
                    if (count != null) {
                        count.library = lib;
                        ret.add(count);
                    }
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)) {
View Full Code Here

        @Override
        public void libraryChanged(LibraryEvent e) {
            switch (e.getAction()) {
            case LibraryEvent.ADD_TOOL:
                if (e.getData() instanceof AddTool) {
                    ComponentFactory factory = ((AddTool) e.getData()).getFactory();
                    if (factory instanceof SubcircuitFactory) {
                        SubcircuitFactory circFact = (SubcircuitFactory) factory;
                        processCircuit(circFact.getSubcircuit());
                    }
                }
                break;
            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);
View Full Code Here

        SimulationTreeModel model = (SimulationTreeModel) tree.getModel();
        if (ret instanceof JLabel) {
            JLabel label = (JLabel) ret;
            if (value instanceof SimulationTreeNode) {
                SimulationTreeNode node = (SimulationTreeNode) value;
                ComponentFactory factory = node.getComponentFactory();
                if (factory != null) {
                    label.setIcon(new RendererIcon(factory, node.isCurrentView(model)));
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.comp.ComponentFactory

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.