Example #1
0
  /**
   * Creates a region (first deleting it if one with that name exists)
   *
   * @param string
   * @param xaxis
   * @return
   * @throws Exception
   */
  public static final IRegion replaceCreateRegion(
      final IRegionSystem system, final String name, final RegionType type) throws Exception {

    if (system.getRegion(name) != null) {
      system.removeRegion(system.getRegion(name));
    }
    return system.createRegion(name, type);
  }
Example #2
0
 /**
  * Call to get a unique region name
  *
  * @param nameStub
  * @param system
  * @return
  */
 public static String getUniqueName(
     final String nameStub, final IRegionSystem system, final String... usedNames) {
   int i = 1;
   @SuppressWarnings("unchecked")
   final List<String> used =
       (List<String>) (usedNames != null ? Arrays.asList(usedNames) : Collections.emptyList());
   while (system.getRegion(nameStub + " " + i) != null || used.contains(nameStub + " " + i)) {
     ++i;
     if (i > 10000) break; // something went wrong!
   }
   return nameStub + " " + i;
 }