Browse Source

added input for process-need/max at Node creation

deleting a Node/Edge now resets the Attribute window
undeleting a Edge no longer shows the Edge Weight dialog
jascha Bohne 7 years ago
parent
commit
f27a84ffa7

+ 8 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/graphs/MyGraph.java

@@ -8,6 +8,8 @@ import org.graphstream.graph.Node;
 import org.graphstream.graph.implementations.SingleGraph;
 
 import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
+import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.OptionsManager;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.ToolboxManager;
 
 /**
@@ -99,8 +101,12 @@ public class MyGraph extends SingleGraph {
 	 *            the Edge that was just created
 	 */
 	private void edgeCreatedNotify(Edge e) {
-		if (Layer.UNDERLAY.equals(this.getAttribute("layer"))) {
-			ToolboxManager.createWeighDialog(e);
+		boolean doWeight = Layer.UNDERLAY.equals(this.getAttribute("layer")) 
+				&& (e.getAttribute("weight") == null
+				|| (e.getAttribute("weight") != null
+				&& (OptionsManager.getDefaultWeight() == Main.getInstance().convertAttributeTypes(e.getAttribute("weight"), new Double(0.0)))));
+		if (doWeight) {
+			ToolboxManager.createWeightDialog(e);
 		}
 		for (EdgeCreatedListener list : allEdgeListeners) {
 			list.edgeCreated(e, id);

+ 1 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/io/MySourceBase.java

@@ -40,7 +40,6 @@ import java.util.List;
 import java.util.Stack;
 
 import org.graphstream.graph.implementations.AbstractElement.AttributeChangeEvent;
-import org.graphstream.graph.implementations.SingleGraph;
 import org.graphstream.stream.AttributeSink;
 import org.graphstream.stream.ElementSink;
 import org.graphstream.stream.Sink;
@@ -196,7 +195,7 @@ public class MySourceBase implements Source {
 		addElementSink(sink);
 		resetSubGraphs();
 		try {
-			superID = ((SingleGraph) sink).getId();
+			superID = ((MyGraph) sink).getId();
 		} catch (Exception e) {
 			Debug.out(e.toString() + "\n" + e.getStackTrace().toString());
 		}

+ 1 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/MenuBarManager.java

@@ -88,6 +88,7 @@ public final class MenuBarManager {
 		if (v.getSelectedNodeID() != null) {
 			v.deleteNode(v.getSelectedNodeID());
 		}
+		PropertiesManager.showNewDataSet(null);
 	}
 
 	/**

+ 4 - 4
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/OptionsManager.java

@@ -30,7 +30,7 @@ import javafx.scene.layout.GridPane;
 public final class OptionsManager {
 	// SETTINGS
 	/** The Default Weight for all new Edges. */
-	private static int defaultWeight = 0;
+	private static double defaultWeight = 0;
 	/** Flag whether to show the weight labels on Edges. */
 	private static boolean showWeight = true;
 	/** The default latitude of nodes (defaults to Piloty Building) */
@@ -63,7 +63,7 @@ public final class OptionsManager {
 		grid.setVgap(10);
 		grid.setPadding(new Insets(20, 150, 10, 10));
 		// create dialog elements
-		TextField defaultWeightField = new TextField(Integer.toString(defaultWeight));
+		TextField defaultWeightField = new TextField(Double.toString(defaultWeight));
 
 		RadioButton showWeightButton = new RadioButton();
 		showWeightButton.setSelected(showWeight);
@@ -185,7 +185,7 @@ public final class OptionsManager {
 		addPropDialog.setResultConverter(dialogButton -> {
 			if (dialogButton == addButtonType) {
 				try {
-					defaultWeight = Integer.parseInt(defaultWeightField.getText());
+					defaultWeight = Double.parseDouble(defaultWeightField.getText());
 					if (defaultLat != Double.parseDouble(defaultLatitudeField.getText())
 							|| defaultLong != Double.parseDouble(defaultLongitudeField.getText())) {
 						coordinatesChanged = true;
@@ -246,7 +246,7 @@ public final class OptionsManager {
 	 * 
 	 * @return the default weight
 	 */
-	public static int getDefaultWeight() {
+	public static double getDefaultWeight() {
 		return defaultWeight;
 	}
 

+ 41 - 3
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ToolboxManager.java

@@ -269,19 +269,19 @@ public final class ToolboxManager {
 	 * @param e
 	 *            the new Edge that needs a weight
 	 */
-	public static void createWeighDialog(Edge e) {
+	public static void createWeightDialog(Edge e) {
 		if (e.equals(lastCreatedEdge)) {
 			return;
 		}
 		lastCreatedEdge = e;
 		Platform.runLater(() -> {
-			TextInputDialog weightDialog = new TextInputDialog(Integer.toString(OptionsManager.getDefaultWeight()));
+			TextInputDialog weightDialog = new TextInputDialog(Double.toString(OptionsManager.getDefaultWeight()));
 			weightDialog.setTitle("Edge Weight");
 			weightDialog.setHeaderText("Please enter the weight of the Edge");
 			weightDialog.setContentText("Edge Weight");
 			Optional<String> result = weightDialog.showAndWait();
 			if (result.isPresent()) {
-				e.addAttribute("weight", result.get());
+				e.addAttribute("weight", Double.parseDouble(result.get()));
 			}
 		});
 	}
@@ -353,4 +353,42 @@ public final class ToolboxManager {
 			}
 		}
 	}
+
+	
+	private static org.graphstream.graph.Node lastCreatedNode = null;
+	
+	
+	public static void createProcMaxDialog(org.graphstream.graph.Node n) {
+		if (n.equals(lastCreatedNode)) {
+			return;
+		}
+		lastCreatedNode = n;
+		Platform.runLater(() -> {
+			TextInputDialog weightDialog = new TextInputDialog(Double.toString(OptionsManager.getDefaultWeight()));
+			weightDialog.setTitle("Maximum Processing Power");
+			weightDialog.setHeaderText("Please enter the maximum processing power of the Node");
+			weightDialog.setContentText("processing power");
+			Optional<String> result = weightDialog.showAndWait();
+			if (result.isPresent()) {
+				n.addAttribute("process-max", Double.parseDouble(result.get()));
+			}
+		});
+	}
+
+	public static void createProcNeedDialog(org.graphstream.graph.Node n) {
+		if (n.equals(lastCreatedNode)) {
+			return;
+		}
+		lastCreatedNode = n;
+		Platform.runLater(() -> {
+			TextInputDialog weightDialog = new TextInputDialog(Double.toString(OptionsManager.getDefaultWeight()));
+			weightDialog.setTitle("needed Processing power");
+			weightDialog.setHeaderText("Please enter the amount of processing power the node needs");
+			weightDialog.setContentText("neede Power");
+			Optional<String> result = weightDialog.showAndWait();
+			if (result.isPresent()) {
+				n.addAttribute("process-need", Double.parseDouble(result.get()));
+			}
+		});
+	}
 }

+ 13 - 8
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/handlers/MyMouseManager.java

@@ -16,6 +16,7 @@ import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
 import de.tu_darmstadt.informatik.tk.scopviz.main.EdgeSelectionHelper;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.PropertiesManager;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.ToolboxManager;
 
 /**
  * Mouse Manager to handle all Mouse based Interaction on the Graph Display
@@ -90,7 +91,7 @@ public class MyMouseManager extends DefaultMouseManager {
 			n.setAttribute("ui.class", "standard");
 			n.setAttribute("typeofNode", "standard");
 			graphManager.selectNode(n.getId());
-			Debug.out("Added Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y + ")");
+			Debug.out("INFORMATION: Added Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y + ")", 1);
 
 			break;
 
@@ -100,8 +101,8 @@ public class MyMouseManager extends DefaultMouseManager {
 			n.setAttribute("ui.class", "source");
 			n.setAttribute("typeofNode", "source");
 			graphManager.selectNode(n.getId());
-			Debug.out("Added Source Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y
-					+ ")");
+			Debug.out("INFORMATION: Added Source Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y
+					+ ")", 1);
 
 			break;
 
@@ -112,7 +113,7 @@ public class MyMouseManager extends DefaultMouseManager {
 			n.setAttribute("typeofNode", "sink");
 			graphManager.selectNode(n.getId());
 			Debug.out(
-					"Added Sink Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y + ")");
+					"INFORMATION: Added Sink Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y + ")", 1);
 
 			break;
 
@@ -121,9 +122,11 @@ public class MyMouseManager extends DefaultMouseManager {
 			n.setAttribute("xyz", cursorPos);
 			n.setAttribute("ui.class", "procEn");
 			n.setAttribute("typeofNode", "procEn");
+			ToolboxManager.createProcMaxDialog(n);
+			
 			graphManager.selectNode(n.getId());
-			Debug.out("Added ProcEn Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y
-					+ ")");
+			Debug.out("INFORMATION: Added ProcEn Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y
+					+ ")", 1);
 
 			break;
 
@@ -132,9 +135,11 @@ public class MyMouseManager extends DefaultMouseManager {
 			n.setAttribute("xyz", cursorPos);
 			n.setAttribute("ui.class", "operator");
 			n.setAttribute("typeofNode", "operator");
+			ToolboxManager.createProcNeedDialog(n);
+			
 			graphManager.selectNode(n.getId());
-			Debug.out("Added Operator Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y
-					+ ")");
+			Debug.out("INFORMATION: Added Operator Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y
+					+ ")", 1);
 
 			break;