浏览代码

added graphnml import (I think)

jascha Bohne 8 年之前
父节点
当前提交
be74c9b9d8

+ 34 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/debug/Debug.java

@@ -14,6 +14,24 @@ import de.tu_darmstadt.informatik.tk.scopviz.io.MyFileSourceGraphML;
  */
 public final class Debug {
 
+	private static int logLevel = 2;
+
+	/**
+	 * @return the logLevel (1 = INFORMTAION, 2 = WARNING, 3 = ERROR)
+	 */
+	public static int getLogLevel() {
+		return logLevel;
+	}
+
+	/**
+	 * All Logs with a severity smaller than the loglevel will be ignored
+	 * 
+	 * @param logLevel the logLevel to set
+	 */
+	public static void setLogLevel(int logLevel) {
+		Debug.logLevel = logLevel;
+	}
+
 	/**
 	 * Private Constructor to prevent instantiation.
 	 */
@@ -61,6 +79,22 @@ public final class Debug {
 		}
 	}
 
+	/**
+	 * Short form for System.out.println(). 
+	 * Also look if a message is important enough to be printed
+	 * 
+	 * @param s
+	 *            String to be printed on the console
+	 * 
+	 * @param severity 
+	 * 			  the severity of the message (1 = INFORMATION, 2 = WARNING, 3 = ERROR)
+	 */
+	public static void out(String s, int severity) {
+		if (DEBUG_ENABLED && severity >= logLevel) {
+			System.out.println(s);
+		}
+	}
+
 	/**
 	 * Short form for System.out.println().
 	 * 

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

@@ -135,12 +135,11 @@ public class GraphMLImporter {
 		try {
 			fs.readAll(fileURL);
 		} catch (IOException e) {
-			System.out.println("GraphML File doesn't exist or can't be opened");
+			Debug.out("GraphML File doesn't exist or can't be opened");
 			e.printStackTrace();
 		}
 		fs.removeSink(g);
 		handleAttributes(g);
-		Debug.out(g.getId());
 		return g;
 	}
 

+ 4 - 4
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/io/MyFileSourceGraphML.java

@@ -633,9 +633,9 @@ public class MyFileSourceGraphML extends MySourceBase implements FileSource, XML
 				} else if (isEvent(e, XMLEvent.END_ELEMENT, "graph")) {
 					currentReaderState = ReaderState.GRAPH_END;
 				} else if (isEvent(e, XMLEvent.START_ELEMENT, "data")) {
-					// <data> is ignored
 					pushback(e);
-					__data();
+					Data data = __data();
+					sendGraphAttributeAdded(sourceId, data.key.name, data.value);
 					e = getNextEvent();
 				} else {
 					throw newParseError(e, "expecting %s, got %s", "<graph>, </graph>, <node>, <edge> or <data>",
@@ -880,7 +880,7 @@ public class MyFileSourceGraphML extends MySourceBase implements FileSource, XML
 		if (name == null)
 			name = id;
 
-		Debug.out("add key \"" + id + "\"");
+		Debug.out("add key \"" + id + "\"", 1);
 		Key k = new Key();
 		k.name = name;
 		k.domain = domain;
@@ -1187,7 +1187,7 @@ public class MyFileSourceGraphML extends MySourceBase implements FileSource, XML
 
 			break;
 		default:
-			Debug.out("ignored Yed attribute: " + name);
+			Debug.out("ignored Yed attribute: " + name, 1);
 			data = null;
 			break;
 		}