Explorar o código

ShapeStylesheet, TODO and Importer

StylesheetManager
	updated the shape Stylesheet to use new 		shapes
	set new Default Size (10px -> 15px)

GrapmMLExporter & MyFilesourceGraphml
	removed deprecated TODOs

GraphMLImporter
	now properly sets defaultValues for 			Attributes without values
jascha Bohne %!s(int64=8) %!d(string=hai) anos
pai
achega
1f7aaa66b9

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

@@ -81,14 +81,13 @@ public class GraphMLExporter {
 			e.removeAttribute("ui.j2dsk");
 			for (String s : e.getEachAttributeKey()) {
 				Class<? extends Object> c = e.getAttribute(s).getClass();
-				// TODO: should something be done with the Attributes that do
-				// not fit?
 				if (!c.isPrimitive() && !(c == String.class) && !(c == Character.class) && !(c == Boolean.class)
 						&& !(c == Integer.class) && !(c == Long.class) && !(c == Short.class) && !(c == Byte.class)
 						&& !(c == Float.class) && !(c == Double.class)) {
 					Debug.out("Could not parse an Attribute because it is not Primitive or a String \n\t"
 							+ "(Attribute: " + s + ", Value: " + e.getAttribute(s) + ", from Edge: " + e + ", Type: "
 							+ c + ") ");
+					e.removeAttribute(s);
 				}
 			}
 		}
@@ -106,6 +105,7 @@ public class GraphMLExporter {
 					Debug.out("Could not parse an Attribute because it is not Primitive or a String \n\t"
 							+ "(Attribute: " + s + ", Value: " + n.getAttribute(s) + ", from Node: " + n + ", Type: "
 							+ c + ") ");
+					n.removeAttribute(s);
 				}
 			}
 		}

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

@@ -61,16 +61,16 @@ public class GraphMLImporter {
 	 */
 	private void handleAttributes(MyGraph g) {
 		for (Node n : g.getNodeSet()) {
-			if (!n.hasAttribute("typeofNode")) {
+			if (!n.hasAttribute("typeofNode") || n.getAttribute("typeofNode").equals("")) {
 				n.addAttribute("typeofNode", "standard");
 			}
-			if (!n.hasAttribute("typeofDevice")) {
+			if (!n.hasAttribute("typeofDevice") || n.getAttribute("typeofDevice").equals("")) {
 				n.addAttribute("typeofDevice", "unknown");
 			}
-			if (!n.hasAttribute("lat")) {
+			if (!n.hasAttribute("lat") || n.getAttribute("long").equals("")) {
 				n.addAttribute("lat", OptionsManager.getDefaultLat());
 			}
-			if (!n.hasAttribute("long")) {
+			if (!n.hasAttribute("long") || n.getAttribute("long").equals("")) {
 				n.addAttribute("long", OptionsManager.getDefaultLong());
 			}
 
@@ -78,18 +78,18 @@ public class GraphMLImporter {
 				n.addAttribute("ui.label", n.getAttribute("yEd.label").toString());
 				n.removeAttribute("yEd.label");
 			}
-			if (n.hasAttribute("yEd.x")) {
+			if (n.hasAttribute("yEd.x") || n.getAttribute("yEd.y").equals("")) {
 				n.addAttribute("x", Double.parseDouble(n.getAttribute("yEd.x").toString()));
 				n.removeAttribute("yEd.x");
 			}
-			if (n.hasAttribute("yEd.y")) {
+			if (n.hasAttribute("yEd.y") || n.getAttribute("yEd.y").equals("")) {
 				n.addAttribute("y", Double.parseDouble(n.getAttribute("yEd.y").toString()));
 				n.removeAttribute("yEd.y");
 			}
-			if (!n.hasAttribute("process-need")){
+			if (!n.hasAttribute("process-need") || n.getAttribute("process-need").equals("")){
 				n.addAttribute("process-need", 0);
 			}
-			if (!n.hasAttribute("process-max")){
+			if (!n.hasAttribute("process-max") || n.getAttribute("process-max").equals("")){
 				n.addAttribute("process-max", 0);
 			}
 		}

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

@@ -580,7 +580,6 @@ public class MyFileSourceGraphML extends MySourceBase implements FileSource, XML
 		return value.toUpperCase().replaceAll("\\W", "_");
 	}
 
-	// TODO: handle malformed files on state switches
 	/**
 	 * parses a Stream of xml Events to a graphstream graph it has limited
 	 * support for yEd attributes
@@ -1105,7 +1104,6 @@ public class MyFileSourceGraphML extends MySourceBase implements FileSource, XML
 		return d;
 	}
 
-	// TODO color parsing
 	/**
 	 * Parses a yEdattribute. returns null if the Attribute is unknown.
 	 * 
@@ -1132,8 +1130,6 @@ public class MyFileSourceGraphML extends MySourceBase implements FileSource, XML
 		Data data = null;
 		Key k = null;
 		switch (name) {
-		// TODO weight
-
 		case "Geometry":
 			// the coordinates
 			yPosition = new Data();
@@ -1189,10 +1185,6 @@ public class MyFileSourceGraphML extends MySourceBase implements FileSource, XML
 			data.key = k;
 			data.value = buffer.toString();
 
-			break;
-		case "Fill":
-			// TODO colour
-
 			break;
 		default:
 			Debug.out("ignored Yed attribute: " + name);
@@ -1400,13 +1392,6 @@ public class MyFileSourceGraphML extends MySourceBase implements FileSource, XML
 			}
 		}
 
-		// TODO: see if this experimental fix breaks anything
-		/*
-		 * for (Key k : keys.values()) { if ((k.domain == KeyDomain.NODE ||
-		 * k.domain == KeyDomain.ALL) && !sentAttributes.contains(k))
-		 * sendNodeAttributeAdded(sourceId, id, k.name, getDefaultValue(k)); }
-		 */
-
 		if (isEvent(e, XMLEvent.START_ELEMENT, "graph")) {
 			Location loc = e.getLocation();
 

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

@@ -20,13 +20,13 @@ public class StylesheetManager {
 	 * The Stylesheet that is given to every graph that is added to display
 	 * everything correctly.
 	 */
-	public static final String DEFAULT_STYLESHEET = "node{text-alignment:at-right;} \n"
+	public static final String DEFAULT_STYLESHEET = "node{text-alignment:at-right; size:15px;} \n"
 			+ "edge{text-offset: 4px,-4px;} edge.selected{fill-color: #FF0000;}";
 	/**
 	 * Part of the stylesheet that styles the different Nodes with shapes.
 	 */
-	public static final String STYLE_NODES_SHAPES = "node.standard{shape: circle;}" + "node.source{shape: rounded-box;}"
-			+ "node.procEn{shape: diamond;}" + "node.sink{shape: cross;}";
+	public static final String STYLE_NODES_SHAPES = "node.standard{shape: diamond;}" + "node.source{shape: triangle;}"
+			+ "node.procEn{shape: circle;}" + "node.sink{shape: box;}" + "node.operator{shape: circle;}";
 	/**
 	 * Part of the stylesheet that styles the different Nodes with sprites.
 	 */