コード例 #1
0
ファイル: MemState.java プロジェクト: EricStudley/logisim
  public void paint(Graphics g, int leftX, int topY) {
    int addrBits = getAddrBits();
    int dataBits = contents.getWidth();
    int boxX = leftX + (addrBits <= 12 ? ENTRY_XOFFS12 : ENTRY_XOFFS32);
    int boxY = topY + ENTRY_YOFFS;
    int boxW = addrBits <= 12 ? TABLE_WIDTH12 : TABLE_WIDTH32;
    int boxH = ROWS * ENTRY_HEIGHT;

    GraphicsUtil.switchToWidth(g, 1);
    g.drawRect(boxX, boxY, boxW, boxH);
    int entryWidth = boxW / columns;
    for (int row = 0; row < ROWS; row++) {
      long addr = (curScroll / columns * columns) + columns * row;
      int x = boxX;
      int y = boxY + ENTRY_HEIGHT * row;
      int yoffs = ENTRY_HEIGHT - 3;
      if (isValidAddr(addr)) {
        g.setColor(Color.GRAY);
        GraphicsUtil.drawText(
            g,
            StringUtil.toHexString(getAddrBits(), (int) addr),
            x - 2,
            y + yoffs,
            GraphicsUtil.H_RIGHT,
            GraphicsUtil.V_BASELINE);
      }
      g.setColor(Color.BLACK);
      for (int col = 0; col < columns && isValidAddr(addr); col++) {
        int val = contents.get(addr);
        if (addr == curAddr) {
          g.fillRect(x, y, entryWidth, ENTRY_HEIGHT);
          g.setColor(Color.WHITE);
          GraphicsUtil.drawText(
              g,
              StringUtil.toHexString(dataBits, val),
              x + entryWidth / 2,
              y + yoffs,
              GraphicsUtil.H_CENTER,
              GraphicsUtil.V_BASELINE);
          g.setColor(Color.BLACK);
        } else {
          GraphicsUtil.drawText(
              g,
              StringUtil.toHexString(dataBits, val),
              x + entryWidth / 2,
              y + yoffs,
              GraphicsUtil.H_CENTER,
              GraphicsUtil.V_BASELINE);
        }
        addr++;
        x += entryWidth;
      }
    }
  }
コード例 #2
0
  public void getRowData(int firstRow, int numRows, ValueTable.Cell[][] rowData) {
    Model model = getModel();
    TestException[] results = model.getResults();
    int numPass = model.getPass();
    int numFail = model.getFail();
    TestVector vec = model.getVector();
    int columns = vec.columnName.length;
    String msg[] = new String[columns];
    Value[] altdata = new Value[columns];
    String passMsg = Strings.get("passStatus");
    String failMsg = Strings.get("failStatus");

    for (int i = firstRow; i < firstRow + numRows; i++) {
      int row = model.sortedIndex(i);
      Value[] data = vec.data.get(row);
      String rowmsg = null;
      String status = null;
      boolean failed = false;
      if (row < numPass + numFail) {
        TestException err = results[row];
        if (err != null && err instanceof FailException) {
          failed = true;
          for (FailException e = (FailException) err; e != null; e = e.getMore()) {
            int col = e.getColumn();
            msg[col] =
                StringUtil.format(
                    Strings.get("expectedValueMessage"),
                    e.getExpected().toDisplayString(getColumnValueRadix(col + 1)));
            altdata[col] = e.getComputed();
          }
        } else if (err != null) {
          failed = true;
          rowmsg = err.getMessage();
        }
        status = failed ? failMsg : passMsg;
      }

      rowData[i - firstRow][0] =
          new ValueTable.Cell(status, rowmsg != null ? failColor : null, null, rowmsg);

      for (int col = 0; col < columns; col++) {
        rowData[i - firstRow][col + 1] =
            new ValueTable.Cell(
                altdata[col] != null ? altdata[col] : data[col],
                msg[col] != null ? failColor : null,
                null,
                msg[col]);
        msg[col] = null;
        altdata[col] = null;
      }
    }
  }
コード例 #3
0
ファイル: Strings.java プロジェクト: sivart73/Brandonsim
 public static String get(String key, String arg) {
   return StringUtil.format(source.get(key), arg);
 }