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

49
LINES

< > BotCompany Repo | #1019188 // Marked Faces Album [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (13915L/77K).

!7

cmodule MarkedFaces extends DynSCP {
  File dir;

  transient DynamicHStack buttons;
  transient ButtonImageLoader imageLoader;
  
  start {
    dir = ai_markedFacesDir();
    ownResource(vmBus_onDirChange(dir, r updateButtons));
  }

  JComponent visualize2() {
    setDir(dir);
    ret getComponent();
  }
  
  void setDir(File dir) {
    temp enter();
    setField(+dir);

    buttons = makeNiceButtons();
    imageLoader = new ButtonImageLoader(buttons) {
      void setAButtonsImage(JButton b, File f) {
        BufferedImage img = loadBufferedImage(f);
        BufferedImage preview = scaleBufferedImageToHeight(imageHeight, img);
        Rect face = cast unstruct(getFileInfoField(f, "Face position"));
        if (face != null)
          drawRect(preview, rescaleRect_imageToImage(face, img, preview), Color.white);
        setButtonImage(b, preview);
      }
    };
    updateButtons();
    setComponent(jHigherScrollPane(jfullcenter(buttons)));
  }
  
  void updateButtons {
    if (dir == null || buttons == null) ret;
    temp enter();
    L<File> imageFiles = listImageFiles(dir);
    L<TextImageAction> l = filesForNiceButtons(latestFilesFirst(imageFiles), f showImage);
    for (final TextImageAction tia : l)
      tia.popupMenuMaker = imageFilesPopupMenuFunction(tia);
    replaceNiceButtons(buttons, l);
    setModuleName(n2(l, "Marked Face"));
    if (imageLoader != null) imageLoader.update();
  }
}

Author comment

Began life as a copy of #1019109

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019188
Snippet name: Marked Faces Album [Dyn Module]
Eternal ID of this version: #1019188/5
Text MD5: 90b5e7f6f356249ec467342eecdc3658
Transpilation MD5: 564281116470102aa769c4beb5bc6191
Author: stefan
Category: javax / gui
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-20 13:44:27
Source code size: 1471 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 318 / 3932
Version history: 4 change(s)
Referenced in: [show references]