Mercurial > hg > truffle
comparison visualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java @ 4512:015fb895586b
Moved visualizer to new directory.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 07 Feb 2012 22:41:09 +0100 |
parents | |
children | 24d9f3310ed6 |
comparison
equal
deleted
inserted
replaced
4511:6cb549627941 | 4512:015fb895586b |
---|---|
1 /* | |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 package com.sun.hotspot.igv.graal.filters; | |
25 | |
26 import com.sun.hotspot.igv.data.Properties; | |
27 import com.sun.hotspot.igv.filter.AbstractFilter; | |
28 import com.sun.hotspot.igv.graph.Connection; | |
29 import com.sun.hotspot.igv.graph.Connection.ConnectionStyle; | |
30 import com.sun.hotspot.igv.graph.Diagram; | |
31 import com.sun.hotspot.igv.graph.Figure; | |
32 import com.sun.hotspot.igv.graph.InputSlot; | |
33 import java.awt.Color; | |
34 import java.util.List; | |
35 | |
36 /** | |
37 * Filter that colors usage and successor edges differently. | |
38 * | |
39 * @author Peter Hofer | |
40 */ | |
41 public class GraalEdgeColorFilter extends AbstractFilter { | |
42 | |
43 private Color successorColor = Color.BLUE; | |
44 private Color usageColor = Color.RED; | |
45 private Color memoryColor = Color.GREEN; | |
46 | |
47 public GraalEdgeColorFilter() { | |
48 } | |
49 | |
50 @Override | |
51 public String getName() { | |
52 return "Graal Edge Color Filter"; | |
53 } | |
54 | |
55 @Override | |
56 public void apply(Diagram d) { | |
57 List<Figure> figures = d.getFigures(); | |
58 for (Figure f : figures) { | |
59 Properties p = f.getProperties(); | |
60 int predCount; | |
61 if (p.get("predecessorCount") != null) { | |
62 predCount = Integer.parseInt(p.get("predecessorCount")); | |
63 } else { | |
64 predCount = 0; | |
65 } | |
66 for (InputSlot is : f.getInputSlots()) { | |
67 Color color; | |
68 ConnectionStyle style = ConnectionStyle.NORMAL; | |
69 if (is.getPosition() < predCount) { | |
70 color = successorColor; | |
71 style = ConnectionStyle.BOLD; | |
72 } else { | |
73 color = usageColor; | |
74 } | |
75 | |
76 is.setColor(color); | |
77 for (Connection c : is.getConnections()) { | |
78 if (c.getLabel() == null || !c.getLabel().endsWith("#NDF")) { | |
79 c.setColor(color); | |
80 c.setStyle(style); | |
81 } else if ("EndNode".equals(c.getOutputSlot().getFigure().getProperties().get("class")) | |
82 || "EndNode".equals(c.getOutputSlot().getProperties().get("class"))) { | |
83 c.setColor(successorColor); | |
84 c.setStyle(ConnectionStyle.BOLD); | |
85 } | |
86 } | |
87 } | |
88 } | |
89 } | |
90 | |
91 public Color getUsageColor() { | |
92 return usageColor; | |
93 } | |
94 | |
95 public void setUsageColor(Color usageColor) { | |
96 this.usageColor = usageColor; | |
97 } | |
98 | |
99 public void setMemoryColor(Color memoryColor) { | |
100 this.memoryColor = memoryColor; | |
101 } | |
102 | |
103 public Color getMemoryColor() { | |
104 return memoryColor; | |
105 } | |
106 | |
107 public Color getSuccessorColor() { | |
108 return successorColor; | |
109 } | |
110 | |
111 public void setSuccessorColor(Color successorColor) { | |
112 this.successorColor = successorColor; | |
113 } | |
114 } |