Browse Source

Merge remote-tracking branch 'origin/Julian'

Jan Enders 8 years ago
parent
commit
51fea3c2c7

+ 13 - 14
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ButtonManager.java

@@ -1,14 +1,11 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui;
 
-import java.awt.Event;
 import java.io.IOException;
-import java.net.URLConnection;
 import java.util.ArrayList;
 
 import org.graphstream.graph.implementations.Graphs;
 import org.jxmapviewer.viewer.WaypointPainter;
 
-import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
 import de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
@@ -21,14 +18,11 @@ import javafx.event.ActionEvent;
 import javafx.scene.control.Alert;
 import javafx.scene.control.Alert.AlertType;
 import javafx.scene.control.Button;
-import javafx.scene.control.TableRow;
-import javafx.scene.input.MouseButton;
-import javafx.scene.input.MouseEvent;
 
 /**
  * Manager to contain the various handlers for the buttons of the UI.
  * 
- * @author Jan Enders (jan.enders@stud.tu-darmstadt.de)
+ * @author Jan Enders (jan.enders@stud.tu-darmstadt.de), Julian Ohl, Dominik Renkel
  * @version 1.2
  *
  */
@@ -148,8 +142,8 @@ public final class ButtonManager {
 		controller.getOpenButton().setText("Open...");
 		
 		//hide metricbox/update button
+		controller.rightSide.getChildren().remove(controller.updateButtonAPane);
 		controller.metricbox.setVisible(false);
-		controller.updateMetricButton.setVisible(false);
 	}
 
 	/**
@@ -168,15 +162,21 @@ public final class ButtonManager {
 		controller.getOpenButton().setText("Open...");
 		
 		//hide metricbox/update button
+		controller.rightSide.getChildren().remove(controller.updateButtonAPane);
 		controller.metricbox.setVisible(false);
-		controller.updateMetricButton.setVisible(false);
 	}
 
 	/**
 	 * Handler for the Mapping Layer switch Button.
 	 */
 	public static void mappingAction(ActionEvent arg0) {
-
+		
+		//show metricbox/update button
+		if (!(GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING))){
+			controller.rightSide.getChildren().add(controller.updateButtonAPane);
+			controller.metricbox.setVisible(true);
+		}
+				
 		switchfromSymbolLayer();
 
 		GraphDisplayManager.setCurrentLayer(Layer.MAPPING);
@@ -187,9 +187,8 @@ public final class ButtonManager {
 
 		controller.getOpenButton().setText("Open Mapping...");
 		
-		//show metricbox/update button
-		controller.metricbox.setVisible(true);
-		controller.updateMetricButton.setVisible(true);
+		
+		
 	}
 
 	/**
@@ -227,8 +226,8 @@ public final class ButtonManager {
 		}
 		
 		//hide metricbox/update button
+		controller.rightSide.getChildren().remove(controller.updateButtonAPane);
 		controller.metricbox.setVisible(false);
-		controller.updateMetricButton.setVisible(false);
 
 		GraphDisplayManager.switchActiveGraph();
 		setBorderStyle((Button) arg0.getSource());

+ 53 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ConsoleManager.java

@@ -0,0 +1,53 @@
+package de.tu_darmstadt.informatik.tk.scopviz.ui;
+
+import javafx.scene.paint.Color;
+import javafx.scene.text.Text;
+
+/**
+ * 
+ * @author Julian Ohl
+ * @version 1.0
+ */
+public class ConsoleManager {
+
+	/**
+	 * Reference to the GUI Controller for Access to various GUI Elements.
+	 */
+	private static GUIController controller;
+	
+	/**
+	 * Initialize console window by setting controller
+	 * 
+	 * @param c our GUIController 
+	 */
+	public static void initialize(GUIController c){
+		controller = c;
+	}
+	
+	/**
+	 * Add normal text to the console output
+	 * @param s the text, which should be displayed
+	 */
+	public static void addNormalText(String s){
+		StringBuilder sb = new StringBuilder();
+		
+		sb.append(System.lineSeparator()).append(s);
+		
+		controller.consoleWindow.getChildren().add(new Text(sb.toString()));
+	}
+	
+	/**
+	 * Add error text to the console output
+	 * @param s the text, which should be displayed
+	 */
+	public static void addErrorText(String s){
+		StringBuilder sb = new StringBuilder();
+		
+		sb.append(System.lineSeparator()).append(s);
+		
+		Text errorText = new Text(sb.toString()); 
+		
+		errorText.setFill(Color.RED);
+		controller.consoleWindow.getChildren().add(errorText);
+	}
+}

+ 21 - 3
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/GUIController.java

@@ -42,6 +42,7 @@ import javafx.scene.layout.AnchorPane;
 import javafx.scene.layout.Pane;
 import javafx.scene.layout.StackPane;
 import javafx.scene.layout.VBox;
+import javafx.scene.text.TextFlow;
 import javafx.util.Pair;
 
 /**
@@ -150,10 +151,20 @@ public class GUIController implements Initializable {
 	@FXML
 	public ChoiceBox<String> mapViewChoiceBox;
 	
+	@FXML
+	public TextFlow consoleWindow;
+	
+	@FXML
+	public VBox rightSide;
+	
 	//The anchorpane of the top left box (toolbox, symbol visualization layer box)
 	@FXML
 	public AnchorPane topLeftAPane;
 	
+	//The anchorpane of the metric update button
+	@FXML
+	public AnchorPane updateButtonAPane;
+	
 	/**
 	 * Initializes all the references to the UI elements specified in the FXML
 	 * file. Gets called during FXML loading. Asserts the correct injection of
@@ -174,7 +185,8 @@ public class GUIController implements Initializable {
 		// Initialize the Managers for the various for UI elements
 		ToolboxManager.initializeItems();
 		PropertiesManager.initializeItems(properties);
-
+		ConsoleManager.initialize(this);
+		
 		GraphDisplayManager.init(this);
 
 		// Bind all the handlers to their corresponding UI elements
@@ -189,7 +201,7 @@ public class GUIController implements Initializable {
 
 		// Setup the Keyboard Shortcuts
 		KeyboardShortcuts.initialize(Main.getInstance().getPrimaryStage());
-
+		
 	}
 
 	private void initializeWorldView() {
@@ -401,6 +413,8 @@ public class GUIController implements Initializable {
 		
 		//Update button initialization
 		updateMetricButton.setOnAction((event) -> MetricboxManager.updateMetrics());
+		//TODO
+		rightSide.getChildren().remove(updateButtonAPane);
 	}
 
 	/**
@@ -464,6 +478,9 @@ public class GUIController implements Initializable {
 		assert propertiesObjectColumn != null : "fx:id=\"propertiesObject\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert propertiesTypeColumn != null : "fx:id=\"propertiesType\" was not injected: check your FXML file 'MainWindow.fxml'.";
 
+		assert rightSide != null : "fx:id=\"rightSide\" was not injected: check your FXML file 'MainWindow.fxml'.";
+		assert consoleWindow != null : "fx:id=\"consoleWindow\" was not injected: check your FXML file 'MainWindow.fxml'.";
+		
 		assert metricBoxMetricColumn != null : "fx:id=\"metricBoxMetricColumn\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert metricBoxValueColumn != null : "fx:id=\"metricBoxValueColumn\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert metricBoxUpdateColumn != null : "fx:id=\"metricBoxUpdateColumn\" was not injected: check your FXML file 'MainWindow.fxml'.";
@@ -471,13 +488,14 @@ public class GUIController implements Initializable {
 		assert updateMetricButton != null : "fx:id=\"updateMetricButton\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		
 		assert topLeftAPane != null : "fx:id=\"topLeftAPane\" was not injected: check your FXML file 'MainWindow.fxml'.";
+		assert updateButtonAPane != null : "fx:id=\"updateButton\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		
 		assert symbolToolVBox != null : "fx:id=\"symbolToolVBox\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert edgesVisibleCheckbox != null : "fx:id=\"edgesVisibleCheckbox\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert nodeLabelCheckbox != null : "fx:id=\"nodeLabelCheckbox\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert edgeWeightCheckbox != null : "fx:id=\"egdeWeightCheckbox\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert mapViewChoiceBox != null : "fx:id=\"mapViewChoiceBox\" was not injected: check your FXML file 'MainWindow.fxml'.";
-
+		
 		assert stackPane != null : "fx:id=\"stackPane\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert swingNodeWorldView != null : "fx:id=\"swingNodeWorldView\" was not injected: check your FXML file 'MainWindow.fxml'.";
 	}

+ 1 - 3
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/MetricRowData.java

@@ -66,9 +66,8 @@ public class MetricRowData {
 		StringBuilder sb = new StringBuilder();
 		sb.append(metric.getName());
 
-		// TODO Concurrent modification exception? wahrscheinlich nicht
 		for (Pair<String, String> p : list) {
-			sb.append(System.lineSeparator()).append(p.getKey());
+			sb.append(System.lineSeparator()).append("\t").append(p.getKey());
 		}
 		return sb.toString();
 	}
@@ -85,7 +84,6 @@ public class MetricRowData {
 
 		StringBuilder sb = new StringBuilder();
 
-		// TODO Concurrent modification exception? wahrscheinlich nicht
 		for (Pair<String, String> p : list) {
 			sb.append(System.lineSeparator()).append(p.getValue());
 		}

+ 6 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/MetricboxManager.java

@@ -19,6 +19,12 @@ public class MetricboxManager {
 	private static GUIController controller;
 	private static ObservableList<MetricRowData> metrics;
 	
+	/**
+	 * Private Constructor to prevent Instantiation.
+	 */
+	private MetricboxManager(){
+	}
+	
 	/**
 	 * Initialize metricbox by setting controller, initializing all metrics and set them as items
 	 * 
@@ -55,7 +61,6 @@ public class MetricboxManager {
 	 */
 	public static void updateMetrics(){
 		
-		//TODO if rausnehmen und nur beim MenuItem anwenden?
 		if(GraphDisplayManager.getCurrentLayer() == Layer.MAPPING){
 			
 			for(MetricRowData d: metrics){

+ 8 - 0
scopviz/src/main/resources/GUITheme.css

@@ -21,3 +21,11 @@
   -fx-background-repeat: no-repeat;
   -fx-background-position: center
 }
+
+.consoleWindow{
+    -fx-content-display: top;
+  -fx-border-insets: 2 0 0 0;
+  -fx-border-color: -fx-text-box-border;
+  -fx-border-width: 2;
+
+}

+ 15 - 3
scopviz/src/main/resources/MainWindow.fxml

@@ -8,6 +8,7 @@
 <?import javafx.scene.control.Menu?>
 <?import javafx.scene.control.MenuBar?>
 <?import javafx.scene.control.MenuItem?>
+<?import javafx.scene.control.ScrollPane?>
 <?import javafx.scene.control.SeparatorMenuItem?>
 <?import javafx.scene.control.SplitPane?>
 <?import javafx.scene.control.TableColumn?>
@@ -16,6 +17,8 @@
 <?import javafx.scene.layout.Pane?>
 <?import javafx.scene.layout.StackPane?>
 <?import javafx.scene.layout.VBox?>
+<?import javafx.scene.text.Text?>
+<?import javafx.scene.text.TextFlow?>
 
 <VBox minHeight="768.0" minWidth="1024.0" prefHeight="768.0" prefWidth="1024.0" stylesheets="@GUITheme.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.tu_darmstadt.informatik.tk.scopviz.ui.GUIController">
   <children>
@@ -134,7 +137,7 @@
                               </AnchorPane>
                             <AnchorPane SplitPane.resizableWithParent="false">
                                  <children>
-                                    <VBox prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
+                                    <VBox fx:id="rightSide" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                        <children>
                                         <AnchorPane minWidth="170.0" VBox.vgrow="NEVER">
                                              <children>
@@ -158,9 +161,18 @@
                                                 </TableView>
                                              </children>
                                           </AnchorPane>
-                                          <AnchorPane prefHeight="25.0">
+                                          <ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="200.0" prefWidth="200.0" vbarPolicy="ALWAYS">
+                                             <content>
+                                                <TextFlow fx:id="consoleWindow" styleClass="consoleWindow">
+                                                   <children>
+                                                      <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Hi" />
+                                                   </children>
+                                                </TextFlow>
+                                             </content>
+                                          </ScrollPane>
+                                          <AnchorPane fx:id="updateButtonAPane" prefHeight="25.0">
                                              <children>
-                                                <Button fx:id="updateMetricButton" mnemonicParsing="false" prefHeight="25.0" text="Update metrics" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
+                                                <Button fx:id="updateMetricButton" mnemonicParsing="false" prefHeight="25.0" text="Update metrics" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
                                              </children>
                                           </AnchorPane>
                                        </children>