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

59
LINES

< > BotCompany Repo | #1006689 // showImage_centered

JavaX fragment (include)

please include function showImage.

static ImageSurface showImage_centered(final BufferedImage img) {
  ret (ImageSurface) swing(func {
    ImageSurface is = new ImageSurface(img);
    JPanel panel = new JPanel(new GridBagLayout);
    panel.add(is);
    JFrame frame = showPackedFrame(new JScrollPane(panel));
    frameIcon(frame, showImage_defaultIcon);
    return is;
  });
}

static ImageSurface showImage_centered(final BufferedImage img, fS title) {
  ret setFrameTitle(showImage_centered(img), title);
}

static ImageSurface showImage_centered(S title, BufferedImage img) {
  ret showImage_centered(img, title);
}

static ImageSurface showImage_centered(S title, RGBImage img) {
  return showImage_centered(title, img.getBufferedImage());
}

static ImageSurface showImage_centered(ImageSurface is, BufferedImage img) {
  if (is == null) ret showImage_centered(img);
  is.setImage(img);
  ret is;
}

// make or update the ImageSurface
static ImageSurface showImage_centered(ImageSurface is, S title, BufferedImage img) {
  if (is == null) ret showImage_centered(title, img);
  is.setImage(img);
  setFrameTitle(is, title);
  ret is;
}

static ImageSurface showImage_centered(ImageSurface surface, RGBImage img, S title) {
  ret setFrameTitle(showImage_centered(img, surface), title);
}

static ImageSurface showImage_centered(RGBImage img, ImageSurface surface) {
  if (surface == null)
    ret showImage_centered(img);
  else {
    surface.setImage(img);
    ret surface;
  }
}

static ImageSurface showImage_centered(RGBImage img) {
  return showImage_centered(img.getBufferedImage());
}

static ImageSurface showImage_centered(ImageSurface surface, S title, RGBImage img) {
  ret showImage_centered(surface, img, title);
}

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: 592 / 621
Version history: 7 change(s)
Referenced in: [show references]