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

23
LINES

< > BotCompany Repo | #1016079 // formLayouter_rightAligned - splits available width among text areas

JavaX fragment (include)

1  
static F1<Container, Dimension> formLayouter_rightAligned() {
2  
  ret func(Container parent) -> Dimension {
3  
    L<Component> l = getComponents(parent);
4  
    BitSet bitOnes = layouting_bigOnes(l);
5  
    int nBigOnes = bigOnes.cardinality();
6  
    int mandatoryWidth = totalPreferredWidth(listWithoutIndicesInBitSet(l, bigOnes));
7  
    int gap = 4, outerSpacing = 5;
8  
    Dimension size = parent.getSize();
9  
    int totalSpace = size.width-outerSpacing*2-(l(l)-1)*gap;
10  
    int liberalSpace = totalSpace-mandatoryWidth;
11  
    double perBigOne = doubleRatio(liberalSpace, nBigOnes);
12  
    double x = nBigOnes == 0 ? size.width-outerSpacing-mandatoryWidth : outerSpacing;
13  
    for i over l: {
14  
      Component c = l.get(i);
15  
      bool big = contains(bigOnes, i);
16  
      double w = big ? perBigOne : c.getPreferredSize().width;
17  
      int actualX = iround(x);
18  
      c.setBounds(actualX, 10, iround(x+w)-actualX, size.height-outerSpacing*2);
19  
      x += w+gap;
20  
    }
21  
    ret componentsBoundingSize(parent, outerSpacing);
22  
  };
23  
}

Author comment

Began life as a copy of #1014730

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: #1016079
Snippet name: formLayouter_rightAligned - splits available width among text areas
Eternal ID of this version: #1016079/1
Text MD5: 9b555f7f5fcd6814f0a4795c2cb6e6a7
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-05 17:53:28
Source code size: 1022 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 365 / 410
Referenced in: [show references]