Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/misctests/fpustack/GraphPanel.java
40948 views
1
/*
2
* Copyright (c) 2008, 2018, 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
package jit.misctests.fpustack;
24
25
import java.util.*;
26
import java.awt.*;
27
import java.applet.Applet;
28
import nsk.share.TestFailure;
29
30
public class GraphPanel extends Panel {
31
private Panel graph; // the container
32
33
private ilayout layout = null; // the strategy
34
35
36
private int nodesN; // number of nodes
37
private Node nodes[] = new Node[200]; // nodes container
38
39
/**
40
** constructor
41
**
42
** @param Panel the container
43
** @param layout a strategy to layout the nodes
44
**
45
**/
46
GraphPanel(Panel graph, layout ls ) {
47
this.graph = graph;
48
layout = ls;
49
}
50
51
52
53
54
/**
55
** add a node via label text.
56
**
57
** @param lbl the label
58
** @return the index of the node in array nodes[]
59
**
60
**/
61
62
public int addNode(String lbl) {
63
Node n = new Node();
64
if (nodesN > 0) {
65
n.x = nodes[nodesN-1].x + 30;
66
n.y = nodes[nodesN-1].y + 30;
67
}
68
n.lbl = lbl;
69
70
nodes[nodesN] = n;
71
return nodesN++;
72
}
73
74
75
76
/**
77
** add a node via label text.
78
**
79
** @param lbl the label
80
** @return the index of the node in array nodes[]
81
**
82
**/
83
84
public void addNodes(String lb1, String lb2, String lb3) {
85
addNode(lb1);
86
addNode(lb2);
87
addNode(lb3);
88
}
89
90
91
92
/**
93
** layout the nodes on the panel. the layout is used
94
**
95
**
96
**/
97
public synchronized void formatNodes( ) {
98
99
// format nodes
100
FontMetrics fm = getFontMetrics(getFont());
101
Dimension d = getSize();
102
103
Node[] ns = new Node[ nodesN ];
104
System.arraycopy(nodes, 0, ns, 0, nodesN);
105
layout.formatNodes( ns, d, fm );
106
107
}
108
109
110
111
}
112
113