User Tools

Site Tools


zalozeni:grafika:maintablecellforinstance

MainTableCellForInstance

Metoda getMainTableCellForInstance() tridy ExperimentTypeGraphicFactory vraci pro danou ExperimentInstance v zavislosti na ExperimentStatus instanci tridy GenericCell. Obecne povidani o GenericCell vcetne direktiv, ktere je treba pri jejim vytvareni dodrzovat, je mozno nalezt zde.

Konretni implementace GenericCell pro zobrazeni ExperimentInstance s ExperimentStaus = RUNNING je prilozena.

Graf je elegantne resen tridou DokuwikiGraph a AnchorPane graphPane, do ktere se graf vklada. Konstruktor definuje view, ke ktremu se tento controller vaze. Jakekoliv prekreslovani v prubehu mereni je rizeno Listenerama, ktere se definuji v metode setExpInst().

Metoda fillGraphics(), ktera plni grafiku pri prvotnim vykresleni, vola metody setBackgroundColor() (v zavislosti na ExperimentStatus zvoli pozadi bunky. Barvy definovany v jadre) a setImage(), ktera vlozi do imgView obrazek reprezentujici ExperimentStatus. Jake obrazky pro jaky ExperimentStatus jsem pouzil je ukazano zde. Obrazky je treba definovat rucne.

obrazek soubor pouzito pro ExperimentStatus
cancel.png SUSPENDED
check.png ENDED, ABORTED
lock.png NEW_LOCKED
play.png RUNNING
pause.png PAUSED
trash.png CRASHED
unlock.png NEW
public class DokuwikiRunningCellController extends GenericCell {
 
	@FXML
	private AnchorPane graphPane;
	@FXML
	private Label lblTemp;
	@FXML
	private ImageView imgView;
 
	private DokuwikiGraph graph;
 
	private DokuwikiExpInstanceSettignsService instanceSS;
	private DokuwikiDataService dataService;
 
	public DokuwikiRunningCellController(ExperimentInstance expInst) {
		super(expInst);
		setFXMLFile("DokuwikiRunningCell.fxml");
	}
 
	public void initialize(URL location, ResourceBundle resources) {
	}
 
	@Override
	public void setExpInst(ExperimentInstance expInst) {
		super.setExpInst(expInst);
		instanceSS = (DokuwikiExpInstanceSettignsService) expInst.getSettignsService();
		dataService = (DokuwikiDataService) expInst.getDataService();
 
		ServiceLocator.getInstance().getLogicModuleManager().registerListener(expInst, new ExperimentLogicListener() {
			@Override
			public void processEvent(LogicModuleEvent event) {
				if (event instanceof TempReadOutEvent) {
					TempReadOutEvent pevent = (TempReadOutEvent) event;
					lblTemp.setText(pevent.getTempString());
				}
			}
		});
	}
 
	@Override
	public void fillGraphics() {
		if (expInst == null)
			return;
 
		setBackgroundColor();
		setImage();
 
		lblTemp.setText("");
 
		graph = new DokuwikiGraph(graphPane, instanceSS, true);
		graph.repaint(dataService);
	}
 
	private void setImage() {
		if (expInst.getStatus() == ExperimentStatus.RUNNING) {
			imgView.setImage(new Image(this.getClass().getResourceAsStream("play.png")));
		}		
	}
 
}
zalozeni/grafika/maintablecellforinstance.txt · Last modified: 2016/07/28 17:29 by jlochman