# HG changeset patch # User Peter Hofer # Date 1321622667 -3600 # Node ID 3c31c42c0cd3db0b07500e47f97882e624b60f36 # Parent 6e1abd79e7c8e13d1448142795b1d398824102e8 IdealGraphPrinter: add the ability to specify edge labels in XML input diff -r 6e1abd79e7c8 -r 3c31c42c0cd3 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java Thu Nov 17 19:11:55 2011 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java Fri Nov 18 14:24:27 2011 +0100 @@ -58,23 +58,29 @@ return o1.getToIndex() - o2.getToIndex(); } }; - + private char toIndex; private char fromIndex; private int from; private int to; private State state; - + private String label; + public InputEdge(char toIndex, int from, int to) { - this((char)0, toIndex, from, to); + this((char) 0, toIndex, from, to, null); } public InputEdge(char fromIndex, char toIndex, int from, int to) { + this(fromIndex, toIndex, from, to, null); + } + + public InputEdge(char fromIndex, char toIndex, int from, int to, String label) { this.toIndex = toIndex; this.fromIndex = fromIndex; this.from = from; this.to = to; this.state = State.SAME; + this.label = label; } public State getState() { @@ -105,6 +111,10 @@ return to; } + public String getLabel() { + return label; + } + @Override public boolean equals(Object o) { if (o == null || !(o instanceof InputEdge)) { diff -r 6e1abd79e7c8 -r 3c31c42c0cd3 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Thu Nov 17 19:11:55 2011 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Fri Nov 18 14:24:27 2011 +0100 @@ -85,6 +85,7 @@ public static final String FROM_INDEX_PROPERTY = "fromIndex"; public static final String TO_INDEX_PROPERTY = "toIndex"; public static final String TO_INDEX_ALT_PROPERTY = "index"; + public static final String LABEL_PROPERTY = "label"; public static final String METHOD_ELEMENT = "method"; public static final String INLINE_ELEMENT = "inline"; public static final String BYTECODES_ELEMENT = "bytecodes"; @@ -379,13 +380,14 @@ int toIndex = 0; int from = -1; int to = -1; + String label = null; try { String fromIndexString = readAttribute(FROM_INDEX_PROPERTY); if (fromIndexString != null) { fromIndex = Integer.parseInt(fromIndexString); } - + String toIndexString = readAttribute(TO_INDEX_PROPERTY); if (toIndexString == null) { toIndexString = readAttribute(TO_INDEX_ALT_PROPERTY); @@ -394,13 +396,15 @@ toIndex = Integer.parseInt(toIndexString); } + label = readAttribute(LABEL_PROPERTY); + from = lookupID(readRequiredAttribute(FROM_PROPERTY)); to = lookupID(readRequiredAttribute(TO_PROPERTY)); } catch (NumberFormatException e) { throw new SAXException(e); } - InputEdge conn = new InputEdge((char) fromIndex, (char) toIndex, from, to); + InputEdge conn = new InputEdge((char) fromIndex, (char) toIndex, from, to, label); return start(conn); } diff -r 6e1abd79e7c8 -r 3c31c42c0cd3 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/graphdocument.xsd --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/graphdocument.xsd Thu Nov 17 19:11:55 2011 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/graphdocument.xsd Fri Nov 18 14:24:27 2011 +0100 @@ -105,6 +105,7 @@ + diff -r 6e1abd79e7c8 -r 3c31c42c0cd3 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java Thu Nov 17 19:11:55 2011 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java Fri Nov 18 14:24:27 2011 +0100 @@ -30,7 +30,6 @@ import com.sun.hotspot.igv.graph.OutputSlot; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Properties.PropertyMatcher; -import java.awt.Color; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -100,7 +99,7 @@ for (InputSlot s : f.getInputSlots()) { for (Connection c : s.getConnections()) { - Connection newConn = diagram.createConnection(slot, c.getOutputSlot()); + Connection newConn = diagram.createConnection(slot, c.getOutputSlot(), c.getLabel()); newConn.setColor(c.getColor()); newConn.setStyle(c.getStyle()); } @@ -157,7 +156,7 @@ } } for (Connection c : nextSlot.getConnections()) { - Connection newConn = diagram.createConnection(c.getInputSlot(), slot); + Connection newConn = diagram.createConnection(c.getInputSlot(), slot, c.getLabel()); newConn.setColor(c.getColor()); newConn.setStyle(c.getStyle()); } diff -r 6e1abd79e7c8 -r 3c31c42c0cd3 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java Thu Nov 17 19:11:55 2011 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java Fri Nov 18 14:24:27 2011 +0100 @@ -49,10 +49,12 @@ private Color color; private ConnectionStyle style; private List controlPoints; + private String label; - protected Connection(InputSlot inputSlot, OutputSlot outputSlot) { + protected Connection(InputSlot inputSlot, OutputSlot outputSlot, String label) { this.inputSlot = inputSlot; this.outputSlot = outputSlot; + this.label = label; this.inputSlot.connections.add(this); this.outputSlot.connections.add(this); controlPoints = new ArrayList(); @@ -94,6 +96,10 @@ return source; } + public String getLabel() { + return label; + } + public void remove() { inputSlot.getFigure().removePredecessor(outputSlot.getFigure()); inputSlot.connections.remove(this); @@ -102,12 +108,21 @@ } public String getToolTipText() { - return "From " + this.getOutputSlot().getFigure().toString() + " to " + this.getInputSlot().getFigure(); + StringBuilder builder = new StringBuilder(); + if (label != null) { + builder.append(label).append(": from "); + } else { + builder.append("From "); + } + builder.append(getOutputSlot().getFigure()); + builder.append(" to "); + builder.append(getInputSlot().getFigure()); + return builder.toString(); } @Override public String toString() { - return "Connection(" + getFrom().getVertex() + " to " + getTo().getVertex() + ")"; + return "Connection('" + label + "', " + getFrom().getVertex() + " to " + getTo().getVertex() + ")"; } public Port getFrom() { diff -r 6e1abd79e7c8 -r 3c31c42c0cd3 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java Thu Nov 17 19:11:55 2011 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java Fri Nov 18 14:24:27 2011 +0100 @@ -112,10 +112,10 @@ return f; } - public Connection createConnection(InputSlot inputSlot, OutputSlot outputSlot) { + public Connection createConnection(InputSlot inputSlot, OutputSlot outputSlot, String label) { assert inputSlot.getFigure().getDiagram() == this; assert outputSlot.getFigure().getDiagram() == this; - return new Connection(inputSlot, outputSlot); + return new Connection(inputSlot, outputSlot, label); } public Map> calcSourceToFigureRelation() { @@ -176,7 +176,7 @@ } InputSlot inputSlot = toFigure.getInputSlots().get(toIndex); - Connection c = d.createConnection(inputSlot, outputSlot); + Connection c = d.createConnection(inputSlot, outputSlot, e.getLabel()); if (e.getState() == InputEdge.State.NEW) { c.setStyle(Connection.ConnectionStyle.BOLD);