User Tools

Site Tools


zalozeni:grafika:settingsgraphic

SettingsGraphics

Grafika s nastavenim musi implementovat ExperimentEditorSettingsPaneController interface. Jeji nejjednodussi mozna podoba je ukazana. Prislusny fxml obsahujici anchorPane a edtStartT musi byt svazan s DokuwikiExperimentSettingsPaneController na urovni fxml.

Reseni nastaveni jedinou grafikou vede jednak ke zjednoduseni, jednak s sebou prinasi i jiste komplikace. Tento controller meni nastaveni obojiho: instanceSS a defaultSS (po zbeznem pohledu do kodu neni tezke odhalit, jak se mezi jednotlivymi nastavenimi rozlisuje - metody saveSettings(), loadSettings()).

Bezpodminecna je implementace obou verzi pretizene metody setSettingsService().

public class DokuwikiExperimentSettingsPaneController implements ExperimentEditorSettingsPaneController {
 
	@FXML
	private AnchorPane anchorPane;
	@FXML
	private TextField edtStartT;
 
	private DokuwikiInstrument instrument;
	private DokuwikiExpInstanceSettignsService instanceSS;
	private DokuwikiExpTypeSettingsService defaultSS;
 
	public void initialize(URL location, ResourceBundle resources) {
		// TODO Auto-generated method stub
	}
 
	public void setInstrument(Instrument instrument) {
		this.instrument = (DokuwikiInstrument) instrument;
	}
 
	public void setSettingsService(ExpInstanceSettingsService expInstSS) {
		this.instanceSS = (DokuwikiExpInstanceSettignsService) expInstSS;
	}
 
	public void setSettingsService(ExpTypeSettingsService expTypeSS) {
		this.defaultSS = (DokuwikiExpTypeSettingsService) defaultSS;
	}
 
	public void loadSettings() {
		try {
			loadSettings(instanceSS);
		} catch (Exception e) {
			loadSettings(defaultSS);
		}
	}
 
	private void loadSettings(DokuwikiExperimentSettingsInterface settings) {
		edtStartT.setText(DecimalHelper.toString(settings.getStartT(), 1));
	}
 
	public void saveSettings() {
		DokuwikiExperimentSettingsInterface settings;
		if (instanceSS != null) {
			settings = (DokuwikiExperimentSettingsInterface) instanceSS;
		} else if (defaultSS != null) {
			settings = (DokuwikiExperimentSettingsInterface) defaultSS;
		} else
			return;
 
		settings.setStartT(Double.parseDouble(edtStartT.getText()));
	}
 
	public void processEvent(EventHandler<KeyEvent> keyEvent) {
		edtStartT.setOnKeyReleased(keyEvent);
	}
 
	public double getPrefHeight() {
		return anchorPane.getPrefHeight();
	}
 
}
zalozeni/grafika/settingsgraphic.txt · Last modified: 2016/07/25 09:30 by jlochman