Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Graphics2D/ScaledTransform/ScaledTransform.java
41153 views
1
/*
2
* Copyright (c) 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
import java.awt.Dialog;
24
import java.awt.Frame;
25
import java.awt.Graphics;
26
import java.awt.Graphics2D;
27
import java.awt.GraphicsConfiguration;
28
import java.awt.GraphicsDevice;
29
import java.awt.GraphicsEnvironment;
30
import java.awt.Panel;
31
import java.awt.geom.AffineTransform;
32
33
/*
34
* @test
35
* @bug 8069361
36
* @key headful
37
* @summary SunGraphics2D.getDefaultTransform() does not include scale factor
38
* @author Alexander Scherbatiy
39
* @run main ScaledTransform
40
*/
41
public class ScaledTransform {
42
43
private static volatile boolean passed = false;
44
45
public static void main(String[] args) {
46
GraphicsEnvironment ge = GraphicsEnvironment.
47
getLocalGraphicsEnvironment();
48
49
if (ge.isHeadlessInstance()) {
50
return;
51
}
52
53
for (GraphicsDevice gd : ge.getScreenDevices()) {
54
for (GraphicsConfiguration gc : gd.getConfigurations()) {
55
testScaleFactor(gc);
56
}
57
}
58
}
59
60
private static void testScaleFactor(final GraphicsConfiguration gc) {
61
final Dialog dialog = new Dialog((Frame) null, "Test", true, gc);
62
63
try {
64
dialog.setSize(100, 100);
65
Panel panel = new Panel() {
66
67
@Override
68
public void paint(Graphics g) {
69
if (g instanceof Graphics2D) {
70
AffineTransform gcTx = gc.getDefaultTransform();
71
AffineTransform gTx
72
= ((Graphics2D) g).getTransform();
73
passed = gcTx.getScaleX() == gTx.getScaleX()
74
&& gcTx.getScaleY() == gTx.getScaleY();
75
} else {
76
passed = true;
77
}
78
dialog.setVisible(false);
79
}
80
};
81
dialog.add(panel);
82
dialog.setVisible(true);
83
84
if (!passed) {
85
throw new RuntimeException("Transform is not scaled!");
86
}
87
} finally {
88
dialog.dispose();
89
}
90
}
91
}
92
93