Ver Fonte

Merged everything, formatted and fixed imports

Jan Enders há 8 anos atrás
pai
commit
5c3609fbdb

+ 19 - 18
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/GraphManager.java

@@ -10,7 +10,6 @@ import org.graphstream.graph.Graph;
 import org.graphstream.graph.Node;
 import org.graphstream.ui.geom.Point3;
 import org.graphstream.ui.swingViewer.ViewPanel;
-import org.graphstream.ui.swingViewer.util.DefaultCamera;
 import org.graphstream.ui.view.Viewer;
 import org.graphstream.ui.view.ViewerPipe;
 
@@ -221,19 +220,18 @@ public class GraphManager {
 	 */
 	public void selectNode(String nodeID) {
 		if (nodeID != null && g.getNode(nodeID) != null) {
-			
+
 			// set last selected node color to null
-			if(getSelectedNodeID() != null)
+			if (getSelectedNodeID() != null)
 				g.getNode(getSelectedNodeID()).changeAttribute("ui.style", "fill-color: #000000; size: 10px;");
-			
+
 			// set last selected edge color to black
-			else if(getSelectedEdgeID() != null)
+			else if (getSelectedEdgeID() != null)
 				g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style", "fill-color: #000000;");
-			
-			
+
 			setSelectedNodeID(nodeID);
 			setSelectedEdgeID(null);
-			
+
 			// set selected node color to red
 			g.getNode(nodeID).changeAttribute("ui.style", "fill-color: #FF0000; size: 15px;");
 		}
@@ -248,16 +246,16 @@ public class GraphManager {
 	public void selectEdge(String edgeID) {
 		if (edgeID != null && g.getEdge(edgeID) != null) {
 			// Set last selected Edge Color to Black
-			if(getSelectedEdgeID() != null)
+			if (getSelectedEdgeID() != null)
 				g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style", "fill-color: #000000;");
-			
+
 			// Set last selected Node color to black
-			else if(getSelectedNodeID() != null)
+			else if (getSelectedNodeID() != null)
 				g.getNode(getSelectedNodeID()).changeAttribute("ui.style", "fill-color: #000000; size: 10px;");
-				
+
 			setSelectedNodeID(null);
 			setSelectedEdgeID(edgeID);
-			
+
 			// set selected edge color to red
 			g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style", "fill-color: #FF0000;");
 		}
@@ -266,7 +264,7 @@ public class GraphManager {
 	/**
 	 * Deselect any currently selected nodes or edges.
 	 */
-	//TODO remove selection style & call this before save
+	// TODO remove selection style & call this before save
 	public void deselect() {
 		this.selectedNodeID = null;
 		this.selectedEdgeID = null;
@@ -294,14 +292,17 @@ public class GraphManager {
 	public void zoomOut() {
 		zoom(0.05);
 	}
-	
+
 	/**
-	 * Zooms the view by the given Amount, positive values zoom out, negative values zoom in.
+	 * Zooms the view by the given Amount, positive values zoom out, negative
+	 * values zoom in.
 	 * 
-	 * @param amount the amount of zoom, should usually be between -0.2 and 0.2 for reasonable zoom.
+	 * @param amount
+	 *            the amount of zoom, should usually be between -0.2 and 0.2 for
+	 *            reasonable zoom.
 	 */
 	public void zoom(double amount) {
-		view.getCamera().setViewPercent( view.getCamera().getViewPercent() * (1 + amount));
+		view.getCamera().setViewPercent(view.getCamera().getViewPercent() * (1 + amount));
 	}
 
 	public ViewerPipe getFromViewer() {

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

@@ -17,11 +17,7 @@ import de.tu_darmstadt.informatik.tk.scopviz.main.SelectionMode;
 import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
 import javafx.scene.control.Button;
-import javafx.scene.control.Skin;
-import javafx.scene.effect.DropShadow;
-import javafx.scene.effect.InnerShadow;
 import javafx.scene.input.MouseEvent;
-import javafx.scene.layout.Background;
 
 /**
  * Manager to contain the various handlers for the buttons of the UI.
@@ -84,7 +80,8 @@ public class ButtonManager {
 			Point3 cursorPos = graphManager.getView().getCamera().transformPxToGu(event.getX(), event.getY());
 			Node n;
 			Edge selectedEdge = AuxilFunctions.getClosestEdge(cursorPos);
-			if (Main.getInstance().getCreationMode().equals(CreationMode.CREATE_NONE) && Main.getInstance().getSelectionMode() == SelectionMode.SELECT_EDGES && selectedEdge != null) {
+			if (Main.getInstance().getCreationMode().equals(CreationMode.CREATE_NONE)
+					&& Main.getInstance().getSelectionMode() == SelectionMode.SELECT_EDGES && selectedEdge != null) {
 				Main.getInstance().getGraphManager().selectEdge(selectedEdge.getId());
 			}
 
@@ -153,8 +150,6 @@ public class ButtonManager {
 		public void handle(ActionEvent arg0) {
 			GraphDisplayManager.setCurrentLayer(Layer.OPERATOR);
 			GraphDisplayManager.switchActiveGraph();
-			
-			
 
 			setBorderStyle((Button) arg0.getSource());
 		}
@@ -167,7 +162,7 @@ public class ButtonManager {
 		public void handle(ActionEvent arg0) {
 			GraphDisplayManager.setCurrentLayer(Layer.MAPPING);
 			GraphDisplayManager.switchActiveGraph();
-			
+
 			setBorderStyle((Button) arg0.getSource());
 		}
 
@@ -179,16 +174,17 @@ public class ButtonManager {
 		public void handle(ActionEvent arg0) {
 			GraphDisplayManager.setCurrentLayer(Layer.SYMBOL);
 			GraphDisplayManager.switchActiveGraph();
-			
+
 			setBorderStyle((Button) arg0.getSource());
 		}
 
 	};
 
-		
 	/**
 	 * Changes the border of the button that was pressed to red
-	 * @param currentButton the button that was pressed
+	 * 
+	 * @param currentButton
+	 *            the button that was pressed
 	 */
 	private static void setBorderStyle(Button currentButton) {
 

+ 7 - 8
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/GUIController.java

@@ -24,7 +24,6 @@ import javafx.scene.control.TableCell;
 import javafx.scene.control.TableColumn;
 import javafx.scene.control.TableRow;
 import javafx.scene.control.TableView;
-import javafx.scene.control.ToggleButton;
 import javafx.scene.control.cell.PropertyValueFactory;
 import javafx.scene.control.cell.TextFieldTableCell;
 import javafx.scene.layout.Pane;
@@ -228,13 +227,13 @@ public class GUIController implements Initializable {
 		operatorButton.setOnAction(ButtonManager.operatorHandler);
 		mappingButton.setOnAction(ButtonManager.mappingHandler);
 		symbolRepButton.setOnAction(ButtonManager.symbolRepHandler);
-		
-		ArrayList<Button> layerButtons = new ArrayList<Button> ();
+
+		ArrayList<Button> layerButtons = new ArrayList<Button>();
 		layerButtons.add(underlayButton);
 		layerButtons.add(operatorButton);
 		layerButtons.add(mappingButton);
 		layerButtons.add(symbolRepButton);
-		ButtonManager.setGuiController(this,layerButtons);
+		ButtonManager.setGuiController(this, layerButtons);
 	}
 
 	/**
@@ -247,7 +246,7 @@ public class GUIController implements Initializable {
 		swingNode.setContent((JPanel) Main.getInstance().getGraphManager().getView());
 		swingNode.setOnMousePressed(GraphDisplayManager.rememberLastClickedPosHandler);
 		swingNode.setOnMouseDragged(GraphDisplayManager.mouseDraggedHandler);
-		
+
 		pane.setMinSize(200, 200);
 	}
 
@@ -270,7 +269,7 @@ public class GUIController implements Initializable {
 						return new ToolboxManager.PairValueCell();
 					}
 				});
-		
+
 		toolbox.getColumns().setAll(toolboxObjectColumn, toolboxStringColumn);
 
 		// Click event for TableView row
@@ -279,7 +278,7 @@ public class GUIController implements Initializable {
 			row.setOnMouseClicked(ToolboxManager.rowClickedHandler);
 			return row;
 		});
-		
+
 		// nothing is selected at the start
 		toolbox.getSelectionModel().clearSelection();
 
@@ -303,7 +302,7 @@ public class GUIController implements Initializable {
 		properties.getColumns().setAll(propertiesStringColumn, propertiesObjectColumn);
 
 		properties.setRowFactory(PropertiesManager.rightClickCallback);
-		
+
 		properties.setPlaceholder(new Label("No graph element selected"));
 		properties.getSelectionModel().clearSelection();
 

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

@@ -33,10 +33,10 @@ import javafx.stage.Stage;
  */
 public class GraphDisplayManager {
 	private static final String GRAPH_STRING_ID_PREFIX = "graph";
-	
+
 	private static Point3 oldMousePos;
 	private static Point3 oldViewCenter;
-	
+
 	private static ArrayList<GraphManager> vList = new ArrayList<GraphManager>();
 	private static int count = 0;
 	private static GUIController guiController;
@@ -91,7 +91,7 @@ public class GraphDisplayManager {
 	public static int addGraph(Stage stage, boolean replaceCurrent) {
 		String id = getGraphStringID(count);
 		Graph g = importer.readGraph(id, stage);
-		if (g==null){
+		if (g == null) {
 			return currentGraphManager;
 		}
 		return addGraph(g, replaceCurrent);
@@ -211,38 +211,39 @@ public class GraphDisplayManager {
 		GraphDisplayManager.currentLayer = currentLayer;
 	}
 
-	public static final EventHandler<ScrollEvent> scrollHandler  = new EventHandler<ScrollEvent>() {
+	public static final EventHandler<ScrollEvent> scrollHandler = new EventHandler<ScrollEvent>() {
 
 		@Override
 		public void handle(ScrollEvent event) {
 			double deltaY = event.getDeltaY();
-			getCurrentGraphManager().zoom(deltaY/-100);
+			getCurrentGraphManager().zoom(deltaY / -100);
 		}
-		
+
 	};
-	
-	public static final EventHandler<MouseEvent> rememberLastClickedPosHandler = new EventHandler<MouseEvent>(){
-		
+
+	public static final EventHandler<MouseEvent> rememberLastClickedPosHandler = new EventHandler<MouseEvent>() {
+
 		@Override
-		public void handle(MouseEvent event){
+		public void handle(MouseEvent event) {
 			Camera cam = getCurrentGraphManager().getView().getCamera();
-			oldMousePos  = cam.transformPxToGu(event.getSceneX(), event.getSceneY());
+			oldMousePos = cam.transformPxToGu(event.getSceneX(), event.getSceneY());
 			oldViewCenter = getCurrentGraphManager().getView().getCamera().getViewCenter();
-			Debug.out("Last mouse click position remembered: "+ oldMousePos.x +"/"+oldMousePos.y);
+			Debug.out("Last mouse click position remembered: " + oldMousePos.x + "/" + oldMousePos.y);
 		}
 	};
-	
-	public static final EventHandler<MouseEvent> mouseDraggedHandler =  new EventHandler<MouseEvent>(){
-		
+
+	public static final EventHandler<MouseEvent> mouseDraggedHandler = new EventHandler<MouseEvent>() {
+
 		@Override
-		public void handle(MouseEvent event){
+		public void handle(MouseEvent event) {
 			Camera cam = getCurrentGraphManager().getView().getCamera();
 			Point3 newMousePos = cam.transformPxToGu(event.getSceneX(), event.getSceneY());
 			double offsetX = oldMousePos.x - newMousePos.x;
 			double offsetY = oldMousePos.y - newMousePos.y;
 			double newX = oldViewCenter.x + offsetX;
 			double newY = oldViewCenter.y + offsetY;
-			Debug.out("Pan by "+offsetX+"/"+offsetY+": Center moved from "+oldViewCenter.x+"/"+oldViewCenter.y+" to "+newX+"/"+newY);
+			Debug.out("Pan by " + offsetX + "/" + offsetY + ": Center moved from " + oldViewCenter.x + "/"
+					+ oldViewCenter.y + " to " + newX + "/" + newY);
 			cam.setViewCenter(newX, newY, oldViewCenter.z);
 		}
 	};

+ 11 - 17
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/MenuBarManager.java

@@ -1,6 +1,5 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui;
 
-import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
 import de.tu_darmstadt.informatik.tk.scopviz.io.GraphMLExporter;
 import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
 import de.tu_darmstadt.informatik.tk.scopviz.main.GraphManager;
@@ -138,24 +137,24 @@ public class MenuBarManager {
 			MenuItem src = (MenuItem) evt.getSource();
 			if (src.getText().equals("Select Edges")) {
 				src.setText("Select Nodes");
-				
+
 				// unselect CreationMode
 				Main.getInstance().setCreationMode(CreationMode.CREATE_NONE);
 				controller.toolbox.getSelectionModel().clearSelection();
-				
+
 				// set SelectMode
 				Main.getInstance().setSelectionMode(SelectionMode.SELECT_EDGES);
-				
+
 			} else {
 				src.setText("Select Edges");
-				
+
 				// unselect CreationMode
 				Main.getInstance().setCreationMode(CreationMode.CREATE_NONE);
 				controller.toolbox.getSelectionModel().clearSelection();
-				
+
 				// set SelectMode
 				Main.getInstance().setSelectionMode(SelectionMode.SELECT_NODES);
-				
+
 			}
 		}
 	};
@@ -193,17 +192,12 @@ public class MenuBarManager {
 			Alert alert = new Alert(AlertType.INFORMATION);
 			alert.setTitle("About this programm");
 			alert.setHeaderText(null);
-			alert.setContentText(""
-					+ "Visualization Software of the Telecooperation group, \n"
-					+ "Department of Computer Science, \n"
-					+ "Technische Universität Darmstadt. \n"
-					+ "\n"
-					+ "Created by: \n"
-					+ "Jan Enders, Jascha Bohne, Dominik Renkel, \n"
-					+ "Julian Ohl und Matthias Wilhelm \n"
-					+ "comissioned by Julien Gedeon");
+			alert.setContentText("" + "Visualization Software of the Telecooperation group, \n"
+					+ "Department of Computer Science, \n" + "Technische Universität Darmstadt. \n" + "\n"
+					+ "Created by: \n" + "Jan Enders, Jascha Bohne, Dominik Renkel, \n"
+					+ "Julian Ohl und Matthias Wilhelm \n" + "comissioned by Julien Gedeon");
 			alert.getDialogPane().getChildren().stream().filter(node -> node instanceof Label)
-							.forEach(node -> ((Label)node).setMinHeight(Region.USE_PREF_SIZE));
+					.forEach(node -> ((Label) node).setMinHeight(Region.USE_PREF_SIZE));
 			alert.showAndWait();
 		}
 	};

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

@@ -26,13 +26,11 @@ import javafx.scene.control.Dialog;
 import javafx.scene.control.Label;
 import javafx.scene.control.MenuItem;
 import javafx.scene.control.TableColumn.CellEditEvent;
-import javafx.scene.input.MouseEvent;
 import javafx.scene.control.TableRow;
 import javafx.scene.control.TableView;
 import javafx.scene.control.TextField;
 import javafx.scene.layout.GridPane;
 import javafx.util.Callback;
-import javafx.util.Pair;
 
 /**
  * Manager for the Properties pane and its contents.
@@ -77,13 +75,15 @@ public class PropertiesManager {
 
 			Object classType = editedPair.getClassType();
 			String key = editedPair.getKey();
-			
-			//handling the problem when using his own names for properties needed by graphstream
-			//e.g. "ui.label" as "ID", might need an extra function/structure if more of these
-			if(key.equals("ID")){
+
+			// handling the problem when using his own names for properties
+			// needed by graphstream
+			// e.g. "ui.label" as "ID", might need an extra function/structure
+			// if more of these
+			if (key.equals("ID")) {
 				key = "ui.label";
 			}
-			
+
 			String oldValue = t.getOldValue();
 			String newValue = t.getNewValue();
 
@@ -120,7 +120,7 @@ public class PropertiesManager {
 				setItemsProperties();
 				Debug.out("invalid input for this attribute type");
 			}
-			
+
 			// Unselect row after updating Property
 			properties.getSelectionModel().clearSelection();
 		}

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

@@ -126,9 +126,9 @@ public class ToolboxManager {
 					else
 						main.setCreationMode(CreationMode.CREATE_UNDIRECTED_EDGE);
 				}
-				
+
 				// Unselecet Rows if Creation Mode is None
-				if(main.getCreationMode().equals(CreationMode.CREATE_NONE)){
+				if (main.getCreationMode().equals(CreationMode.CREATE_NONE)) {
 					controller.toolbox.getSelectionModel().clearSelection();
 				}
 			}

+ 9 - 11
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/handlers/MyViewerListener.java

@@ -1,6 +1,5 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui.handlers;
 
-import org.graphstream.graph.Edge;
 import org.graphstream.ui.view.ViewerListener;
 
 import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
@@ -68,7 +67,7 @@ public class MyViewerListener implements ViewerListener {
 			return;
 		}
 		deselectNodesAfterEdgeCreation(id);
-		
+
 		switch (Main.getInstance().getSelectionMode()) {
 		case SELECT_NODES:
 			graphManager.selectNode(id);
@@ -98,9 +97,9 @@ public class MyViewerListener implements ViewerListener {
 					newID = Main.getInstance().getUnusedID();
 					graphManager.getGraph().addEdge(newID, lastClickedID, id, true);
 					Debug.out("Created an directed edge with Id " + newID + " between " + lastClickedID + " and " + id);
-					
+
 					deselectNodesAfterEdgeCreation(lastClickedID);
-					
+
 					lastClickedID = null;
 					graphManager.selectEdge(newID);
 				}
@@ -137,13 +136,12 @@ public class MyViewerListener implements ViewerListener {
 			Main.getInstance().setCreationMode(CreationMode.CREATE_NONE);
 		}
 	}
-	
-	
-	private void selectNodeForEdgeCreation(String nodeID){
+
+	private void selectNodeForEdgeCreation(String nodeID) {
 		graphManager.getGraph().getNode(nodeID).changeAttribute("ui.style", "fill-color: #00FF00; size: 15px;");
 	}
-	
-	private void deselectNodesAfterEdgeCreation(String nodeID){
+
+	private void deselectNodesAfterEdgeCreation(String nodeID) {
 		String uiStyle = "fill-color: #000000; size: 10px;";
 		graphManager.getGraph().getNode(nodeID).changeAttribute("ui.style", uiStyle);
 	}
@@ -153,7 +151,7 @@ public class MyViewerListener implements ViewerListener {
 	 */
 	@Override
 	public void buttonReleased(String id) {
-		
+
 	}
 
 	/**
@@ -161,7 +159,7 @@ public class MyViewerListener implements ViewerListener {
 	 */
 	@Override
 	public void viewClosed(String viewName) {
-		
+
 	}
 
 }