예제 #1
0
 private boolean noProperContent() {
   return model == null
       || model.getRowCount() <= 0
       || model.getColCount() <= 0
       || colWidth == null
       || colWidth.length <= 0;
 }
예제 #2
0
 public void refresh(boolean refreshModel) {
   if (model == null) {
     colWidth = null;
     cellShift = 0;
     hotPointX = 0;
     hotPointY = 0;
     environment.onAreaNewContent(this);
     environment.onAreaNewHotPoint(this);
     return;
   }
   if (refreshModel) model.refresh();
   final int colCount = model.getColCount();
   final int rowCount = model.getRowCount();
   if (colCount <= 0 || rowCount <= 0) {
     colWidth = null;
     cellShift = 0;
     hotPointX = 0;
     hotPointY = 0;
     environment.onAreaNewContent(this);
     environment.onAreaNewHotPoint(this);
     return;
   }
   initialHotPointX = appearance.getInitialHotPointX(model);
   colWidth = new int[colCount];
   int totalWidth = initialHotPointX;
   for (int i = 0; i < colCount; ++i) {
     final int width = appearance.getColWidth(model, i);
     colWidth[i] = width >= 1 ? width : 1;
     totalWidth += (colWidth[i] + 1);
   }
   if (hotPointY > rowCount) hotPointY = rowCount;
   if (hotPointY < rowCount && hotPointX >= totalWidth)
     hotPointX =
         totalWidth - 1; // totalWidth may not be zero as always we have at least one column here;
   if (hotPointY == rowCount) hotPointX = 0;
   environment.onAreaNewContent(this);
   environment.onAreaNewHotPoint(this);
 }
예제 #3
0
 @Override
 public String getLine(int index) {
   if (noProperContent())
     return index <= 0 ? environment.staticStr(LangStatic.TABLE_NO_CONTENT) : "";
   if (index < 0 || index >= model.getRowCount()) return "";
   final int currentCol = getColUnderPos(hotPointX);
   String line = getStringOfLen(appearance.getRowPrefix(model, index), initialHotPointX, "", "");
   if (index != hotPointY || currentCol < 0) {
     for (int i = 0; i < model.getColCount(); ++i)
       line += getStringOfLen(appearance.getCellText(model, i, index), colWidth[i], ">", " ");
     return line;
   }
   if (currentCol > 0)
     for (int i = 0; i < currentCol; ++i)
       line += getStringOfLen(appearance.getCellText(model, i, index), colWidth[i], ">", " ");
   String currentColText = appearance.getCellText(model, currentCol, index);
   if (cellShift > 0 && cellShift < currentColText.length())
     currentColText = currentColText.substring(cellShift);
   line += getStringOfLen(currentColText, colWidth[currentCol], ">", " ");
   if (currentCol + 1 < colWidth.length)
     for (int i = currentCol + 1; i < colWidth.length; ++i)
       line += getStringOfLen(appearance.getCellText(model, i, index), colWidth[i], ">", " ");
   return line;
 }