Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/misctests/fpustack/GraphApplet.java
40948 views
1
/*
2
* Copyright (c) 2008, 2020, 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
/*
25
* @test
26
* @key headful
27
*
28
* @summary converted from VM Testbase jit/misctests/fpustack.
29
* VM Testbase keywords: [jit, desktop, jdk_desktop, quick]
30
*
31
* @library /vmTestbase
32
* /test/lib
33
* @run main/othervm jit.misctests.fpustack.GraphApplet
34
*/
35
36
package jit.misctests.fpustack;
37
38
import java.util.*;
39
import java.awt.*;
40
import java.applet.Applet;
41
import nsk.share.TestFailure;
42
43
44
public class GraphApplet extends Applet {
45
private GraphPanel panel;
46
private boolean isApplet = true;
47
private boolean initialized = false;
48
49
/**
50
** main method for testing that class
51
**
52
**/
53
public static void main( String[] args ) {
54
Frame f = new Frame("GraphApplet");
55
GraphApplet app = new GraphApplet();
56
app.isApplet = false;
57
app.setSize(600,400);
58
f.setLayout( new BorderLayout() );
59
f.add("Center",app);
60
f.setSize(600,400);
61
62
app.init();
63
// f.pack();
64
f.show(true);
65
app.start();
66
67
try {
68
Thread.currentThread().sleep(5*1000);
69
} catch (InterruptedException e) {
70
}
71
72
f.show(false);
73
app.stop();
74
f.dispose();
75
return;
76
}
77
78
/**
79
** init-Method in applet's lifecycle.
80
** the graphic panel is build up and the date is filled.
81
**/
82
public synchronized void init() {
83
System.out.println( "GraphApplet : init");
84
setLayout(new BorderLayout());
85
86
panel = new GraphPanel(this, new layout() );
87
fill( panel );
88
add("Center", panel);
89
Panel p = new Panel();
90
add("South", p);
91
initialized = true;
92
}
93
94
public synchronized void start() {
95
System.out.println( "GraphApplet : start");
96
panel.formatNodes();
97
}
98
public synchronized void stop() {
99
initialized = false;
100
System.out.println( "GraphApplet : stop");
101
}
102
103
public synchronized void destroy() {
104
System.out.println( "GraphApplet : destroy");
105
}
106
107
/**
108
** paint the Applet
109
**/
110
public synchronized void paint(Graphics g) {
111
try {
112
while ( ! initialized )
113
Thread.currentThread().sleep(5);
114
} catch (InterruptedException e) {}
115
if (g instanceof PrintGraphics )
116
System.out.println( "printing GraphApplet ...");
117
}
118
119
public synchronized void print(Graphics g) {
120
try {
121
while ( ! initialized )
122
Thread.currentThread().sleep(5);
123
} catch (InterruptedException e) {}
124
System.out.println( "Print Applet " + g);
125
panel.print(g);
126
}
127
128
public void print() {
129
// System.out.println( "Print Applet");
130
Toolkit kit = getToolkit();
131
try {
132
133
PrintJob job = kit.getPrintJob( new Frame("x"), "PrintableFrame print job",
134
null);
135
// do the printing if the user didn't cancel the print job
136
if (job != null) {
137
Graphics g = job.getGraphics();
138
printAll(g); // not paint(g)
139
g.dispose(); // finish with this page
140
job.end(); // finish with the PrintJob
141
}
142
} catch (Exception ex) {
143
System.out.println( "print exception " + ex);
144
}
145
}
146
147
/**
148
**
149
** @param panel the container for nodes
150
**
151
**/
152
private void
153
fill( GraphPanel panel ) {
154
panel.addNodes("Node1", "Node2", "Node3" );
155
}
156
}
157
158