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

59
LINES

< > BotCompany Repo | #1006689 // showImage_centered

JavaX fragment (include)

1  
please include function showImage.
2  
3  
static ImageSurface showImage_centered(final BufferedImage img) {
4  
  ret (ImageSurface) swing(func {
5  
    ImageSurface is = new ImageSurface(img);
6  
    JPanel panel = new JPanel(new GridBagLayout);
7  
    panel.add(is);
8  
    JFrame frame = showPackedFrame(new JScrollPane(panel));
9  
    frameIcon(frame, showImage_defaultIcon);
10  
    return is;
11  
  });
12  
}
13  
14  
static ImageSurface showImage_centered(final BufferedImage img, fS title) {
15  
  ret setFrameTitle(showImage_centered(img), title);
16  
}
17  
18  
static ImageSurface showImage_centered(S title, BufferedImage img) {
19  
  ret showImage_centered(img, title);
20  
}
21  
22  
static ImageSurface showImage_centered(S title, RGBImage img) {
23  
  return showImage_centered(title, img.getBufferedImage());
24  
}
25  
26  
static ImageSurface showImage_centered(ImageSurface is, BufferedImage img) {
27  
  if (is == null) ret showImage_centered(img);
28  
  is.setImage(img);
29  
  ret is;
30  
}
31  
32  
// make or update the ImageSurface
33  
static ImageSurface showImage_centered(ImageSurface is, S title, BufferedImage img) {
34  
  if (is == null) ret showImage_centered(title, img);
35  
  is.setImage(img);
36  
  setFrameTitle(is, title);
37  
  ret is;
38  
}
39  
40  
static ImageSurface showImage_centered(ImageSurface surface, RGBImage img, S title) {
41  
  ret setFrameTitle(showImage_centered(img, surface), title);
42  
}
43  
44  
static ImageSurface showImage_centered(RGBImage img, ImageSurface surface) {
45  
  if (surface == null)
46  
    ret showImage_centered(img);
47  
  else {
48  
    surface.setImage(img);
49  
    ret surface;
50  
  }
51  
}
52  
53  
static ImageSurface showImage_centered(RGBImage img) {
54  
  return showImage_centered(img.getBufferedImage());
55  
}
56  
57  
static ImageSurface showImage_centered(ImageSurface surface, S title, RGBImage img) {
58  
  ret showImage_centered(surface, img, title);
59  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006689
Snippet name: showImage_centered
Eternal ID of this version: #1006689/8
Text MD5: 07573cb4c5a0c776caaf4726db692089
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-03 01:52:20
Source code size: 1790 bytes / 59 lines
Pitched / IR pitched: No / No
Views / Downloads: 593 / 622
Version history: 7 change(s)
Referenced in: [show references]