diff --git a/src/java/org/apache/commons/graph/visualize/Colored.java b/src/java/org/apache/commons/graph/visualize/Colored.java
new file mode 100644
index 0000000..f7fc513
--- /dev/null
+++ b/src/java/org/apache/commons/graph/visualize/Colored.java
@@ -0,0 +1,8 @@
+package org.apache.commons.graph.visualize;
+
+import java.awt.Color;
+
+public interface Colored {
+ public Color getBackgroundColor();
+ public Color getTextColor();
+}
diff --git a/src/java/org/apache/commons/graph/visualize/TouchGraph.java b/src/java/org/apache/commons/graph/visualize/TouchGraph.java
index 986f7d6..8fa14eb 100644
--- a/src/java/org/apache/commons/graph/visualize/TouchGraph.java
+++ b/src/java/org/apache/commons/graph/visualize/TouchGraph.java
@@ -1,234 +1,248 @@
-package org.apache.commons.graph.visualize;
-
-import java.util.Random;
-import java.util.Iterator;
-
-import java.io.OutputStream;
-import java.io.PrintWriter;
-
-import java.awt.Color;
-
-import org.apache.commons.graph.*;
-
-/**
- * Description of the Class
- */
-public class TouchGraph
-{
- private Color vertexColor = Color.yellow;
- private Color textColor = Color.black;
- private Color edgeColor = Color.red;
-
- private double lengthFactor = 500.0;
- private double defaultLength = 1.0;
- private int fontSize = 18;
-
- private Random random = new Random();
-
- /**
- * Constructor for the TouchGraph object
- */
- public TouchGraph() { }
-
- /**
- * Gets the colorText attribute of the TouchGraph object
- */
- private String getColorText(Color color)
- {
- return Integer.toHexString(color.getRGB()).toUpperCase();
- }
-
- /**
- * Sets the vertexColor attribute of the TouchGraph object
- */
- public void setVertexColor(Color vertexColor)
- {
- this.vertexColor = vertexColor;
- }
-
- /**
- * Gets the vertexColor attribute of the TouchGraph object
- */
- public Color getVertexColor()
- {
- return this.vertexColor;
- }
-
- /**
- * Gets the vertexColorText attribute of the TouchGraph object
- */
- private String getVertexColorText()
- {
- return getColorText(getVertexColor());
- }
-
- /**
- * Sets the textColor attribute of the TouchGraph object
- */
- public void setTextColor(Color vertexColor)
- {
- this.vertexColor = vertexColor;
- }
-
- /**
- * Gets the textColor attribute of the TouchGraph object
- */
- public Color getTextColor()
- {
- return this.vertexColor;
- }
-
- /**
- * Gets the textColorText attribute of the TouchGraph object
- */
- private String getTextColorText()
- {
- return getColorText(getTextColor());
- }
-
- /**
- * Sets the edgeColor attribute of the TouchGraph object
- */
- public void setEdgeColor(Color edgeColor)
- {
- this.edgeColor = edgeColor;
- }
-
- /**
- * Gets the edgeColor attribute of the TouchGraph object
- */
- public Color getEdgeColor()
- {
- return this.edgeColor;
- }
-
- /**
- * Gets the edgeColorText attribute of the TouchGraph object
- */
- private String getEdgeColorText()
- {
- return getColorText(getEdgeColor());
- }
-
- /**
- * Sets the fontSize attribute of the TouchGraph object
- */
- public void setFontSize(int size)
- {
- this.fontSize = size;
- }
-
- /**
- * Gets the fontSize attribute of the TouchGraph object
- */
- public int getFontSize()
- {
- return fontSize;
- }
-
- /**
- * Sets the defaultEdgeLength attribute of the TouchGraph object
- */
- public void setDefaultEdgeLength(int length)
- {
- this.defaultLength = length;
- }
-
- /**
- * Gets the defaultEdgeLength attribute of the TouchGraph object
- */
- public double getDefaultEdgeLength()
- {
- return defaultLength;
- }
-
- /**
- * Description of the Method
- */
- protected void writeNodeset(PrintWriter pw,
- DirectedGraph graph)
- {
- pw.println("");
- Iterator vertices =
- graph.getVertices().iterator();
- while (vertices.hasNext())
- {
- Vertex v = (Vertex) vertices.next();
-
- pw.println("");
- pw.println("");
-
- String label;
- if (v instanceof Named)
- {
- label = ((Named) v).getName();
- }
- else
- {
- label = v.toString();
- }
-
- pw.println("");
-
- pw.println("");
- }
-
- pw.println("");
- }
-
- /**
- * Description of the Method
- */
- protected void writeEdgeset(PrintWriter pw, DirectedGraph graph)
- {
- pw.println("");
-
- Iterator edges = graph.getEdges().iterator();
- while (edges.hasNext())
- {
- Edge next = (Edge) edges.next();
-
- int length = new Double(lengthFactor *
- defaultLength).intValue();
-
- if (graph instanceof WeightedGraph)
- {
- length =
- new Double(lengthFactor *
- ((WeightedGraph) graph)
- .getWeight(next)).intValue();
- }
-
- pw.println("");
-
- }
- pw.println("");
- }
-
- /**
- * Description of the Method
- */
- public void toXML(DirectedGraph graph,
- OutputStream os)
- {
- PrintWriter pw = new PrintWriter(os);
- pw.println("");
- pw.println("");
- writeNodeset(pw, graph);
- writeEdgeset(pw, graph);
- pw.println("");
- pw.flush();
-
- return;
- }
-}
+package org.apache.commons.graph.visualize;
+
+import java.util.Random;
+import java.util.Iterator;
+
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import java.awt.Color;
+
+import org.apache.commons.graph.*;
+
+/**
+ * Description of the Class
+ */
+public class TouchGraph
+{
+ private Color vertexColor = Color.yellow;
+ private Color textColor = Color.black;
+ private Color edgeColor = Color.red;
+
+ private double lengthFactor = 500.0;
+ private double defaultLength = 1.0;
+ private int fontSize = 18;
+
+ private Random random = new Random();
+
+ /**
+ * Constructor for the TouchGraph object
+ */
+ public TouchGraph() { }
+
+ /**
+ * Gets the colorText attribute of the TouchGraph object
+ */
+ private String getColorText(Color color)
+ {
+ String RC = Integer.toHexString( color.getRGB()).toUpperCase();
+ return RC.substring( 2, 8 );
+ }
+
+ /**
+ * Sets the vertexColor attribute of the TouchGraph object
+ */
+ public void setVertexColor(Color vertexColor)
+ {
+ this.vertexColor = vertexColor;
+ }
+
+ /**
+ * Gets the vertexColor attribute of the TouchGraph object
+ */
+ public Color getVertexColor()
+ {
+ return this.vertexColor;
+ }
+
+ /**
+ * Gets the vertexColorText attribute of the TouchGraph object
+ */
+ private String getVertexColorText()
+ {
+ return getColorText(getVertexColor());
+ }
+
+ /**
+ * Sets the textColor attribute of the TouchGraph object
+ */
+ public void setTextColor(Color vertexColor)
+ {
+ this.vertexColor = vertexColor;
+ }
+
+ /**
+ * Gets the textColor attribute of the TouchGraph object
+ */
+ public Color getTextColor()
+ {
+ return this.vertexColor;
+ }
+
+ /**
+ * Gets the textColorText attribute of the TouchGraph object
+ */
+ private String getTextColorText()
+ {
+ return getColorText(getTextColor());
+ }
+
+ /**
+ * Sets the edgeColor attribute of the TouchGraph object
+ */
+ public void setEdgeColor(Color edgeColor)
+ {
+ this.edgeColor = edgeColor;
+ }
+
+ /**
+ * Gets the edgeColor attribute of the TouchGraph object
+ */
+ public Color getEdgeColor()
+ {
+ return this.edgeColor;
+ }
+
+ /**
+ * Gets the edgeColorText attribute of the TouchGraph object
+ */
+ private String getEdgeColorText()
+ {
+ return getColorText(getEdgeColor());
+ }
+
+ /**
+ * Sets the fontSize attribute of the TouchGraph object
+ */
+ public void setFontSize(int size)
+ {
+ this.fontSize = size;
+ }
+
+ /**
+ * Gets the fontSize attribute of the TouchGraph object
+ */
+ public int getFontSize()
+ {
+ return fontSize;
+ }
+
+ /**
+ * Sets the defaultEdgeLength attribute of the TouchGraph object
+ */
+ public void setDefaultEdgeLength(int length)
+ {
+ this.defaultLength = length;
+ }
+
+ /**
+ * Gets the defaultEdgeLength attribute of the TouchGraph object
+ */
+ public double getDefaultEdgeLength()
+ {
+ return defaultLength;
+ }
+
+ /**
+ * Description of the Method
+ */
+ protected void writeNodeset(PrintWriter pw,
+ DirectedGraph graph)
+ {
+ pw.println("");
+ Iterator vertices =
+ graph.getVertices().iterator();
+ while (vertices.hasNext())
+ {
+ Vertex v = (Vertex) vertices.next();
+
+ pw.println("");
+ pw.println("");
+
+ String label;
+ if (v instanceof Named)
+ {
+ label = ((Named) v).getName();
+ }
+ else
+ {
+ label = v.toString();
+ }
+
+ String backColor = null;
+ String textColor = null;
+
+ if (v instanceof Colored) {
+ backColor = getColorText(((Colored) v).getBackgroundColor());
+ textColor = getColorText(((Colored) v).getTextColor() );
+ } else {
+ backColor = getVertexColorText();
+ textColor = getTextColorText();
+ }
+
+ pw.println("");
+
+ pw.println("");
+ }
+
+ pw.println("");
+ }
+
+ /**
+ * Description of the Method
+ */
+ protected void writeEdgeset(PrintWriter pw, DirectedGraph graph)
+ {
+ pw.println("");
+
+ Iterator edges = graph.getEdges().iterator();
+ while (edges.hasNext())
+ {
+ Edge next = (Edge) edges.next();
+
+ int length = new Double(lengthFactor *
+ defaultLength).intValue();
+
+ if (graph instanceof WeightedGraph)
+ {
+ length =
+ new Double(lengthFactor *
+ ((WeightedGraph) graph)
+ .getWeight(next)).intValue();
+ }
+
+ pw.println("");
+
+ }
+ pw.println("");
+ }
+
+ /**
+ * Description of the Method
+ */
+ public void toXML(DirectedGraph graph,
+ OutputStream os)
+ {
+ PrintWriter pw = new PrintWriter(os);
+ pw.println("");
+ pw.println("");
+ writeNodeset(pw, graph);
+ writeEdgeset(pw, graph);
+ pw.println("");
+ pw.flush();
+
+ return;
+ }
+}
+
+