Mercurial > hg > truffle
annotate visualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java @ 12690:c3bdd186e6cf
fix possible NPE in TruffleCompiler with TraceTruffleCompilation and background compilation enabled.
With background compilation, the installed code can already be invalidated when compiledMethod.getCode() is called, in which case it returns null.
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Wed, 06 Nov 2013 13:31:28 +0100 |
parents | 015fb895586b |
children |
rev | line source |
---|---|
4512
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 * |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 */ |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 package com.sun.hotspot.igv.graph; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import com.sun.hotspot.igv.data.InputNode; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import com.sun.hotspot.igv.data.Properties; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import com.sun.hotspot.igv.data.Source; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import com.sun.hotspot.igv.layout.Vertex; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import java.awt.*; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import java.awt.image.BufferedImage; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import java.util.List; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import java.util.*; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 /** |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 * |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 * @author Thomas Wuerthinger |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 */ |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 public class Figure extends Properties.Entity implements Source.Provider, Vertex { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 public static final int INSET = 12; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 public static int SLOT_WIDTH = 12; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 public static final int OVERLAPPING = 6; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 public static final int SLOT_START = 4; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 public static final int SLOT_OFFSET = 8; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 public static final boolean VERTICAL_LAYOUT = true; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 protected List<InputSlot> inputSlots; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 protected List<OutputSlot> outputSlots; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 private Source source; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 private Diagram diagram; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 private Point position; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 private List<Figure> predecessors; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 private List<Figure> successors; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 private Color color; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 private int id; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 private String idString; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 private String[] lines; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 private int heightCash = -1; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 private int widthCash = -1; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 public int getHeight() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 if (heightCash == -1) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 Graphics g = image.getGraphics(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 g.setFont(diagram.getFont().deriveFont(Font.BOLD)); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 FontMetrics metrics = g.getFontMetrics(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 String nodeText = diagram.getNodeText(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 heightCash = nodeText.split("\n").length * metrics.getHeight() + INSET; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 return heightCash; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 public static <T> List<T> getAllBefore(List<T> inputList, T tIn) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 List<T> result = new ArrayList<>(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 for(T t : inputList) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 if(t.equals(tIn)) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 break; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 result.add(t); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 return result; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 public static int getSlotsWidth(Collection<? extends Slot> slots) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 int result = Figure.SLOT_OFFSET; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 for(Slot s : slots) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 result += s.getWidth() + Figure.SLOT_OFFSET; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 return result; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 public int getWidth() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 if (widthCash == -1) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 int max = 0; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 Graphics g = image.getGraphics(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 g.setFont(diagram.getFont().deriveFont(Font.BOLD)); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 FontMetrics metrics = g.getFontMetrics(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 for (String s : getLines()) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 int cur = metrics.stringWidth(s); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 if (cur > max) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 max = cur; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 widthCash = max + INSET; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 widthCash = Math.max(widthCash, Figure.getSlotsWidth(inputSlots)); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 widthCash = Math.max(widthCash, Figure.getSlotsWidth(outputSlots)); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 return widthCash; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 protected Figure(Diagram diagram, int id) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 this.diagram = diagram; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 this.source = new Source(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 inputSlots = new ArrayList<>(5); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 outputSlots = new ArrayList<>(1); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 predecessors = new ArrayList<>(6); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 successors = new ArrayList<>(6); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 this.id = id; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 idString = Integer.toString(id); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 this.position = new Point(0, 0); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 this.color = Color.WHITE; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 public int getId() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 return id; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 public void setColor(Color color) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 this.color = color; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 public Color getColor() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 return color; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 public List<Figure> getPredecessors() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 return Collections.unmodifiableList(predecessors); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 public Set<Figure> getPredecessorSet() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 Set<Figure> result = new HashSet<>(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 for (Figure f : getPredecessors()) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 result.add(f); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 return Collections.unmodifiableSet(result); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 public Set<Figure> getSuccessorSet() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 Set<Figure> result = new HashSet<>(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 for (Figure f : getSuccessors()) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 result.add(f); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 return Collections.unmodifiableSet(result); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 public List<Figure> getSuccessors() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 return Collections.unmodifiableList(successors); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 protected void addPredecessor(Figure f) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 this.predecessors.add(f); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 protected void addSuccessor(Figure f) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 this.successors.add(f); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 protected void removePredecessor(Figure f) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 assert predecessors.contains(f); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 predecessors.remove(f); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 protected void removeSuccessor(Figure f) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 assert successors.contains(f); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 successors.remove(f); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 @Override |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 public void setPosition(Point p) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 this.position = p; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 @Override |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 public Point getPosition() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 return position; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 public Diagram getDiagram() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 return diagram; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 @Override |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 public Source getSource() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 return source; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
199 public InputSlot createInputSlot() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 InputSlot slot = new InputSlot(this, -1); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 inputSlots.add(slot); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 return slot; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 public InputSlot createInputSlot(int index) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 InputSlot slot = new InputSlot(this, index); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 inputSlots.add(slot); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 Collections.sort(inputSlots, Slot.slotIndexComparator); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 return slot; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 public void removeSlot(Slot s) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 assert inputSlots.contains(s) || outputSlots.contains(s); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 List<Connection> connections = new ArrayList<>(s.getConnections()); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 for (Connection c : connections) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 c.remove(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 if (inputSlots.contains(s)) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 inputSlots.remove(s); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 } else if (outputSlots.contains(s)) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 outputSlots.remove(s); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 public OutputSlot createOutputSlot() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 OutputSlot slot = new OutputSlot(this, -1); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
230 outputSlots.add(slot); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 return slot; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
234 public OutputSlot createOutputSlot(int index) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
235 OutputSlot slot = new OutputSlot(this, index); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 outputSlots.add(slot); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 Collections.sort(outputSlots, Slot.slotIndexComparator); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 return slot; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
239 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 public List<InputSlot> getInputSlots() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 return Collections.unmodifiableList(inputSlots); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 public Set<Slot> getSlots() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 Set<Slot> result = new HashSet<>(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
247 result.addAll(getInputSlots()); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 result.addAll(getOutputSlots()); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 return result; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
251 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
252 public List<OutputSlot> getOutputSlots() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
253 return Collections.unmodifiableList(outputSlots); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
255 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
256 void removeInputSlot(InputSlot s) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 s.removeAllConnections(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 inputSlots.remove(s); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
260 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 void removeOutputSlot(OutputSlot s) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
262 s.removeAllConnections(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
263 outputSlots.remove(s); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 public String[] getLines() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
267 if (lines == null) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
268 updateLines(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
270 return lines; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
271 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 public void updateLines() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 String[] strings = diagram.getNodeText().split("\n"); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 String[] result = new String[strings.length]; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
276 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
277 for (int i = 0; i < strings.length; i++) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 result[i] = resolveString(strings[i], getProperties()); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 lines = result; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 public static final String resolveString(String string, Properties properties) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
286 StringBuilder sb = new StringBuilder(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 boolean inBrackets = false; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 StringBuilder curIdent = new StringBuilder(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 for (int i = 0; i < string.length(); i++) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 char c = string.charAt(i); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 if (inBrackets) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
293 if (c == ']') { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 String value = properties.get(curIdent.toString()); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 if (value == null) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
296 value = ""; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
297 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 sb.append(value); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 inBrackets = false; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 } else { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 curIdent.append(c); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
303 } else { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 if (c == '[') { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
305 inBrackets = true; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 curIdent = new StringBuilder(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
307 } else { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 sb.append(c); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
309 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
310 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
311 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
312 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 return sb.toString(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
315 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
316 @Override |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 public Dimension getSize() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 if (VERTICAL_LAYOUT) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 int width = Math.max(getWidth(), Figure.SLOT_WIDTH * (Math.max(inputSlots.size(), outputSlots.size()) + 1)); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 int height = getHeight() + 2 * Figure.SLOT_WIDTH - 2 * Figure.OVERLAPPING; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
321 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
323 return new Dimension(width, height); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
324 } else { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 int width = getWidth() + 2 * Figure.SLOT_WIDTH - 2*Figure.OVERLAPPING; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 int height = Figure.SLOT_WIDTH * (Math.max(inputSlots.size(), outputSlots.size()) + 1); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 return new Dimension(width, height); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
328 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
329 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
330 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
331 @Override |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 public String toString() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 return idString; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
334 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
335 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
336 @Override |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
337 public boolean isRoot() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
339 List<InputNode> sourceNodes = source.getSourceNodes(); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
340 if (sourceNodes.size() > 0 && sourceNodes.get(0).getProperties().get("name") != null) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
341 return source.getSourceNodes().get(0).getProperties().get("name").equals("Root"); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 } else { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
343 return false; |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
345 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
346 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 @Override |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 public int compareTo(Vertex f) { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 return toString().compareTo(f.toString()); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
350 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
351 |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
352 public Rectangle getBounds() { |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
353 return new Rectangle(this.getPosition(), new Dimension(this.getWidth(), this.getHeight())); |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
354 } |
015fb895586b
Moved visualizer to new directory.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
355 } |