Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.Circuit$MyComponentListener


        LogisimFile file;
        try {
            file = loader.openLogisimFile(templReader);
        } catch (Exception t) {
            file = LogisimFile.createNew(loader);
            file.addCircuit(new Circuit("main"));
        } finally {
            try { templReader.close(); } catch (IOException e) { }
        }
        return file;
    }
View Full Code Here


@SuppressWarnings("serial")
class CircuitJList extends JList<Circuit> {
    public CircuitJList(Project proj, boolean includeEmpty) {
        LogisimFile file = proj.getLogisimFile();
        Circuit current = proj.getCurrentCircuit();
        Vector<Circuit> options = new Vector<Circuit>();
        boolean currentFound = false;
        for (Circuit circ : file.getCircuits()) {
            if (!includeEmpty || circ.getBounds() != Bounds.EMPTY_BOUNDS) {
                if (circ == current) currentFound = true;
View Full Code Here

        return shouldSnapValue == null ? true : shouldSnapValue.booleanValue();
    }

    private boolean hasConflictTranslated(Collection<Component> components,
            int dx, int dy, boolean selfConflicts) {
        Circuit circuit = proj.getCurrentCircuit();
        if (circuit == null) {
            return false;
        }

        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;
                            }

                        }
                    }
                }
                Location newLoc = comp.getLocation().translate(dx, dy);
                Bounds newBounds = comp.getBounds().translate(dx, dy);
                for (Component comp2 : circuit.getAllContaining(newLoc)) {
                    Bounds bds = comp2.getBounds();
                    if (bds.equals(newBounds)) {
                        if (selfConflicts || !components.contains(comp2)) {
                            return true;
                        }
View Full Code Here

                    : getFromLocale("dropComponentsAction");
        }

        @Override
        public void doIt(Project proj) {
            Circuit circuit = proj.getCurrentCircuit();
            CircuitMutation xn = new CircuitMutation(circuit);
            sel.dropAll(xn);
            CircuitTransactionResult result = xn.execute();
            xnReverse = result.getReverseTransaction();
        }
View Full Code Here

            return getFromLocale("deleteSelectionAction");
        }

        @Override
        public void doIt(Project proj) {
            Circuit circuit = proj.getCurrentCircuit();
            CircuitMutation xn = new CircuitMutation(circuit);
            sel.deleteAllHelper(xn);
            CircuitTransactionResult result = xn.execute();
            xnReverse = result.getReverseTransaction();
        }
View Full Code Here

            return getFromLocale("duplicateSelectionAction");
        }

        @Override
        public void doIt(Project proj) {
            Circuit circuit = proj.getCurrentCircuit();
            CircuitMutation xn = new CircuitMutation(circuit);
            sel.duplicateHelper(xn);

            CircuitTransactionResult result = xn.execute();
            xnReverse = result.getReverseTransaction();
View Full Code Here

    }

    @Override
    protected void paintComponent(Graphics g) {
        if (circuitState != null) {
            Circuit circuit = circuitState.getCircuit();
            Bounds bds = circuit.getBounds(g);
            Dimension size = getSize();
            double scaleX = (double) (size.width - 2 * BORDER) / bds.getWidth();
            double scaleY = (double) (size.height - 2 * BORDER) / bds.getHeight();
            double scale = Math.min(1.0, Math.min(scaleX, scaleY));

            Graphics gCopy = g.create();
            int borderX = (int) ((size.width - bds.getWidth() * scale) / 2);
            int borderY = (int) ((size.height - bds.getHeight() * scale) / 2);
            gCopy.translate(borderX, borderY);
            if (scale != 1.0 && g instanceof Graphics2D) {
                ((Graphics2D) gCopy).scale(scale, scale);
            }
            gCopy.translate(-bds.getX(), -bds.getY());

            ComponentDrawContext context = new ComponentDrawContext(this, circuit,
                    circuitState, g, gCopy);
            context.setShowState(false);
            context.setShowColor(false);
            circuit.draw(context, Collections.<Component>emptySet());
            if (ports != null) {
                gCopy.setColor(AppearancePort.COLOR);
                int width = Math.max(4, (int) ((2 / scale) + 0.5));
                GraphicsUtil.switchToWidth(gCopy, width);
                for (Instance port : ports) {
View Full Code Here

        }

        @Override
        public void doIt(Project proj) {
            Clipboard clip = Clipboard.get();
            Circuit circuit = proj.getCurrentCircuit();
            CircuitMutation xn = new CircuitMutation(circuit);
            Collection<Component> comps = clip.getComponents();
            Collection<Component> toAdd = computeAdditions(comps);
            if (toAdd.size() > 0) {
                sel.pasteHelper(xn, toAdd);
View Full Code Here

            return getFromLocale("moveSelectionAction");
        }

        @Override
        public void doIt(Project proj) {
            Circuit circuit = proj.getCurrentCircuit();
            CircuitMutation xn = new CircuitMutation(circuit);

            sel.translateHelper(xn, dx, dy);
            if (replacements != null) {
                xn.replace(replacements);
View Full Code Here

        if (zoomFactor != 1.0 && gScaled instanceof Graphics2D) {
            ((Graphics2D) gScaled).scale(zoomFactor, zoomFactor);
        }
        drawWithUserState(g, gScaled, proj);
        drawWidthIncompatibilityData(g, gScaled, proj);
        Circuit circ = proj.getCurrentCircuit();

        CircuitState circState = proj.getCircuitState();
        ComponentDrawContext ptContext = new ComponentDrawContext(canvas,
                circ, circState, g, gScaled);
        ptContext.setHighlightedWires(highlightedWires);
View Full Code Here

TOP

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

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.