package nl.tudelft.dnainator.ui.controllers;

import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.fxml.FXML;
import javafx.scene.Group;
import javafx.scene.input.MouseEvent;
import nl.tudelft.dnainator.ui.models.GraphModel;

/**
 * Controller class for all graph interaction.
 */
public class GraphController {
	@FXML private Group graphRoot;
	private ObjectProperty<GraphModel> graphModel;

	@FXML
	private void initialize() {
		this.graphModel = new SimpleObjectProperty<GraphModel>(this, "graphModel");

		setModel(new GraphModel());
	}

	/**
	 * @return The current {@link GraphModel}.
	 */
	public final GraphModel getModel() {
		return graphModel.get();
	}

	/**
	 * @param graphModel The new {@link GraphModel}.
	 */
	public final void setModel(GraphModel graphModel) {
		this.graphModel.set(graphModel);
	}

	/**
	 * @return The graph model property.
	 */
	public ObjectProperty<GraphModel> modelProperty() {
		return graphModel;
	}

	@FXML
	private void onMouseClick(MouseEvent e) {
		System.out.println(getModel().getNodes().get(0));
	}
}

@@ -225,16 +225,70 @@
 eEvent;%0A
+import nl.tudelft.dnainator.core.DefaultSequenceNode;%0A
 import n
@@ -329,16 +329,16 @@
 hModel;%0A
-
 %0A/**%0A * 
@@ -618,31 +618,300 @@
 %0A%0A%09%09
-setModel(new GraphModel
+GraphModel model = new GraphModel();%0A%09%09setModel(model);%0A%09%09// FIXME: have to read into javafx listeners concerning lazy evaluation.%0A%09%09model.nodesProperty().addListener((observable, oldValue, newValue) -%3E redraw());%0A%09%09model.edgesProperty().addListener((observable, oldValue, newValue) -%3E redraw
 ());
@@ -1368,16 +1368,18 @@
  e) %7B%0A%09%09
+//
 System.o
@@ -1420,13 +1420,230 @@
 et(0));%0A
+%09%09// CHECKSTYLE.OFF: MagicNumber%0A%09%09getModel().getNodes().add(new DefaultSequenceNode(%225%22, %22Hooman%22, 42, 43, %22ACTG%22));%0A%09%09// CHECKSTYLE.ON: MagicNumber%0A%09%7D%0A%0A%09private void redraw() %7B%0A%09%09System.out.println(%22Redrawing...%22);%0A
 %09%7D%0A%7D%0A

Attach listeners to GraphModel's ObservableLists