Browse Source

Symbol Representation

Added Checkboxes and functionality for disable node labels, edges and
edge weights
dominik 7 years ago
parent
commit
577fdb9e28

+ 3 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/GraphManager.java

@@ -508,6 +508,9 @@ public class GraphManager {
 	 */
 	public void setStylesheet(String stylesheet) {
 		this.stylesheet = stylesheet;
+		g.removeAttribute("ui.stylesheet");
+		stylesheet = stylesheet.concat(OptionsManager.getNodeGraphics());
+		g.addAttribute("ui.stylesheet", stylesheet);
 	}
 
 }

+ 78 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ButtonManager.java

@@ -14,10 +14,18 @@ import de.tu_darmstadt.informatik.tk.scopviz.main.GraphManager;
 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.main.SelectionMode;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
 import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
+import javafx.geometry.Insets;
 import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.Label;
+import javafx.scene.control.ToggleButton;
 import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.VBox;
 
 /**
  * Manager to contain the various handlers for the buttons of the UI.
@@ -33,6 +41,8 @@ public final class ButtonManager {
 
 	/** List of the Buttons for Layer switching */
 	private static ArrayList<Button> layerButtons;
+	
+	private static GUIController controller;
 
 	/**
 	 * Private Constructor to prevent Instantiation.
@@ -46,8 +56,10 @@ public final class ButtonManager {
 	 * @param nList
 	 *            the Layer switching Buttons
 	 */
-	public static void initialize(ArrayList<Button> nList) {
+	public static void initialize(ArrayList<Button> nList, GUIController guiController) {
 		layerButtons = nList;
+		
+		controller = guiController;
 	}
 
 	/**
@@ -196,13 +208,77 @@ public final class ButtonManager {
 
 		@Override
 		public void handle(ActionEvent arg0) {
+			if(!GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)){
+				controller.toolbox.setVisible(false);
+				controller.symbolToolVBox.setVisible(true);
+				
+			}
+			
 			GraphDisplayManager.setCurrentLayer(Layer.SYMBOL);
 			GraphDisplayManager.switchActiveGraph();
-
+			
 			setBorderStyle((Button) arg0.getSource());
 		}
 
 	};
+	
+	public static ChangeListener<Boolean> edgeVisibleListener = new ChangeListener<Boolean>(){
+
+		@Override
+		public void changed(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
+			// Show edges
+			if(newVal){
+				for(Edge edge : Main.getInstance().getGraphManager().getGraph().getEachEdge()){
+					edge.removeAttribute("ui.hide");
+				}
+				
+			// Hide edges
+			}else{
+				for(Edge edge : Main.getInstance().getGraphManager().getGraph().getEachEdge()){
+					edge.addAttribute("ui.hide");
+				}
+			}
+		}
+		
+	};
+	
+	public static ChangeListener<Boolean> nodeLabelListener = new ChangeListener<Boolean>(){
+
+		@Override
+		public void changed(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
+			GraphManager graphManager = Main.getInstance().getGraphManager();
+			String stylesheet = graphManager.getStylesheet();
+			
+			// Show node weights
+			if(newVal){
+				graphManager.setStylesheet(stylesheet.replace("node{text-mode:hidden;}", ""));
+				
+			// Hide node weights
+			}else{
+				graphManager.setStylesheet(stylesheet.concat("node{text-mode:hidden;}"));
+			}
+		}
+		
+	};
+	
+	public static ChangeListener<Boolean> edgeWeightListener = new ChangeListener<Boolean>(){
+
+		@Override
+		public void changed(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
+			GraphManager graphManager = Main.getInstance().getGraphManager();
+			String stylesheet = graphManager.getStylesheet();
+			
+			// Show Edges weights
+			if(newVal){
+				graphManager.setStylesheet(stylesheet.replace("edge{text-mode:hidden;}", ""));
+				
+			// Hide Edges weights
+			}else{
+				graphManager.setStylesheet(stylesheet.concat("edge{text-mode:hidden;}"));
+			}
+		}
+		
+	};
 
 	/**
 	 * Changes the border of the button that was pressed to red

+ 42 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/GUIController.java

@@ -3,7 +3,16 @@ package de.tu_darmstadt.informatik.tk.scopviz.ui;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.ResourceBundle;
+
+import javax.swing.JFrame;
 import javax.swing.JPanel;
+
+import org.jxmapviewer.JXMapViewer;
+import org.jxmapviewer.OSMTileFactoryInfo;
+import org.jxmapviewer.viewer.DefaultTileFactory;
+import org.jxmapviewer.viewer.GeoPosition;
+import org.jxmapviewer.viewer.TileFactoryInfo;
+
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.KeyboardShortcuts;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyAnimationTimer;
@@ -14,7 +23,9 @@ import javafx.beans.value.ObservableValue;
 import javafx.embed.swing.SwingNode;
 import javafx.fxml.FXML;
 import javafx.fxml.Initializable;
+import javafx.geometry.Insets;
 import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
 import javafx.scene.control.Label;
 import javafx.scene.control.ListView;
 import javafx.scene.control.MenuItem;
@@ -24,7 +35,9 @@ import javafx.scene.control.TableRow;
 import javafx.scene.control.TableView;
 import javafx.scene.control.cell.PropertyValueFactory;
 import javafx.scene.control.cell.TextFieldTableCell;
+import javafx.scene.layout.GridPane;
 import javafx.scene.layout.Pane;
+import javafx.scene.layout.VBox;
 import javafx.scene.text.Text;
 import javafx.util.Callback;
 import javafx.util.Pair;
@@ -44,6 +57,8 @@ public class GUIController implements Initializable {
 	@FXML
 	public SwingNode swingNode;
 	@FXML
+	public SwingNode swingNodeWorldView;
+	@FXML
 	public Pane pane;
 
 	// The buttons present in the UI
@@ -116,6 +131,15 @@ public class GUIController implements Initializable {
 	public Text selectModusText;
 	@FXML
 	public Text actualLayerText;
+	
+	@FXML 
+	public VBox symbolToolVBox;
+	@FXML
+	public CheckBox edgesVisibleCheckbox;
+	@FXML
+	public CheckBox nodeLabelCheckbox;
+	@FXML
+	public CheckBox edgeWeightCheckbox;
 
 	/**
 	 * Initializes all the references to the UI elements specified in the FXML
@@ -146,6 +170,7 @@ public class GUIController implements Initializable {
 		initializeLayerButton();
 		initializeDisplayPane();
 		initializeMenuBar();
+		initializeSymbolRepToolbox();
 
 		// Initialize the Text Labels for displaying the current state of the
 		// Application
@@ -183,6 +208,15 @@ public class GUIController implements Initializable {
 		zoomIn.setOnAction(ButtonManager.zoomInHandler);
 		zoomOut.setOnAction(ButtonManager.zoomOutHandler);
 	}
+	
+	private void initializeSymbolRepToolbox(){
+		// Hide SymbolRep Toolbox View
+		symbolToolVBox.setVisible(false);
+		
+		edgesVisibleCheckbox.selectedProperty().addListener(ButtonManager.edgeVisibleListener);
+		nodeLabelCheckbox.selectedProperty().addListener(ButtonManager.nodeLabelListener);
+		edgeWeightCheckbox.selectedProperty().addListener(ButtonManager.edgeWeightListener);
+	}
 
 	/**
 	 * Set the Handlers for the Layer switch Buttons.
@@ -198,7 +232,7 @@ public class GUIController implements Initializable {
 		layerButtons.add(operatorButton);
 		layerButtons.add(mappingButton);
 		layerButtons.add(symbolRepButton);
-		ButtonManager.initialize(layerButtons);
+		ButtonManager.initialize(layerButtons, this);
 	}
 
 	/**
@@ -350,5 +384,12 @@ public class GUIController implements Initializable {
 		assert createModusText != null : "fx:id=\"createModusText\" was not injected: check your FXML file 'NewBetterCoolerWindowTest.fxml'.";
 		assert selectModusText != null : "fx:id=\"selectModusText\" was not injected: check your FXML file 'NewBetterCoolerWindowTest.fxml'.";
 		assert actualLayerText != null : "fx:id=\"actualLayerText\" was not injected: check your FXML file 'NewBetterCoolerWindowTest.fxml'.";
+		
+		assert symbolToolVBox != null : "fx:id=\"symbolToolVBox\" was not injected: check your FXML file 'NewBetterCoolerWindowTest.fxml'.";
+		assert edgesVisibleCheckbox != null : "fx:id=\"edgesVisibleCheckbox\" was not injected: check your FXML file 'NewBetterCoolerWindowTest.fxml'.";
+		assert nodeLabelCheckbox != null : "fx:id=\"nodeLabelCheckbox\" was not injected: check your FXML file 'NewBetterCoolerWindowTest.fxml'.";
+		assert edgeWeightCheckbox != null : "fx:id=\"egdeWeightCheckbox\" was not injected: check your FXML file 'NewBetterCoolerWindowTest.fxml'.";
+		
+		assert swingNodeWorldView != null : "fx:id=\"swingNodeWorldView\" was not injected: check your FXML file 'NewBetterCoolerWindowTest.fxml'.";
 	}
 }

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

@@ -163,6 +163,7 @@ public final class GraphDisplayManager {
 		// create and format the GraphManager
 		GraphManager v = new GraphManager(g);
 		g.addAttribute("layer", currentLayer);
+		OptionsManager.setNodeGraphics(OptionsManager.STYLE_NODES_SHAPES);
 		v.setStylesheet(OptionsManager.DEFAULT_STYLESHEET);
 		g.addAttribute("ui.antialias");
 
@@ -180,7 +181,6 @@ public final class GraphDisplayManager {
 		// display the graph
 		vList.add(v);
 		switchActiveGraph();
-		OptionsManager.adjustNodeGraphics(OptionsManager.getAllNodeGraphics()[0]);
 		return ret;
 	}
 

+ 28 - 7
scopviz/src/main/resources/NewBetterCoolerWindowTest.fxml

@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <?import javafx.embed.swing.SwingNode?>
+<?import javafx.geometry.Insets?>
 <?import javafx.scene.control.Button?>
+<?import javafx.scene.control.CheckBox?>
 <?import javafx.scene.control.ListView?>
 <?import javafx.scene.control.Menu?>
 <?import javafx.scene.control.MenuBar?>
@@ -26,8 +28,8 @@
             <MenuItem fx:id="open" mnemonicParsing="false" text="Open…" />
             <MenuItem fx:id="add" mnemonicParsing="false" text="Add…" />
             <SeparatorMenuItem mnemonicParsing="false" />
-            <MenuItem fx:id="save" mnemonicParsing="false" text="Save" accelerator="Shortcut+S"/>
-            <MenuItem fx:id="saveAs" mnemonicParsing="false" text="Save As…" accelerator="Shortcut+Shift+S"/>
+            <MenuItem fx:id="save" accelerator="Shortcut+S" mnemonicParsing="false" text="Save" />
+            <MenuItem fx:id="saveAs" accelerator="Shortcut+Shift+S" mnemonicParsing="false" text="Save As…" />
             <SeparatorMenuItem mnemonicParsing="false" />
             <MenuItem fx:id="preferences" mnemonicParsing="false" text="Preferences" />
             <SeparatorMenuItem mnemonicParsing="false" />
@@ -37,10 +39,10 @@
         <Menu mnemonicParsing="false" text="Edit">
           <items>
             <SeparatorMenuItem mnemonicParsing="false" />
-            <MenuItem fx:id="delete" mnemonicParsing="false" text="Delete" accelerator="Shortcut+D"/>
-            <MenuItem fx:id="undelete" mnemonicParsing="false" text="Undelete" accelerator="Shortcut+Z"/>
+            <MenuItem fx:id="delete" accelerator="Shortcut+D" mnemonicParsing="false" text="Delete" />
+            <MenuItem fx:id="undelete" accelerator="Shortcut+Z" mnemonicParsing="false" text="Undelete" />
             <SeparatorMenuItem mnemonicParsing="false" />
-            <MenuItem fx:id="selectMode" mnemonicParsing="false" text="Select Edges" accelerator="Shortcut+E"/>
+            <MenuItem fx:id="selectMode" accelerator="Shortcut+E" mnemonicParsing="false" text="Select Edges" />
           </items>
         </Menu>
         <Menu mnemonicParsing="false" text="Help">
@@ -66,6 +68,24 @@
                                         <TableColumn fx:id="toolboxStringColumn" editable="false" maxWidth="-1.0" minWidth="90.0" prefWidth="-1.0" sortable="false" />
                                       </columns>
                                     </TableView>
+                                    <VBox fx:id="symbolToolVBox" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
+                                       <children>
+                                          <CheckBox fx:id="edgesVisibleCheckbox" mnemonicParsing="false" selected="true" text="Edges">
+                                             <padding>
+                                                <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
+                                             </padding>
+                                          </CheckBox>
+                                          <CheckBox fx:id="nodeLabelCheckbox" mnemonicParsing="false" selected="true" text="Labels">
+                                             <padding>
+                                                <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
+                                             </padding>
+                                          </CheckBox>
+                                          <CheckBox fx:id="edgeWeightCheckbox" mnemonicParsing="false" selected="true" text="Weights">
+                                             <padding>
+                                                <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
+                                             </padding>
+                                          </CheckBox>
+                                       </children></VBox>
                                 </children>
                               </AnchorPane>
                             <AnchorPane>
@@ -73,8 +93,8 @@
                                     <TableView fx:id="properties" editable="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                       <columns>
                                         <TableColumn fx:id="propertiesStringColumn" editable="false" maxWidth="1920.0" minWidth="90.0" prefWidth="150.0" sortable="false" text="Property" />
-                                        <TableColumn fx:id="propertiesObjectColumn" maxWidth="1920.0" minWidth="90.0" prefWidth="150.0" sortable="false"  text="Value" />
-                                        <TableColumn fx:id="propertiesTypeColumn" editable="false" maxWidth="1920.0" minWidth="90.0" prefWidth="150.0" sortable="false"  text="Type" />
+                                        <TableColumn fx:id="propertiesObjectColumn" maxWidth="1920.0" minWidth="90.0" prefWidth="150.0" sortable="false" text="Value" />
+                                        <TableColumn fx:id="propertiesTypeColumn" editable="false" maxWidth="1920.0" minWidth="90.0" prefWidth="150.0" sortable="false" text="Type" />
                                       </columns>
                                        <columnResizePolicy>
                                           <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
@@ -95,6 +115,7 @@
                                     <Pane fx:id="pane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                        <children>
                                           <SwingNode fx:id="swingNode" />
+                                          <SwingNode fx:id="swingNodeWorldView" />
                                        </children></Pane>
                                     <Button fx:id="zoomOut" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="30.0" text="-" textAlignment="JUSTIFY" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0" />
                                     <Button fx:id="zoomIn" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="30.0" text="+" textAlignment="JUSTIFY" AnchorPane.bottomAnchor="45.0" AnchorPane.rightAnchor="10.0" />