void updateVisibleLinesAndColumns() {
    // Calculates how many lines and columns will be actually visible at the
    // moment.
    int currentVisibleLines = getNumberOfVisibleLines();
    int currentVisibleColumns = getNumberOfVisibleColumns();
    if ((currentlyVisibleLines != currentVisibleLines)
        || (currentlyVisibleColumns != currentVisibleColumns)) {
      currentlyVisibleLines = currentVisibleLines;
      currentlyVisibleColumns = currentVisibleColumns;

      // Include room for the newline characters.
      int properWidth = codeModel.getTotalWidthInCharacters();
      int properLines = currentlyVisibleLines + 1;
      charBuffer = new FormattedCharacterBuffer(properLines, properWidth);
      bufferedImage =
          new BufferedImage(
              properWidth * fontCharWidth,
              properLines * fontLineHeight,
              BufferedImage.TYPE_INT_RGB);
      bufferedGraphics = (Graphics2D) bufferedImage.getGraphics();
    }
  }
Updates/rewrites the internal representation of the character buffer (that will be drawn) from
the data model. Updating the character buffer from the data model requires a bit of care: The
model provides a sequence of rows, each divided into a fixed number of columns, and each cell
(identified by a row/column combination) can have multiple lines of text. To properly copy this
into a FormattedCharacterBuffer, the code iterates over all rows first. For each row, it
determines what the maximum number of text lines is (over all columns) - this is needed to
determine the overall height of the row. The individual cells are then filled into the right
row, and everything advances to the next row.
java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/CodeDisplay/CodeDisplay.java