User Tools

Site Tools


zalozeni:grafika:graphicfactory

ExperimentTypeGraphicFactory

Trida ExperimentTypeGraphicFactory, ktera je predavana tridou ExperimentType je zodpovedna za predavani dilcich grafickych modulu. Jeji konkretni implementace je zde ukazana.

AnchorPaneHelper je trida z jadra, ktera nacte patricnou kombinaci view+controller do objektu reprezentovaneho tridou GraphicControllerDTO (ktery je rovnez definovan v jadre).

public class GraphicControllerDTO {
	private Object controller;
	private Pane graphic;
 
	+ getters, setters
}

Pri vytvareni GraphicControlelrDTO je controlleru automaticky predan i patricny parametr (ExperimentInstance, List<ExperimentIntance>, Instrument). Pouze prvni metoda getSettingsGraphic() nic nepredava. To je z duvodu, ze tento Pane je v aplikaci pouzit dvakrat - poprve v nastaveni (kde nacita a uklada nastaveni z ExperimentType) a podruhe v editaci ExperimentInstance (kde nacita nastaveni z ExperimentType, pokud nejsou u ExperimentInstance, ale uklada vzdy jako ExperimentInstance). V zavislosti na tom, zda ma tento controller nastavenu ExperimentInstance je rizeno patricne ukladani.

Posledni dve metody vraceji misto GraphicControllerDTO tridu GenericCell, ktera ma sva specifika, ktera jsou vysvetlena zde.

Detailni popis grafiky, kterou vraceji jednotlive metody, je mozno nalezt

  • getSettingsGraphic zde
  • getMeasurementControllPanel zde
  • getExperimentTabs zde
  • getCallibrationGraphic zde
  • getProtocolGraphic zde
  • getCorrectionersGraphics zde
  • getExperimentInfoTab zde
  • getMainTableCellForInstance zde
  • getMainResultCellForInstanceszde

Co se lokalizace tyce, jakykoliv preklad vkladany do grafiky by mel byt obsazen v grafickem bundleu.

public class DokuwikiGraphicFactory implements ExperimentTypeGraphicFactory {
 
	public GraphicControllerDTO getSettingsGraphic() {
		return AnchorPaneHelper.loadFXPaneByName(DokuwikiExperimentSettingsPaneController.class
				.getResource("DokuwikiExperimentSettingsPane.fxml"));
	}
 
	public GraphicControllerDTO getMeasurementControllPanel(ExperimentInstance expInstance) {
		GraphicControllerDTO gcDTO = AnchorPaneHelper.loadFXPaneByName(DokuwikiControllPaneController.class
				.getResource("DokuwikiControllPane.fxml"));
		((DokuwikiControllPaneController) gcDTO.getController()).setExpInstance(expInstance);
		return gcDTO;
	}
 
	public GraphicControllerDTO getExperimentTabs(ExperimentInstance expInstance) {
		GraphicControllerDTO gcDTO = AnchorPaneHelper.loadFXPaneByName(DokuwikiTabsController.class.getResource("DokuwikiTabs.fxml"));
		((DokuwikiTabsController) gcDTO.getController()).setExpInstance(expInstance);
		return gcDTO;
	}
 
	public GraphicControllerDTO getCallibrationGraphic(Instrument instrument) {
		GraphicControllerDTO gcDTO = AnchorPaneHelper.loadFXPaneByName(DokuwikiCallibrationPaneController.class
				.getResource("DokuwikiCallibrationPane.fxml"));
		((DokuwikiCallibrationPaneController) gcDTO.getController()).setInstrument(instrument);
		return gcDTO;
	}
 
	public GraphicControllerDTO getProtocolGraphic() {
		return AnchorPaneHelper.loadFXPaneByName(DokuwikiProtocolPaneController.class.getResource("DokuwikiProtocolPane.fxml"));
	}
 
	public GraphicControllerDTO getCorrectionersGraphics(Instrument actualInstrument) {
		GraphicControllerDTO gcDTO = AnchorPaneHelper.loadFXPaneByName(DokuwikiCorrectionerPaneController.class
				.getResource("DokuwikiCorrectionerPane.fxml"));
		((DokuwikiCorrectionerPaneController) gcDTO.getController()).setInstrument(actualInstrument);
		return gcDTO;
	}
 
	public GraphicControllerDTO getExperimentInfoTab(ExperimentInstance expInstance) {
		GraphicControllerDTO gcDTO = AnchorPaneHelper.loadFXPaneByName(DokuwikiInfoPaneController.class
				.getResource("DokuwikiInfoPane.fxml"));
		((DokuwikiInfoPaneController) gcDTO.getController()).setExpInstance(expInstance);
		return gcDTO;
	}
 
	public GenericCell getMainTableCellForInstance(ExperimentInstance expInstance) {
		GenericCell cell = null;
 
		switch (expInstance.getStatus()) {
		case NEW: {
			cell = new DokuwikiPrepareCellController(expInstance);
			break;
		}
		case NEW_LOCKED: {
			cell = new DokuwikiPrepareCellController(expInstance);
			break;
		}
		case RUNNING: {
			cell = new DokuwikiRunningCellController(expInstance);
			break;
		}
		case PAUSED: {
			cell = new DokuwikiPausedCellController(expInstance);
			break;
		}
		case SUSPENDED: {
			cell = new DokuwikiPausedCellController(expInstance);
			break;
		}
		case CRASHED: {
			cell = new DokuwikiCrashedCellController(expInstance);
			break;
		}
		case ENDED: {
			cell = new DokuwikiEndedCellController(expInstance);
			break;
		}
		case ABORTED: {
			cell = new DokuwikiEndedCellController(expInstance);
			break;
		}
		}
 
		return cell;
	}
 
	public GenericCell getMainResultCellForInstances(List<ExperimentInstance> expInstances) {
		return new DokuwikiMainResultCellController(expInstances);
	}
}
zalozeni/grafika/graphicfactory.txt · Last modified: 2016/07/25 10:30 by jlochman