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

36
LINES

< > BotCompany Repo | #1035975 // G22RegionPanel

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (63282L) is out of date.

srecord noeq G22RegionPanel(IImageRegion region) > MetaWithChangeListeners is Swingable {
  settable transient G22Utils g22utils;
  settable BufferedImage originalImage;
  settableWithVar bool showOriginalColors = true;
  transient ImageSurface is;

  cachedVisualize {
    is = g22utils.stdImageSurface();
    imageSurfaceCheckerBoardBackground(is);
    varShowOriginalColors().onChangeAndNow(l0 updateImage);
    
    ret northAndCenterWithMargins(
      jcenteredline(
        liveValueCheckBox(varShowOriginalColors(),
          "Show original colors"),
        jbutton("Save mask", rThread saveMask)
      ),
      g22utils.wrap(is));
  }
  
  void updateImage {
    if (showOriginalColors)
      is.setImage(new CutOutRegionFromImage(region)
        .margin(10).fullImage(originalImage)!);
    else
      is.setImage(regionToBinaryImage(region));
  }
  
  void saveMask {
    var maskSize = g22utils.projectInfo().defaultMaskSize();
    var maskImage = g22standardRegionToMaskImage(region, maskSize);
    new G22MaskConcept mask;
    mask.maskImage = maskImage;
    g22utils.registerConcept(mask);
  }
}

Author comment

Began life as a copy of #1035971

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1035975
Snippet name: G22RegionPanel
Eternal ID of this version: #1035975/7
Text MD5: 507bf0b863fa7e9c052563d051fa091d
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-15 19:44:27
Source code size: 1144 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 16 / 48
Version history: 6 change(s)
Referenced in: [show references]