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

56
LINES

< > BotCompany Repo | #1005729 // showImageConceptsAsTable

JavaX fragment (include)

sbool showImageConceptsAsTable_latestFirst;

static JTable showImageConceptsAsTable(S title) {
  ret showImageConceptsAsTable(title, null);
}

static JTable showImageConceptsAsTable(S title, JTable table) {
  new L<L> data;
  Collection<Concept> concepts = allConcepts();
  if (showImageConceptsAsTable_latestFirst) concepts = reversed(concepts);
  for (Concept c : concepts) {
    S n = shortDynClassName(c) + c.id;
    if (c instanceof PNGFile) try {
      BufferedImage img = c/PNGFile.loadImage();
      if (img != null)
        data.add(ll(n, img));
      else
        data.add(ll(n, missingImageIcon()));
    } catch e {
      data.add(ll(n, missingImageIcon()));
    }
      
    for (S field : conceptFields(c)) {
      O o = cget(c, field);
      BufferedImage img = showImageConceptsAsTable_toBufferedImage(o);
      if (img != null)
        data.add(ll(n + "." + field, img));
      if (o instanceof Collection /*&& !o instanceof Concept.RefL*/) {
        int i = 0;
        for (O x : (Collection) o) {
          img = showImageConceptsAsTable_toBufferedImage(o);
          if (img != null)
            data.add(ll(n + "." + field + "[" + i + "]", img));
          ++i;
        }
      }
    }
  }
  
  L<S> cols = splitAtSpace("Concept.Field Image");
  
  if (table == null) table = sexyTable();
  fillTableWithData(table, data, cols);
  table.setRowHeight(100);
  
  showFrame(title, table);
  ret table;
}

static BufferedImage showImageConceptsAsTable_toBufferedImage(O o) {
  if (o instanceof BWImage)
    ret ((BWImage) o).getBufferedImage();
  if (o instanceof RGBImage)
    ret ((RGBImage) o).getBufferedImage();
  null;
}

Author comment

Began life as a copy of #1005397

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005729
Snippet name: showImageConceptsAsTable
Eternal ID of this version: #1005729/1
Text MD5: 9e61d1db92946639b8a7397f0f61f2b9
Author: stefan
Category: javax / concepts / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-05 13:53:19
Source code size: 1699 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 511 / 499
Referenced in: [show references]