package net.xprova.netlistgraph;

import net.xprova.dot.GraphDotFormatter;

public class NetlistGraphDotFormatter extends GraphDotFormatter<Vertex> {

	private final NetlistGraph parent;

	@Override
	public String getEdgeLabel(Vertex s, Vertex d) {

		return parent.getPinName(s, d);

	}

	public NetlistGraphDotFormatter(NetlistGraph parent) {

		super();

		this.parent = parent;

	}

	@Override
	public String getShape(Vertex v) {

		if (v.type == VertexType.NET) {

			if ("input".equals(v.subtype) || "output".equals(v.subtype)) {

				return "shape=circle, fixedsize=false, style=\"filled, solid\", fillcolor=plum, color=black, fontname=Arial";

			} else {

				return "shape=circle, fixedsize=false, fontname=Arial";

			}

		} else {

			boolean isFlop = parent.getNet(v, "CK") != null;

			boolean isBlock = v.subtype.equals("BLOCK");

			if (isBlock) {

				return "shape=square, fixedsize=false, style=\"filled, solid\", fillcolor=white, color=black, fontname=Arial";

			} else if (isFlop) {

				boolean isVulnerable = parent.getNet(v, "V") != null;

				if (isVulnerable) {

					return "shape=box, fixedsize=false, style=\"filled, solid\", fillcolor=indianred1, color=black, fontname=Arial";

				} else {

					return "shape=box, fixedsize=false, style=\"filled, solid\", fillcolor=limegreen, color=black, fontname=Arial";

				}

			} else {

				return "shape=cds, fixedsize=false, style=\"filled, solid\", fillcolor=khaki1, color=black, fontname=Arial, width=1, height=0.75";

				// return "shape=box, fixedsize=false";
			}

		}
	}

}

@@ -737,16 +737,114 @@
 else %7B%0A%0A
+%09%09%09// TODO: replace this heuristic with better way of determining if%0A%09%09%09// vertex is a flip-flop%0A%0A
 %09%09%09boole
@@ -855,16 +855,17 @@
 sFlop = 
+(
 parent.g
@@ -882,24 +882,57 @@
 CK%22) != null
+) %7C%7C (v.subtype.contains(%22DFF%22)) 
 ;%0A%0A%09%09%09boolea

Modify FF detection heuristic in NetlistGraphDotFormatter