author | ohair |
Tue, 25 May 2010 15:58:33 -0700 | |
changeset 5506 | 202f599c92aa |
parent 2380 | 822dcdd94e7a |
permissions | -rw-r--r-- |
2380
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
2380
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
4 |
* |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
8 |
* |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
13 |
* accompanied this code). |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
14 |
* |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
18 |
* |
5506 | 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. |
|
2380
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
22 |
*/ |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
23 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
24 |
/* @test |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
25 |
* @summary verify that first element is a dash |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
26 |
* @bug 6793344 |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
27 |
*/ |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
28 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
29 |
import java.awt.*; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
30 |
import java.awt.image.*; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
31 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
32 |
import javax.swing.JButton; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
33 |
import javax.swing.JFrame; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
34 |
import javax.swing.SwingUtilities; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
35 |
import javax.swing.WindowConstants; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
36 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
37 |
public class DashStrokeTest extends Component { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
38 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
39 |
static BufferedImage bi; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
40 |
static boolean printed = false; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
41 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
42 |
public Dimension getPreferredSize() { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
43 |
return new Dimension(200,200); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
44 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
45 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
46 |
public static void drawGui() { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
47 |
bi = new BufferedImage(200, 20, BufferedImage.TYPE_INT_RGB); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
48 |
Graphics2D g2d = bi.createGraphics(); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
49 |
BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
50 |
BasicStroke.JOIN_ROUND, 1.0f, new float[] { 0.0f, 200 }, |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
51 |
1.0f); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
52 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
53 |
g2d.setStroke(dashStroke); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
54 |
g2d.setColor(Color.RED); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
55 |
g2d.drawLine(5,10, 100,10); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
56 |
printed =true; |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
57 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
58 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
59 |
public static void main(String[] args) { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
60 |
try { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
61 |
SwingUtilities.invokeAndWait(new Runnable() { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
62 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
63 |
@Override |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
64 |
public void run() { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
65 |
drawGui(); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
66 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
67 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
68 |
}); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
69 |
} catch (Exception e) { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
70 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
71 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
72 |
if (printed) { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
73 |
checkBI(bi, Color.RED); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
74 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
75 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
76 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
77 |
static void checkBI(BufferedImage bi, Color badColor) { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
78 |
int badrgb = badColor.getRGB(); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
79 |
|
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
80 |
int col = bi.getRGB(6, 9); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
81 |
if (col == badrgb) { |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
82 |
throw new RuntimeException("A pixel was turned on. "); |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
83 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
84 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
85 |
} |
822dcdd94e7a
6793344: BasicStroke's first element dash pattern is not a dash
jgodinez
parents:
diff
changeset
|
86 |