User Tools

Site Tools


struktura:marklar-fx-common:settings:experiment

Experiment

Cela zalozka s experimentem ma controller SettingsExperimentTabControler. Tento controller zobrazuje typ experimentu a pod nej pak vklada specificke nastaveni zvoleneho ExperimentType. Toto nastaveni musi odvozovat od interface ExperimentEditorSettingsPaneController a je ziskavano z ExperimentTypeGraphicFacotry.

public GraphicControllerDTO getSettingsGraphic();

Jelikoz ExperimentEditorSettingsPaneController obstarava nastaveni ExperimentType (prostrednictvim teto zalozky v nastaveni) i nastaveni ExperimentInstance (pri editaci/vytvareni ExperimentInstance), je treba pri jeho implementaci dodrzovat par direktiv. Jeho interface

public interface ExperimentEditorSettingsPaneController extends Initializable {
 
  public void setInstrument(Instrument instrument);
  public void setSettingsService(ExpInstanceSettingsService expInstSS);
  public void setSettingsService(ExpTypeSettingsService expTypeSS);
 
  public void loadSettings();
  public void saveSettings();
 
  public void processEvent(EventHandler<KeyEvent> keyEvent);
  public double getPrefHeight();
}

Komentar k pretizene metode setSettingsService(…) bude nasledovat. processEvent() pouze predava event jednotlivym komponentam (napr. stisk Enter = ulozeni), getPrefHeight() vraci preferovanou vysku celeho view.

Ukladani/nacitani nastaveni se provadi v zavislosti na tom, jaka z ExpInstanceSettingsService a ExpTypeSettingsService je deklarovana. Konkretni implementace metody loadSettings() muze vypadat nasledovne

@Override
public void loadSettings() {
  try {
    // OK, if ExpInstanceSettingsService is set
    loadSettigns(instanceSS);
  } catch (Exception e) {
    loadSettigns(defaultSS);
  }
}

Ukladani nastaveni by pak melo vypadat nasledovne

@Override
public void saveSettings() {
  DilExpSettingsInterface settings;
  if (instanceSS != null) {
    settings = (DilExpSettingsInterface) instanceSS;
  } else if (defaultSS != null) {
    settings = (DilExpSettingsInterface) defaultSS;
  } else
    return;
 
  settings.setStartT(Double.parseDouble(edtStartT.getText()));
  settings.setEndT(Double.parseDouble(edtEndT.getText()));
}

Vice k teto problematice je napsano v xxxxxxx

struktura/marklar-fx-common/settings/experiment.txt · Last modified: 2016/07/21 10:53 by jlochman