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

Last change on this file since 201 was 155, checked in by Tim Baarslag, 6 years ago

Fixed refactor TODO of createExperimentalOutcomeComparisonUserModel

Made fixed seed a checkbox

User guide fixes

File size: 2.5 KB
RevLine 
[83]1package genius.gui.tree;
2
[95]3import genius.core.listener.Listener;
[84]4import genius.core.utility.UncertainAdditiveUtilitySpace;
5import genius.core.utility.UtilitySpace;
[83]6import genius.gui.panels.BooleanModel;
[91]7import genius.gui.panels.IntegerModel;
[83]8
9/**
[139]10 * Holds the uncertainty settings (while editing a profile). This MVC model
11 * contains listenable fields and coordinates changes
[83]12 */
13public class UncertaintySettingsModel {
[130]14 private final BooleanModel isEnabled;
15 private final IntegerModel comparisons;
16 private final IntegerModel errors;
[155]17 private final BooleanModel isFixedSeed;
[130]18 private final BooleanModel isExperimental;
19 private final long totalBids;
[83]20
21 /**
[95]22 * @oaran space the {@link UtilitySpace} we're working with. This panel is
23 * enabled by default iff the space is an
24 * {@link UncertainAdditiveUtilitySpace}. If the space is
25 * {@link UncertainAdditiveUtilitySpace} we also copy the default
26 * values from there. Otherwise all default values are set to 0.
[83]27 */
[95]28 public UncertaintySettingsModel(UtilitySpace space) {
[130]29 final UncertainAdditiveUtilitySpace uspace = space instanceof UncertainAdditiveUtilitySpace
30 ? (UncertainAdditiveUtilitySpace) space
31 : null;
32
33 isEnabled = new BooleanModel(uspace != null);
34
[84]35 totalBids = space.getDomain().getNumberOfPossibleBids();
[130]36
[155]37 isFixedSeed = new BooleanModel(
38 (uspace != null) ? uspace.isFixedSeed() : true);
39
[130]40 isExperimental = new BooleanModel(
41 uspace != null ? uspace.isExperimental() : false);
42
[91]43 comparisons = new IntegerModel(
[155]44 uspace != null ? uspace.getComparisons() : 0, 0, (int) totalBids, 1);
[130]45
[91]46 errors = new IntegerModel(uspace != null ? uspace.getErrors() : 0, 0,
[88]47 (int) totalBids, 1);
[95]48
49 // copy enabledness -> lockedness of other components
50 isEnabled.addListener(new Listener<Boolean>() {
51 @Override
52 public void notifyChange(Boolean enabled) {
53 updateEnabledness(!enabled);
54 }
55 });
56 updateEnabledness(!isEnabled.getValue());
[83]57 }
58
[91]59 public IntegerModel getComparisons() {
[83]60 return comparisons;
61 }
62
[91]63 public IntegerModel getErrors() {
[83]64 return errors;
65 }
66
67 public BooleanModel getIsExperimental() {
68 return isExperimental;
69 }
70
71 public BooleanModel getIsEnabled() {
72 return isEnabled;
[155]73 }
74
75 public BooleanModel getIsFixedSeed() {
76 return isFixedSeed;
[83]77 }
78
79 public long getTotalBids() {
80 return totalBids;
81 }
82
[95]83 private void updateEnabledness(boolean lock) {
84 comparisons.setLock(lock);
85 errors.setLock(lock);
[155]86 isFixedSeed.setLock(lock);
[95]87 isExperimental.setLock(lock);
88 }
89
[83]90}
Note: See TracBrowser for help on using the repository browser.