예제 #1
0
  /**
   * Draws the offsets in the offset view.
   *
   * @param g The graphics context of the hex panel.
   */
  private void drawOffsets(final Graphics g) {
    final int linesToDraw = getNumberOfVisibleRows();

    final String formatString = m_addressMode == AddressMode.BIT32 ? "%08X" : "%016X";
    final long elementSize = getElementSize();

    final long baseAddress = m_model.getStartAddress() == -1 ? 0 : m_model.getStartAddress();

    // Iterate over the data and print the offsets
    for (int i = 0; i < linesToDraw; i++) {
      final int elementIndex = m_firstRow + i;

      final long elementAddress = baseAddress + (elementIndex * elementSize);

      final String offsetString = String.format(formatString, elementAddress);

      if (elementAddress == m_model.getStackPointer()) {
        highlightStackPointer(g, i);
      }

      if (isEnabled()) {
        g.setColor(m_fontColorOffsets);
      } else {
        g.setColor(m_disabledColor != m_bgColorOffset ? m_disabledColor : Color.WHITE);
      }

      g.drawString(
          offsetString,
          PADDING_LEFT - (m_charWidth * m_firstColumn),
          m_paddingTop + (i * m_rowHeight));
    }
  }
예제 #2
0
  public String getValueAt(final Point point) {
    final int line = ((point.y - m_paddingTop) + m_rowHeight) / m_rowHeight;

    final long elementSize = getElementSize();

    final long startAddress = m_model.getStartAddress() + (m_firstRow * elementSize);

    final long elementAddress = startAddress + (line * elementSize);

    return m_model.hasData(elementAddress, elementSize) ? m_model.getElement(elementAddress) : null;
  }
예제 #3
0
  /**
   * Draws the stack values onto the screen.
   *
   * @param g The graphics context to paint on.
   */
  private void drawElements(final Graphics g) {
    if (isEnabled()) {
      // Choose the right color for the offset text
      g.setColor(m_fontColorValues);
    } else {
      g.setColor(m_disabledColor != m_bgColorOffset ? m_disabledColor : Color.WHITE);
    }

    final int x = (10 + m_offsetViewWidth) - (m_charWidth * m_firstColumn);

    int linesToDraw = getNumberOfVisibleRows();

    if ((m_firstRow + linesToDraw) >= m_model.getNumberOfEntries()) {
      linesToDraw = m_model.getNumberOfEntries() - m_firstRow; // TODO: This can make linesToDraw
      // negative

      if (linesToDraw < 0) {
        // FIXME: This is a workaround for case 2337. The issue is real
        // but reproducing it can take hours. For this reason I am now
        // implementing this workaround, but in the future the underlying
        // cause of this behavior should be determined and fixed.

        return;
      }
    }

    if (m_model.getStartAddress() == -1) {
      return;
    }

    final long elementSize = getElementSize();

    if (m_status == DefinitionStatus.DEFINED) {
      final long startAddress = m_model.getStartAddress() + (m_firstRow * elementSize);

      final long numberOfBytes = linesToDraw * elementSize;

      if (!m_model.hasData(startAddress, numberOfBytes)) {
        setDefinitionStatus(DefinitionStatus.UNDEFINED);
        setEnabled(false);

        if (m_updateTimer != null) {
          m_updateTimer.setRepeats(false);
          m_updateTimer.stop();
        }

        m_updateTimer = new Timer(1000, new WaitingForDataAction(startAddress, numberOfBytes));
        m_updateTimer.setRepeats(true);
        m_updateTimer.start();

        return;
      }

      // Iterate over the data and print the offsets
      for (int i = 0; i < linesToDraw; i++) {
        final long elementAddress = startAddress + (i * elementSize);

        g.drawString(m_model.getElement(elementAddress), x, m_paddingTop + (i * m_rowHeight));
      }
    } else {
      // Iterate over the data and print the offsets
      for (int i = 0; i < linesToDraw; i++) {
        g.drawString(
            Strings.repeat("?", 2 * getElementSize()), x, m_paddingTop + (i * m_rowHeight));
      }
    }
  }