32 import java.awt.GraphicsConfiguration;
33 import java.awt.GraphicsDevice;
34 import java.awt.Image;
35 import java.awt.ImageCapabilities;
36 import java.awt.Transparency;
37 import java.awt.image.ColorModel;
38 import java.awt.color.ColorSpace;
39 import java.awt.image.ComponentColorModel;
40 import java.awt.image.DirectColorModel;
41 import java.awt.image.DataBuffer;
42 import java.awt.image.VolatileImage;
43 import java.awt.image.WritableRaster;
44 import java.awt.geom.AffineTransform;
45 import java.awt.Rectangle;
46 import sun.java2d.Disposer;
47 import sun.java2d.DisposerRecord;
48 import sun.java2d.SurfaceData;
49 import sun.java2d.loops.RenderLoops;
50 import sun.java2d.loops.SurfaceType;
51 import sun.java2d.loops.CompositeType;
52 import sun.java2d.x11.X11SurfaceData;
53 import sun.awt.image.OffScreenImage;
54 import sun.awt.image.SunVolatileImage;
55 import sun.awt.image.SurfaceManager;
56
57 /**
58 * This is an implementation of a GraphicsConfiguration object for a
59 * single X11 visual.
60 *
61 * @see java.awt.GraphicsEnvironment
62 * @see GraphicsDevice
63 */
64 public class X11GraphicsConfig extends GraphicsConfiguration
65 implements SurfaceManager.ProxiedGraphicsConfig
66 {
67 protected X11GraphicsDevice screen;
68 protected int visual;
69 int depth;
70 int colormap;
71 ColorModel colorModel;
248
249 /**
250 * Returns the default Transform for this configuration. This
251 * Transform is typically the Identity transform for most normal
252 * screens. Device coordinates for screen and printer devices will
253 * have the origin in the upper left-hand corner of the target region of
254 * the device, with X coordinates
255 * increasing to the right and Y coordinates increasing downwards.
256 * For image buffers, this Transform will be the Identity transform.
257 */
258 public AffineTransform getDefaultTransform() {
259 double scale = getScale();
260 return AffineTransform.getScaleInstance(scale, scale);
261 }
262
263 public int getScale() {
264 return getDevice().getScaleFactor();
265 }
266
267 public int scaleUp(int x) {
268 return x * getScale();
269 }
270
271 public int scaleDown(int x) {
272 return x / getScale();
273 }
274
275 /**
276 *
277 * Returns a Transform that can be composed with the default Transform
278 * of a Graphics2D so that 72 units in user space will equal 1 inch
279 * in device space.
280 * Given a Graphics2D, g, one can reset the transformation to create
281 * such a mapping by using the following pseudocode:
282 * <pre>
283 * GraphicsConfiguration gc = g.getGraphicsConfiguration();
284 *
285 * g.setTransform(gc.getDefaultTransform());
286 * g.transform(gc.getNormalizingTransform());
287 * </pre>
288 * Note that sometimes this Transform will be identity (e.g. for
289 * printers or metafile output) and that this Transform is only
290 * as accurate as the information supplied by the underlying system.
291 * For image buffers, this Transform will be the Identity transform,
292 * since there is no valid distance measurement.
|
32 import java.awt.GraphicsConfiguration;
33 import java.awt.GraphicsDevice;
34 import java.awt.Image;
35 import java.awt.ImageCapabilities;
36 import java.awt.Transparency;
37 import java.awt.image.ColorModel;
38 import java.awt.color.ColorSpace;
39 import java.awt.image.ComponentColorModel;
40 import java.awt.image.DirectColorModel;
41 import java.awt.image.DataBuffer;
42 import java.awt.image.VolatileImage;
43 import java.awt.image.WritableRaster;
44 import java.awt.geom.AffineTransform;
45 import java.awt.Rectangle;
46 import sun.java2d.Disposer;
47 import sun.java2d.DisposerRecord;
48 import sun.java2d.SurfaceData;
49 import sun.java2d.loops.RenderLoops;
50 import sun.java2d.loops.SurfaceType;
51 import sun.java2d.loops.CompositeType;
52 import sun.java2d.pipe.Region;
53 import sun.java2d.x11.X11SurfaceData;
54 import sun.awt.image.OffScreenImage;
55 import sun.awt.image.SunVolatileImage;
56 import sun.awt.image.SurfaceManager;
57
58 /**
59 * This is an implementation of a GraphicsConfiguration object for a
60 * single X11 visual.
61 *
62 * @see java.awt.GraphicsEnvironment
63 * @see GraphicsDevice
64 */
65 public class X11GraphicsConfig extends GraphicsConfiguration
66 implements SurfaceManager.ProxiedGraphicsConfig
67 {
68 protected X11GraphicsDevice screen;
69 protected int visual;
70 int depth;
71 int colormap;
72 ColorModel colorModel;
249
250 /**
251 * Returns the default Transform for this configuration. This
252 * Transform is typically the Identity transform for most normal
253 * screens. Device coordinates for screen and printer devices will
254 * have the origin in the upper left-hand corner of the target region of
255 * the device, with X coordinates
256 * increasing to the right and Y coordinates increasing downwards.
257 * For image buffers, this Transform will be the Identity transform.
258 */
259 public AffineTransform getDefaultTransform() {
260 double scale = getScale();
261 return AffineTransform.getScaleInstance(scale, scale);
262 }
263
264 public int getScale() {
265 return getDevice().getScaleFactor();
266 }
267
268 public int scaleUp(int x) {
269 return Region.clipRound(x * (double)getScale());
270 }
271
272 public int scaleDown(int x) {
273 return Region.clipRound(x / (double)getScale());
274 }
275
276 /**
277 *
278 * Returns a Transform that can be composed with the default Transform
279 * of a Graphics2D so that 72 units in user space will equal 1 inch
280 * in device space.
281 * Given a Graphics2D, g, one can reset the transformation to create
282 * such a mapping by using the following pseudocode:
283 * <pre>
284 * GraphicsConfiguration gc = g.getGraphicsConfiguration();
285 *
286 * g.setTransform(gc.getDefaultTransform());
287 * g.transform(gc.getNormalizingTransform());
288 * </pre>
289 * Note that sometimes this Transform will be identity (e.g. for
290 * printers or metafile output) and that this Transform is only
291 * as accurate as the information supplied by the underlying system.
292 * For image buffers, this Transform will be the Identity transform,
293 * since there is no valid distance measurement.
|