package nl.tudelft.dnainator.ui.models;

import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import nl.tudelft.dnainator.core.DefaultSequenceNode;
import nl.tudelft.dnainator.core.Edge;
import nl.tudelft.dnainator.core.SequenceNode;

/**
 * The bridging class between an implementation of {@link Graph} and JavaFX.
 * As the name implies, the GraphModel defines the Model part of the MVC pattern.
 */
public class GraphModel {
	private ListProperty<SequenceNode> nodesProperty;
	private ListProperty<Edge<Integer>> edgesProperty;

	/**
	 * Instantiates a new GraphModel object.
	 */
	public GraphModel() {
		nodesProperty = new SimpleListProperty<>(this, "nodes");
		edgesProperty = new SimpleListProperty<>(this, "edges");

		nodesProperty.set(FXCollections.observableArrayList());
		edgesProperty.set(FXCollections.observableArrayList());

		// CHECKSTYLE.OFF: MagicNumber
		getNodes().add(new DefaultSequenceNode("1", "Cat, Dog", 5, 7, "A"));
		getNodes().add(new DefaultSequenceNode("2", "Dog", 8, 10, "C"));
		getNodes().add(new DefaultSequenceNode("3", "Cat", 8, 9, "G"));
		getNodes().add(new DefaultSequenceNode("4", "Cat, Dog", 10, 13, "T"));

		getEdges().add(new Edge<Integer>(1, 2));
		getEdges().add(new Edge<Integer>(1, 3));
		getEdges().add(new Edge<Integer>(2, 4));
		getEdges().add(new Edge<Integer>(3, 4));
		// CHECKSTYLE.ON: MagicNumber
	}

	/**
	 * @return The {@link ObservableList} of nodes.
	 */
	public final ObservableList<SequenceNode> getNodes() {
		return nodesProperty.get();
	}

	/**
	 * Sets the nodes property to the new {@link ObservableList} of nodes.
	 * @param l The new {@link ObservableList} of nodes.
	 */
	public final void setNodes(ObservableList<SequenceNode> l) {
		nodesProperty.set(l);
	}

	/**
	 * @return The nodes property.
	 */
	public ListProperty<SequenceNode> nodesProperty() {
		return nodesProperty;
	}

	/**
	 * @return The {@link ObservableList} of edges.
	 */
	public final ObservableList<Edge<Integer>> getEdges() {
		return edgesProperty.get();
	}

	/**
	 * Sets the edges property to the new {@link ObservableList} of edges.
	 * @param l The new {@link ObservableList} of edges.
	 */
	public final void setEdges(ObservableList<Edge<Integer>> l) {
		edgesProperty.set(l);
	}

	/**
	 * @return The edges property.
	 */
	public ListProperty<Edge<Integer>> edgesProperty() {
		return edgesProperty;
	}
}

@@ -34,16 +34,40 @@
 odels;%0A%0A
+import java.util.List;%0A%0A
 import j
@@ -237,62 +237,8 @@
 st;%0A
-import nl.tudelft.dnainator.core.DefaultSequenceNode;%0A
 impo
@@ -318,16 +318,66 @@
 nceNode;
+%0Aimport nl.tudelft.dnainator.graph.Neo4jSingleton;
 %0A%0A/**%0A *
@@ -436,14 +436,44 @@
 ink 
+nl.tudelft.dnainator.graph.
 Graph%7D
+%0A *
  and
@@ -480,19 +480,16 @@
  JavaFX.
-%0A *
  As the 
@@ -1008,523 +1008,252 @@
 ));%0A
-%0A%09%09// CHECKSTYLE.OFF: MagicNumber%0A%09%09getNodes().add(new DefaultSequenceNode(%221%22, %22Cat, Dog%22, 5, 7, %22A%22));%0A%09%09getNodes().add(new DefaultSequenceNode(%222%22, %22Dog%22, 8, 10, %22C%22));%0A%09%09getNodes().add(new DefaultSequenceNode(%223%22, %22Cat%22, 8, 9, %22G%22));%0A%09%09getNodes().add(new DefaultSequenceNode(%224%22, %22Cat, Dog%22, 10, 13, %22T%22));%0A%0A%09%09getEdges().add(new Edge%3CInteger%3E(1, 2));%0A%09%09getEdges().add(new Edge%3CInteger%3E(1, 3));%0A%09%09getEdges().add(new Edge%3CInteger%3E(2, 4));%0A%09%09getEdges().add(new Edge%3CInteger%3E(3, 4));%0A%09%09// CHECKSTYLE.ON: MagicNumber
+%09%7D%0A%0A%09/**%0A%09 * @param n The rank whose %7B@link SequenceNode%7Ds to return.%0A%09 * @return All %7B@link SequenceNode%7Ds at rank %3Ccode%3En%3C/code%3E/%0A%09 */%0A%09public List%3CSequenceNode%3E getRank(int n) %7B%0A%09%09return Neo4jSingleton.getInstance().getDatabase().getRank(n);
 %0A%09%7D%0A

connect with neo4j and drop fake data