예제 #1
0
파일: KTable.java 프로젝트: URMC/i2b2
 /**
  * Resizes the given column to its optimal width.
  *
  * <p>Is also called if user doubleclicks in the resize area of a resizable column.
  *
  * <p>The optimal width is determined by asking the CellRenderers for the visible cells of the
  * column for the optimal with and taking the minimum of the results. Note that the optimal width
  * is only determined for the visible area of the table because otherwise this could take very
  * long time.
  *
  * @param column The column to resize
  * @return int The optimal with that was determined or -1, if column out of range.
  */
 public int resizeColumnOptimal(int column) {
   if (column >= 0 && column < m_Model.getColumnCount()) {
     int optWidth = 5;
     for (int i = 0; i < m_Model.getFixedRowCount(); i++) {
       int width =
           m_Model
               .getCellRenderer(column, i)
               .getOptimalWidth(m_GC, column, i, m_Model.getContentAt(column, i), true);
       if (width > optWidth) optWidth = width;
     }
     for (int i = m_TopRow; i < m_TopRow + m_RowsVisible; i++) {
       int width =
           m_Model
               .getCellRenderer(column, i)
               .getOptimalWidth(m_GC, column, i, m_Model.getContentAt(column, i), true);
       if (width > optWidth) optWidth = width;
     }
     m_Model.setColumnWidth(column, optWidth);
     redraw();
     return optWidth;
   }
   return -1;
 }
예제 #2
0
파일: KTable.java 프로젝트: URMC/i2b2
  protected void drawCell(GC gc, int col, int row) {
    if ((row < 0) || (row >= m_Model.getRowCount())) {
      return;
    }

    Rectangle rect = getCellRect(col, row);

    m_Model
        .getCellRenderer(col, row)
        .drawCell(
            gc,
            rect,
            col,
            row,
            m_Model.getContentAt(col, row),
            showAsSelected(col, row),
            col < m_Model.getFixedColumnCount() || row < m_Model.getFixedRowCount(),
            col == m_ClickColumnIndex && row == m_ClickRowIndex);
  }