Browse Source

Add functionality in Operator selection box now works, switch
functionality needs Jaschas changes to GraphManager first

Jan Enders 7 years ago
parent
commit
aad1c87829

+ 7 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ButtonManager.java

@@ -5,7 +5,6 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.stream.Collectors;
 
-import org.graphstream.graph.Graph;
 import org.jxmapviewer.viewer.GeoPosition;
 import org.jxmapviewer.viewer.WaypointPainter;
 
@@ -499,10 +498,17 @@ public final class ButtonManager {
 		//Platform.runLater(() -> controller.opGraphSelectionBox.setValue(controller.opGraphSelectionBox.getItems().get(0)));
 	}
 
+	public static void addToOpGraphComboBox(String id){
+		controller.opGraphSelectionBox.getItems().add(controller.opGraphSelectionBox.getItems().size()-1, id);
+	}
+	
 	public static void opGraphSelectedAction(ActionEvent v) {
 		
 		if (controller.opGraphSelectionBox.getValue().equals("Add...")){
 			MenuBarManager.addAction(v);
+			Platform.runLater(() -> controller.opGraphSelectionBox.setValue(controller.opGraphSelectionBox.getItems().get(controller.opGraphSelectionBox.getItems().size()-2)));
+		} else {
+			//FIXME: aktuell zu bearbeitenden graphen im GraphManager setzen (erfordert Jaschas Implementierung)!
 		}
 	}
 

+ 9 - 10
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/GraphDisplayManager.java

@@ -121,7 +121,7 @@ public final class GraphDisplayManager {
 	 * 
 	 * @return the id to access the specific Graph
 	 */
-	public static int addGraph() {
+	public static MyGraph addGraph() {
 		String id = getGraphStringID(count);
 		MyGraph g = new MyGraph(id);
 		return addGraph(g, true);
@@ -138,7 +138,7 @@ public final class GraphDisplayManager {
 	 *            the current layer, if false they will be merged.
 	 * @return the id to access the specific Graph
 	 */
-	public static int addGraph(String fileName, boolean replaceCurrent) {
+	public static MyGraph addGraph(String fileName, boolean replaceCurrent) {
 		String id = getGraphStringID(count);
 		MyGraph g = importer.readGraph(id, Main.class.getResource(fileName));
 		return addGraph(g, replaceCurrent);
@@ -154,11 +154,11 @@ public final class GraphDisplayManager {
 	 *            the current layer, if false they will be merged.
 	 * @return the id to access the specific Graph
 	 */
-	public static int addGraph(Stage stage, boolean replaceCurrent) {
+	public static MyGraph addGraph(Stage stage, boolean replaceCurrent) {
 		String id = getGraphStringID(count);
 		MyGraph g = importer.readGraph(id, stage);
 		if (g == null) {
-			return currentGraphManager;
+			return getGraphManager().getGraph();
 		}
 		return addGraph(g, replaceCurrent);
 	}
@@ -173,7 +173,7 @@ public final class GraphDisplayManager {
 	 *            the current layer, if false they will be merged.
 	 * @return the id to access the specific Graph
 	 */
-	public static int addGraph(URL fileURL, boolean replaceCurrent) {
+	public static MyGraph addGraph(URL fileURL, boolean replaceCurrent) {
 		String id = getGraphStringID(count);
 		MyGraph g = importer.readGraph(id, fileURL);
 		return addGraph(g, replaceCurrent);
@@ -190,13 +190,12 @@ public final class GraphDisplayManager {
 	 *            the current layer, if false they will be merged.
 	 * @return the id to access the specific graph
 	 */
-	public static int addGraph(MyGraph g, boolean replaceCurrent) {
+	public static MyGraph addGraph(MyGraph g, boolean replaceCurrent) {
 		if (g == null) {
 			throw new NullArgumentException();
 		}
 
 		GraphManager v;
-		int ret = 0;
 		// replacing the current graph or merging
 		if (replaceCurrent) {
 			v = new GraphManager(g);
@@ -206,7 +205,7 @@ public final class GraphDisplayManager {
 			v.getGraph().addAttribute("ui.antialias");
 			removeAllCurrentGraphs();
 			vList.add(v);
-			ret = count++;
+			count++;
 			// set basic style
 			v.setStylesheet(StylesheetManager.DEFAULT_STYLESHEET);
 		} else {
@@ -217,7 +216,7 @@ public final class GraphDisplayManager {
 			g.addAttribute("ui.antialias");
 			removeAllCurrentGraphs();
 			vList.add(v);
-			ret = count++;
+			count++;
 			// set basic style
 			v.setStylesheet(StylesheetManager.DEFAULT_STYLESHEET);
 		}
@@ -226,7 +225,7 @@ public final class GraphDisplayManager {
 		v.convertUiClass();
 		// display the graph
 		switchActiveGraph();
-		return ret;
+		return g;
 	}
 
 	/**

+ 3 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/MenuBarManager.java

@@ -1,6 +1,7 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui;
 
 import de.tu_darmstadt.informatik.tk.scopviz.graphs.GraphManager;
+import de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph;
 import de.tu_darmstadt.informatik.tk.scopviz.io.GraphMLExporter;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
@@ -47,8 +48,8 @@ public final class MenuBarManager {
 	 * Handler for the "add" MenuItem.
 	 */
 	public static final void addAction(ActionEvent event) {
-		GraphDisplayManager.addGraph(Main.getInstance().getPrimaryStage(), false);
-		ButtonManager.setupOpGraphComboBox();
+		MyGraph newGraph = GraphDisplayManager.addGraph(Main.getInstance().getPrimaryStage(), false);
+		ButtonManager.addToOpGraphComboBox(newGraph.getId());
 	}
 
 	/**