blob: ff800de6467ae86b2ad218661db6c84870b041b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
@VaadinApache2LicenseForJavaFiles@
*/
package com.vaadin.shared.ui;
public final class AlignmentInfo {
/** Bitmask values for client server communication */
public static class Bits {
public static final int ALIGNMENT_LEFT = 1;
public static final int ALIGNMENT_RIGHT = 2;
public static final int ALIGNMENT_TOP = 4;
public static final int ALIGNMENT_BOTTOM = 8;
public static final int ALIGNMENT_HORIZONTAL_CENTER = 16;
public static final int ALIGNMENT_VERTICAL_CENTER = 32;
}
public static final AlignmentInfo LEFT = new AlignmentInfo(
Bits.ALIGNMENT_LEFT);
public static final AlignmentInfo RIGHT = new AlignmentInfo(
Bits.ALIGNMENT_RIGHT);
public static final AlignmentInfo TOP = new AlignmentInfo(
Bits.ALIGNMENT_TOP);
public static final AlignmentInfo BOTTOM = new AlignmentInfo(
Bits.ALIGNMENT_BOTTOM);
public static final AlignmentInfo CENTER = new AlignmentInfo(
Bits.ALIGNMENT_HORIZONTAL_CENTER);
public static final AlignmentInfo MIDDLE = new AlignmentInfo(
Bits.ALIGNMENT_VERTICAL_CENTER);
public static final AlignmentInfo TOP_LEFT = new AlignmentInfo(
Bits.ALIGNMENT_TOP + Bits.ALIGNMENT_LEFT);
private final int bitMask;
public AlignmentInfo(int bitMask) {
this.bitMask = bitMask;
}
public AlignmentInfo(AlignmentInfo horizontal, AlignmentInfo vertical) {
this(horizontal.getBitMask() + vertical.getBitMask());
}
public int getBitMask() {
return bitMask;
}
public boolean isTop() {
return (bitMask & Bits.ALIGNMENT_TOP) == Bits.ALIGNMENT_TOP;
}
public boolean isBottom() {
return (bitMask & Bits.ALIGNMENT_BOTTOM) == Bits.ALIGNMENT_BOTTOM;
}
public boolean isLeft() {
return (bitMask & Bits.ALIGNMENT_LEFT) == Bits.ALIGNMENT_LEFT;
}
public boolean isRight() {
return (bitMask & Bits.ALIGNMENT_RIGHT) == Bits.ALIGNMENT_RIGHT;
}
public boolean isVerticalCenter() {
return (bitMask & Bits.ALIGNMENT_VERTICAL_CENTER) == Bits.ALIGNMENT_VERTICAL_CENTER;
}
public boolean isHorizontalCenter() {
return (bitMask & Bits.ALIGNMENT_HORIZONTAL_CENTER) == Bits.ALIGNMENT_HORIZONTAL_CENTER;
}
public String getVerticalAlignment() {
if (isBottom()) {
return "bottom";
} else if (isVerticalCenter()) {
return "middle";
}
return "top";
}
public String getHorizontalAlignment() {
if (isRight()) {
return "right";
} else if (isHorizontalCenter()) {
return "center";
}
return "left";
}
}
|