Examples of Bounds


Examples of com.cburch.logisim.data.Bounds

    }
  }

  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) {
      dim = new Dimension(width, height);
    } else {
      dim = canvasPane.supportPreferredSize(width, height);
    }
    if (!immediate) {
      Bounds old = oldPreferredSize;
      if (old != null
          && Math.abs(old.getWidth() - dim.width) < THRESH_SIZE_UPDATE
          && Math.abs(old.getHeight() - dim.height) < THRESH_SIZE_UPDATE) {
        return;
      }
    }
    oldPreferredSize = Bounds.create(0, 0, dim.width, dim.height);
    setPreferredSize(dim);
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

        export(circ);
      }
    }
   
    private void export(Circuit circuit) {
      Bounds bds = circuit.getBounds(canvas.getGraphics())
        .expand(BORDER_SIZE);
      int width = (int) Math.round(bds.getWidth() * scale);
      int height = (int) Math.round(bds.getHeight() * scale);
      BufferedImage img = new BufferedImage(width, height,
          BufferedImage.TYPE_INT_RGB);
      Graphics base = img.getGraphics();
      Graphics g = base.create();
      g.setColor(Color.white);
      g.fillRect(0, 0, width, height);
      g.setColor(Color.black);
      if (g instanceof Graphics2D) {
        ((Graphics2D) g).scale(scale, scale);
        ((Graphics2D) g).translate(-bds.getX(), -bds.getY());
      } else {
        JOptionPane.showMessageDialog(frame,
            Strings.get("couldNotCreateImage"));
        monitor.close();
      }
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

      if (circ.hasConflict(c)) {
        canvas.setErrorMessage(Strings.getter("exclusiveError"));
        return;
      }
     
      Bounds bds = c.getBounds(g);
      if (bds.getX() < 0 || bds.getY() < 0) {
        canvas.setErrorMessage(Strings.getter("negativeCoordError"));
        return;
      }

      try {
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

      source.paintIcon(c, x, y, base);
    }
  }

  private void expose(java.awt.Component c, int x, int y) {
    Bounds bds = getBounds();
    c.repaint(x + bds.getX(), y + bds.getY(),
      bds.getWidth(), bds.getHeight());
  }
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

      state = value;
    }
  }

  private Bounds getBounds() {
    Bounds ret = bounds;
    if (ret == null) {
      ComponentFactory source = getFactory();
      if (source == null) {
        ret = Bounds.EMPTY_BOUNDS;
      } else {
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

  @Override
  public Bounds getOffsetBounds(AttributeSet attrs) {
    Direction facing = attrs.getValue(StdAttr.FACING);
    Direction defaultFacing = source.getAppearance().getFacing();
    Bounds bds = source.getAppearance().getOffsetBounds();
    return bds.rotate(defaultFacing, facing, 0, 0);
  }
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

    instance.recomputeBounds();
    configureLabel(instance); // since this affects the circuit's bounds
  }
 
  private void configureLabel(Instance instance) {
    Bounds bds = instance.getBounds();
    Direction loc = instance.getAttributeValue(CircuitAttributes.LABEL_LOCATION_ATTR);
   
    int x = bds.getX() + bds.getWidth() / 2;
    int y = bds.getY() + bds.getHeight() / 2;
    int ha = GraphicsUtil.H_CENTER;
    int va = GraphicsUtil.V_CENTER;
    if (loc == Direction.EAST) {
      x = bds.getX() + bds.getWidth() + 2;
      ha = GraphicsUtil.H_LEFT;
    } else if (loc == Direction.WEST) {
      x = bds.getX() - 2;
      ha = GraphicsUtil.H_RIGHT;
    } else if (loc == Direction.SOUTH) {
      y = bds.getY() + bds.getHeight() + 2;
      va = GraphicsUtil.V_TOP;
    } else {
      y = bds.getY() - 2;
      va = GraphicsUtil.V_BASELINE;
    }
    instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, x, y, ha, va);
  }
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

 
  private void configurePorts(Instance instance) {
    BitWidth widthObj = instance.getAttributeValue(StdAttr.WIDTH);
    int width = widthObj.getWidth();
    Boolean parallelObj = instance.getAttributeValue(ATTR_LOAD);
    Bounds bds = instance.getBounds();
    Port[] ps;
    if (parallelObj == null || parallelObj.booleanValue()) {
      Integer lenObj = instance.getAttributeValue(ATTR_LENGTH);
      int len = lenObj == null ? 8 : lenObj.intValue();
      ps = new Port[6 + 2 * len];
      ps[LD] = new Port(10, -20, Port.INPUT, 1);
      ps[LD].setToolTip(Strings.getter("shiftRegLoadTip"));
      for (int i = 0; i < len; i++) {
        ps[6 + 2 * i]     = new Port(20 + 10 * i, -20, Port.INPUT, width);
        ps[6 + 2 * i + 1] = new Port(20 + 10 * i,  20, Port.OUTPUT, width);
      }
    } else {
      ps = new Port[5];
    }
    ps[OUT] = new Port(bds.getWidth(), 0, Port.OUTPUT, width);
    ps[SH= new Port( 0, -10, Port.INPUT, 1);
    ps[IN= new Port( 0,   0, Port.INPUT, width);
    ps[CK= new Port( 010, Port.INPUT, 1);
    ps[CLR] = new Port(1020, Port.INPUT, 1);
    ps[OUT].setToolTip(Strings.getter("shiftRegOutTip"));
    ps[SH].setToolTip(Strings.getter("shiftRegShiftTip"));
    ps[IN].setToolTip(Strings.getter("shiftRegInTip"));
    ps[CK].setToolTip(Strings.getter("shiftRegClockTip"));
    ps[CLR].setToolTip(Strings.getter("shiftRegClearTip"));
    instance.setPorts(ps);

    instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT,
        bds.getX() + bds.getWidth() / 2,
        bds.getY() + bds.getHeight() / 4,
        GraphicsUtil.H_CENTER, GraphicsUtil.V_CENTER);
  }
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

      Integer lenObj = painter.getAttributeValue(ATTR_LENGTH);
      int len = lenObj == null ? 8 : lenObj.intValue();
      if (painter.getShowState()) {
        if (wid <= 4) {
          ShiftRegisterData data = getData(painter);
          Bounds bds = painter.getBounds();
          int x = bds.getX() + 20;
          int y = bds.getY();
          Object label = painter.getAttributeValue(StdAttr.LABEL);
          if (label == null || label.equals("")) {
            y += bds.getHeight() / 2;
          } else {
            y += 3 * bds.getHeight() / 4;
          }
          Graphics g = painter.getGraphics();
          for (int i = 0; i < len; i++) {
            String s = data.get(len - 1 - i).toHexString();
            GraphicsUtil.drawCenteredText(g, s, x, y);
            x += 10;
          }
        }
      } else {
        Bounds bds = painter.getBounds();
        int x = bds.getX() + bds.getWidth() / 2;
        int y = bds.getY();
        int h = bds.getHeight();
        Graphics g = painter.getGraphics();
        Object label = painter.getAttributeValue(StdAttr.LABEL);
        if (label == null || label.equals("")) {
          String a = Strings.get("shiftRegisterLabel1");
          GraphicsUtil.drawCenteredText(g, a, x, y + h / 4);
View Full Code Here

Examples of com.cburch.logisim.data.Bounds

    Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
    boolean drawSquare = painter.getAttributeValue(ATTR_DOT_SHAPE) == SHAPE_SQUARE;

    State data = getState(painter);
    long ticks = painter.getTickCount();
    Bounds bds = painter.getBounds();
    boolean showState = painter.getShowState();
    Graphics g = painter.getGraphics();
    int rows = data.rows;
    int cols = data.cols;
    for (int j = 0; j < rows; j++) {
      for (int i = 0; i < cols; i++) {
        int x = bds.getX() + 10 * i;
        int y = bds.getY() + 10 * j;
        if (showState) {
          Value val = data.get(j, i, ticks);
          Color c;
          if (val == Value.TRUE) c = onColor;
          else if (val == Value.FALSE) c = offColor;
          else c = Value.ERROR_COLOR;
          g.setColor(c);
         
          if (drawSquare) g.fillRect(x, y, 10, 10);
          else g.fillOval(x + 1, y + 1, 8, 8);
        } else {
          g.setColor(Color.GRAY);
          g.fillOval(x + 1, y + 1, 8, 8);
        }
      }
    }
    g.setColor(Color.BLACK);
    GraphicsUtil.switchToWidth(g, 2);
    g.drawRect(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
    GraphicsUtil.switchToWidth(g, 1);
    painter.drawPorts();
  }
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.