소스 검색

Merged, fixed, tried integrating Graph Viewer

Merged with Jascha
Fixed Visualizer to have static method
Tried integrating Graph Viewer into GUI without success
MainApp for GUI, App for GraphViewer
Jan Enders 8 년 전
부모
커밋
cbf022176c

+ 0 - 5
scopviz/pom.xml

@@ -21,11 +21,6 @@
       <version>3.8.1</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-    	<groupId>com.tinkerpop.blueprints</groupId>
-    	<artifactId>blueprints-core</artifactId>
-    	<version>2.6.0</version>
-    </dependency>
     <dependency>
     	<groupId>org.graphstream</groupId>
     	<artifactId>gs-core</artifactId>

+ 3 - 7
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/App.java

@@ -13,13 +13,9 @@ public class App {
 	public static void main(String[] args) {
 
 		GraphMLImporter importer = new GraphMLImporter();
-		try {
-			Graph g = importer.readGraph("src/main/resources/TestGraphML.txt");
-			g.display();
-		} catch (IOException e) {
-			System.err.println("Error while reading or displaying test GraphML file!");
-			e.printStackTrace();
-		}
+		Graph g = importer.readGraph("src/main/resources/Example.graphml");
+		g.display(false);
+		
 		System.out.println("Hello World!");
 	}
 }

+ 0 - 5
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/GraphMLExporter.java

@@ -11,11 +11,6 @@ import org.graphstream.stream.file.FileSinkGraphML;
  * 
  */
 public class GraphMLExporter {
-
-import org.graphstream.*;
-
-public class GraphMLExporter {
-	public void writeGraph(Graph g, String fileName) {
 	/**
 	 * Exports the current state of the Graph to a GraphML file.
 	 * 

+ 2 - 4
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/GraphMLImporter.java

@@ -13,8 +13,7 @@ import org.graphstream.stream.file.FileSourceGraphML;
  *
  */
 public class GraphMLImporter {
-
-	public Graph readGraph(String fileName) throws IOException {
+	
 	/**
 	 * Imports a GraphML file.
 	 * 
@@ -26,14 +25,13 @@ public class GraphMLImporter {
 		Graph g = new DefaultGraph("g");
 		FileSource fs = new FileSourceGraphML();
 		fs.addSink(g);
-		fs.readAll(fileName);
-		fs.removeSink(g);
 		try {
 			fs.readAll(fileName);
 		} catch (IOException e) {
 			System.out.println("GraphML File doesn't exist or can't be opened");
 			e.printStackTrace();
 		}
+		fs.removeSink(g);
 		return g;
 	}
 }

+ 3 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/Visualizer.java

@@ -1,6 +1,7 @@
 package de.tu_darmstadt.informatik.tk.scopviz;
 
 import org.graphstream.graph.*;
+import org.graphstream.ui.swingViewer.ViewPanel;
 import org.graphstream.ui.view.*;
 
 /**
@@ -17,9 +18,9 @@ public class Visualizer {
    * @param g the Graph that the view is based on
    * @return a View of the Graph, inheriting from JPanel
    */
-  public View getView (final Graph g){
+  public static ViewPanel getView (final Graph g){
     Viewer viewer = new Viewer(g, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
-    View view = viewer.addDefaultView(false);
+    ViewPanel view = viewer.addDefaultView(false);
     return view;
   }
 }

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

@@ -1,8 +1,16 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui;
 
+import java.awt.Dimension;
 import java.io.IOException;
 
 import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.graphstream.graph.Graph;
+import org.graphstream.ui.swingViewer.ViewPanel;
+import org.graphstream.ui.view.View;
 
 import javafx.application.Application;
 import javafx.embed.swing.SwingNode;
@@ -14,15 +22,21 @@ import javafx.scene.layout.BorderPane;
 import javafx.scene.layout.VBox;
 import javafx.stage.Stage;
 
+import de.tu_darmstadt.informatik.tk.scopviz.*;
+
 public class MainApp extends Application {
 
 	private Stage primaryStage;
 	private VBox rootLayout;
+	private Graph graph;
 
 	@Override
 	public void start(Stage primaryStage) {
 		this.primaryStage = primaryStage;
 
+		GraphMLImporter importer = new GraphMLImporter();
+		graph = importer.readGraph("src/main/resources/Example.graphml");
+		
 		initRootLayout();
 
 	}
@@ -41,7 +55,7 @@ public class MainApp extends Application {
 			Pane pane = (Pane) anchor.getChildren().get(1);
 			SwingNode swingNode = (SwingNode) pane.getChildren().get(0);
 
-			swingNode.setContent(new JButton("BLAAAAAA"));
+			swingNode.setContent(new JLabel("Graph Anzeige"));
 
 			primaryStage.setScene(scene);
 			primaryStage.show();