public static void loadFromText(String text) {
   try {
     if (singleton == null) {
       // default behavior is to create a singleton for
       // an in memory dbserver
       useDBServer();
     }
     singleton.loadFromText(text);
   } catch (Exception e) {
     ExceptionWindow.getExceptionWindow(e);
   }
 }
 public static void createEmpty() {
   try {
     if (singleton == null) {
       // default behavior is to create a singleton for
       // an in memory dbserver
       useDBServer();
     }
     singleton.createEmpty();
   } catch (Exception e) {
     ExceptionWindow.getExceptionWindow(e);
   }
 }
 public static StorageListener useDBServer(String dbName) {
   // assumed persistent
   if (singleton != null) {
     return (singleton);
   }
   try {
     singleton = (StorageListener) DBServer.init(dbName);
   } catch (Exception e) {
     ExceptionWindow.getExceptionWindow(e);
   }
   return (singleton);
 }
 public static StorageListener useDBServer() {
   // assume in memory with some initial state
   if (singleton != null) {
     return (singleton);
   }
   try {
     singleton = (StorageListener) DBServer.initInMemory();
   } catch (Exception e) {
     ExceptionWindow.getExceptionWindow(e);
   }
   return (singleton);
 }
Exemple #5
0
  public static Color getColor(String name, Color def) {
    if (name == null) {
      // System.out.println("illegal color: " + name);
      // Thread.dumpStack();
      return (def);
    }
    name = name.toLowerCase();
    Color nc = (Color) colors.get(name);
    if (nc == null) {
      StringTokenizer st = new StringTokenizer(name, ", ");
      // System.out.println(st.countTokens();

      if ((st.countTokens() < 3) || (st.countTokens() > 4)) {
        // System.out.println("illegal color");
        nc = def;
      } else {
        try {
          int r = Integer.parseInt(st.nextToken());
          int g = Integer.parseInt(st.nextToken());
          int b = Integer.parseInt(st.nextToken());
          if (st.countTokens() == 0) {
            nc = new GuessColor(r, g, b);
          } else {
            int a = Integer.parseInt(st.nextToken());
            nc = new GuessColor(r, g, b, a);
          }
          colors.put(name, nc);
        } catch (Exception e) {
          ExceptionWindow.getExceptionWindow(e);
          StatusBar.setErrorStatus("Invalid color, using default");
          nc = def;
        }
      }
    }
    return (nc);
  }