< prev index next >

src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterGraphicsConfig.java

Print this page




  32 
  33 public class CPrinterGraphicsConfig extends GraphicsConfiguration {
  34     public static CPrinterGraphicsConfig getConfig(PageFormat pf) {
  35         return new CPrinterGraphicsConfig(pf);
  36     }
  37 
  38     GraphicsDevice gd;
  39     PageFormat pf;
  40 
  41     public CPrinterGraphicsConfig(PageFormat pf) {
  42         this.gd = new CPrinterDevice(this);
  43         this.pf = pf;
  44     }
  45 
  46     public PageFormat getPageFormat() {
  47         return pf;
  48     }
  49 
  50     /**
  51      * Returns the {@link GraphicsDevice} associated with this
  52      * <code>GraphicsConfiguration</code>.
  53      * @return a <code>GraphicsDevice</code> object that is
  54      * associated with this <code>GraphicsConfiguration</code>.
  55      */
  56     public GraphicsDevice getDevice() {
  57         return gd;
  58     }
  59 
  60     /**
  61      * Returns a {@link BufferedImage} with a data layout and color model
  62      * compatible with this <code>GraphicsConfiguration</code>.  This
  63      * method has nothing to do with memory-mapping
  64      * a device.  The returned <code>BufferedImage</code> has
  65      * a layout and color model that is closest to this native device
  66      * configuration and can therefore be optimally blitted to this
  67      * device.
  68      * @param width the width of the returned <code>BufferedImage</code>
  69      * @param height the height of the returned <code>BufferedImage</code>
  70      * @return a <code>BufferedImage</code> whose data layout and color
  71      * model is compatible with this <code>GraphicsConfiguration</code>.
  72      */
  73     public BufferedImage createCompatibleImage(int width, int height) {
  74         return createCompatibleImage(width, height, Transparency.OPAQUE);
  75     }
  76 
  77     /**
  78      * Returns a {@link VolatileImage} with a data layout and color model
  79      * compatible with this <code>GraphicsConfiguration</code>.
  80      * The returned <code>VolatileImage</code>
  81      * may have data that is stored optimally for the underlying graphics
  82      * device and may therefore benefit from platform-specific rendering
  83      * acceleration.
  84      * @param width the width of the returned <code>VolatileImage</code>
  85      * @param height the height of the returned <code>VolatileImage</code>
  86      * @return a <code>VolatileImage</code> whose data layout and color
  87      * model is compatible with this <code>GraphicsConfiguration</code>.
  88      * @see Component#createVolatileImage(int, int)
  89      */
  90     public VolatileImage createCompatibleVolatileImage(int width, int height) {
  91         return createCompatibleVolatileImage(width, height, Transparency.OPAQUE);
  92     }
  93 
  94     // empty implementation (this should not be called)
  95     public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency) {
  96         return null;
  97     }
  98 
  99     /**
 100      * Returns a <code>BufferedImage</code> that supports the specified
 101      * transparency and has a data layout and color model
 102      * compatible with this <code>GraphicsConfiguration</code>.  This
 103      * method has nothing to do with memory-mapping
 104      * a device. The returned <code>BufferedImage</code> has a layout and
 105      * color model that can be optimally blitted to a device
 106      * with this <code>GraphicsConfiguration</code>.
 107      * @param width the width of the returned <code>BufferedImage</code>
 108      * @param height the height of the returned <code>BufferedImage</code>
 109      * @param transparency the specified transparency mode
 110      * @return a <code>BufferedImage</code> whose data layout and color
 111      * model is compatible with this <code>GraphicsConfiguration</code>
 112      * and also supports the specified transparency.
 113      * @see Transparency#OPAQUE
 114      * @see Transparency#BITMASK
 115      * @see Transparency#TRANSLUCENT
 116      */
 117     public BufferedImage createCompatibleImage(int width, int height, int transparency) {
 118         //+++gdb what to do?
 119         return null;
 120     }
 121 
 122     /**
 123      * Returns the {@link ColorModel} associated with this
 124      * <code>GraphicsConfiguration</code>.
 125      * @return a <code>ColorModel</code> object that is associated with
 126      * this <code>GraphicsConfiguration</code>.
 127      */
 128     public ColorModel getColorModel() {
 129         return getColorModel(Transparency.OPAQUE);
 130     }
 131 
 132     /**
 133      * Returns the <code>ColorModel</code> associated with this
 134      * <code>GraphicsConfiguration</code> that supports the specified
 135      * transparency.
 136      * @param transparency the specified transparency mode
 137      * @return a <code>ColorModel</code> object that is associated with
 138      * this <code>GraphicsConfiguration</code> and supports the
 139      * specified transparency.
 140      */
 141     public ColorModel getColorModel(int transparency) {
 142         return ColorModel.getRGBdefault();
 143     }
 144 
 145     /**
 146      * Returns the default {@link AffineTransform} for this
 147      * <code>GraphicsConfiguration</code>. This
 148      * <code>AffineTransform</code> is typically the Identity transform
 149      * for most normal screens.  The default <code>AffineTransform</code>
 150      * maps coordinates onto the device such that 72 user space
 151      * coordinate units measure approximately 1 inch in device
 152      * space.  The normalizing transform can be used to make
 153      * this mapping more exact.  Coordinates in the coordinate space
 154      * defined by the default <code>AffineTransform</code> for screen and
 155      * printer devices have the origin in the upper left-hand corner of
 156      * the target region of the device, with X coordinates
 157      * increasing to the right and Y coordinates increasing downwards.
 158      * For image buffers not associated with a device, such as those not
 159      * created by <code>createCompatibleImage</code>,
 160      * this <code>AffineTransform</code> is the Identity transform.
 161      * @return the default <code>AffineTransform</code> for this
 162      * <code>GraphicsConfiguration</code>.
 163      */
 164     public AffineTransform getDefaultTransform() {
 165         return new AffineTransform();
 166     }
 167 
 168     /**
 169      *
 170      * Returns a <code>AffineTransform</code> that can be concatenated
 171      * with the default <code>AffineTransform</code>
 172      * of a <code>GraphicsConfiguration</code> so that 72 units in user
 173      * space equals 1 inch in device space.
 174      * <p>
 175      * For a particular {@link Graphics2D}, g, one
 176      * can reset the transformation to create
 177      * such a mapping by using the following pseudocode:
 178      * <pre>
 179      *      GraphicsConfiguration gc = g.getGraphicsConfiguration();
 180      *
 181      *      g.setTransform(gc.getDefaultTransform());
 182      *      g.transform(gc.getNormalizingTransform());
 183      * </pre>
 184      * Note that sometimes this <code>AffineTransform</code> is identity,
 185      * such as for printers or metafile output, and that this
 186      * <code>AffineTransform</code> is only as accurate as the information
 187      * supplied by the underlying system.  For image buffers not
 188      * associated with a device, such as those not created by
 189      * <code>createCompatibleImage</code>, this
 190      * <code>AffineTransform</code> is the Identity transform
 191      * since there is no valid distance measurement.
 192      * @return an <code>AffineTransform</code> to concatenate to the
 193      * default <code>AffineTransform</code> so that 72 units in user
 194      * space is mapped to 1 inch in device space.
 195      */
 196     public AffineTransform getNormalizingTransform() {
 197         return new AffineTransform();
 198     }
 199 
 200     /**
 201      * Returns the bounds of the <code>GraphicsConfiguration</code>
 202      * in the device coordinates. In a multi-screen environment
 203      * with a virtual device, the bounds can have negative X
 204      * or Y origins.
 205      * @return the bounds of the area covered by this
 206      * <code>GraphicsConfiguration</code>.
 207      * @since 1.3
 208      */
 209     public Rectangle getBounds() {
 210         return new Rectangle(0, 0, (int)pf.getWidth(), (int)pf.getHeight());
 211     }
 212 }


  32 
  33 public class CPrinterGraphicsConfig extends GraphicsConfiguration {
  34     public static CPrinterGraphicsConfig getConfig(PageFormat pf) {
  35         return new CPrinterGraphicsConfig(pf);
  36     }
  37 
  38     GraphicsDevice gd;
  39     PageFormat pf;
  40 
  41     public CPrinterGraphicsConfig(PageFormat pf) {
  42         this.gd = new CPrinterDevice(this);
  43         this.pf = pf;
  44     }
  45 
  46     public PageFormat getPageFormat() {
  47         return pf;
  48     }
  49 
  50     /**
  51      * Returns the {@link GraphicsDevice} associated with this
  52      * {@code GraphicsConfiguration}.
  53      * @return a {@code GraphicsDevice} object that is
  54      * associated with this {@code GraphicsConfiguration}.
  55      */
  56     public GraphicsDevice getDevice() {
  57         return gd;
  58     }
  59 
  60     /**
  61      * Returns a {@link BufferedImage} with a data layout and color model
  62      * compatible with this {@code GraphicsConfiguration}.  This
  63      * method has nothing to do with memory-mapping
  64      * a device.  The returned {@code BufferedImage} has
  65      * a layout and color model that is closest to this native device
  66      * configuration and can therefore be optimally blitted to this
  67      * device.
  68      * @param width the width of the returned {@code BufferedImage}
  69      * @param height the height of the returned {@code BufferedImage}
  70      * @return a {@code BufferedImage} whose data layout and color
  71      * model is compatible with this {@code GraphicsConfiguration}.
  72      */
  73     public BufferedImage createCompatibleImage(int width, int height) {
  74         return createCompatibleImage(width, height, Transparency.OPAQUE);
  75     }
  76 
  77     /**
  78      * Returns a {@link VolatileImage} with a data layout and color model
  79      * compatible with this {@code GraphicsConfiguration}.
  80      * The returned {@code VolatileImage}
  81      * may have data that is stored optimally for the underlying graphics
  82      * device and may therefore benefit from platform-specific rendering
  83      * acceleration.
  84      * @param width the width of the returned {@code VolatileImage}
  85      * @param height the height of the returned {@code VolatileImage}
  86      * @return a {@code VolatileImage} whose data layout and color
  87      * model is compatible with this {@code GraphicsConfiguration}.
  88      * @see Component#createVolatileImage(int, int)
  89      */
  90     public VolatileImage createCompatibleVolatileImage(int width, int height) {
  91         return createCompatibleVolatileImage(width, height, Transparency.OPAQUE);
  92     }
  93 
  94     // empty implementation (this should not be called)
  95     public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency) {
  96         return null;
  97     }
  98 
  99     /**
 100      * Returns a {@code BufferedImage} that supports the specified
 101      * transparency and has a data layout and color model
 102      * compatible with this {@code GraphicsConfiguration}.  This
 103      * method has nothing to do with memory-mapping
 104      * a device. The returned {@code BufferedImage} has a layout and
 105      * color model that can be optimally blitted to a device
 106      * with this {@code GraphicsConfiguration}.
 107      * @param width the width of the returned {@code BufferedImage}
 108      * @param height the height of the returned {@code BufferedImage}
 109      * @param transparency the specified transparency mode
 110      * @return a {@code BufferedImage} whose data layout and color
 111      * model is compatible with this {@code GraphicsConfiguration}
 112      * and also supports the specified transparency.
 113      * @see Transparency#OPAQUE
 114      * @see Transparency#BITMASK
 115      * @see Transparency#TRANSLUCENT
 116      */
 117     public BufferedImage createCompatibleImage(int width, int height, int transparency) {
 118         //+++gdb what to do?
 119         return null;
 120     }
 121 
 122     /**
 123      * Returns the {@link ColorModel} associated with this
 124      * {@code GraphicsConfiguration}.
 125      * @return a {@code ColorModel} object that is associated with
 126      * this {@code GraphicsConfiguration}.
 127      */
 128     public ColorModel getColorModel() {
 129         return getColorModel(Transparency.OPAQUE);
 130     }
 131 
 132     /**
 133      * Returns the {@code ColorModel} associated with this
 134      * {@code GraphicsConfiguration} that supports the specified
 135      * transparency.
 136      * @param transparency the specified transparency mode
 137      * @return a {@code ColorModel} object that is associated with
 138      * this {@code GraphicsConfiguration} and supports the
 139      * specified transparency.
 140      */
 141     public ColorModel getColorModel(int transparency) {
 142         return ColorModel.getRGBdefault();
 143     }
 144 
 145     /**
 146      * Returns the default {@link AffineTransform} for this
 147      * {@code GraphicsConfiguration}. This
 148      * {@code AffineTransform} is typically the Identity transform
 149      * for most normal screens.  The default {@code AffineTransform}
 150      * maps coordinates onto the device such that 72 user space
 151      * coordinate units measure approximately 1 inch in device
 152      * space.  The normalizing transform can be used to make
 153      * this mapping more exact.  Coordinates in the coordinate space
 154      * defined by the default {@code AffineTransform} for screen and
 155      * printer devices have the origin in the upper left-hand corner of
 156      * the target region of the device, with X coordinates
 157      * increasing to the right and Y coordinates increasing downwards.
 158      * For image buffers not associated with a device, such as those not
 159      * created by {@code createCompatibleImage},
 160      * this {@code AffineTransform} is the Identity transform.
 161      * @return the default {@code AffineTransform} for this
 162      * {@code GraphicsConfiguration}.
 163      */
 164     public AffineTransform getDefaultTransform() {
 165         return new AffineTransform();
 166     }
 167 
 168     /**
 169      *
 170      * Returns a {@code AffineTransform} that can be concatenated
 171      * with the default {@code AffineTransform}
 172      * of a {@code GraphicsConfiguration} so that 72 units in user
 173      * space equals 1 inch in device space.
 174      * <p>
 175      * For a particular {@link Graphics2D}, g, one
 176      * can reset the transformation to create
 177      * such a mapping by using the following pseudocode:
 178      * <pre>
 179      *      GraphicsConfiguration gc = g.getGraphicsConfiguration();
 180      *
 181      *      g.setTransform(gc.getDefaultTransform());
 182      *      g.transform(gc.getNormalizingTransform());
 183      * </pre>
 184      * Note that sometimes this {@code AffineTransform} is identity,
 185      * such as for printers or metafile output, and that this
 186      * {@code AffineTransform} is only as accurate as the information
 187      * supplied by the underlying system.  For image buffers not
 188      * associated with a device, such as those not created by
 189      * {@code createCompatibleImage}, this
 190      * {@code AffineTransform} is the Identity transform
 191      * since there is no valid distance measurement.
 192      * @return an {@code AffineTransform} to concatenate to the
 193      * default {@code AffineTransform} so that 72 units in user
 194      * space is mapped to 1 inch in device space.
 195      */
 196     public AffineTransform getNormalizingTransform() {
 197         return new AffineTransform();
 198     }
 199 
 200     /**
 201      * Returns the bounds of the {@code GraphicsConfiguration}
 202      * in the device coordinates. In a multi-screen environment
 203      * with a virtual device, the bounds can have negative X
 204      * or Y origins.
 205      * @return the bounds of the area covered by this
 206      * {@code GraphicsConfiguration}.
 207      * @since 1.3
 208      */
 209     public Rectangle getBounds() {
 210         return new Rectangle(0, 0, (int)pf.getWidth(), (int)pf.getHeight());
 211     }
 212 }
< prev index next >