Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.CircuitState


            GraphicsUtil.switchToWidth(g, 1);
            g.setColor(Color.BLACK);
        }

        // draw circuit and selection
        CircuitState circState = proj.getCircuitState();
        boolean printerView = AppPreferences.PRINTER_VIEW.getBoolean();
        ComponentDrawContext context = new ComponentDrawContext(canvas,
                circ, circState, base, g, printerView);
        context.setHighlightedWires(highlightedWires);
        circ.draw(context, hidden);
View Full Code Here


    private static final int SPINE_DOT = Wire.WIDTH + 4;

    static void drawLines(ComponentDrawContext context,
            SplitterAttributes attrs, Location origin) {
        boolean showState = context.getShowState();
        CircuitState state = showState ? context.getCircuitState() : null;
        if (state == null) {
            showState = false;
        }


        SplitterParameters parms = attrs.getParameters();
        int x0 = origin.getX();
        int y0 = origin.getY();
        int x = x0 + parms.getEnd0X();
        int y = y0 + parms.getEnd0Y();
        int dx = parms.getEndToEndDeltaX();
        int dy = parms.getEndToEndDeltaY();
        int dxEndSpine = parms.getEndToSpineDeltaX();
        int dyEndSpine = parms.getEndToSpineDeltaY();

        Graphics g = context.getGraphics();
        Color oldColor = g.getColor();
        GraphicsUtil.switchToWidth(g, Wire.WIDTH);
        for (int i = 0, n = attrs.fanout; i < n; i++) {
            if (showState) {
                Value val = state.getValue(Location.create(x, y));
                g.setColor(val.getColor());
            }
            g.drawLine(x, y, x + dxEndSpine, y + dyEndSpine);
            x += dx;
            y += dy;
View Full Code Here

    }

    static void drawLegacy(ComponentDrawContext context, SplitterAttributes attrs,
            Location origin) {
        Graphics g = context.getGraphics();
        CircuitState state = context.getCircuitState();
        Direction facing = attrs.facing;
        int fanout = attrs.fanout;
        SplitterParameters parms = attrs.getParameters();

        g.setColor(Color.BLACK);
        int x0 = origin.getX();
        int y0 = origin.getY();
        int x1 = x0 + parms.getEnd0X();
        int y1 = y0 + parms.getEnd0Y();
        int dx = parms.getEndToEndDeltaX();
        int dy = parms.getEndToEndDeltaY();
        if (facing == Direction.NORTH || facing == Direction.SOUTH) {
            int ySpine = (y0 + y1) / 2;
            GraphicsUtil.switchToWidth(g, Wire.WIDTH);
            g.drawLine(x0, y0, x0, ySpine);
            int xi = x1;
            int yi = y1;
            for (int i = 1; i <= fanout; i++) {
                if (context.getShowState()) {
                    g.setColor(state.getValue(Location.create(xi, yi)).getColor());
                }
                int xSpine = xi + (xi == x0 ? 0 : (xi < x0 ? 10 : -10));
                g.drawLine(xi, yi, xSpine, ySpine);
                xi += dx;
                yi += dy;
            }
            if (fanout > 3) {
                GraphicsUtil.switchToWidth(g, SPINE_WIDTH);
                g.setColor(Color.BLACK);
                g.drawLine(x1 + dx, ySpine, x1 + (fanout - 2) * dx, ySpine);
            } else {
                g.setColor(Color.BLACK);
                g.fillOval(x0 - SPINE_DOT / 2, ySpine - SPINE_DOT / 2,
                        SPINE_DOT, SPINE_DOT);
            }
        } else {
            int xSpine = (x0 + x1) / 2;
            GraphicsUtil.switchToWidth(g, Wire.WIDTH);
            g.drawLine(x0, y0, xSpine, y0);
            int xi = x1;
            int yi = y1;
            for (int i = 1; i <= fanout; i++) {
                if (context.getShowState()) {
                    g.setColor(state.getValue(Location.create(xi, yi)).getColor());
                }
                int ySpine = yi + (yi == y0 ? 0 : (yi < y0 ? 10 : -10));
                g.drawLine(xi, yi, xSpine, ySpine);
                xi += dx;
                yi += dy;
View Full Code Here

        JOptionPane.showMessageDialog(frame,
            getFromLocale("couldNotCreateImage"));
        monitor.close();
      }

      CircuitState circuitState = canvas.getProject().getCircuitState(circuit);
      ComponentDrawContext context = new ComponentDrawContext(canvas,
          circuit, circuitState, base, g, printerView);
      circuit.draw(context, null);
      g.dispose();
    }
View Full Code Here

        if (currentState == value) {
            return;
        }

        Simulator oldSim = currentSim;
        CircuitState oldState = currentState;
        currentSim = sim;
        currentState = value;
        if (bottomState == null) {
            bottomState = currentState;
        } else if (currentState == null) {
            bottomState = null;
        } else {
            CircuitState cur = bottomState;
            while (cur != null && cur != currentState) {
                cur = cur.getParentState();
            }
            if (cur == null) {
                bottomState = currentState;
            }

        }

        boolean oldPresent = oldState != null;
        boolean present = currentState != null;
        if (oldPresent != present) {
            computeEnabled();
        }

        if (currentSim != oldSim) {
            double freq = currentSim == null ? 1.0 : currentSim.getTickFrequency();
            for (int i = 0; i < tickFreqs.length; i++) {
                tickFreqs[i].setSelected(Math.abs(tickFreqs[i].freq - freq) < 0.001);
            }

            if (oldSim != null) {
                oldSim.removeSimulatorListener(myListener);
            }

            if (currentSim != null) {
                currentSim.addSimulatorListener(myListener);
            }

            myListener.simulatorStateChanged(new SimulatorEvent(sim));
        }

        clearItems(downStateItems);
        CircuitState cur = bottomState;
        while (cur != null && cur != currentState) {
            downStateItems.add(new CircuitStateMenuItem(cur));
            cur = cur.getParentState();
        }
        if (cur != null) {
            cur = cur.getParentState();
        }

        clearItems(upStateItems);
        while (cur != null) {
            upStateItems.add(0, new CircuitStateMenuItem(cur));
            cur = cur.getParentState();
        }
        recreateStateMenus();
    }
View Full Code Here

    public void setLogModel(Model value) {
        this.logModel = value;

        DefaultTreeModel model = (DefaultTreeModel) getModel();
        CircuitNode curRoot = (CircuitNode) model.getRoot();
        CircuitState state = logModel == null ? null : logModel.getCircuitState();
        if (state == null) {
            if (curRoot != null) {
                model.setRoot(null);
            }
View Full Code Here

    public String toString() {
        return longDescriptor;
    }

    public Value fetchValue(CircuitState root) {
        CircuitState cur = root;
        for (int i = 0; i < path.length; i++) {
            SubcircuitFactory circFact = (SubcircuitFactory) path[i].getFactory();
            cur = circFact.getSubstate(cur, path[i]);
        }
        Loggable log = (Loggable) comp.getFeature(Loggable.class);
View Full Code Here

    }

    private void computeSize(boolean immediate) {
        hidePopup();
        Bounds bounds;
        CircuitState circState = circuitState;
        if (circState == null) {
            bounds = Bounds.create(0, 0, 50, 50);
        } else {
            bounds = circState.getCircuit().getAppearance().getAbsoluteBounds();
        }
        int width = bounds.getX() + bounds.getWidth() + BOUNDS_BUFFER;
        int height = bounds.getY() + bounds.getHeight() + BOUNDS_BUFFER;
        Dimension dim;
        if (canvasPane == null) {
View Full Code Here

        fileHeader = value;
        fireFilePropertyChanged(new ModelEvent());
    }

    public void propagationCompleted() {
        CircuitState circuitState = getCircuitState();
        Value[] vals = new Value[selection.size()];
        boolean changed = false;
        for (int i = selection.size() - 1; i >= 0; i--) {
            SelectionItem item = selection.get(i);
            vals[i] = item.fetchValue(circuitState);
View Full Code Here

            }
            Collections.sort(newChildren, new CompareByName());
            Collections.sort(subcircs, this);
            for (Component comp : subcircs) {
                SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
                CircuitState state = factory.getSubstate(circuitState, comp);
                CircuitNode toAdd = null;
                for (TreeNode o : children) {
                    if (o instanceof CircuitNode) {
                        CircuitNode n = (CircuitNode) o;
                        if (n.circuitState == state) {
View Full Code Here

TOP

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

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.