1 /* 2 * Copyright (c) 2009, 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 /* 25 * @test 26 * @bug 6657026 27 * @summary Tests shared MetalBumps in different application contexts 28 * @author Sergey Malenkov 29 * @modules java.desktop/sun.awt 30 */ 31 32 import sun.awt.SunToolkit; 33 34 import java.awt.Color; 35 import java.awt.Component; 36 import java.awt.Font; 37 import java.awt.FontMetrics; 38 import java.awt.Graphics; 39 import java.awt.Image; 40 import java.awt.Rectangle; 41 import java.awt.Shape; 42 import java.awt.image.BufferedImage; 43 import java.awt.image.ImageObserver; 44 import java.text.AttributedCharacterIterator; 45 import javax.swing.Icon; 46 import javax.swing.plaf.metal.MetalBorders.ToolBarBorder; 47 48 public class Test6657026 extends ToolBarBorder implements Runnable { 49 50 public static void main(String[] args) throws Exception { 51 new Test6657026().test(); 52 53 ThreadGroup group = new ThreadGroup("$$$"); 54 Thread thread = new Thread(group, new Test6657026()); 55 thread.start(); 56 thread.join(); 57 } 58 59 public void run() { 60 SunToolkit.createNewAppContext(); 61 test(); 62 } 63 64 private void test() { 65 MyGraphics mg = new MyGraphics(); 66 Icon icon = bumps; 67 icon.paintIcon(mg.component, mg, 0, 0); 68 if (mg.image != null) { 69 boolean failed = true; 70 int value = mg.image.getRGB(0, 0); 71 for (int x = 0; x < mg.image.getWidth(); x++) { 72 for (int y = 0; y < mg.image.getHeight(); y++) { 73 int current = mg.image.getRGB(x, y); 74 if (current != value) { 75 mg.image.setRGB(x, y, value); 76 failed = false; 77 } 78 79 } 80 } 81 if (failed) { 82 throw new Error("shared metal bumps"); 83 } 84 } 85 } 86 87 private static class MyGraphics extends Graphics { 88 89 private final Component component = new Component() {}; 90 private BufferedImage image; 91 92 public Graphics create() { 93 return null; // TODO: check 94 } 95 96 public void translate(int x, int y) { 97 // TODO: check 98 } 99 100 public Color getColor() { 101 return null; // TODO: check 102 } 103 104 public void setColor(Color color) { 105 // TODO: check 106 } 107 108 public void setPaintMode() { 109 // TODO: check 110 } 111 112 public void setXORMode(Color c1) { 113 // TODO: check 114 } 115 116 public Font getFont() { 117 return null; // TODO: check 118 } 119 120 public void setFont(Font font) { 121 // TODO: check 122 } 123 124 public FontMetrics getFontMetrics(Font font) { 125 return null; // TODO: check 126 } 127 128 public Rectangle getClipBounds() { 129 return null; // TODO: check 130 } 131 132 public void clipRect(int x, int y, int width, int height) { 133 // TODO: check 134 } 135 136 public void setClip(int x, int y, int width, int height) { 137 // TODO: check 138 } 139 140 public Shape getClip() { 141 return null; // TODO: check 142 } 143 144 public void setClip(Shape clip) { 145 // TODO: check 146 } 147 148 public void copyArea(int x, int y, int width, int height, int dx, int dy) { 149 // TODO: check 150 } 151 152 public void drawLine(int x1, int y1, int x2, int y2) { 153 // TODO: check 154 } 155 156 public void fillRect(int x, int y, int width, int height) { 157 // TODO: check 158 } 159 160 public void clearRect(int x, int y, int width, int height) { 161 // TODO: check 162 } 163 164 public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { 165 // TODO: check 166 } 167 168 public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { 169 // TODO: check 170 } 171 172 public void drawOval(int x, int y, int width, int height) { 173 // TODO: check 174 } 175 176 public void fillOval(int x, int y, int width, int height) { 177 // TODO: check 178 } 179 180 public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { 181 // TODO: check 182 } 183 184 public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { 185 // TODO: check 186 } 187 188 public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) { 189 // TODO: check 190 } 191 192 public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) { 193 // TODO: check 194 } 195 196 public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { 197 // TODO: check 198 } 199 200 public void drawString(String str, int x, int y) { 201 // TODO: check 202 } 203 204 public void drawString(AttributedCharacterIterator iterator, int x, int y) { 205 // TODO: check 206 } 207 208 public boolean drawImage(Image img, int x, int y, ImageObserver observer) { 209 return false; // TODO: check 210 } 211 212 public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { 213 return false; // TODO: check 214 } 215 216 public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) { 217 return false; // TODO: check 218 } 219 220 public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { 221 return false; // TODO: check 222 } 223 224 public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { 225 if (img instanceof BufferedImage) { 226 this.image = (BufferedImage) img; 227 } 228 return false; // TODO: check 229 } 230 231 public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { 232 return false; // TODO: check 233 } 234 235 public void dispose() { 236 // TODO: check 237 } 238 } 239 }