[1] | 1 | package genius.gui.uncertainty;
|
---|
| 2 |
|
---|
| 3 | import javax.swing.JOptionPane;
|
---|
| 4 |
|
---|
| 5 | import genius.core.listener.Listener;
|
---|
| 6 | import genius.core.repository.ProfileRepItem;
|
---|
| 7 | import genius.core.uncertainty.UncertainPreferenceContainer;
|
---|
| 8 | import genius.gui.panels.BooleanModel;
|
---|
| 9 |
|
---|
| 10 | public class PerceivedUtilityModel {
|
---|
| 11 |
|
---|
| 12 | private BooleanModel confirmationModel = new BooleanModel(false);
|
---|
| 13 |
|
---|
| 14 | private PerturbationModel perturbationModel;
|
---|
| 15 | private FlatteningModel flatteningModel;
|
---|
| 16 |
|
---|
| 17 | private BooleanModel perturbationActivationModel = new BooleanModel(false);
|
---|
| 18 | private BooleanModel flatteningActivationModel = new BooleanModel(false);
|
---|
| 19 |
|
---|
| 20 | private final ProfileRepItem profile;
|
---|
| 21 |
|
---|
| 22 | private UncertainPreferenceContainer uncertainPrefContainer = null;
|
---|
| 23 |
|
---|
| 24 | public PerceivedUtilityModel(ProfileRepItem profile) {
|
---|
| 25 |
|
---|
| 26 | this.profile = profile;
|
---|
| 27 | this.perturbationModel = new PerturbationModel(profile);
|
---|
| 28 | this.flatteningModel = new FlatteningModel(profile);
|
---|
| 29 | connect();
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | public void connect() {
|
---|
| 33 |
|
---|
| 34 | confirmationModel.addListener (new Listener<Boolean>() {
|
---|
| 35 |
|
---|
| 36 | @Override
|
---|
| 37 | public void notifyChange(Boolean data) {
|
---|
| 38 | if (confirmationModel.getValue() == true && perturbationActivationModel.getValue() == true) {
|
---|
| 39 | uncertainPrefContainer = perturbationModel.createContainer();
|
---|
| 40 | JOptionPane.showMessageDialog(null , "Perturbation User Model Created Successfully! \nPerturbation: "
|
---|
| 41 | + perturbationModel.getPerturbationBox().getText());
|
---|
| 42 | }
|
---|
| 43 | else if (confirmationModel.getValue() == true && flatteningActivationModel.getValue() == true) {
|
---|
| 44 | uncertainPrefContainer = flatteningModel.createContainer();
|
---|
| 45 | JOptionPane.showMessageDialog(null , "Flattened User Model Created Successfully! \n Strategy: "
|
---|
| 46 | +flatteningModel.getStrategyNamesModel().getSelection() +"\n");
|
---|
| 47 | }
|
---|
| 48 | confirmationModel.setValue(false);
|
---|
| 49 | perturbationActivationModel.setValue(false);
|
---|
| 50 | flatteningActivationModel.setValue(false);
|
---|
| 51 | }
|
---|
| 52 | });
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | public BooleanModel getConfirmationModel() {
|
---|
| 56 | return confirmationModel;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | public UncertainPreferenceContainer getUncertainPrefContainer() {
|
---|
| 60 | return uncertainPrefContainer;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | public BooleanModel getPerturbationActivationModel() {
|
---|
| 65 | return perturbationActivationModel;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | public BooleanModel getFlatteningActivationModel() {
|
---|
| 69 | return flatteningActivationModel;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | public PerturbationModel getPerturbationModel() {
|
---|
| 74 | return perturbationModel;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | public FlatteningModel getFlatteningModel() {
|
---|
| 78 | return flatteningModel;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | public ProfileRepItem getProfile() {
|
---|
| 82 | return profile;
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|