Merge
authorjgodinez
Tue, 05 May 2009 09:09:24 -0700
changeset 1187f8b061ea131c
parent 1178 b056c42ea5b4
parent 1186 662a327cfe1d
child 1194 9ba256e2e5c1
child 1199 2b86dbc51d11
child 1207 86d2541a9ba2
child 1317 9cf4ef04d9a7
Merge
src/share/native/sun/java2d/pipe/RenderBuffer.c
     1.1 --- a/make/sun/awt/FILES_c_unix.gmk	Mon May 04 18:28:26 2009 -0700
     1.2 +++ b/make/sun/awt/FILES_c_unix.gmk	Tue May 05 09:09:24 2009 -0700
     1.3 @@ -125,7 +125,6 @@
     1.4          FourByteAbgrPre.c \
     1.5  	BufferedMaskBlit.c \
     1.6  	BufferedRenderPipe.c \
     1.7 -	RenderBuffer.c \
     1.8  	ShapeSpanIterator.c \
     1.9  	SpanClipRenderer.c \
    1.10  	awt_ImageRep.c \
     2.1 --- a/make/sun/awt/FILES_c_windows.gmk	Mon May 04 18:28:26 2009 -0700
     2.2 +++ b/make/sun/awt/FILES_c_windows.gmk	Tue May 05 09:09:24 2009 -0700
     2.3 @@ -70,7 +70,6 @@
     2.4          FourByteAbgrPre.c \
     2.5  	BufferedMaskBlit.c \
     2.6  	BufferedRenderPipe.c \
     2.7 -	RenderBuffer.c \
     2.8  	ShapeSpanIterator.c \
     2.9  	SpanClipRenderer.c \
    2.10  	SurfaceData.c \
     3.1 --- a/make/sun/awt/mapfile-vers	Mon May 04 18:28:26 2009 -0700
     3.2 +++ b/make/sun/awt/mapfile-vers	Tue May 05 09:09:24 2009 -0700
     3.3 @@ -65,7 +65,6 @@
     3.4  		Java_sun_awt_image_ShortComponentRaster_initIDs;
     3.5                  Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile;
     3.6                  Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans;
     3.7 -                Java_sun_java2d_pipe_RenderBuffer_copyFromArray;
     3.8  		Java_sun_java2d_pipe_SpanClipRenderer_eraseTile;
     3.9  		Java_sun_java2d_pipe_SpanClipRenderer_fillTile;
    3.10                  Java_sun_java2d_pipe_ShapeSpanIterator_addSegment;
     4.1 --- a/make/sun/awt/mapfile-vers-linux	Mon May 04 18:28:26 2009 -0700
     4.2 +++ b/make/sun/awt/mapfile-vers-linux	Tue May 05 09:09:24 2009 -0700
     4.3 @@ -117,7 +117,6 @@
     4.4  		Java_sun_java2d_loops_MaskBlit_MaskBlit;
     4.5  		Java_sun_java2d_loops_MaskFill_MaskFill;
     4.6                  Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans;
     4.7 -                Java_sun_java2d_pipe_RenderBuffer_copyFromArray;
     4.8  		Java_sun_java2d_pipe_SpanClipRenderer_initIDs;
     4.9  		sun_awt_image_GifImageDecoder_initIDs;
    4.10  
     5.1 --- a/src/share/classes/sun/font/TrueTypeFont.java	Mon May 04 18:28:26 2009 -0700
     5.2 +++ b/src/share/classes/sun/font/TrueTypeFont.java	Tue May 05 09:09:24 2009 -0700
     5.3 @@ -552,17 +552,6 @@
     5.4          ByteBuffer os2_Table = getTableBuffer(os_2Tag);
     5.5          setStyle(os2_Table);
     5.6          setCJKSupport(os2_Table);
     5.7 -
     5.8 -        ByteBuffer head_Table = getTableBuffer(headTag);
     5.9 -        int upem = -1;
    5.10 -        if (head_Table != null && head_Table.capacity() >= 18) {
    5.11 -            ShortBuffer sb = head_Table.asShortBuffer();
    5.12 -            upem = sb.get(9) & 0xffff;
    5.13 -        }
    5.14 -        setStrikethroughMetrics(os2_Table, upem);
    5.15 -
    5.16 -        ByteBuffer post_Table = getTableBuffer(postTag);
    5.17 -        setUnderlineMetrics(post_Table, upem);
    5.18      }
    5.19  
    5.20      /* The array index corresponds to a bit offset in the TrueType
    5.21 @@ -1020,8 +1009,26 @@
    5.22      }
    5.23  
    5.24      public void getStyleMetrics(float pointSize, float[] metrics, int offset) {
    5.25 +
    5.26 +        if (ulSize == 0f && ulPos == 0f) {
    5.27 +
    5.28 +            ByteBuffer head_Table = getTableBuffer(headTag);
    5.29 +            int upem = -1;
    5.30 +            if (head_Table != null && head_Table.capacity() >= 18) {
    5.31 +                ShortBuffer sb = head_Table.asShortBuffer();
    5.32 +                upem = sb.get(9) & 0xffff;
    5.33 +            }
    5.34 +
    5.35 +            ByteBuffer os2_Table = getTableBuffer(os_2Tag);
    5.36 +            setStrikethroughMetrics(os2_Table, upem);
    5.37 +
    5.38 +            ByteBuffer post_Table = getTableBuffer(postTag);
    5.39 +            setUnderlineMetrics(post_Table, upem);
    5.40 +        }
    5.41 +
    5.42          metrics[offset] = stPos * pointSize;
    5.43          metrics[offset+1] = stSize * pointSize;
    5.44 +
    5.45          metrics[offset+2] = ulPos * pointSize;
    5.46          metrics[offset+3] = ulSize * pointSize;
    5.47      }
     6.1 --- a/src/share/classes/sun/java2d/pipe/RenderBuffer.java	Mon May 04 18:28:26 2009 -0700
     6.2 +++ b/src/share/classes/sun/java2d/pipe/RenderBuffer.java	Tue May 05 09:09:24 2009 -0700
     6.3 @@ -63,7 +63,7 @@
     6.4       * (This value can be adjusted if the cost of JNI downcalls is reduced
     6.5       * in a future release.)
     6.6       */
     6.7 -    private static final int COPY_FROM_ARRAY_THRESHOLD = 28;
     6.8 +    private static final int COPY_FROM_ARRAY_THRESHOLD = 6;
     6.9  
    6.10      protected final Unsafe unsafe;
    6.11      protected final long baseAddress;
    6.12 @@ -93,20 +93,6 @@
    6.13      }
    6.14  
    6.15      /**
    6.16 -     * Copies length bytes from the Java-level srcArray to the native
    6.17 -     * memory located at dstAddr.  Note that this method performs no bounds
    6.18 -     * checking.  Verification that the copy will not result in memory
    6.19 -     * corruption should be done by the caller prior to invocation.
    6.20 -     *
    6.21 -     * @param srcArray the source array
    6.22 -     * @param srcPos the starting position of the source array (in bytes)
    6.23 -     * @param dstAddr pointer to the destination block of native memory
    6.24 -     * @param length the number of bytes to copy from source to destination
    6.25 -     */
    6.26 -    private static native void copyFromArray(Object srcArray, long srcPos,
    6.27 -                                             long dstAddr, long length);
    6.28 -
    6.29 -    /**
    6.30       * The behavior (and names) of the following methods are nearly
    6.31       * identical to their counterparts in the various NIO Buffer classes.
    6.32       */
    6.33 @@ -147,9 +133,9 @@
    6.34  
    6.35      public RenderBuffer put(byte[] x, int offset, int length) {
    6.36          if (length > COPY_FROM_ARRAY_THRESHOLD) {
    6.37 -            long offsetInBytes = offset * SIZEOF_BYTE;
    6.38 +            long offsetInBytes = offset * SIZEOF_BYTE + Unsafe.ARRAY_BYTE_BASE_OFFSET;
    6.39              long lengthInBytes = length * SIZEOF_BYTE;
    6.40 -            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
    6.41 +            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
    6.42              position(position() + lengthInBytes);
    6.43          } else {
    6.44              int end = offset + length;
    6.45 @@ -178,9 +164,9 @@
    6.46      public RenderBuffer put(short[] x, int offset, int length) {
    6.47          // assert (position() % SIZEOF_SHORT == 0);
    6.48          if (length > COPY_FROM_ARRAY_THRESHOLD) {
    6.49 -            long offsetInBytes = offset * SIZEOF_SHORT;
    6.50 +            long offsetInBytes = offset * SIZEOF_SHORT + Unsafe.ARRAY_SHORT_BASE_OFFSET;
    6.51              long lengthInBytes = length * SIZEOF_SHORT;
    6.52 -            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
    6.53 +            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
    6.54              position(position() + lengthInBytes);
    6.55          } else {
    6.56              int end = offset + length;
    6.57 @@ -215,9 +201,9 @@
    6.58      public RenderBuffer put(int[] x, int offset, int length) {
    6.59          // assert (position() % SIZEOF_INT == 0);
    6.60          if (length > COPY_FROM_ARRAY_THRESHOLD) {
    6.61 -            long offsetInBytes = offset * SIZEOF_INT;
    6.62 +            long offsetInBytes = offset * SIZEOF_INT + Unsafe.ARRAY_INT_BASE_OFFSET;
    6.63              long lengthInBytes = length * SIZEOF_INT;
    6.64 -            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
    6.65 +            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
    6.66              position(position() + lengthInBytes);
    6.67          } else {
    6.68              int end = offset + length;
    6.69 @@ -246,9 +232,9 @@
    6.70      public RenderBuffer put(float[] x, int offset, int length) {
    6.71          // assert (position() % SIZEOF_FLOAT == 0);
    6.72          if (length > COPY_FROM_ARRAY_THRESHOLD) {
    6.73 -            long offsetInBytes = offset * SIZEOF_FLOAT;
    6.74 +            long offsetInBytes = offset * SIZEOF_FLOAT + Unsafe.ARRAY_FLOAT_BASE_OFFSET;
    6.75              long lengthInBytes = length * SIZEOF_FLOAT;
    6.76 -            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
    6.77 +            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
    6.78              position(position() + lengthInBytes);
    6.79          } else {
    6.80              int end = offset + length;
    6.81 @@ -277,9 +263,9 @@
    6.82      public RenderBuffer put(long[] x, int offset, int length) {
    6.83          // assert (position() % SIZEOF_LONG == 0);
    6.84          if (length > COPY_FROM_ARRAY_THRESHOLD) {
    6.85 -            long offsetInBytes = offset * SIZEOF_LONG;
    6.86 +            long offsetInBytes = offset * SIZEOF_LONG + Unsafe.ARRAY_LONG_BASE_OFFSET;
    6.87              long lengthInBytes = length * SIZEOF_LONG;
    6.88 -            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
    6.89 +            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
    6.90              position(position() + lengthInBytes);
    6.91          } else {
    6.92              int end = offset + length;
     7.1 --- a/src/share/classes/sun/java2d/pipe/RenderingEngine.java	Mon May 04 18:28:26 2009 -0700
     7.2 +++ b/src/share/classes/sun/java2d/pipe/RenderingEngine.java	Tue May 05 09:09:24 2009 -0700
     7.3 @@ -95,6 +95,11 @@
     7.4       * <pre>
     7.5       *     java -Dsun.java2d.renderer=&lt;classname&gt;
     7.6       * </pre>
     7.7 +     *
     7.8 +     * If no specific {@code RenderingEngine} is specified on the command
     7.9 +     * or Ductus renderer is specified, it will attempt loading the
    7.10 +     * sun.dc.DuctusRenderingEngine class using Class.forName as a fastpath;
    7.11 +     * if not found, use the ServiceLoader.
    7.12       * If no specific {@code RenderingEngine} is specified on the command
    7.13       * line then the last one returned by enumerating all subclasses of
    7.14       * {@code RenderingEngine} known to the ServiceLoader is used.
    7.15 @@ -115,9 +120,21 @@
    7.16          reImpl = (RenderingEngine)
    7.17              AccessController.doPrivileged(new PrivilegedAction() {
    7.18                  public Object run() {
    7.19 +                    final String ductusREClass = "sun.dc.DuctusRenderingEngine";
    7.20                      String reClass =
    7.21 -                        System.getProperty("sun.java2d.renderer",
    7.22 -                                           "sun.dc.DuctusRenderingEngine");
    7.23 +                        System.getProperty("sun.java2d.renderer", ductusREClass);
    7.24 +                    if (reClass.equals(ductusREClass)) {
    7.25 +                        try {
    7.26 +                            Class cls = Class.forName(ductusREClass);
    7.27 +                            return cls.newInstance();
    7.28 +                        } catch (ClassNotFoundException x) {
    7.29 +                            // not found
    7.30 +                        } catch (IllegalAccessException x) {
    7.31 +                            // should not reach here
    7.32 +                        } catch (InstantiationException x) {
    7.33 +                            // should not reach here
    7.34 +                        }
    7.35 +                    }
    7.36  
    7.37                      ServiceLoader<RenderingEngine> reLoader =
    7.38                          ServiceLoader.loadInstalled(RenderingEngine.class);
     8.1 --- a/src/share/classes/sun/java2d/pisces/Stroker.java	Mon May 04 18:28:26 2009 -0700
     8.2 +++ b/src/share/classes/sun/java2d/pisces/Stroker.java	Tue May 05 09:09:24 2009 -0700
     8.3 @@ -181,7 +181,7 @@
     8.4                                Transform4 transform) {
     8.5          this.lineWidth = lineWidth;
     8.6          this.lineWidth2 = lineWidth >> 1;
     8.7 -        this.scaledLineWidth2 = (long)transform.m00*lineWidth2;
     8.8 +        this.scaledLineWidth2 = ((long)transform.m00*lineWidth2) >> 16;
     8.9          this.capStyle = capStyle;
    8.10          this.joinStyle = joinStyle;
    8.11          this.miterLimit = miterLimit;
    8.12 @@ -243,8 +243,8 @@
    8.13              if (ilen == 0) {
    8.14                  dx = dy = 0;
    8.15              } else {
    8.16 -                dx = (int)( (ly*scaledLineWidth2)/ilen >> 16);
    8.17 -                dy = (int)(-(lx*scaledLineWidth2)/ilen >> 16);
    8.18 +                dx = (int)( (ly*scaledLineWidth2)/ilen);
    8.19 +                dy = (int)(-(lx*scaledLineWidth2)/ilen);
    8.20              }
    8.21          } else {
    8.22              double dlx = x1 - x0;
     9.1 --- a/src/share/native/sun/java2d/pipe/RenderBuffer.c	Mon May 04 18:28:26 2009 -0700
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,71 +0,0 @@
     9.4 -/*
     9.5 - * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
     9.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 - *
     9.8 - * This code is free software; you can redistribute it and/or modify it
     9.9 - * under the terms of the GNU General Public License version 2 only, as
    9.10 - * published by the Free Software Foundation.  Sun designates this
    9.11 - * particular file as subject to the "Classpath" exception as provided
    9.12 - * by Sun in the LICENSE file that accompanied this code.
    9.13 - *
    9.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
    9.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.17 - * version 2 for more details (a copy is included in the LICENSE file that
    9.18 - * accompanied this code).
    9.19 - *
    9.20 - * You should have received a copy of the GNU General Public License version
    9.21 - * 2 along with this work; if not, write to the Free Software Foundation,
    9.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.23 - *
    9.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    9.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
    9.26 - * have any questions.
    9.27 - */
    9.28 -
    9.29 -#include "jni.h"
    9.30 -#include "jni_util.h"
    9.31 -#include "jlong.h"
    9.32 -#include <string.h>
    9.33 -
    9.34 -#include "sun_java2d_pipe_RenderBuffer.h"
    9.35 -
    9.36 -/**
    9.37 - * Note: The code in this file is nearly identical to that in
    9.38 - *       java/nio/Bits.c...
    9.39 - */
    9.40 -
    9.41 -#define MBYTE 1048576
    9.42 -
    9.43 -JNIEXPORT void JNICALL
    9.44 -Java_sun_java2d_pipe_RenderBuffer_copyFromArray
    9.45 -    (JNIEnv *env, jclass rb,
    9.46 -     jobject srcArray, jlong srcPos, jlong dstAddr, jlong length)
    9.47 -{
    9.48 -    jbyte *bytes;
    9.49 -    size_t size;
    9.50 -
    9.51 -    while (length > 0) {
    9.52 -        /*
    9.53 -         * Copy no more than one megabyte at a time, to allow for GC.
    9.54 -         * (Probably not an issue for STR, since our buffer size is likely
    9.55 -         * much smaller than a megabyte, but just in case...)
    9.56 -         */
    9.57 -        size = (size_t)(length > MBYTE ? MBYTE : length);
    9.58 -
    9.59 -        bytes = (*env)->GetPrimitiveArrayCritical(env, srcArray, NULL);
    9.60 -        if (bytes == NULL) {
    9.61 -            JNU_ThrowInternalError(env, "Unable to get array");
    9.62 -            return;
    9.63 -        }
    9.64 -
    9.65 -        memcpy(jlong_to_ptr(dstAddr), bytes + srcPos, size);
    9.66 -
    9.67 -        (*env)->ReleasePrimitiveArrayCritical(env, srcArray,
    9.68 -                                              bytes, JNI_ABORT);
    9.69 -
    9.70 -        length -= size;
    9.71 -        dstAddr += size;
    9.72 -        srcPos += size;
    9.73 -    }
    9.74 -}
    10.1 --- a/test/java/awt/PrintJob/EdgeTest/EdgeTest.java	Mon May 04 18:28:26 2009 -0700
    10.2 +++ b/test/java/awt/PrintJob/EdgeTest/EdgeTest.java	Tue May 05 09:09:24 2009 -0700
    10.3 @@ -27,6 +27,7 @@
    10.4   * @summary Verifies that (0, 0) is the upper-left corner of the page, not
    10.5   *          the upper-left corner adjusted for the margins.
    10.6   * @author dpm
    10.7 + * @run main/manual EdgeTest
    10.8   */
    10.9  
   10.10  import java.awt.*;
   10.11 @@ -43,7 +44,9 @@
   10.12                                  }
   10.13                              );
   10.14          f.setVisible(true);
   10.15 -        PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", null);
   10.16 +        JobAttributes job = new JobAttributes();
   10.17 +        job.setDialog(JobAttributes.DialogType.NONE);
   10.18 +        PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", job, null);
   10.19          if (pj != null) {
   10.20              Graphics g = pj.getGraphics();
   10.21              Dimension d = pj.getPageDimension();
    11.1 --- a/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java	Mon May 04 18:28:26 2009 -0700
    11.2 +++ b/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java	Tue May 05 09:09:24 2009 -0700
    11.3 @@ -44,7 +44,10 @@
    11.4      public MultipleEndFrame() {
    11.5          super("MultipleEnd");
    11.6          setVisible(true);
    11.7 -        PrintJob pj  = getToolkit().getPrintJob(this, "MuiltipleEnd", null);
    11.8 +
    11.9 +        JobAttributes job = new JobAttributes();
   11.10 +        job.setDialog(JobAttributes.DialogType.NONE);
   11.11 +        PrintJob pj  = getToolkit().getPrintJob(this, "MultipleEnd", job, null);
   11.12          if (pj != null) {
   11.13              pj.end();
   11.14              pj.end();
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/java/awt/print/PrinterJob/Collate2DPrintingTest.java	Tue May 05 09:09:24 2009 -0700
    12.3 @@ -0,0 +1,252 @@
    12.4 +/*
    12.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + *
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + *
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + *
   12.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   12.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   12.24 + * have any questions.
   12.25 + */
   12.26 +
   12.27 +/**
   12.28 + * @test
   12.29 + * @bug 6362683
   12.30 + * @summary Collation should work.
   12.31 + * @run main/manual Collate2DPrintingTest
   12.32 + */
   12.33 +import java.awt.*;
   12.34 +import java.awt.event.*;
   12.35 +import java.awt.print.*;
   12.36 +import javax.print.attribute.standard.*;
   12.37 +import javax.print.attribute.*;
   12.38 +import javax.print.*;
   12.39 +import java.io.*;
   12.40 +
   12.41 +public class Collate2DPrintingTest
   12.42 +    extends Frame implements Doc, Printable, ActionListener {
   12.43 +
   12.44 +        Button print2D = new Button("2D Print");
   12.45 +        Button printMerlin = new Button("PrintService");
   12.46 +        PrinterJob pj = PrinterJob.getPrinterJob();
   12.47 +        PrintService defService = null;
   12.48 +        HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
   12.49 +
   12.50 +    public Collate2DPrintingTest() {
   12.51 +
   12.52 +        Panel butPanel = new Panel();
   12.53 +        butPanel.add(print2D);
   12.54 +        butPanel.add(printMerlin);
   12.55 +        print2D.addActionListener(this);
   12.56 +        printMerlin.addActionListener(this);
   12.57 +        addWindowListener (new WindowAdapter() {
   12.58 +            public void windowClosing (WindowEvent e) {
   12.59 +                dispose();
   12.60 +            }
   12.61 +        });
   12.62 +        add("South", butPanel);
   12.63 +
   12.64 +        defService = PrintServiceLookup.lookupDefaultPrintService();
   12.65 +        PrintService[] pservice;
   12.66 +        if (defService == null) {
   12.67 +            pservice = PrintServiceLookup.lookupPrintServices(null, null);
   12.68 +            if (pservice.length == 0) {
   12.69 +                throw new RuntimeException("No printer found.  TEST ABORTED");
   12.70 +            }
   12.71 +            defService = pservice[0];
   12.72 +        }
   12.73 +        prSet.add(SheetCollate.COLLATED);
   12.74 +        prSet.add(new Copies(2));
   12.75 +        pj.setPrintable(Collate2DPrintingTest.this);
   12.76 +        setSize(300, 200);
   12.77 +        setVisible(true);
   12.78 +    }
   12.79 +
   12.80 +
   12.81 +    public int print(Graphics g, PageFormat pf, int pageIndex)
   12.82 +          throws PrinterException {
   12.83 +        g.drawString("Page: " + pageIndex, 100, 100);
   12.84 +        if (pageIndex == 2) {
   12.85 +            return Printable.NO_SUCH_PAGE;
   12.86 +        } else {
   12.87 +            return Printable.PAGE_EXISTS;
   12.88 +        }
   12.89 +    }
   12.90 +
   12.91 +    public void actionPerformed (ActionEvent ae) {
   12.92 +        try {
   12.93 +            if (ae.getSource() == print2D) {
   12.94 +                if (pj.printDialog(prSet)) {
   12.95 +                    pj.print(prSet);
   12.96 +                }
   12.97 +            } else {
   12.98 +                DocPrintJob pj = defService.createPrintJob();
   12.99 +                pj.print(this, prSet);
  12.100 +            }
  12.101 +            System.out.println ("DONE");
  12.102 +        } catch (Exception e) {
  12.103 +            e.printStackTrace();
  12.104 +        }
  12.105 +    }
  12.106 +
  12.107 +    public DocAttributeSet getAttributes() {
  12.108 +        return null;
  12.109 +    }
  12.110 +
  12.111 +    public DocFlavor getDocFlavor() {
  12.112 +        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
  12.113 +        return flavor;
  12.114 +    }
  12.115 +
  12.116 +    public Object getPrintData() {
  12.117 +        return this;
  12.118 +    }
  12.119 +
  12.120 +    public Reader getReaderForText() {
  12.121 +        return null;
  12.122 +    }
  12.123 +
  12.124 +    public InputStream getStreamForBytes() {
  12.125 +        return null;
  12.126 +    }
  12.127 +
  12.128 +  public static void main( String[] args) {
  12.129 +
  12.130 +  String[] instructions =
  12.131 +        {
  12.132 +         "You must have a printer available to perform this test",
  12.133 +         "The print result should be collated."
  12.134 +       };
  12.135 +      Sysout.createDialog( );
  12.136 +      Sysout.printInstructions( instructions );
  12.137 +
  12.138 +     new Collate2DPrintingTest();
  12.139 +  }
  12.140 +}
  12.141 +
  12.142 +
  12.143 +class Sysout {
  12.144 +   private static TestDialog dialog;
  12.145 +
  12.146 +   public static void createDialogWithInstructions( String[] instructions )
  12.147 +    {
  12.148 +      dialog = new TestDialog( new Frame(), "Instructions" );
  12.149 +      dialog.printInstructions( instructions );
  12.150 +      dialog.setVisible(true);
  12.151 +      println( "Any messages for the tester will display here." );
  12.152 +    }
  12.153 +
  12.154 +   public static void createDialog( )
  12.155 +    {
  12.156 +      dialog = new TestDialog( new Frame(), "Instructions" );
  12.157 +      String[] defInstr = { "Instructions will appear here. ", "" } ;
  12.158 +      dialog.printInstructions( defInstr );
  12.159 +      dialog.setVisible(true);
  12.160 +      println( "Any messages for the tester will display here." );
  12.161 +    }
  12.162 +
  12.163 +
  12.164 +   public static void printInstructions( String[] instructions )
  12.165 +    {
  12.166 +      dialog.printInstructions( instructions );
  12.167 +    }
  12.168 +
  12.169 +
  12.170 +   public static void println( String messageIn )
  12.171 +    {
  12.172 +      dialog.displayMessage( messageIn );
  12.173 +    }
  12.174 +
  12.175 +}// Sysout  class
  12.176 +
  12.177 +/**
  12.178 +  This is part of the standard test machinery.  It provides a place for the
  12.179 +   test instructions to be displayed, and a place for interactive messages
  12.180 +   to the user to be displayed.
  12.181 +  To have the test instructions displayed, see Sysout.
  12.182 +  To have a message to the user be displayed, see Sysout.
  12.183 +  Do not call anything in this dialog directly.
  12.184 +  */
  12.185 +class TestDialog extends Dialog {
  12.186 +
  12.187 +   TextArea instructionsText;
  12.188 +   TextArea messageText;
  12.189 +   int maxStringLength = 80;
  12.190 +
  12.191 +   //DO NOT call this directly, go through Sysout
  12.192 +   public TestDialog( Frame frame, String name )
  12.193 +    {
  12.194 +      super( frame, name );
  12.195 +      int scrollBoth = TextArea.SCROLLBARS_BOTH;
  12.196 +      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
  12.197 +      add( "North", instructionsText );
  12.198 +
  12.199 +      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
  12.200 +      add("Center", messageText);
  12.201 +
  12.202 +      pack();
  12.203 +
  12.204 +      setVisible(true);
  12.205 +    }// TestDialog()
  12.206 +
  12.207 +   //DO NOT call this directly, go through Sysout
  12.208 +   public void printInstructions( String[] instructions )
  12.209 +    {
  12.210 +      //Clear out any current instructions
  12.211 +      instructionsText.setText( "" );
  12.212 +
  12.213 +      //Go down array of instruction strings
  12.214 +
  12.215 +      String printStr, remainingStr;
  12.216 +      for( int i=0; i < instructions.length; i++ )
  12.217 +       {
  12.218 +         //chop up each into pieces maxSringLength long
  12.219 +         remainingStr = instructions[ i ];
  12.220 +         while( remainingStr.length() > 0 )
  12.221 +          {
  12.222 +            //if longer than max then chop off first max chars to print
  12.223 +            if( remainingStr.length() >= maxStringLength )
  12.224 +             {
  12.225 +               //Try to chop on a word boundary
  12.226 +               int posOfSpace = remainingStr.
  12.227 +                  lastIndexOf( ' ', maxStringLength - 1 );
  12.228 +
  12.229 +               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
  12.230 +
  12.231 +               printStr = remainingStr.substring( 0, posOfSpace + 1 );
  12.232 +               remainingStr = remainingStr.substring( posOfSpace + 1 );
  12.233 +             }
  12.234 +            //else just print
  12.235 +            else
  12.236 +             {
  12.237 +               printStr = remainingStr;
  12.238 +               remainingStr = "";
  12.239 +             }
  12.240 +
  12.241 +            instructionsText.append( printStr + "\n" );
  12.242 +
  12.243 +          }// while
  12.244 +
  12.245 +       }// for
  12.246 +
  12.247 +    }//printInstructions()
  12.248 +
  12.249 +   //DO NOT call this directly, go through Sysout
  12.250 +   public void displayMessage( String messageIn )
  12.251 +    {
  12.252 +      messageText.append( messageIn + "\n" );
  12.253 +    }
  12.254 +
  12.255 + }// TestDialog  class
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/java/awt/print/PrinterJob/PrtException.java	Tue May 05 09:09:24 2009 -0700
    13.3 @@ -0,0 +1,78 @@
    13.4 +/*
    13.5 + * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   13.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   13.24 + * have any questions.
   13.25 + */
   13.26 +/*
   13.27 +  @test
   13.28 +  @bug 4429544
   13.29 +  @summary This test should not throw a printer exception. Test has been modified to correspond with the behavior of 1.5 and above.
   13.30 +  @run main PrtException
   13.31 +*/
   13.32 +
   13.33 +import java.awt.*;
   13.34 +import java.awt.print.*;
   13.35 +import javax.print.*;
   13.36 +
   13.37 +public class PrtException implements Printable {
   13.38 +    PrinterJob pj;
   13.39 +
   13.40 +    public PrtException() {
   13.41 +
   13.42 +        try{
   13.43 +            PrintService[] svc;
   13.44 +            PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
   13.45 +            if (defService == null) {
   13.46 +                svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
   13.47 +                if (svc.length == 0) {
   13.48 +                    throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
   13.49 +                }
   13.50 +                defService = svc[0];
   13.51 +            }
   13.52 +
   13.53 +            System.out.println("PrintService found : "+defService);
   13.54 +            pj = PrinterJob.getPrinterJob();;
   13.55 +            pj.setPrintService(defService);
   13.56 +            //pj.setPrintable(this); // commenting this line should not result in PrinterException
   13.57 +            pj.print();
   13.58 +        } catch(PrinterException e ) {
   13.59 +            e.printStackTrace();
   13.60 +            throw new RuntimeException(" PrinterException should not be thrown. TEST FAILED");
   13.61 +        }
   13.62 +        System.out.println("TEST PASSED");
   13.63 +    }
   13.64 +
   13.65 +
   13.66 +    public int print(Graphics g,PageFormat pf,int pageIndex) {
   13.67 +        Graphics2D g2= (Graphics2D)g;
   13.68 +        if(pageIndex>=1){
   13.69 +            return Printable.NO_SUCH_PAGE;
   13.70 +        }
   13.71 +        g2.translate(pf.getImageableX(), pf.getImageableY());
   13.72 +        g2.setColor(Color.black);
   13.73 +        g2.drawString("Hello world.", 10, 10);
   13.74 +
   13.75 +        return Printable.PAGE_EXISTS;
   13.76 +    }
   13.77 +
   13.78 +    public static void main(String arg[]) {
   13.79 +        PrtException sp = new PrtException();
   13.80 +    }
   13.81 +}
    14.1 --- a/test/javax/print/CheckDupFlavor.java	Mon May 04 18:28:26 2009 -0700
    14.2 +++ b/test/javax/print/CheckDupFlavor.java	Tue May 05 09:09:24 2009 -0700
    14.3 @@ -1,5 +1,5 @@
    14.4  /*
    14.5 - * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
    14.6 + * Copyright 2004-2009 Sun Microsystems, Inc.  All Rights Reserved.
    14.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.8   *
    14.9   * This code is free software; you can redistribute it and/or modify it
   14.10 @@ -35,17 +35,19 @@
   14.11  
   14.12  public class CheckDupFlavor {
   14.13      public static void main(String[] args){
   14.14 -        PrintService pservice =
   14.15 -                     PrintServiceLookup.lookupDefaultPrintService();
   14.16 -
   14.17 -        if (pservice == null) {
   14.18 -                System.out.println("No default PrintService found. Test ABORTED.");
   14.19 -            return;
   14.20 +        PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
   14.21 +        PrintService[] pservice;
   14.22 +        if (defService == null) {
   14.23 +            pservice = PrintServiceLookup.lookupPrintServices(null, null);
   14.24 +            if (pservice.length == 0) {
   14.25 +                throw new RuntimeException("No printer found.  TEST ABORTED");
   14.26 +            }
   14.27 +            defService = pservice[0];
   14.28          }
   14.29  
   14.30 -        System.out.println("Default service = "+pservice);
   14.31 +        System.out.println("PrintService = "+defService);
   14.32  
   14.33 -        DocFlavor[] flavors = pservice.getSupportedDocFlavors();
   14.34 +        DocFlavor[] flavors = defService.getSupportedDocFlavors();
   14.35          if (flavors==null) {
   14.36              System.out.println("No flavors supported. Test PASSED.");
   14.37              return;
   14.38 @@ -54,13 +56,13 @@
   14.39  
   14.40          ArrayList flavorList = new ArrayList();
   14.41          for (int i=0; i<flavors.length; i++) {
   14.42 -                if (flavors[i] == null) {
   14.43 -                        throw new RuntimeException("Null flavor. Test FAILED.");
   14.44 -                } else if (flavorList.contains(flavors[i])) {
   14.45 -                        throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
   14.46 -                } else {
   14.47 -                        flavorList.add(flavors[i]);
   14.48 -                }
   14.49 +            if (flavors[i] == null) {
   14.50 +                 throw new RuntimeException("Null flavor. Test FAILED.");
   14.51 +            } else if (flavorList.contains(flavors[i])) {
   14.52 +                 throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
   14.53 +            } else {
   14.54 +                flavorList.add(flavors[i]);
   14.55 +            }
   14.56          }
   14.57          System.out.println("No duplicate found. Test PASSED.");
   14.58      }
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/javax/print/LookupServices.java	Tue May 05 09:09:24 2009 -0700
    15.3 @@ -0,0 +1,50 @@
    15.4 +/*
    15.5 + * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * This code is free software; you can redistribute it and/or modify it
    15.9 + * under the terms of the GNU General Public License version 2 only, as
   15.10 + * published by the Free Software Foundation.
   15.11 + *
   15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 + * version 2 for more details (a copy is included in the LICENSE file that
   15.16 + * accompanied this code).
   15.17 + *
   15.18 + * You should have received a copy of the GNU General Public License version
   15.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 + *
   15.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   15.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   15.24 + * have any questions.
   15.25 + */
   15.26 +
   15.27 +/*
   15.28 + * @test
   15.29 + * @bug 4510477 6520186
   15.30 + * @summary No crash with HP OfficeJet 600 installed.
   15.31 + * @run main LookupServices
   15.32 +*/
   15.33 +
   15.34 +import javax.print.attribute.*;
   15.35 +import javax.print.*;
   15.36 +
   15.37 +public class LookupServices {
   15.38 +    public static void main (String [] args) {
   15.39 +
   15.40 +        DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
   15.41 +        HashPrintRequestAttributeSet prSet = null;
   15.42 +
   15.43 +        PrintService[] serv = PrintServiceLookup.lookupPrintServices(flavor, null);
   15.44 +        System.out.println("default "+PrintServiceLookup.lookupDefaultPrintService());
   15.45 +        if (serv.length==0) {
   15.46 +            System.out.println("no PrintService supports GIF");
   15.47 +            return;
   15.48 +        }
   15.49 +
   15.50 +        System.out.println("Selected print service: "+ serv[0]);
   15.51 +    }
   15.52 +
   15.53 +}
    16.1 --- a/test/javax/print/TestRaceCond.java	Mon May 04 18:28:26 2009 -0700
    16.2 +++ b/test/javax/print/TestRaceCond.java	Tue May 05 09:09:24 2009 -0700
    16.3 @@ -43,6 +43,10 @@
    16.4          PrintService[] pservs = PrintServiceLookup.lookupPrintServices(null, null);
    16.5          PrintService pserv2 = PrintServiceLookup.lookupDefaultPrintService();
    16.6  
    16.7 +        if ((pserv1 == null) || (pserv2==null)) {
    16.8 +            return;
    16.9 +        }
   16.10 +
   16.11          if (pserv1.hashCode() != pserv2.hashCode()) {
   16.12              throw new RuntimeException("Different hashCodes for equal print "
   16.13                              + "services: " + pserv1.hashCode() + " "
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/javax/print/attribute/Chroma.java	Tue May 05 09:09:24 2009 -0700
    17.3 @@ -0,0 +1,66 @@
    17.4 +/*
    17.5 + * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
    17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 + *
    17.8 + * This code is free software; you can redistribute it and/or modify it
    17.9 + * under the terms of the GNU General Public License version 2 only, as
   17.10 + * published by the Free Software Foundation.
   17.11 + *
   17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 + * version 2 for more details (a copy is included in the LICENSE file that
   17.16 + * accompanied this code).
   17.17 + *
   17.18 + * You should have received a copy of the GNU General Public License version
   17.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 + *
   17.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   17.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   17.24 + * have any questions.
   17.25 + */
   17.26 +/*
   17.27 + * @test 1.3 01/05/11
   17.28 + * @bug 4456750
   17.29 + * @summary Test for supported chromaticity values with null DocFlavor.
   17.30 + *          No exception should be thrown.
   17.31 + * @run main Chroma
   17.32 +*/
   17.33 +
   17.34 +// Chroma.java
   17.35 +import java.io.*;
   17.36 +
   17.37 +import javax.print.*;
   17.38 +import javax.print.attribute.*;
   17.39 +import javax.print.attribute.standard.*;
   17.40 +
   17.41 +public class Chroma {
   17.42 +
   17.43 +   public static void main(String args[]) {
   17.44 +
   17.45 +      StreamPrintServiceFactory []fact =
   17.46 +        StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
   17.47 +              DocFlavor.SERVICE_FORMATTED.PRINTABLE,
   17.48 +              DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
   17.49 +
   17.50 +      if (fact.length != 0) {
   17.51 +          OutputStream out = new ByteArrayOutputStream();
   17.52 +          StreamPrintService sps = fact[0].getPrintService(out);
   17.53 +          checkChroma(sps);
   17.54 +      }
   17.55 +
   17.56 +      PrintService defSvc = PrintServiceLookup.lookupDefaultPrintService();
   17.57 +      if (defSvc != null) {
   17.58 +           checkChroma(defSvc);
   17.59 +      }
   17.60 +
   17.61 +   }
   17.62 +
   17.63 +    static void checkChroma(PrintService svc) {
   17.64 +       if (svc.isAttributeCategorySupported(Chromaticity.class)) {
   17.65 +            svc.getSupportedAttributeValues(Chromaticity.class,null,null);
   17.66 +       }
   17.67 +    }
   17.68 +
   17.69 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/javax/print/attribute/ChromaticityValues.java	Tue May 05 09:09:24 2009 -0700
    18.3 @@ -0,0 +1,97 @@
    18.4 +/*
    18.5 + * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   18.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   18.24 + * have any questions.
   18.25 + */
   18.26 +/*
   18.27 + * @test
   18.28 + * @bug 4446106
   18.29 + * @summary Test for chromaticity values.
   18.30 + * @run main ChromaticityValues
   18.31 +*/
   18.32 +
   18.33 +
   18.34 +
   18.35 +import javax.print.*;
   18.36 +import javax.print.attribute.*;
   18.37 +import javax.print.attribute.standard.*;
   18.38 +import java.util.ArrayList;
   18.39 +
   18.40 +public class ChromaticityValues {
   18.41 +
   18.42 +    public static void main(String args[]) {
   18.43 +        System.out.println("=======================================================================");
   18.44 +        System.out.println("INSTRUCTIONS: This test is only for WINDOWS platform. ");
   18.45 +        System.out.println("You should have a printer configured as your default printer in your system.");
   18.46 +        System.out.println("=======================================================================");
   18.47 +
   18.48 +        String os=System.getProperty("os.name").toLowerCase();
   18.49 +
   18.50 +        if (!(os.indexOf("win")>=0)) {
   18.51 +            System.out.println("Not a Windows System.  TEST ABORTED");
   18.52 +            return;
   18.53 +        }
   18.54 +
   18.55 +        PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
   18.56 +        if (pservice == null) {
   18.57 +            throw new RuntimeException("A printer is required for this test.");
   18.58 +        }
   18.59 +
   18.60 +        System.out.println("Default Service is "+pservice);
   18.61 +        ColorSupported psa = (ColorSupported)pservice.getAttribute(ColorSupported.class);
   18.62 +        ArrayList cValues = new ArrayList();
   18.63 +
   18.64 +        if (pservice.isAttributeCategorySupported(Chromaticity.class)) {
   18.65 +            Chromaticity[] values =(Chromaticity[])
   18.66 +                (pservice.getSupportedAttributeValues(Chromaticity.class, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null));
   18.67 +            if ((values != null) && (values.length > 0)) {
   18.68 +                for (int i=0; i<values.length; i++) {
   18.69 +                    cValues.add(values[i]);
   18.70 +                }
   18.71 +            } else {
   18.72 +                System.out.println("Chromaticity value is unknown. TEST ABORTED");
   18.73 +                return;
   18.74 +            }
   18.75 +
   18.76 +        } else {
   18.77 +            System.out.println("Chromaticity is not supported. TEST ABORTED");
   18.78 +            return;
   18.79 +
   18.80 +        }
   18.81 +
   18.82 +        if (psa != null) {
   18.83 +            if (psa.equals(ColorSupported.SUPPORTED)) {
   18.84 +                if (cValues.size() < 2) {
   18.85 +                    throw new RuntimeException("ColorSupported is supported, values for Chromaticity should be monochrome and color.");
   18.86 +                }
   18.87 +            } else {
   18.88 +                if ((cValues.size() != 1) ||
   18.89 +                    (!cValues.contains(Chromaticity.MONOCHROME))) {
   18.90 +                    throw new RuntimeException("ColorSupported is not supported, values for Chromaticity should only be monochrome.");
   18.91 +                }
   18.92 +            }
   18.93 +        } else { // ColorSupported unknown
   18.94 +            if (!cValues.contains(Chromaticity.COLOR)) {
   18.95 +                throw new RuntimeException("ColorSupported is unknown, values for Chromaticity should at least include color.");
   18.96 +            }
   18.97 +
   18.98 +        }
   18.99 +    }
  18.100 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/javax/print/attribute/GetCopiesSupported.java	Tue May 05 09:09:24 2009 -0700
    19.3 @@ -0,0 +1,57 @@
    19.4 +/*
    19.5 + * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   19.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   19.24 + * have any questions.
   19.25 + */
   19.26 +/*
   19.27 +  @test
   19.28 +  @bug 4463280
   19.29 +  @summary No ClassCastException should occur.
   19.30 +  @run main GetCopiesSupported
   19.31 +*/
   19.32 +
   19.33 +import javax.print.*;
   19.34 +import javax.print.attribute.*;
   19.35 +import javax.print.attribute.standard.*;
   19.36 +
   19.37 +public class GetCopiesSupported {
   19.38 +
   19.39 +    public static void main(String args[]) {
   19.40 +        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
   19.41 +        PrintService[] pservice;
   19.42 +        if (service == null) {
   19.43 +             pservice = PrintServiceLookup.lookupPrintServices(null, null);
   19.44 +            if (pservice.length == 0) {
   19.45 +                    throw new RuntimeException("No printer found.  TEST ABORTED");
   19.46 +            }
   19.47 +            service = pservice[0];
   19.48 +        }
   19.49 +
   19.50 +        if (service != null) {
   19.51 +            CopiesSupported c = (CopiesSupported)
   19.52 +               service.getSupportedAttributeValues(Copies.class,
   19.53 +                                                   null, null);
   19.54 +
   19.55 +           System.out.println("CopiesSupported : "+c);
   19.56 +        }
   19.57 +    }
   19.58 +
   19.59 +
   19.60 +}
    20.1 --- a/test/javax/print/attribute/PSCopiesFlavorTest.java	Mon May 04 18:28:26 2009 -0700
    20.2 +++ b/test/javax/print/attribute/PSCopiesFlavorTest.java	Tue May 05 09:09:24 2009 -0700
    20.3 @@ -1,5 +1,5 @@
    20.4  /*
    20.5 - * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
    20.6 + * Copyright 2007-2009 Sun Microsystems, Inc.  All Rights Reserved.
    20.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.8   *
    20.9   * This code is free software; you can redistribute it and/or modify it
   20.10 @@ -37,26 +37,26 @@
   20.11     public static void main(String args[]) {
   20.12  
   20.13         DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
   20.14 -       PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
   20.15 -       if (!(ps.isDocFlavorSupported(flavor))) {
   20.16 -           System.out.println("unsupported flavor :" + flavor);
   20.17 -           return;
   20.18 +       PrintService[] ps = PrintServiceLookup.lookupPrintServices(flavor, null);
   20.19 +       if (ps.length > 0) {
   20.20 +           System.out.println("found PrintService: "+ps[0]);
   20.21 +           Copies c = new Copies(1);
   20.22 +           PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
   20.23 +           aset.add(c);
   20.24 +           boolean suppVal = ps[0].isAttributeValueSupported(c, flavor, null);
   20.25 +           AttributeSet us = ps[0].getUnsupportedAttributes(flavor, aset);
   20.26 +           if (suppVal || us == null) {
   20.27 +               throw new RuntimeException("Copies should be unsupported value");
   20.28 +           }
   20.29 +
   20.30 +           Object value = ps[0].getSupportedAttributeValues(Copies.class,
   20.31 +                                                            flavor, null);
   20.32 +
   20.33 +            //Copies Supported
   20.34 +            if(value instanceof CopiesSupported) {
   20.35 +                throw new RuntimeException("Copies should have no supported values.");
   20.36 +            }
   20.37         }
   20.38 -       Copies c = new Copies(1);
   20.39 -       PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
   20.40 -       aset.add(c);
   20.41 -       boolean suppVal = ps.isAttributeValueSupported(c, flavor, null);
   20.42 -       AttributeSet us = ps.getUnsupportedAttributes(flavor, aset);
   20.43 -       if (suppVal || us == null) {
   20.44 -           throw new RuntimeException("Copies should be unsupported value");
   20.45 -       }
   20.46 -
   20.47 -       Object value = ps.getSupportedAttributeValues(Copies.class, flavor, null);
   20.48 -
   20.49 -        //Copies Supported
   20.50 -        if(value instanceof CopiesSupported) {
   20.51 -            throw new RuntimeException("Copies should have no supported values.");
   20.52 -        }
   20.53  
   20.54     }
   20.55  }
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/javax/print/attribute/SidesPageRangesTest.java	Tue May 05 09:09:24 2009 -0700
    21.3 @@ -0,0 +1,122 @@
    21.4 +/*
    21.5 + * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   21.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   21.24 + * have any questions.
   21.25 + */
   21.26 +/*
   21.27 + * @test
   21.28 + * @bug 4903366
   21.29 + * @summary No crash should occur.
   21.30 + * @run main SidesPageRangesTest
   21.31 +*/
   21.32 +import java.awt.*;
   21.33 +import javax.print.*;
   21.34 +import javax.print.attribute.standard.*;
   21.35 +import javax.print.attribute.*;
   21.36 +import java.io.*;
   21.37 +import java.util.Locale;
   21.38 +import java.net.URL;
   21.39 +
   21.40 +public class SidesPageRangesTest {
   21.41 +        /**
   21.42 +         * Constructor
   21.43 +         */
   21.44 +         public SidesPageRangesTest() {
   21.45 +                super();
   21.46 +        }
   21.47 +        /**
   21.48 +         * Starts the application.
   21.49 +         */
   21.50 +        public static void main(java.lang.String[] args) {
   21.51 +                SidesPageRangesTest pd = new SidesPageRangesTest();
   21.52 +                PrintService defService = null;
   21.53 +                DocFlavor flavors[]  = null;
   21.54 +                PrintService[] pservice;
   21.55 +                defService = PrintServiceLookup.lookupDefaultPrintService();
   21.56 +                if (defService == null) {
   21.57 +                    pservice = PrintServiceLookup.lookupPrintServices(null, null);
   21.58 +                    if (pservice.length == 0) {
   21.59 +                        throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
   21.60 +                    }
   21.61 +                    defService = pservice[0];
   21.62 +                }
   21.63 +                System.out.println("Default Print Service "+defService);
   21.64 +
   21.65 +
   21.66 +                if (defService.isAttributeCategorySupported(PageRanges.class)) {
   21.67 +                        System.out.println("\nPageRanges Attribute category is supported");
   21.68 +                } else {
   21.69 +                        System.out.println("\nPageRanges Attribute category is not supported. terminating...");
   21.70 +                        System.exit(1);
   21.71 +                }
   21.72 +
   21.73 +                flavors = defService.getSupportedDocFlavors();
   21.74 +                System.out.println("\nGetting Supported values for PageRanges for each supported DocFlavor");
   21.75 +                System.out.println("===============================================================\n");
   21.76 +                for (int y = 0; y < flavors.length; y ++) {
   21.77 +                    System.out.println("\n\n");
   21.78 +
   21.79 +                    System.out.println("Doc Flavor: "+flavors[y]);
   21.80 +                    System.out.println("-----------------------------");
   21.81 +
   21.82 +                    Object vals = defService.getSupportedAttributeValues(PageRanges.class, flavors[y], null);
   21.83 +                    if (vals == null) {
   21.84 +                        System.out.println("No supported values for PageRanges for this doc flavor. ");
   21.85 +                    }
   21.86 +
   21.87 +                    PageRanges[] pr = null;
   21.88 +                    if (vals instanceof PageRanges[]) {
   21.89 +                        pr = (PageRanges[]) vals;
   21.90 +                        for (int x = 0; x < pr.length; x ++) {
   21.91 +                            System.out.println("\nSupported Value "+pr[x]);
   21.92 +                            System.out.println("is "+pr[x]+" value supported? "+defService.isAttributeValueSupported(pr[x], flavors[y], null));
   21.93 +
   21.94 +                            if (!defService.isAttributeValueSupported(pr[x], flavors[y], null)) {
   21.95 +                                throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
   21.96 +                            }
   21.97 +                        }
   21.98 +                    } else if (vals instanceof PageRanges) {
   21.99 +                        System.out.println(vals);
  21.100 +                        System.out.println("is "+vals+" value supported? "+defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null));
  21.101 +                        if (!defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null)) {
  21.102 +                            throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
  21.103 +                        }
  21.104 +                    }
  21.105 +
  21.106 +                    // SIDES test
  21.107 +                    vals = defService.getSupportedAttributeValues(Sides.class, flavors[y], null);
  21.108 +                    if (vals == null) {
  21.109 +                        System.out.println("No supported values for Sides for this doc flavor. ");
  21.110 +                    }
  21.111 +
  21.112 +                    Sides[] s = null;
  21.113 +                    if (vals instanceof Sides[]) {
  21.114 +                        s = (Sides[]) vals;
  21.115 +                        for (int x = 0; x < s.length; x ++) {
  21.116 +                            System.out.println("\nSupported Value "+s[x]);
  21.117 +                            System.out.println("is "+s[x]+" value supported? "+defService.isAttributeValueSupported(s[x], flavors[y], null));
  21.118 +                            if  (!defService.isAttributeValueSupported(s[x], flavors[y], null)) {
  21.119 +                                throw new RuntimeException("Sides contradicts getSupportedAttributeValues");
  21.120 +                            }
  21.121 +                        }
  21.122 +                    }
  21.123 +                }
  21.124 +        }
  21.125 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/javax/print/attribute/SupportedPrintableAreas.java	Tue May 05 09:09:24 2009 -0700
    22.3 @@ -0,0 +1,83 @@
    22.4 +/*
    22.5 + * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + *
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + *
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + *
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + *
   22.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   22.24 + * have any questions.
   22.25 + */
   22.26 +
   22.27 +/*
   22.28 + * @test
   22.29 + * @bug 4762773 6289206 6324049 6362765
   22.30 + * @summary Tests that get non-null return list of printable areas.
   22.31 + * @run main SupportedPrintableAreas
   22.32 + */
   22.33 +
   22.34 +
   22.35 +import javax.print.*;
   22.36 +import javax.print.event.*;
   22.37 +import javax.print.attribute.*;
   22.38 +import javax.print.attribute.standard.*;
   22.39 +
   22.40 +public class SupportedPrintableAreas {
   22.41 +
   22.42 +  public static void main(String[] args) {
   22.43 +     PrintService[] svc;
   22.44 +     PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
   22.45 +     if (printer == null) {
   22.46 +         svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
   22.47 +         if (svc.length == 0) {
   22.48 +             throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
   22.49 +         }
   22.50 +         printer = svc[0];
   22.51 +     }
   22.52 +     System.out.println("PrintService found : "+printer);
   22.53 +
   22.54 +     if (!printer.isAttributeCategorySupported(MediaPrintableArea.class)) {
   22.55 +         return;
   22.56 +     }
   22.57 +     Object value = printer.getSupportedAttributeValues(
   22.58 +                    MediaPrintableArea.class, null, null);
   22.59 +     if (!value.getClass().isArray()) {
   22.60 +         throw new RuntimeException("unexpected value");
   22.61 +      }
   22.62 +
   22.63 +     PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
   22.64 +     value = printer.getSupportedAttributeValues(
   22.65 +                    MediaPrintableArea.class, null, aset);
   22.66 +     if (!value.getClass().isArray()) {
   22.67 +         throw new RuntimeException("unexpected value");
   22.68 +      }
   22.69 +
   22.70 +     Media media = (Media)printer.getDefaultAttributeValue(Media.class);
   22.71 +     aset.add(media);
   22.72 +     value = printer.getSupportedAttributeValues(
   22.73 +                    MediaPrintableArea.class, null, aset);
   22.74 +     if (!value.getClass().isArray()) {
   22.75 +         throw new RuntimeException("unexpected value");
   22.76 +     }
   22.77 +
   22.78 +     // test for 6289206
   22.79 +     aset.add(MediaTray.MANUAL);
   22.80 +     value = printer.getSupportedAttributeValues(
   22.81 +                    MediaPrintableArea.class, null, aset);
   22.82 +     if ((value != null) && !value.getClass().isArray()) {
   22.83 +         throw new RuntimeException("unexpected value");
   22.84 +     }
   22.85 +  }
   22.86 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/javax/print/attribute/autosense/PrintAutoSenseData.java	Tue May 05 09:09:24 2009 -0700
    23.3 @@ -0,0 +1,152 @@
    23.4 +/*
    23.5 + * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
    23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 + *
    23.8 + * This code is free software; you can redistribute it and/or modify it
    23.9 + * under the terms of the GNU General Public License version 2 only, as
   23.10 + * published by the Free Software Foundation.
   23.11 + *
   23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 + * version 2 for more details (a copy is included in the LICENSE file that
   23.16 + * accompanied this code).
   23.17 + *
   23.18 + * You should have received a copy of the GNU General Public License version
   23.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 + *
   23.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   23.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   23.24 + * have any questions.
   23.25 + */
   23.26 +
   23.27 +/*
   23.28 + * @test
   23.29 + * @bug 4468109
   23.30 + * @summary Test for printing AUTOSENSE DocFlavor.  No exception should be thrown.
   23.31 + * @run main PrintAutoSenseData
   23.32 +*/
   23.33 +
   23.34 +import java.io.*;
   23.35 +import javax.print.*;
   23.36 +import javax.print.attribute.*;
   23.37 +import javax.print.attribute.standard.*;
   23.38 +import java.net.URL;
   23.39 +
   23.40 +public class PrintAutoSenseData
   23.41 +{
   23.42 +  private DocFlavor flavor = DocFlavor.URL.AUTOSENSE; //represents the docflavor.
   23.43 +  private PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor, null);
   23.44 +
   23.45 +
   23.46 +  public PrintAutoSenseData()
   23.47 +  {
   23.48 +     if (service.length == 0)
   23.49 +     {
   23.50 +        System.out.println("No print service available...");
   23.51 +        return;
   23.52 +     }
   23.53 +
   23.54 +     System.out.println("selected PrintService: " + this.service[0]);
   23.55 +     if (service[0].isDocFlavorSupported(flavor)) {
   23.56 +         System.out.println("DocFlavor.URL.AUTOSENSE supported");
   23.57 +     } else {
   23.58 +         System.out.println("DocFlavor.URL.AUTOSENSE not supported. Testing aborted !!");
   23.59 +         return;
   23.60 +     }
   23.61 +
   23.62 +     DocPrintJob job = service[0].createPrintJob();
   23.63 +     this.print();
   23.64 +  }
   23.65 +
   23.66 +  // The print method prints sample file with DocFlavor.URL.AUTOSENSE.
   23.67 +  void print()
   23.68 +  {
   23.69 +         String fileName = "./sample.txt";
   23.70 +         DocPrintJob job = service[0].createPrintJob();
   23.71 +
   23.72 +         // The representation class is a URL.
   23.73 +         System.out.println("printing " + fileName + " using doc flavor: " + this.flavor);
   23.74 +         System.out.println("Rep. class name: " + this.flavor.getRepresentationClassName() + " MimeType: " + this.flavor.getMimeType());
   23.75 +
   23.76 +         Doc doc = new URLDoc(fileName, this.flavor);
   23.77 +         HashPrintRequestAttributeSet prSet =
   23.78 +             new HashPrintRequestAttributeSet();
   23.79 +         prSet.add(new Destination(new File("./dest.prn").toURI()));
   23.80 +         //print the document.
   23.81 +         try {
   23.82 +            job.print(doc, prSet);
   23.83 +         } catch ( Exception e ) {
   23.84 +            e.printStackTrace();
   23.85 +         }
   23.86 +  }
   23.87 +
   23.88 +  public static void main(String[] args) {
   23.89 +     new PrintAutoSenseData();
   23.90 +  }
   23.91 +
   23.92 +}
   23.93 +
   23.94 +/* This class is for reading autosense data with URL representation class */
   23.95 +
   23.96 +class URLDoc implements Doc
   23.97 +{
   23.98 +   protected String fileName = null;
   23.99 +   protected DocFlavor flavor = null;
  23.100 +   protected Object printData = null;
  23.101 +   protected InputStream instream = null;
  23.102 +
  23.103 +   public URLDoc(String filename, DocFlavor docFlavor)
  23.104 +   {
  23.105 +      this.fileName = filename;
  23.106 +      this.flavor = docFlavor;
  23.107 +   }
  23.108 +
  23.109 +   public DocFlavor getDocFlavor() {
  23.110 +       return DocFlavor.URL.AUTOSENSE;
  23.111 +   }
  23.112 +
  23.113 +   public DocAttributeSet getAttributes()
  23.114 +   {
  23.115 +       HashDocAttributeSet hset = new HashDocAttributeSet();
  23.116 +       return hset;
  23.117 +   }
  23.118 +
  23.119 +   public Object getPrintData()
  23.120 +   {
  23.121 +     if ( this.printData == null )
  23.122 +     {
  23.123 +        this.printData = URLDoc.class.getResource(this.fileName);
  23.124 +        System.out.println("getPrintData(): " + this.printData);
  23.125 +     }
  23.126 +     return this.printData;
  23.127 +   }
  23.128 +
  23.129 +   public Reader getReaderForText()
  23.130 +   {
  23.131 +     return null;
  23.132 +   }
  23.133 +
  23.134 +   public InputStream getStreamForBytes()
  23.135 +   {
  23.136 +     System.out.println("getStreamForBytes(): " + this.printData);
  23.137 +     try
  23.138 +     {
  23.139 +        if ( (this.printData != null) && (this.printData instanceof URL) )
  23.140 +        {
  23.141 +           this.instream = ((URL)this.printData).openStream();
  23.142 +        }
  23.143 +        if (this.instream == null)
  23.144 +        {
  23.145 +           URL url = URLDoc.class.getResource(this.fileName);
  23.146 +           this.instream = url.openStream();
  23.147 +        }
  23.148 +      }
  23.149 +      catch ( IOException ie )
  23.150 +      {
  23.151 +         System.out.println("URLDoc: exception: " + ie.toString());
  23.152 +      }
  23.153 +      return this.instream;
  23.154 +   }
  23.155 +}
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/sun/pisces/StrokeShapeTest.java	Tue May 05 09:09:24 2009 -0700
    24.3 @@ -0,0 +1,71 @@
    24.4 +/*
    24.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.7 + *
    24.8 + * This code is free software; you can redistribute it and/or modify it
    24.9 + * under the terms of the GNU General Public License version 2 only, as
   24.10 + * published by the Free Software Foundation.
   24.11 + *
   24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   24.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   24.15 + * version 2 for more details (a copy is included in the LICENSE file that
   24.16 + * accompanied this code).
   24.17 + *
   24.18 + * You should have received a copy of the GNU General Public License version
   24.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   24.21 + *
   24.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   24.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   24.24 + * have any questions.
   24.25 + */
   24.26 +import java.awt.*;
   24.27 +import java.awt.geom.Ellipse2D;
   24.28 +import java.awt.geom.GeneralPath;
   24.29 +import java.awt.image.BufferedImage;
   24.30 +import java.io.File;
   24.31 +
   24.32 +import javax.imageio.ImageIO;
   24.33 +
   24.34 +/**
   24.35 + * @author chrisn@google.com (Chris Nokleberg)
   24.36 + * @author yamauchi@google.com (Hiroshi Yamauchi)
   24.37 + */
   24.38 +public class StrokeShapeTest {
   24.39 +  public static void main(String[] args) throws Exception {
   24.40 +    BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
   24.41 +    Graphics2D g = image.createGraphics();
   24.42 +    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   24.43 +    g.setPaint(Color.WHITE);
   24.44 +    g.fill(new Rectangle(image.getWidth(), image.getHeight()));
   24.45 +    g.translate(25, 100);
   24.46 +
   24.47 +    Stroke stroke = new BasicStroke(200, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
   24.48 +    Shape shape = new Polygon(new int[] {0, 1500, 0}, new int[] {750, 0, -750}, 3);
   24.49 +
   24.50 +    g.scale(.1, .1);
   24.51 +    g.setPaint(Color.BLACK);
   24.52 +    g.setStroke(stroke);
   24.53 +    g.draw(shape);
   24.54 +    g.setPaint(Color.RED);
   24.55 +    g.fill(stroke.createStrokedShape(shape));
   24.56 +
   24.57 +    // To visually check it
   24.58 +    //ImageIO.write(image, "PNG", new File(args[0]));
   24.59 +
   24.60 +    boolean blackPixelFound = false;
   24.61 +    outer:
   24.62 +    for (int x = 0; x < 200; ++x) {
   24.63 +      for (int y = 0; y < 200; ++y) {
   24.64 +        if (image.getRGB(x, y) == Color.BLACK.getRGB()) {
   24.65 +          blackPixelFound = true;
   24.66 +          break outer;
   24.67 +        }
   24.68 +      }
   24.69 +    }
   24.70 +    if (blackPixelFound) {
   24.71 +      throw new RuntimeException("The shape hasn't been filled in red.");
   24.72 +    }
   24.73 +  }
   24.74 +}