Examples of CircuitState


Examples of com.cburch.logisim.circuit.CircuitState

  }
 
  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

Examples of com.cburch.logisim.circuit.CircuitState

  //
  public void projectChanged(ProjectEvent event) {
    int action = event.getAction();
    if (action == ProjectEvent.ACTION_SET_STATE) {
      Simulator sim = project.getSimulator();
      CircuitState root = sim.getCircuitState();
      if (model.getRootState() != root) {
        model = new SimulationTreeModel(root);
        tree.setModel(model);
      }
      model.setCurrentView(project.getCircuitState());
View Full Code Here

Examples of com.cburch.logisim.circuit.CircuitState

    }
    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);
    gScaled.setColor(Color.RED);
    circState.drawOscillatingPoints(ptContext);
    gScaled.setColor(Color.BLUE);
    proj.getSimulator().drawStepPoints(ptContext);
    gScaled.dispose();
  }
View Full Code Here

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

Examples of com.cburch.logisim.circuit.CircuitState

    return context.getCircuitState().getProject();
  }
 
  public Value getPort(int portIndex) {
    InstanceComponent c = comp;
    CircuitState s = context.getCircuitState();
    if (c != null && s != null) {
      return s.getValue(c.getEnd(portIndex).getLocation());
    } else {
      return Value.UNKNOWN;
    }
  }
View Full Code Here

Examples of com.cburch.logisim.circuit.CircuitState

    EndData e = comp.getEnd(i);
    Location pt = e.getLocation();
    int x = pt.getX();
    int y = pt.getY();
    if (getShowState()) {
      CircuitState state = getCircuitState();
      g.setColor(state.getValue(pt).getColor());
    } else {
      g.setColor(Color.BLACK);
    }
    g.fillOval(x - PIN_OFFS, y - PIN_OFFS, PIN_RAD, PIN_RAD);
    g.setColor(curColor);
View Full Code Here

Examples of com.cburch.logisim.circuit.CircuitState

  public void drawPin(Component comp, int i) {
    EndData e = comp.getEnd(i);
    Location pt = e.getLocation();
    Color curColor = g.getColor();
    if (getShowState()) {
      CircuitState state = getCircuitState();
      g.setColor(state.getValue(pt).getColor());
    } else {
      g.setColor(Color.BLACK);
    }
    g.fillOval(pt.getX() - PIN_OFFS, pt.getY() - PIN_OFFS, PIN_RAD, PIN_RAD);
    g.setColor(curColor);
View Full Code Here

Examples of com.cburch.logisim.circuit.CircuitState

  public void drawPins(Component comp) {
    Color curColor = g.getColor();
    for (EndData e : comp.getEnds()) {
      Location pt = e.getLocation();
      if (getShowState()) {
        CircuitState state = getCircuitState();
        g.setColor(state.getValue(pt).getColor());
      } else {
        g.setColor(Color.BLACK);
      }
      g.fillOval(pt.getX() - PIN_OFFS, pt.getY() - PIN_OFFS, PIN_RAD, PIN_RAD);
    }
View Full Code Here

Examples of com.cburch.logisim.circuit.CircuitState

    return false;
  }

  private void showPopup(Set<AppearancePort> portObjects) {
    dragStart = null;
    CircuitState circuitState = canvas.getCircuitState();
    if (circuitState == null) return;
    ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size());
    for (AppearancePort portObject : portObjects) {
      ports.add(portObject.getPin());
    }
View Full Code Here

Examples of com.cburch.logisim.circuit.CircuitState

  }
 
  public void setCurrentState(Simulator sim, CircuitState value) {
    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
TOP
Copyright © 2018 www.massapi.com. 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.