< prev index next >

src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java

Print this page




 116                                 int colormap, boolean doubleBuffer)
 117     {
 118         this.screen = device;
 119         this.visual = visualnum;
 120         this.doubleBuffer = doubleBuffer;
 121         this.depth = depth;
 122         this.colormap = colormap;
 123         init (visualnum, screen.getScreen());
 124 
 125         // add a record to the Disposer so that we destroy the native
 126         // AwtGraphicsConfigData when this object goes away (i.e. after a
 127         // display change event)
 128         long x11CfgData = getAData();
 129         Disposer.addRecord(disposerReferent,
 130                            new X11GCDisposerRecord(x11CfgData));
 131     }
 132 
 133     /**
 134      * Return the graphics device associated with this configuration.
 135      */
 136     public GraphicsDevice getDevice() {
 137         return screen;
 138     }
 139 
 140     /**
 141      * Returns the visual id associated with this configuration.
 142      */
 143     public int getVisual () {
 144         return visual;
 145     }
 146 
 147 
 148     /**
 149      * Returns the depth associated with this configuration.
 150      */
 151     public int getDepth () {
 152         return depth;
 153     }
 154 
 155     /**
 156      * Returns the colormap associated with this configuration.


 239 
 240     public static ComponentColorModel createABGRCCM() {
 241         ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
 242         int[] nBits = {8, 8, 8, 8};
 243         int[] bOffs = {3, 2, 1, 0};
 244         return new ComponentColorModel(cs, nBits, true, true,
 245                                        Transparency.TRANSLUCENT,
 246                                        DataBuffer.TYPE_BYTE);
 247     }
 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         return new AffineTransform();













 260     }
 261 
 262     /**
 263      *
 264      * Returns a Transform that can be composed with the default Transform
 265      * of a Graphics2D so that 72 units in user space will equal 1 inch
 266      * in device space.
 267      * Given a Graphics2D, g, one can reset the transformation to create
 268      * such a mapping by using the following pseudocode:
 269      * <pre>
 270      *      GraphicsConfiguration gc = g.getGraphicsConfiguration();
 271      *
 272      *      g.setTransform(gc.getDefaultTransform());
 273      *      g.transform(gc.getNormalizingTransform());
 274      * </pre>
 275      * Note that sometimes this Transform will be identity (e.g. for
 276      * printers or metafile output) and that this Transform is only
 277      * as accurate as the information supplied by the underlying system.
 278      * For image buffers, this Transform will be the Identity transform,
 279      * since there is no valid distance measurement.


 291         return aData;
 292     }
 293 
 294     public String toString() {
 295         return ("X11GraphicsConfig[dev="+screen+
 296                 ",vis=0x"+Integer.toHexString(visual)+
 297                 "]");
 298     }
 299 
 300     /*
 301      * Initialize JNI field and method IDs for fields that may be
 302      *  accessed from C.
 303      */
 304     private static native void initIDs();
 305 
 306     static {
 307         initIDs ();
 308     }
 309 
 310     public Rectangle getBounds() {
 311         return pGetBounds(screen.getScreen());







 312     }
 313 
 314     private native Rectangle pGetBounds(int screenNum);
 315 
 316     private static class XDBECapabilities extends BufferCapabilities {
 317         public XDBECapabilities() {
 318             super(imageCaps, imageCaps, FlipContents.UNDEFINED);
 319         }
 320     }
 321 
 322     public BufferCapabilities getBufferCapabilities() {
 323         if (bufferCaps == null) {
 324             if (doubleBuffer) {
 325                 bufferCaps = new XDBECapabilities();
 326             } else {
 327                 bufferCaps = super.getBufferCapabilities();
 328             }
 329         }
 330         return bufferCaps;
 331     }




 116                                 int colormap, boolean doubleBuffer)
 117     {
 118         this.screen = device;
 119         this.visual = visualnum;
 120         this.doubleBuffer = doubleBuffer;
 121         this.depth = depth;
 122         this.colormap = colormap;
 123         init (visualnum, screen.getScreen());
 124 
 125         // add a record to the Disposer so that we destroy the native
 126         // AwtGraphicsConfigData when this object goes away (i.e. after a
 127         // display change event)
 128         long x11CfgData = getAData();
 129         Disposer.addRecord(disposerReferent,
 130                            new X11GCDisposerRecord(x11CfgData));
 131     }
 132 
 133     /**
 134      * Return the graphics device associated with this configuration.
 135      */
 136     public X11GraphicsDevice getDevice() {
 137         return screen;
 138     }
 139 
 140     /**
 141      * Returns the visual id associated with this configuration.
 142      */
 143     public int getVisual () {
 144         return visual;
 145     }
 146 
 147 
 148     /**
 149      * Returns the depth associated with this configuration.
 150      */
 151     public int getDepth () {
 152         return depth;
 153     }
 154 
 155     /**
 156      * Returns the colormap associated with this configuration.


 239 
 240     public static ComponentColorModel createABGRCCM() {
 241         ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
 242         int[] nBits = {8, 8, 8, 8};
 243         int[] bOffs = {3, 2, 1, 0};
 244         return new ComponentColorModel(cs, nBits, true, true,
 245                                        Transparency.TRANSLUCENT,
 246                                        DataBuffer.TYPE_BYTE);
 247     }
 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.


 304         return aData;
 305     }
 306 
 307     public String toString() {
 308         return ("X11GraphicsConfig[dev="+screen+
 309                 ",vis=0x"+Integer.toHexString(visual)+
 310                 "]");
 311     }
 312 
 313     /*
 314      * Initialize JNI field and method IDs for fields that may be
 315      *  accessed from C.
 316      */
 317     private static native void initIDs();
 318 
 319     static {
 320         initIDs ();
 321     }
 322 
 323     public Rectangle getBounds() {
 324         Rectangle rect = pGetBounds(screen.getScreen());
 325         if (getScale() != 1) {
 326             rect.x = scaleDown(rect.x);
 327             rect.y = scaleDown(rect.y);
 328             rect.width = scaleDown(rect.width);
 329             rect.height = scaleDown(rect.height);
 330         }
 331         return rect;
 332     }
 333 
 334     private native Rectangle pGetBounds(int screenNum);
 335 
 336     private static class XDBECapabilities extends BufferCapabilities {
 337         public XDBECapabilities() {
 338             super(imageCaps, imageCaps, FlipContents.UNDEFINED);
 339         }
 340     }
 341 
 342     public BufferCapabilities getBufferCapabilities() {
 343         if (bufferCaps == null) {
 344             if (doubleBuffer) {
 345                 bufferCaps = new XDBECapabilities();
 346             } else {
 347                 bufferCaps = super.getBufferCapabilities();
 348             }
 349         }
 350         return bufferCaps;
 351     }


< prev index next >