41 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.ui.group;
|
|
|
15 |
|
73 |
ilm |
16 |
import net.jcip.annotations.Immutable;
|
|
|
17 |
|
|
|
18 |
@Immutable
|
41 |
ilm |
19 |
public class LayoutHints {
|
73 |
ilm |
20 |
private final boolean visible;
|
|
|
21 |
private final boolean largeWidth;
|
|
|
22 |
private final boolean largeHeight;
|
41 |
ilm |
23 |
|
73 |
ilm |
24 |
private final boolean showLabel;
|
|
|
25 |
private final boolean separated;
|
|
|
26 |
private final boolean fillWidth;
|
|
|
27 |
private final boolean fillHeight;
|
|
|
28 |
// true if label and editor are separated
|
|
|
29 |
private final boolean split;
|
65 |
ilm |
30 |
|
|
|
31 |
public static final LayoutHints DEFAULT_FIELD_HINTS = new LayoutHints(false, false, true, false, false, false);
|
|
|
32 |
public static final LayoutHints DEFAULT_LARGE_FIELD_HINTS = new LayoutHints(false, false, true, false, true, false);
|
|
|
33 |
public static final LayoutHints DEFAULT_VERY_LARGE_FIELD_HINTS = new LayoutHints(true, false, true, false, false, false);
|
73 |
ilm |
34 |
public static final LayoutHints DEFAULT_VERY_LARGE_TEXT_HINTS = new LayoutHints(true, false, true, false, true, false, true);
|
65 |
ilm |
35 |
public static final LayoutHints DEFAULT_LIST_HINTS = new LayoutHints(true, true, false, true, true, true);
|
|
|
36 |
public static final LayoutHints DEFAULT_GROUP_HINTS = new LayoutHints(true, false, false, false, true, true);
|
|
|
37 |
public static final LayoutHints DEFAULT_SEPARATED_GROUP_HINTS = new LayoutHints(true, false, true, true, true, true);
|
67 |
ilm |
38 |
public static final LayoutHints DEFAULT_NOLABEL_SEPARATED_GROUP_HINTS = new LayoutHints(true, false, false, true, true, true);
|
41 |
ilm |
39 |
|
73 |
ilm |
40 |
public LayoutHints(boolean largeWidth, boolean largeHeight, boolean showLabel) {
|
|
|
41 |
this(largeWidth, largeHeight, showLabel, false, false, false);
|
|
|
42 |
}
|
|
|
43 |
|
65 |
ilm |
44 |
public LayoutHints(boolean largeWidth, boolean largeHeight, boolean showLabel, boolean separated, boolean fillWidth, boolean fillHeight) {
|
73 |
ilm |
45 |
this(largeWidth, largeHeight, showLabel, separated, fillWidth, fillHeight, false);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public LayoutHints(boolean largeWidth, boolean largeHeight, boolean showLabel, boolean separated, boolean fillWidth, boolean fillHeight, boolean split) {
|
|
|
49 |
this(largeWidth, largeHeight, showLabel, separated, fillWidth, fillHeight, split, true);
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
public LayoutHints(boolean largeWidth, boolean largeHeight, boolean showLabel, boolean separated, boolean fillWidth, boolean fillHeight, boolean split, boolean visible) {
|
65 |
ilm |
53 |
this.largeWidth = largeWidth;
|
|
|
54 |
this.largeHeight = largeHeight;
|
41 |
ilm |
55 |
this.showLabel = showLabel;
|
|
|
56 |
this.separated = separated;
|
65 |
ilm |
57 |
this.fillWidth = fillWidth;
|
|
|
58 |
this.fillHeight = fillHeight;
|
73 |
ilm |
59 |
this.split = split;
|
|
|
60 |
this.visible = visible;
|
41 |
ilm |
61 |
}
|
|
|
62 |
|
67 |
ilm |
63 |
public LayoutHints(LayoutHints localHint) {
|
|
|
64 |
this.largeWidth = localHint.largeWidth;
|
|
|
65 |
this.largeHeight = localHint.largeHeight;
|
|
|
66 |
this.showLabel = localHint.showLabel;
|
|
|
67 |
this.separated = localHint.separated;
|
|
|
68 |
this.fillWidth = localHint.fillWidth;
|
|
|
69 |
this.fillHeight = localHint.fillHeight;
|
73 |
ilm |
70 |
this.split = localHint.split;
|
|
|
71 |
this.visible = localHint.visible;
|
67 |
ilm |
72 |
}
|
|
|
73 |
|
73 |
ilm |
74 |
public final LayoutHintsBuilder getBuilder() {
|
|
|
75 |
return new LayoutHintsBuilder(this.largeWidth, this.largeHeight, this.showLabel).setFillHeight(this.fillHeight).setFillWidth(this.fillWidth).setSeparated(this.separated).setSplit(this.split)
|
|
|
76 |
.setVisible(this.visible);
|
41 |
ilm |
77 |
}
|
|
|
78 |
|
73 |
ilm |
79 |
public boolean largeWidth() {
|
|
|
80 |
return this.largeWidth;
|
67 |
ilm |
81 |
}
|
|
|
82 |
|
65 |
ilm |
83 |
public boolean largeHeight() {
|
73 |
ilm |
84 |
return this.largeHeight;
|
41 |
ilm |
85 |
}
|
|
|
86 |
|
|
|
87 |
public boolean showLabel() {
|
73 |
ilm |
88 |
return this.showLabel;
|
41 |
ilm |
89 |
}
|
|
|
90 |
|
|
|
91 |
public boolean isSeparated() {
|
73 |
ilm |
92 |
return this.separated;
|
41 |
ilm |
93 |
}
|
|
|
94 |
|
65 |
ilm |
95 |
public boolean fillWidth() {
|
73 |
ilm |
96 |
return this.fillWidth;
|
41 |
ilm |
97 |
}
|
|
|
98 |
|
65 |
ilm |
99 |
public boolean fillHeight() {
|
73 |
ilm |
100 |
return this.fillHeight;
|
65 |
ilm |
101 |
}
|
|
|
102 |
|
73 |
ilm |
103 |
public boolean isSplit() {
|
|
|
104 |
return this.split;
|
67 |
ilm |
105 |
}
|
|
|
106 |
|
41 |
ilm |
107 |
@Override
|
|
|
108 |
public String toString() {
|
|
|
109 |
String r = "";
|
73 |
ilm |
110 |
if (this.largeHeight && this.largeWidth) {
|
65 |
ilm |
111 |
r += "LargeW&H";
|
41 |
ilm |
112 |
} else {
|
73 |
ilm |
113 |
if (this.largeHeight) {
|
65 |
ilm |
114 |
r += "LargeH";
|
41 |
ilm |
115 |
}
|
73 |
ilm |
116 |
if (this.largeWidth) {
|
65 |
ilm |
117 |
r += "LargeW";
|
41 |
ilm |
118 |
}
|
|
|
119 |
}
|
73 |
ilm |
120 |
if (this.separated) {
|
|
|
121 |
r += " Separated";
|
|
|
122 |
}
|
|
|
123 |
if (this.showLabel) {
|
|
|
124 |
r += " StdLabel";
|
41 |
ilm |
125 |
} else {
|
73 |
ilm |
126 |
r += " NoLabel";
|
41 |
ilm |
127 |
}
|
73 |
ilm |
128 |
if (this.split) {
|
|
|
129 |
r += " (label and editor splitted)";
|
|
|
130 |
}
|
|
|
131 |
if (this.fillHeight && this.fillWidth) {
|
65 |
ilm |
132 |
r += " FillW&H";
|
|
|
133 |
} else {
|
73 |
ilm |
134 |
if (this.fillHeight) {
|
65 |
ilm |
135 |
r += " FillH";
|
|
|
136 |
}
|
73 |
ilm |
137 |
if (this.fillWidth) {
|
65 |
ilm |
138 |
r += " FillW";
|
|
|
139 |
}
|
41 |
ilm |
140 |
}
|
73 |
ilm |
141 |
if (!this.isVisible()) {
|
|
|
142 |
r += " (hidden)";
|
|
|
143 |
}
|
41 |
ilm |
144 |
return r;
|
|
|
145 |
}
|
73 |
ilm |
146 |
|
|
|
147 |
public boolean isVisible() {
|
|
|
148 |
return visible;
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
@Override
|
|
|
152 |
public int hashCode() {
|
|
|
153 |
final int prime = 31;
|
|
|
154 |
int result = 1;
|
|
|
155 |
result = prime * result + (this.fillHeight ? 1231 : 1237);
|
|
|
156 |
result = prime * result + (this.fillWidth ? 1231 : 1237);
|
|
|
157 |
result = prime * result + (this.largeHeight ? 1231 : 1237);
|
|
|
158 |
result = prime * result + (this.largeWidth ? 1231 : 1237);
|
|
|
159 |
result = prime * result + (this.separated ? 1231 : 1237);
|
|
|
160 |
result = prime * result + (this.showLabel ? 1231 : 1237);
|
|
|
161 |
result = prime * result + (this.split ? 1231 : 1237);
|
|
|
162 |
result = prime * result + (this.visible ? 1231 : 1237);
|
|
|
163 |
return result;
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
@Override
|
|
|
167 |
public boolean equals(Object obj) {
|
|
|
168 |
if (this == obj)
|
|
|
169 |
return true;
|
|
|
170 |
if (obj == null)
|
|
|
171 |
return false;
|
|
|
172 |
if (getClass() != obj.getClass())
|
|
|
173 |
return false;
|
|
|
174 |
final LayoutHints other = (LayoutHints) obj;
|
|
|
175 |
return this.fillHeight == other.fillHeight && this.fillWidth == other.fillWidth && this.largeHeight == other.largeHeight && this.largeWidth == other.largeWidth
|
|
|
176 |
&& this.separated == other.separated && this.showLabel == other.showLabel && this.split == other.split && this.visible == other.visible;
|
|
|
177 |
}
|
41 |
ilm |
178 |
}
|