home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / awt / Cursor.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  6.0 KB  |  189 lines

  1. package java.awt;
  2.  
  3. import java.io.File;
  4. import java.io.Serializable;
  5. import java.security.AccessController;
  6. import java.util.Hashtable;
  7. import java.util.Properties;
  8. import java.util.StringTokenizer;
  9. import sun.security.action.GetPropertyAction;
  10.  
  11. public class Cursor implements Serializable {
  12.    public static final int DEFAULT_CURSOR = 0;
  13.    public static final int CROSSHAIR_CURSOR = 1;
  14.    public static final int TEXT_CURSOR = 2;
  15.    public static final int WAIT_CURSOR = 3;
  16.    public static final int SW_RESIZE_CURSOR = 4;
  17.    public static final int SE_RESIZE_CURSOR = 5;
  18.    public static final int NW_RESIZE_CURSOR = 6;
  19.    public static final int NE_RESIZE_CURSOR = 7;
  20.    public static final int N_RESIZE_CURSOR = 8;
  21.    public static final int S_RESIZE_CURSOR = 9;
  22.    public static final int W_RESIZE_CURSOR = 10;
  23.    public static final int E_RESIZE_CURSOR = 11;
  24.    public static final int HAND_CURSOR = 12;
  25.    public static final int MOVE_CURSOR = 13;
  26.    protected static Cursor[] predefined = new Cursor[14];
  27.    static final String[][] cursorProperties = new String[][]{{"AWT.DefaultCursor", "Default Cursor"}, {"AWT.CrosshairCursor", "Crosshair Cursor"}, {"AWT.TextCursor", "Text Cursor"}, {"AWT.WaitCursor", "Wait Cursor"}, {"AWT.SWResizeCursor", "Southwest Resize Cursor"}, {"AWT.SEResizeCursor", "Southeast Resize Cursor"}, {"AWT.NWResizeCursor", "Northwest Resize Cursor"}, {"AWT.NEResizeCursor", "Northeast Resize Cursor"}, {"AWT.NResizeCursor", "North Resize Cursor"}, {"AWT.SResizeCursor", "South Resize Cursor"}, {"AWT.WResizeCursor", "West Resize Cursor"}, {"AWT.EResizeCursor", "East Resize Cursor"}, {"AWT.HandCursor", "Hand Cursor"}, {"AWT.MoveCursor", "Move Cursor"}};
  28.    int type = 0;
  29.    public static final int CUSTOM_CURSOR = -1;
  30.    private static final Hashtable systemCustomCursors = new Hashtable(1);
  31.    private static final String systemCustomCursorDirPrefix = initCursorDir();
  32.    private static final String systemCustomCursorPropertiesFile;
  33.    private static Properties systemCustomCursorProperties;
  34.    private static final String CursorDotPrefix = "Cursor.";
  35.    private static final String DotFileSuffix = ".File";
  36.    private static final String DotHotspotSuffix = ".HotSpot";
  37.    private static final String DotNameSuffix = ".Name";
  38.    private static final long serialVersionUID = 8028237497568985504L;
  39.    private transient long pData;
  40.    protected String name;
  41.  
  42.    private static String initCursorDir() {
  43.       String var0 = (String)AccessController.doPrivileged(new GetPropertyAction("java.home"));
  44.       return var0 + File.separator + "lib" + File.separator + "images" + File.separator + "cursors" + File.separator;
  45.    }
  46.  
  47.    private static native void initIDs();
  48.  
  49.    public static Cursor getPredefinedCursor(int var0) {
  50.       if (var0 >= 0 && var0 <= 13) {
  51.          if (predefined[var0] == null) {
  52.             predefined[var0] = new Cursor(var0);
  53.          }
  54.  
  55.          return predefined[var0];
  56.       } else {
  57.          throw new IllegalArgumentException("illegal cursor type");
  58.       }
  59.    }
  60.  
  61.    public static Cursor getSystemCustomCursor(String var0) throws AWTException {
  62.       Cursor var1 = (Cursor)systemCustomCursors.get(var0);
  63.       if (var1 == null) {
  64.          Hashtable var2 = systemCustomCursors;
  65.          synchronized(var2) {
  66.             if (systemCustomCursorProperties == null) {
  67.                loadSystemCustomCursorProperties();
  68.             }
  69.          }
  70.  
  71.          String var3 = "Cursor." + var0;
  72.          String var4 = var3 + ".File";
  73.          if (!systemCustomCursorProperties.containsKey(var4)) {
  74.             System.err.println("Cursor.getSystemCustomCursor(" + var0 + ") returned null");
  75.             return null;
  76.          }
  77.  
  78.          String var5 = systemCustomCursorProperties.getProperty(var4);
  79.          String var6 = systemCustomCursorProperties.getProperty(var3 + ".Name");
  80.          if (var6 == null) {
  81.             var6 = var0;
  82.          }
  83.  
  84.          String var7 = systemCustomCursorProperties.getProperty(var3 + ".HotSpot");
  85.          if (var7 == null) {
  86.             throw new AWTException("no hotspot property defined for cursor: " + var0);
  87.          }
  88.  
  89.          StringTokenizer var8 = new StringTokenizer(var7, ",");
  90.          if (var8.countTokens() != 2) {
  91.             throw new AWTException("failed to parse hotspot property for cursor: " + var0);
  92.          }
  93.  
  94.          int var9 = 0;
  95.          int var10 = 0;
  96.  
  97.          try {
  98.             var9 = Integer.parseInt(var8.nextToken());
  99.             var10 = Integer.parseInt(var8.nextToken());
  100.          } catch (NumberFormatException var15) {
  101.             throw new AWTException("failed to parse hotspot property for cursor: " + var0);
  102.          }
  103.  
  104.          try {
  105.             var1 = (Cursor)AccessController.doPrivileged(new 1(var5, var9, var10, var6));
  106.          } catch (Exception var14) {
  107.             throw new AWTException("Exception: " + var14.getClass() + " " + ((Throwable)var14).getMessage() + " occurred while creating cursor " + var0);
  108.          }
  109.  
  110.          if (var1 == null) {
  111.             System.err.println("Cursor.getSystemCustomCursor(" + var0 + ") returned null");
  112.          } else {
  113.             systemCustomCursors.put(var0, var1);
  114.          }
  115.       }
  116.  
  117.       return var1;
  118.    }
  119.  
  120.    public static Cursor getDefaultCursor() {
  121.       return getPredefinedCursor(0);
  122.    }
  123.  
  124.    public Cursor(int var1) {
  125.       if (var1 >= 0 && var1 <= 13) {
  126.          this.type = var1;
  127.          this.name = Toolkit.getProperty(cursorProperties[var1][0], cursorProperties[var1][1]);
  128.       } else {
  129.          throw new IllegalArgumentException("illegal cursor type");
  130.       }
  131.    }
  132.  
  133.    protected Cursor(String var1) {
  134.       this.type = -1;
  135.       this.name = var1;
  136.    }
  137.  
  138.    public int getType() {
  139.       return this.type;
  140.    }
  141.  
  142.    public String getName() {
  143.       return this.name;
  144.    }
  145.  
  146.    public String toString() {
  147.       return this.getClass().getName() + "[" + this.getName() + "]";
  148.    }
  149.  
  150.    private static void loadSystemCustomCursorProperties() throws AWTException {
  151.       Hashtable var0 = systemCustomCursors;
  152.       synchronized(var0) {
  153.          systemCustomCursorProperties = new Properties();
  154.  
  155.          try {
  156.             AccessController.doPrivileged(new 2());
  157.          } catch (Exception var3) {
  158.             systemCustomCursorProperties = null;
  159.             throw new AWTException("Exception: " + var3.getClass() + " " + ((Throwable)var3).getMessage() + " occurred while loading: " + systemCustomCursorPropertiesFile);
  160.          }
  161.  
  162.       }
  163.    }
  164.  
  165.    protected native void finalize() throws Throwable;
  166.  
  167.    // $FF: synthetic method
  168.    static String access$000() {
  169.       return systemCustomCursorDirPrefix;
  170.    }
  171.  
  172.    // $FF: synthetic method
  173.    static String access$100() {
  174.       return systemCustomCursorPropertiesFile;
  175.    }
  176.  
  177.    // $FF: synthetic method
  178.    static Properties access$200() {
  179.       return systemCustomCursorProperties;
  180.    }
  181.  
  182.    static {
  183.       systemCustomCursorPropertiesFile = systemCustomCursorDirPrefix + "cursors.properties";
  184.       systemCustomCursorProperties = null;
  185.       Toolkit.loadLibraries();
  186.       initIDs();
  187.    }
  188. }
  189.