author | alexsch |
Thu, 10 Apr 2014 13:22:23 +0400 | |
changeset 24175 | 3a8694713eab |
permissions | -rw-r--r-- |
24175
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
1 |
/* |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
4 |
* |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
8 |
* |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
13 |
* accompanied this code). |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
14 |
* |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
18 |
* |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
21 |
* questions. |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
22 |
*/ |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
23 |
import java.awt.BasicStroke; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
24 |
import java.awt.BorderLayout; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
25 |
import java.awt.Graphics; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
26 |
import java.awt.Graphics2D; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
27 |
import javax.swing.Icon; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
28 |
import javax.swing.JApplet; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
29 |
import javax.swing.JPanel; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
30 |
import javax.swing.JTree; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
31 |
import javax.swing.SwingUtilities; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
32 |
import javax.swing.plaf.basic.BasicTreeUI; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
33 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
34 |
/* @test |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
35 |
* @bug 8038113 |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
36 |
* @summary [macosx] JTree icon is not rendered in high resolution on Retina |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
37 |
* @run applet/manual=yesno bug8038113.html |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
38 |
*/ |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
39 |
public class bug8038113 extends JApplet { |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
40 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
41 |
@Override |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
42 |
public void init() { |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
43 |
SwingUtilities.invokeLater(new Runnable() { |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
44 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
45 |
@Override |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
46 |
public void run() { |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
47 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
48 |
final JTree tree = new JTree(); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
49 |
final BasicTreeUI treeUI = (BasicTreeUI) tree.getUI(); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
50 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
51 |
final JPanel panel = new JPanel() { |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
52 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
53 |
@Override |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
54 |
public void paint(Graphics g) { |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
55 |
super.paint(g); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
56 |
Graphics2D g2 = (Graphics2D) g; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
57 |
g2.setStroke(new BasicStroke(0.5f)); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
58 |
g2.scale(2, 2); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
59 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
60 |
int x = 10; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
61 |
int y = 10; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
62 |
Icon collapsedIcon = treeUI.getCollapsedIcon(); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
63 |
Icon expandeIcon = treeUI.getExpandedIcon(); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
64 |
int w = collapsedIcon.getIconWidth(); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
65 |
int h = collapsedIcon.getIconHeight(); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
66 |
collapsedIcon.paintIcon(this, g, x, y); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
67 |
g.drawRect(x, y, w, h); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
68 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
69 |
y += 10 + h; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
70 |
w = expandeIcon.getIconWidth(); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
71 |
h = expandeIcon.getIconHeight(); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
72 |
expandeIcon.paintIcon(this, g, x, y); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
73 |
g.drawRect(x, y, w, h); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
74 |
|
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
75 |
} |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
76 |
}; |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
77 |
getContentPane().setLayout(new BorderLayout()); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
78 |
getContentPane().add(panel, BorderLayout.CENTER); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
79 |
} |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
80 |
}); |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
81 |
} |
3a8694713eab
8038113: [macosx] JTree icon is not rendered in high resolution on Retina
alexsch
parents:
diff
changeset
|
82 |
} |