source: src/main/java/genius/gui/tree/UncertaintySettingsModel.java@ 86

Last change on this file since 86 was 86, checked in by Wouter Pasman, 6 years ago

#28 improve robustness of xml parser - trim string before trying to parse ints.

File size: 1.5 KB
Line 
1package genius.gui.tree;
2
3import javax.swing.SpinnerModel;
4import javax.swing.SpinnerNumberModel;
5
6import genius.core.utility.UncertainAdditiveUtilitySpace;
7import genius.core.utility.UtilitySpace;
8import genius.gui.panels.BooleanModel;
9
10/**
11 * Holds the uncertainty settings (while editing a profile)
12 */
13public class UncertaintySettingsModel {
14 private BooleanModel isEnabled;
15 private SpinnerModel comparisons;
16 private SpinnerModel errors;
17 private BooleanModel isExperimental = new BooleanModel(false);
18 private long totalBids;
19
20 /**
21 * @oaran nbids the number of bids in the space.
22 * @param enable
23 * the default value for enabledness of Uncertainty.
24 */
25 public UncertaintySettingsModel(UtilitySpace space, boolean enable) {
26 isEnabled = new BooleanModel(enable);
27 totalBids = space.getDomain().getNumberOfPossibleBids();
28 UncertainAdditiveUtilitySpace uspace = (space instanceof UncertainAdditiveUtilitySpace)
29 ? (UncertainAdditiveUtilitySpace) space : null;
30 comparisons = new SpinnerNumberModel(
31 uspace != null ? uspace.getComparisons() : 0, 0, totalBids, 1);
32 errors = new SpinnerNumberModel(uspace != null ? uspace.getErrors() : 0,
33 0, totalBids, 1.);
34 }
35
36 public SpinnerModel getComparisons() {
37 return comparisons;
38 }
39
40 public SpinnerModel getErrors() {
41 return errors;
42 }
43
44 public BooleanModel getIsExperimental() {
45 return isExperimental;
46 }
47
48 public BooleanModel getIsEnabled() {
49 return isEnabled;
50 }
51
52 public long getTotalBids() {
53 return totalBids;
54 }
55
56}
Note: See TracBrowser for help on using the repository browser.