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

57
LINES

< > BotCompany Repo | #1015431 // showImage_hcentered - align = center, valign = top - TODO

JavaX fragment (include)

please include function showImage.

static ImageSurface showImage_hcentered(final BufferedImage img) {
  ret (ImageSurface) swing(func {
    ImageSurface is = new ImageSurface(img);
    JFrame frame = showPackedFrame(new JScrollPane(vstack(jfullcenter(is))));
    frameIcon(frame, showImage_defaultIcon);
    return is;
  });
}

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

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

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

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

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

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

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

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

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

Author comment

Began life as a copy of #1006689

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: #1015431
Snippet name: showImage_hcentered - align = center, valign = top - TODO
Eternal ID of this version: #1015431/4
Text MD5: cf8071d486781a332485459cb4fa8662
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-13 22:34:10
Source code size: 1756 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 401 / 437
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)