1 /* 2 * Copyright (c) 2009, 2013, 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package test.rt_5300; 27 28 import com.sun.javafx.geom.Arc2D; 29 import com.sun.prism.BasicStroke; 30 import com.sun.prism.Image; 31 import com.sun.prism.PixelFormat; 32 import java.nio.ByteBuffer; 33 import org.junit.Test; 34 import org.junit.Assert; 35 36 public class rt_5300Test { 37 38 public rt_5300Test() { 39 } 40 41 @Test() 42 public void RT5346() { 43 int num_bands = 4; 44 byte[] bytes = new byte[32 * 32 * num_bands]; 45 for( int k = 0; k < bytes.length; k++) 46 { 47 bytes[k] = (byte)0xff; 48 } 49 50 ByteBuffer buf = ByteBuffer.wrap(bytes); 51 buf.rewind(); 52 Image Img = Image.fromByteBgraPreData(buf, 32, 32); 53 Image image = null; 54 try 55 { 56 image = Img.iconify( (ByteBuffer) Img.getPixelBuffer(), 32, 32); 57 } catch (Exception e) { 58 //throw exception System.out.println("Exception Caught: " + e.toString() ); 59 } 60 61 Assert.assertTrue(assertImageIcon(image)); 62 } 63 64 @Test(timeout=5000) 65 public void testArcs() { 66 test(10f, null); 67 test(10f, new float[] {2f, 2f}); 68 } 69 70 public static void test(float lw, float dashes[]) { 71 test(lw, dashes, BasicStroke.CAP_BUTT); 72 test(lw, dashes, BasicStroke.CAP_ROUND); 73 test(lw, dashes, BasicStroke.CAP_SQUARE); 74 } 75 76 public static void test(float lw, float dashes[], int cap) { 77 test(lw, dashes, cap, BasicStroke.JOIN_BEVEL); 78 test(lw, dashes, cap, BasicStroke.JOIN_MITER); 79 test(lw, dashes, cap, BasicStroke.JOIN_ROUND); 80 } 81 82 public static void test(float lw, float dashes[], int cap, int join) { 83 BasicStroke bs; 84 if (dashes == null) { 85 bs = new BasicStroke(lw, cap, join, 10f); 86 } else { 87 bs = new BasicStroke(lw, cap, join, 10f, dashes, 0f); 88 } 89 Arc2D a = new Arc2D(); 90 a.setFrame(0, 0, 100, 100); 91 test(bs, a, Arc2D.OPEN); 92 test(bs, a, Arc2D.CHORD); 93 test(bs, a, Arc2D.PIE); 94 } 95 96 public static void test(BasicStroke bs, Arc2D a, int arctype) { 97 a.setArcType(arctype); 98 for (int s = 0; s <= 360; s += 30) { 99 a.start = s; 100 for (int e = 0; e <= 360; e += 30) { 101 a.extent = e; 102 bs.createStrokedShape(a); 103 } 104 } 105 } 106 107 private boolean assertImageIcon(Image ico) { 108 if (ico == null) return false; 109 if (ico.getPixelFormat() != PixelFormat.INT_ARGB_PRE) { 110 return false; 111 } 112 113 if (ico.getHeight() != 32 && ico.getWidth() != 32) { 114 return false; 115 } else { 116 return true; 117 } 118 119 } 120 121 122 }