1. /*
  2. * @(#)GraphicsConfiguration.java 1.21 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt;
  8. import java.awt.geom.AffineTransform;
  9. import java.awt.image.BufferedImage;
  10. import java.awt.image.ColorModel;
  11. /**
  12. * The <code>GraphicsConfiguration</code> class describes the
  13. * characteristics of a graphics destination such as a printer or monitor.
  14. * There can be many <code>GraphicsConfiguration</code> objects associated
  15. * with a single graphics device. For example, on X11 windowing systems,
  16. * each visual is a different <code>GraphicsConfiguration</code>. On PCs
  17. * and Macintoshes, the different screen resolution/color resolution
  18. * combinations would be different <code>GraphicsConfiguration</code>
  19. * objects.
  20. * @see GraphicsEnvironment
  21. * @see GraphicsDevice
  22. */
  23. /*
  24. * REMIND: What to do about capabilities?
  25. * The
  26. * capabilities of the device can be determined by enumerating the possible
  27. * capabilities and checking if the GraphicsConfiguration
  28. * implements the interface for that capability.
  29. *
  30. * @version 10 Feb 1997
  31. */
  32. public abstract class GraphicsConfiguration {
  33. /**
  34. * This is an abstract class that cannot be instantiated directly.
  35. * Instances must be obtained from a suitable factory or query method.
  36. *
  37. * @see GraphicsDevice#getConfigurations
  38. * @see GraphicsDevice#getDefaultConfiguration
  39. * @see GraphicsDevice#getBestConfiguration
  40. * @see Graphics2D#getDeviceConfiguration
  41. */
  42. protected GraphicsConfiguration() {
  43. }
  44. /**
  45. * Returns the {@link GraphicsDevice} associated with this
  46. * <code>GraphicsConfiguration</code>.
  47. * @return a <code>GraphicsDevice</code> object that is
  48. * associated with this <code>GraphicsConfiguration</code>.
  49. */
  50. public abstract GraphicsDevice getDevice();
  51. /**
  52. * Returns a {@link BufferedImage} with a data layout and color model
  53. * compatible with this <code>GraphicsConfiguration</code>. This
  54. * method has nothing to do with memory-mapping
  55. * a device. The returned <code>BufferedImage</code> has
  56. * a layout and color model that is closest to this native device
  57. * configuration and can therefore be optimally blitted to this
  58. * device.
  59. * @param width the width of the returned <code>BufferedImage</code>
  60. * @param height the height of the returned <code>BufferedImage</code>
  61. * @return a <code>BufferedImage</code> whose data layout and color
  62. * model is compatible with this <code>GraphicsConfiguration</code>.
  63. */
  64. public abstract BufferedImage createCompatibleImage(int width, int height);
  65. /**
  66. * Returns a <code>BufferedImage</code> that supports the specified
  67. * transparency and has a data layout and color model
  68. * compatible with this <code>GraphicsConfiguration</code>. This
  69. * method has nothing to do with memory-mapping
  70. * a device. The returned <code>BufferedImage</code> has a layout and
  71. * color model that can be optimally blitted to a device
  72. * with this <code>GraphicsConfiguration</code>.
  73. * @param width the width of the returned <code>BufferedImage</code>
  74. * @param height the height of the returned <code>BufferedImage</code>
  75. * @param transparency the specified transparency mode
  76. * @return a <code>BufferedImage</code> whose data layout and color
  77. * model is compatible with this <code>GraphicsConfiguration</code>
  78. * and also supports the specified transparency.
  79. * @see Transparency#OPAQUE
  80. * @see Transparency#BITMASK
  81. * @see Transparency#TRANSLUCENT
  82. */
  83. public abstract BufferedImage createCompatibleImage(int width, int height,
  84. int transparency);
  85. /**
  86. * Returns the {@link ColorModel} associated with this
  87. * <code>GraphicsConfiguration</code>.
  88. * @return a <code>ColorModel</code> object that is associated with
  89. * this <code>GraphicsConfiguration</code>.
  90. */
  91. public abstract ColorModel getColorModel();
  92. /**
  93. * Returns the <code>ColorModel</code> associated with this
  94. * <code>GraphicsConfiguration</code> that supports the specified
  95. * transparency.
  96. * @param transparency the specified transparency mode
  97. * @return a <code>ColorModel</code> object that is associated with
  98. * this <code>GraphicsConfiguration</code> and supports the
  99. * specified transparency.
  100. */
  101. public abstract ColorModel getColorModel(int transparency);
  102. /**
  103. * Returns the default {@link AffineTransform} for this
  104. * <code>GraphicsConfiguration</code>. This
  105. * <code>AffineTransform</code> is typically the Identity transform
  106. * for most normal screens. The default <code>AffineTransform</code>
  107. * maps coordinates onto the device such that 72 user space
  108. * coordinate units measure approximately 1 inch in device
  109. * space. The normalizing transform can be used to make
  110. * this mapping more exact. Coordinates in the coordinate space
  111. * defined by the default <code>AffineTransform</code> for screen and
  112. * printer devices have the origin in the upper left-hand corner of
  113. * the target region of the device, with X coordinates
  114. * increasing to the right and Y coordinates increasing downwards.
  115. * For image buffers not associated with a device, such as those not
  116. * created by <code>createCompatibleImage</code>,
  117. * this <code>AffineTransform</code> is the Identity transform.
  118. * @return the default <code>AffineTransform</code> for this
  119. * <code>GraphicsConfiguration</code>.
  120. */
  121. public abstract AffineTransform getDefaultTransform();
  122. /**
  123. *
  124. * Returns a <code>AffineTransform</code> that can be concatenated
  125. * with the default <code>AffineTransform</code>
  126. * of a <code>GraphicsConfiguration</code> so that 72 units in user
  127. * space equals 1 inch in device space.
  128. * <p>
  129. * For a particular {@link Graphics2D}, g, one
  130. * can reset the transformation to create
  131. * such a mapping by using the following pseudocode:
  132. * <pre>
  133. * GraphicsConfiguration gc = g.getGraphicsConfiguration();
  134. *
  135. * g.setTransform(gc.getDefaultTransform());
  136. * g.transform(gc.getNormalizingTransform());
  137. * </pre>
  138. * Note that sometimes this <code>AffineTransform</code> is identity,
  139. * such as for printers or metafile output, and that this
  140. * <code>AffineTransform</code> is only as accurate as the information
  141. * supplied by the underlying system. For image buffers not
  142. * associated with a device, such as those not created by
  143. * <code>createCompatibleImage</code>, this
  144. * <code>AffineTransform</code> is the Identity transform
  145. * since there is no valid distance measurement.
  146. * @return an <code>AffineTransform</code> to concatenate to the
  147. * default <code>AffineTransform</code> so that 72 units in user
  148. * space is mapped to 1 inch in device space.
  149. */
  150. public abstract AffineTransform getNormalizingTransform();
  151. }