Package com.cburch.logisim.comp

Examples of com.cburch.logisim.comp.Component


    }

    void reset() {
        wireData = null;
        for (Iterator<Component> it = componentData.keySet().iterator(); it.hasNext(); ) {
            Component comp = it.next();
            if (!(comp.getFactory() instanceof SubcircuitFactory)) {
                it.remove();
            }

        }
        values.clear();
View Full Code Here


    private class MyCircuitListener implements CircuitListener {
        @Override
        public void circuitChanged(CircuitEvent event) {
            int action = event.getAction();
            if (action == CircuitEvent.ACTION_ADD) {
                Component comp = (Component) event.getData();
                if (comp instanceof Wire) {
                    Wire w = (Wire) comp;
                    markPointAsDirty(w.getEnd0());
                    markPointAsDirty(w.getEnd1());
                } else {
                    markComponentAsDirty(comp);
                }
            } else if (action == CircuitEvent.ACTION_REMOVE) {
                Component comp = (Component) event.getData();
                if (comp.getFactory() instanceof SubcircuitFactory) {
                    // disconnect from tree
                    CircuitState substate = (CircuitState) getData(comp);
                    if (substate != null && substate.parentComp == comp) {
                        substates.remove(substate);
                        substate.parentState = null;
                        substate.parentComp = null;
                    }
                }

                if (comp instanceof Wire) {
                    Wire w = (Wire) comp;
                    markPointAsDirty(w.getEnd0());
                    markPointAsDirty(w.getEnd1());
                } else {
                    if (base != null) {
                        base.checkComponentEnds(CircuitState.this, comp);
                    }

                    dirtyComponents.remove(comp);
                }
            } else if (action == CircuitEvent.ACTION_CLEAR) {
                substates.clear();
                wireData = null;
                componentData.clear();
                values.clear();
                dirtyComponents.clear();
                dirtyPoints.clear();
                causes.clear();
            } else if (action == CircuitEvent.ACTION_CHANGE) {
                Object data = event.getData();
                if (data instanceof Collection) {
                    @SuppressWarnings("unchecked")
                    Collection<Component> comps = (Collection<Component>) data;
                    markComponentsDirty(comps);
                    if (base != null) {
                        for (Component comp : comps) {
                            base.checkComponentEnds(CircuitState.this, comp);
                        }
                    }
                } else {
                    Component comp = (Component) event.getData();
                    markComponentAsDirty(comp);
                    if (base != null) {
                        base.checkComponentEnds(CircuitState.this, comp);
                    }

                }
            } else if (action == CircuitEvent.ACTION_INVALIDATE) {
                Component comp = (Component) event.getData();
                markComponentAsDirty(comp);
                // TODO detemine if this should really be missing if (base != null) base.checkComponentEnds(CircuitState.this, comp);
            } else if (action == CircuitEvent.TRANSACTION_DONE) {
                ReplacementMap map = event.getResult().getReplacementMap(circuit);
                if (map != null) {
                    for (Component comp : map.getReplacedComponents()) {
                        Object compState = componentData.remove(comp);
                        if (compState != null) {
                            Class<?> compFactory = comp.getFactory().getClass();
                            boolean found = false;
                            for (Component repl : map.get(comp)) {
                                if (repl.getFactory().getClass() == compFactory) {
                                    found = true;
                                    setData(repl, compState);
View Full Code Here

        // first see how many elements we have; we can handle some simple
        // cases without creating any new lists
        ArrayList<Component> list = locData.components;
        int retSize = 0;
        Component retValue = null;
        for (Component o : list) {
            if ((o instanceof Wire) == isWire) {
                { retValue = o;
            }
retSize++; }
View Full Code Here

            if (e.state == state) {
                Location p = e.loc;
                g.drawOval(p.getX() - 4, p.getY() - 4, 8, 8);
            } else if (stateMap.containsKey(e.state)) {
                CircuitState substate = stateMap.get(e.state);
                Component subcirc = substate.getSubcircuit();
                Bounds b = subcirc.getBounds();
                g.drawRect(b.getX(), b.getY(), b.getWidth(), b.getHeight());
            }
        }
        GraphicsUtil.switchToWidth(g, 1);
    }
View Full Code Here

    public Bounds getBounds(Graphics g) {
        Iterator<Component> it = unionSet.iterator();
        if (it.hasNext()) {
            bounds = it.next().getBounds(g);
            while (it.hasNext()) {
                Component comp = it.next();
                Bounds bds = comp.getBounds(g);
                bounds = bounds.add(bds);
            }
        } else {
            bounds = Bounds.EMPTY_BOUNDS;
        }
View Full Code Here

        for (Component comp : components) {
            if (!(comp instanceof Wire)) {
                for (EndData endData : comp.getEnds()) {
                    if (endData != null && endData.isExclusive()) {
                        Location endLoc = endData.getLocation().translate(dx, dy);
                        Component conflict = circuit.getExclusive(endLoc);
                        if (conflict != null) {
                            if (selfConflicts || !components.contains(conflict)) {
                                return true;
                            }
View Full Code Here

            return Bounds.EMPTY_BOUNDS;
        } else {
            Iterator<Component> it = components.iterator();
            Bounds ret = it.next().getBounds();
            while (it.hasNext()) {
                Component comp = it.next();
                Bounds bds = comp.getBounds();
                ret = ret.add(bds);
            }
            return ret;
        }
    }
View Full Code Here

                newX = Canvas.snapXToGrid(newX);
                newY = Canvas.snapYToGrid(newY);
            }
            Location newLoc = Location.create(newX, newY);

            Component copy = comp.getFactory().createComponent(newLoc, attrs);
            ret.put(comp, copy);
        }
        return ret;
    }
View Full Code Here

        @Override
        public void circuitChanged(CircuitEvent event) {
            int act = event.getAction();
            if (act == CircuitEvent.ACTION_REMOVE) {
                Component c = (Component) event.getData();
                if (c == painter.getHaloedComponent()) {
                    proj.getFrame().viewComponentAttributes(null, null);
                }
            } else if (act == CircuitEvent.ACTION_CLEAR) {
                if (painter.getHaloedComponent() != null) {
View Full Code Here

                    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

TOP

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

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.