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

56
LINES

< > BotCompany Repo | #1005729 // showImageConceptsAsTable

JavaX fragment (include)

1  
sbool showImageConceptsAsTable_latestFirst;
2  
3  
static JTable showImageConceptsAsTable(S title) {
4  
  ret showImageConceptsAsTable(title, null);
5  
}
6  
7  
static JTable showImageConceptsAsTable(S title, JTable table) {
8  
  new L<L> data;
9  
  Collection<Concept> concepts = allConcepts();
10  
  if (showImageConceptsAsTable_latestFirst) concepts = reversed(concepts);
11  
  for (Concept c : concepts) {
12  
    S n = shortDynClassName(c) + c.id;
13  
    if (c instanceof PNGFile) try {
14  
      BufferedImage img = c/PNGFile.loadImage();
15  
      if (img != null)
16  
        data.add(ll(n, img));
17  
      else
18  
        data.add(ll(n, missingImageIcon()));
19  
    } catch e {
20  
      data.add(ll(n, missingImageIcon()));
21  
    }
22  
      
23  
    for (S field : conceptFields(c)) {
24  
      O o = cget(c, field);
25  
      BufferedImage img = showImageConceptsAsTable_toBufferedImage(o);
26  
      if (img != null)
27  
        data.add(ll(n + "." + field, img));
28  
      if (o instanceof Collection /*&& !o instanceof Concept.RefL*/) {
29  
        int i = 0;
30  
        for (O x : (Collection) o) {
31  
          img = showImageConceptsAsTable_toBufferedImage(o);
32  
          if (img != null)
33  
            data.add(ll(n + "." + field + "[" + i + "]", img));
34  
          ++i;
35  
        }
36  
      }
37  
    }
38  
  }
39  
  
40  
  L<S> cols = splitAtSpace("Concept.Field Image");
41  
  
42  
  if (table == null) table = sexyTable();
43  
  fillTableWithData(table, data, cols);
44  
  table.setRowHeight(100);
45  
  
46  
  showFrame(title, table);
47  
  ret table;
48  
}
49  
50  
static BufferedImage showImageConceptsAsTable_toBufferedImage(O o) {
51  
  if (o instanceof BWImage)
52  
    ret ((BWImage) o).getBufferedImage();
53  
  if (o instanceof RGBImage)
54  
    ret ((RGBImage) o).getBufferedImage();
55  
  null;
56  
}

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: 626 / 593
Referenced in: [show references]