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.

1  
srecord noeq G22RegionPanel(IImageRegion region) > MetaWithChangeListeners is Swingable {
2  
  settable transient G22Utils g22utils;
3  
  settable BufferedImage originalImage;
4  
  settableWithVar bool showOriginalColors = true;
5  
  transient ImageSurface is;
6  
7  
  cachedVisualize {
8  
    is = g22utils.stdImageSurface();
9  
    imageSurfaceCheckerBoardBackground(is);
10  
    varShowOriginalColors().onChangeAndNow(l0 updateImage);
11  
    
12  
    ret northAndCenterWithMargins(
13  
      jcenteredline(
14  
        liveValueCheckBox(varShowOriginalColors(),
15  
          "Show original colors"),
16  
        jbutton("Save mask", rThread saveMask)
17  
      ),
18  
      g22utils.wrap(is));
19  
  }
20  
  
21  
  void updateImage {
22  
    if (showOriginalColors)
23  
      is.setImage(new CutOutRegionFromImage(region)
24  
        .margin(10).fullImage(originalImage)!);
25  
    else
26  
      is.setImage(regionToBinaryImage(region));
27  
  }
28  
  
29  
  void saveMask {
30  
    var maskSize = g22utils.projectInfo().defaultMaskSize();
31  
    var maskImage = g22standardRegionToMaskImage(region, maskSize);
32  
    new G22MaskConcept mask;
33  
    mask.maskImage = maskImage;
34  
    g22utils.registerConcept(mask);
35  
  }
36  
}

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