Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

31
LINES

< > BotCompany Repo | #1017625 // fillTableWithData_makeData

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (7105L/42K).

static Pair<O[][], O[]> fillTableWithData_makeData(L<L> rows, LS colNames) {
  ret fillTableWithData_makeData(rows, asStringArray(colNames));
}

static Pair<O[][], O[]> fillTableWithData_makeData(L<L> rows, S... colNames) {
  Object[][] data = new Object[rows.size()][];
  int w = 0;
  for (int i = 0; i < rows.size(); i++) {
    L l = rows.get(i);
    Object[] r = new Object[l.size()];
    for (int j = 0; j < l.size(); j++) {
      O o = l.get(j);
      
      //print ifdef fillTableWithData_makeData_debug("fillTable " + getClass(o));
      
      if (o cast BufferedImage) o = imageIcon(o);
      ifclass RGBImage
        if (o cast RGBImage) o = imageIcon(o);
      endif
      /*if (o cast File)
        o = f2s(o);*/
      r[j] = o;
    }
    data[i] = r;
    w = Math.max(w, l.size());
  }
  O[] columnNames = new O[w];
  for (int i = 0; i < w; i++)
    columnNames[i] = i < l(colNames) ? colNames[i] : "?";
  ret pair(data, columnNames);
}

Author comment

Began life as a copy of #1004995

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017625
Snippet name: fillTableWithData_makeData
Eternal ID of this version: #1017625/6
Text MD5: 6117e53ce23da159ed2798605ed8dfda
Transpilation MD5: 007579ec47b9b3d31b5c8204ad5adde2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-10 16:18:18
Source code size: 982 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 364 / 439
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)