Bladeren bron

Merge remote-tracking branch 'origin/Julian' into Jan

Jan Enders 8 jaren geleden
bovenliggende
commit
085fdd6484

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

@@ -173,7 +173,7 @@ public final class ButtonManager {
 		
 		//show metricbox/update button
 		if (!(GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING))){
-			controller.rightSide.getChildren().add(controller.updateButtonAPane);
+			controller.rightSide.getChildren().add(2, controller.updateButtonAPane);
 			controller.metricbox.setVisible(true);
 		}
 				

+ 120 - 34
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/PropertiesManager.java

@@ -1,7 +1,9 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.Optional;
 
 import org.graphstream.graph.Edge;
@@ -36,7 +38,7 @@ import javafx.util.Callback;
  * Manager for the Properties pane and its contents.
  * 
  * @author Julian Ohl, Dominik Renkel
- * @version 1.0
+ * @version 1.6
  *
  */
 public final class PropertiesManager {
@@ -57,9 +59,13 @@ public final class PropertiesManager {
 	public static boolean nameSet;
 	/** Flag whether the value has been set. */
 	public static boolean valueSet;
-	
-	
+
 	public static HashSet<TableRow<KeyValuePair>> tableRows = new HashSet<TableRow<KeyValuePair>>();
+	
+	/** list for organizing items in the properties window in a specific order */
+	private static LinkedList<String> itemOrderRules = new LinkedList<String>();
+	/** hashmap for filtering items out of the properties window  */
+	private static HashMap<String, Integer> itemVisibilityRules = new HashMap<String, Integer>();
 
 	/**
 	 * Private Constructor to prevent Instantiation.
@@ -68,7 +74,7 @@ public final class PropertiesManager {
 	}
 
 	/**
-	 * Initializes the Manager by adding the List of properties to display into
+	 * Initializes the Manager by adding the list of properties to display into
 	 * the properties pane.
 	 * 
 	 * @param propertiesInput
@@ -77,6 +83,41 @@ public final class PropertiesManager {
 	public static void initializeItems(TableView<KeyValuePair> propertiesInput) {
 
 		properties = propertiesInput;
+		setItemRules();
+
+	}
+	
+	/**
+	 * setting up the rules for the items displayed in the properties window
+	 * 
+	 * ******************************************************
+	 *  add properties here for grouping or filtering them out
+	 * ******************************************************
+	 */
+	private static void setItemRules() {
+
+		//setting the order for specific properties
+		itemOrderRules.add("ID");
+		itemOrderRules.add("typeofNode");
+		itemOrderRules.add("typeofDevice");
+		itemOrderRules.add("x");
+		itemOrderRules.add("y");
+		itemOrderRules.add("lat");
+		itemOrderRules.add("long");
+		
+		//properties, which shall be filtered out of the properties window
+		itemVisibilityRules.put("layout.frozen", -1);
+		itemVisibilityRules.put("ui.style", -1);
+		itemVisibilityRules.put("ui.j2dsk", -1);
+		itemVisibilityRules.put("ui.clicked", -1);
+		itemVisibilityRules.put("ui.map.selected", -1);
+		itemVisibilityRules.put("xyz", -1);
+
+		//properties, which shall be filtered out of the properties window , only if debug is disabled
+		itemVisibilityRules.put("mapping", -2);
+		itemVisibilityRules.put("mapping-parent", -2);
+		itemVisibilityRules.put("mapping-parent-id", -2);
+		itemVisibilityRules.put("ui.class", -2);
 
 	}
 
@@ -174,15 +215,14 @@ public final class PropertiesManager {
 			});
 
 			// Disable MenuItem in symbol layer
-			//TODO
-			onlyAddPropMenuItem.disableProperty().bind(GraphDisplayManager.inSymbolLayerProperty()); 
-			addPropMenuItem.disableProperty().bind(GraphDisplayManager.inSymbolLayerProperty()); 
-			deletePropMenuItem.disableProperty().bind(GraphDisplayManager.inSymbolLayerProperty()); 
-			
+			// TODO
+			onlyAddPropMenuItem.disableProperty().bind(GraphDisplayManager.inSymbolLayerProperty());
+			addPropMenuItem.disableProperty().bind(GraphDisplayManager.inSymbolLayerProperty());
+			deletePropMenuItem.disableProperty().bind(GraphDisplayManager.inSymbolLayerProperty());
+
 			// add MenuItem to ContextMenu
 			menuOnEmptyRows.getItems().add(onlyAddPropMenuItem);
 			menuOnNonEmptyRows.getItems().addAll(addPropMenuItem, deletePropMenuItem);
-			
 
 			// when empty row right-clicked open special menu (only add),
 			// otherwise normal menu (add & delete)
@@ -225,12 +265,12 @@ public final class PropertiesManager {
 	public static void showNewDataSet(Element selected) {
 
 		ObservableList<KeyValuePair> newData = FXCollections.observableArrayList();
-		
+
 		if (selected == null) {
 			properties.setItems(newData);
 			return;
 		}
-		
+
 		// fix for concurrentModification exception
 		String[] temp = new String[0];
 		temp = selected.getAttributeKeySet().toArray(temp);
@@ -247,16 +287,6 @@ public final class PropertiesManager {
 					newData.add(0, new KeyValuePair(key, String.valueOf(actualAttribute), actualAttribute.getClass()));
 				}
 				break;
-			case "layout.frozen":
-				break;
-			case "ui.style":
-				break;
-			case "ui.j2dsk":
-				break;
-			case "ui.clicked":
-				break;
-			case "ui.map.selected":
-				break;
 			case "weight":
 				if (selected instanceof Edge
 						&& Layer.UNDERLAY == Main.getInstance().getGraphManager().getGraph().getAttribute("layer")) {
@@ -281,23 +311,19 @@ public final class PropertiesManager {
 				if (selected instanceof Node
 						&& Layer.UNDERLAY == Main.getInstance().getGraphManager().getGraph().getAttribute("layer")) {
 					newData.add(new KeyValuePair(key, selected.getAttribute(key).toString(), String.class));
-				}
-
-			case "xyz":
-				break;
-			case "mapping":
-			case "mapping-parent":
-			case "mapping-parent-id":
-			case "ui.class":
-				if (!Debug.DEBUG_ENABLED)
 					break;
+				}
+			break;
 			default:
 				Object actualAttribute = selected.getAttribute(key);
-				newData.add(new KeyValuePair(key, String.valueOf(actualAttribute), actualAttribute.getClass()));
+				if(actualAttribute != null){
+					newData.add(new KeyValuePair(key, String.valueOf(actualAttribute), actualAttribute.getClass()));
+				}
 				break;
 			}
 		}
-		properties.setItems(newData);
+
+		properties.setItems(groupProperties(newData));
 	}
 
 	/**
@@ -335,7 +361,67 @@ public final class PropertiesManager {
 	}
 
 	/**
-	 * contextMenu add button functionality.
+	 * groups and filters a list of items according to the order and visibility rules
+	 * @param data a list of property items
+	 * @return the data with the rules applied
+	 */
+	private static ObservableList<KeyValuePair> groupProperties(ObservableList<KeyValuePair> data) {
+		ObservableList<KeyValuePair> newData = FXCollections.observableArrayList();;
+
+		//adds all items in the order of the rules. Ordered items as an extra list, removed from data
+		for(String s: itemOrderRules){
+			
+			for (int i = 0; i < data.size(); i++) {
+				
+				KeyValuePair kvp = data.get(i);
+
+				if (kvp.getKey().equals(s)) {
+					
+					newData.add(kvp);
+					data.remove(kvp);
+					
+				}
+				
+			}
+			
+		}
+		
+		//filters items according to the rules. Filters on the data without the ordered items
+		for (String key : itemVisibilityRules.keySet()) {
+
+			for (int i = 0; i < data.size(); i++) {
+				KeyValuePair kvp = data.get(i);
+
+				if (kvp.getKey().equals(key)) {
+
+					if (itemVisibilityRules.get(kvp.getKey()) == -1) {
+						data.remove(kvp);
+
+					}
+
+					else if (itemVisibilityRules.get(kvp.getKey()) == -2) {
+
+						if (!Debug.DEBUG_ENABLED) {
+							data.remove(kvp);
+
+						}
+
+					}
+
+					break;
+				}
+
+			}
+		}
+		
+		//adds the filtered data without the ordered items behind the ordered items
+		newData.addAll(data);
+		
+		return newData;
+	}
+
+	/**
+	 * TODO Auslagern contextMenu add button functionality.
 	 */
 	private static void addPropFunctionality() {
 		Debug.out("Add Element");

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

@@ -66,7 +66,7 @@ public final class ToolboxManager {
 
 		@SuppressWarnings("unchecked")
 		ObservableList<Pair<Object, String>> data = FXCollections.observableArrayList(
-				pair(new Image(MainApp.class.getResource("/png/standard.png").toString()), "Standard"),
+				pair(new Image(MainApp.class.getResource("/png/standard_operator.png").toString()), "Standard"),
 				pair(new Image(MainApp.class.getResource("/png/procEn.png").toString()), "ProcEn"),
 				pair(new Image(MainApp.class.getResource("/png/source.png").toString()), "Source"),
 				pair(new Image(MainApp.class.getResource("/png/sink.png").toString()), "Sink"),
@@ -82,7 +82,7 @@ public final class ToolboxManager {
 
 		@SuppressWarnings("unchecked")
 		ObservableList<Pair<Object, String>> data = FXCollections.observableArrayList(
-				pair(new Image(MainApp.class.getResource("/png/operator.png").toString()), "Operator"),
+				pair(new Image(MainApp.class.getResource("/png/standard_operator.png").toString()), "Operator"),
 				pair(new Image(MainApp.class.getResource("/png/source.png").toString()), "Source"),
 				pair(new Image(MainApp.class.getResource("/png/sink.png").toString()), "Sink"),
 				pair(new Image(MainApp.class.getResource("/png/dirEdge.png").toString()), "Directed"));
@@ -98,7 +98,7 @@ public final class ToolboxManager {
 
 		@SuppressWarnings("unchecked")
 		ObservableList<Pair<Object, String>> data = FXCollections.observableArrayList(
-				pair(new Image(MainApp.class.getResource("/png/dirEdge.png").toString()), "Directed"));
+				pair(new Image(MainApp.class.getResource("/png/dirEdge.png").toString()), "Mapping Edge"));
 
 		controller.toolbox.getItems().setAll(data);
 

+ 11 - 9
scopviz/src/main/resources/MainWindow.fxml

@@ -41,7 +41,7 @@
         <Menu mnemonicParsing="false" text="Edit">
           <items>
             <SeparatorMenuItem mnemonicParsing="false" />
-            <MenuItem fx:id="delete" accelerator="Shortcut+D" mnemonicParsing="false" text="Delete" />
+            <MenuItem fx:id="delete" accelerator="DELETE" mnemonicParsing="false" text="Delete" />
             <MenuItem fx:id="undelete" accelerator="Shortcut+Z" mnemonicParsing="false" text="Undelete" />
             <SeparatorMenuItem mnemonicParsing="false" />
             <MenuItem fx:id="updateMetricMI" accelerator="Shortcut+R" mnemonicParsing="false" text="Update metrics" />
@@ -161,20 +161,22 @@
                                                 </TableView>
                                              </children>
                                           </AnchorPane>
+                                          <AnchorPane fx:id="updateButtonAPane" prefHeight="25.0">
+                                             <children>
+                                                <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>
                                           <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" />
+                                                <TextFlow fx:id="consoleWindow" lineSpacing="0.5" styleClass="consoleWindow">
+                                                   <children>                                     
                                                    </children>
+                                                   <padding>
+                                                      <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
+                                                   </padding>
                                                 </TextFlow>
                                              </content>
                                           </ScrollPane>
-                                          <AnchorPane fx:id="updateButtonAPane" prefHeight="25.0">
-                                             <children>
-                                                <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>
                                     </VBox>
                                  </children>

BIN
scopviz/src/main/resources/png/operator.png


BIN
scopviz/src/main/resources/png/operator_green.png


BIN
scopviz/src/main/resources/png/operator_red.png


BIN
scopviz/src/main/resources/png/procEn.png


BIN
scopviz/src/main/resources/png/procEn_green.png


BIN
scopviz/src/main/resources/png/procEn_red.png


BIN
scopviz/src/main/resources/png/sink.png


BIN
scopviz/src/main/resources/png/sink_green.png


BIN
scopviz/src/main/resources/png/sink_red.png


BIN
scopviz/src/main/resources/png/source.png


BIN
scopviz/src/main/resources/png/source_green.png


BIN
scopviz/src/main/resources/png/source_red.png


BIN
scopviz/src/main/resources/png/standard.png


BIN
scopviz/src/main/resources/png/standard_green.png


BIN
scopviz/src/main/resources/png/standard_operator.png


BIN
scopviz/src/main/resources/png/standard_red.png


BIN
scopviz/src/main/resources/png/symbol_icons/raspberry_pi.png