comparison src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java @ 21146:33ff6b03fad1

add support for control flow window and basic block view on graphs Contributed-by: Michael Haupt <michael.haupt@oracle.com> Contributed-by: Peter Hofer <peter.hofer@jku.at> Contributed-by: Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
author Michael Haupt <michael.haupt@oracle.com>
date Wed, 29 Apr 2015 08:31:28 +0200
parents
children
comparison
equal deleted inserted replaced
21142:0b221b4ad707 21146:33ff6b03fad1
1 /*
2 * Copyright (c) 2008, 2015, 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.controlflow;
25
26 import com.sun.hotspot.igv.data.InputBlockEdge;
27 import com.sun.hotspot.igv.layout.Link;
28 import com.sun.hotspot.igv.layout.Port;
29 import java.awt.BasicStroke;
30 import java.awt.Point;
31 import java.awt.Stroke;
32 import java.util.ArrayList;
33 import java.util.List;
34 import org.netbeans.api.visual.widget.ConnectionWidget;
35
36 /**
37 *
38 * @author Thomas Wuerthinger
39 */
40 public class BlockConnectionWidget extends ConnectionWidget implements Link {
41
42 private static final Stroke NORMAL_STROKE = new BasicStroke(1.0f);
43 private static final Stroke BOLD_STROKE = new BasicStroke(2.5f);
44 private static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0);
45 private static final Stroke BOLD_DASHED_STROKE = new BasicStroke(2.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0);
46
47 private BlockWidget from;
48 private BlockWidget to;
49 private Port inputSlot;
50 private Port outputSlot;
51 private List<Point> points;
52 private InputBlockEdge edge;
53 private boolean isDashed = false;
54 private boolean isBold = false;
55
56 public BlockConnectionWidget(ControlFlowScene scene, InputBlockEdge edge) {
57 super(scene);
58
59 this.edge = edge;
60 this.from = (BlockWidget) scene.findWidget(edge.getFrom());
61 this.to = (BlockWidget) scene.findWidget(edge.getTo());
62 inputSlot = to.getInputSlot();
63 outputSlot = from.getOutputSlot();
64 points = new ArrayList<Point>();
65 }
66
67 public InputBlockEdge getEdge() {
68 return edge;
69 }
70
71 public Port getTo() {
72 return inputSlot;
73 }
74
75 public Port getFrom() {
76 return outputSlot;
77 }
78
79 public void setBold(boolean bold) {
80 this.isBold = bold;
81 updateStroke();
82 }
83
84 public void setDashed(boolean dashed) {
85 this.isDashed = dashed;
86 updateStroke();
87 }
88
89 private void updateStroke() {
90 Stroke stroke = NORMAL_STROKE;
91 if (isBold) {
92 if (isDashed) {
93 stroke = BOLD_DASHED_STROKE;
94 } else {
95 stroke = BOLD_STROKE;
96 }
97 } else if (isDashed) {
98 stroke = DASHED_STROKE;
99 }
100 setStroke(stroke);
101 }
102
103 public void setControlPoints(List<Point> p) {
104 this.points = p;
105 }
106
107 @Override
108 public List<Point> getControlPoints() {
109 return points;
110 }
111
112 @Override
113 public String toString() {
114 return "Connection[ " + from.toString() + " - " + to.toString() + "]";
115 }
116
117 @Override
118 public boolean isVIP() {
119 return isBold;
120 }
121 }