~tapaal-contributor/tapaal/autodetect-lens-check2

« back to all changes in this revision

Viewing changes to src/net/tapaal/swinghelpers/GridBagHelper.java

merged in lp:~yrke/tapaal/evenMore-gui-cleanup doing GUI cleanup and fixing memory access check, about menu in Mac, exception in verification and reenabled quick draw

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package net.tapaal.swinghelpers;
 
2
 
 
3
import java.awt.*;
 
4
 
 
5
public class GridBagHelper {
 
6
 
 
7
 
 
8
 
 
9
 
 
10
    public enum Anchor {
 
11
        NORTH(11),
 
12
        EAST(13),
 
13
        WEST(17),
 
14
        NORTHWEST(18);
 
15
 
 
16
        public final int value;
 
17
 
 
18
        Anchor(int value) {
 
19
            this.value = value;
 
20
        }
 
21
    }
 
22
 
 
23
    public enum Fill {
 
24
        HORIZONTAL(2);
 
25
 
 
26
        public final int value;
 
27
 
 
28
        Fill(int value) {
 
29
 
 
30
            this.value = value;
 
31
        }
 
32
    }
 
33
 
 
34
    public static GridBagConstraints as(int gridx, int gridy, Anchor anchor, Fill fill, Insets inset) {
 
35
        var gridBagConstraints = new GridBagConstraints();
 
36
        gridBagConstraints.gridx = gridx;
 
37
        gridBagConstraints.gridy = gridy;
 
38
 
 
39
        if (anchor != null) {
 
40
            gridBagConstraints.anchor = anchor.value;
 
41
        }
 
42
 
 
43
        if (fill != null) {
 
44
            gridBagConstraints.fill = fill.value;
 
45
        }
 
46
 
 
47
        if (inset != null) {
 
48
            gridBagConstraints.insets = inset;
 
49
        }
 
50
 
 
51
        return gridBagConstraints;
 
52
    }
 
53
    public static GridBagConstraints as(int gridx, int gridy, Anchor anchor, Insets inset) {
 
54
        return as(gridx, gridy, anchor, null, inset);
 
55
    }
 
56
 
 
57
    public static GridBagConstraints as(int gridx, int gridy, Fill fill, Insets inset) {
 
58
        return as(gridx, gridy, null, fill, inset);
 
59
    }
 
60
 
 
61
    public static GridBagConstraints as(int gridx, int gridy, Anchor anchor) {
 
62
        return as(gridx, gridy, anchor, null);
 
63
    }
 
64
 
 
65
    public static GridBagConstraints as(int gridx, int gridy, Insets inset) {
 
66
        return as(gridx, gridy, null, null, inset);
 
67
    }
 
68
 
 
69
    public static GridBagConstraints as(int gridx, int gridy) {
 
70
        return as(gridx, gridy, null, null, null);
 
71
    }
 
72
    public static GridBagConstraints as(int gridx, int gridy, int gridwidth, Anchor anchor, Insets inset) {
 
73
        return as(gridx, gridy, gridwidth, 1, anchor, inset);
 
74
    }
 
75
    public static GridBagConstraints as(int gridx, int gridy, int gridwidth, int gridtheight, Anchor anchor, Insets inset) {
 
76
        var r = as(gridx, gridy, anchor, null, inset );
 
77
        r.gridwidth = gridwidth;
 
78
        r.gridheight = gridtheight;
 
79
        return r;
 
80
    }
 
81
 
 
82
}