home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / sun / awt / Win32GraphicsDevice.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.4 KB  |  124 lines

  1. package sun.awt;
  2.  
  3. import java.awt.Component;
  4. import java.awt.GraphicsConfiguration;
  5. import java.awt.GraphicsDevice;
  6. import java.awt.peer.ComponentPeer;
  7. import java.lang.ref.Reference;
  8. import java.lang.ref.WeakReference;
  9. import java.util.Enumeration;
  10. import java.util.Vector;
  11.  
  12. public class Win32GraphicsDevice extends GraphicsDevice {
  13.    int screen;
  14.    GraphicsConfiguration[] configs;
  15.    GraphicsConfiguration defaultConfig;
  16.    int defaultPixID = -1;
  17.    private Vector nonDefaultGCs;
  18.  
  19.    public Win32GraphicsDevice(int var1) {
  20.       this.screen = var1;
  21.    }
  22.  
  23.    public int getType() {
  24.       return 0;
  25.    }
  26.  
  27.    public int getScreen() {
  28.       return this.screen;
  29.    }
  30.  
  31.    public String getIDstring() {
  32.       return "\\Display" + this.screen;
  33.    }
  34.  
  35.    public GraphicsConfiguration[] getConfigurations() {
  36.       if (this.configs == null) {
  37.          int var1 = this.getMaxConfigs(this.screen);
  38.          this.defaultPixID = this.getDefaultPixID(this.screen);
  39.          Vector var2 = new Vector(var1);
  40.          if (this.defaultPixID == 0) {
  41.             this.defaultConfig = Win32GraphicsConfig.getConfig(this, this.defaultPixID);
  42.             var2.addElement(this.defaultConfig);
  43.          } else {
  44.             for(int var3 = 1; var3 <= var1; ++var3) {
  45.                if (this.isPixFmtSupported(var3, this.screen)) {
  46.                   if (var3 == this.defaultPixID) {
  47.                      this.defaultConfig = Win32GraphicsConfig.getConfig(this, var3);
  48.                      var2.addElement(this.defaultConfig);
  49.                   } else {
  50.                      var2.addElement(Win32GraphicsConfig.getConfig(this, var3));
  51.                   }
  52.                }
  53.             }
  54.          }
  55.  
  56.          this.configs = new GraphicsConfiguration[var2.size()];
  57.          var2.copyInto(this.configs);
  58.       }
  59.  
  60.       return this.configs;
  61.    }
  62.  
  63.    protected native int getMaxConfigs(int var1);
  64.  
  65.    protected native boolean isPixFmtSupported(int var1, int var2);
  66.  
  67.    protected native int getDefaultPixID(int var1);
  68.  
  69.    public GraphicsConfiguration getDefaultConfiguration() {
  70.       if (this.defaultConfig == null) {
  71.          this.defaultPixID = this.getDefaultPixID(this.screen);
  72.          this.defaultConfig = Win32GraphicsConfig.getConfig(this, this.defaultPixID);
  73.       }
  74.  
  75.       return this.defaultConfig;
  76.    }
  77.  
  78.    public String toString() {
  79.       return "Win32GraphicsDevice[screen=" + this.screen + "]";
  80.    }
  81.  
  82.    public void displayModeChanged() {
  83.       this.defaultConfig = null;
  84.       this.defaultPixID = this.getDefaultPixID(this.screen);
  85.       this.configs = null;
  86.       this.invalidateGCs();
  87.    }
  88.  
  89.    public synchronized void addNonDefaultGC(WeakReference var1) {
  90.       if (((Reference)var1).get() instanceof Component) {
  91.          if (this.nonDefaultGCs == null) {
  92.             this.nonDefaultGCs = new Vector(1);
  93.          }
  94.  
  95.          this.nonDefaultGCs.addElement(var1);
  96.       }
  97.  
  98.    }
  99.  
  100.    private void invalidateGCs() {
  101.       if (this.nonDefaultGCs != null) {
  102.          Enumeration var5 = this.nonDefaultGCs.elements();
  103.  
  104.          while(var5.hasMoreElements()) {
  105.             WeakReference var1 = (WeakReference)var5.nextElement();
  106.             Object var2 = ((Reference)var1).get();
  107.             if (var2 != null && var2 instanceof Component) {
  108.                Component var3 = (Component)var2;
  109.                this.resetComponentGC(var3);
  110.                ComponentPeer var4 = var3.getPeer();
  111.                if (var4 != null) {
  112.                   this.resetPeerGC(var4);
  113.                }
  114.             }
  115.          }
  116.       }
  117.  
  118.    }
  119.  
  120.    private native void resetComponentGC(Component var1);
  121.  
  122.    private native void resetPeerGC(ComponentPeer var1);
  123. }
  124.