public void setSwingDataCollection(Collection<ICFSecurityISOCountryObj> value) {
   final String S_ProcName = "setSwingDataCollection";
   swingDataCollection = value;
   if (swingDataCollection == null) {
     arrayOfISOCountry = new ICFSecurityISOCountryObj[0];
   } else {
     int len = value.size();
     arrayOfISOCountry = new ICFSecurityISOCountryObj[len];
     Iterator<ICFSecurityISOCountryObj> iter = swingDataCollection.iterator();
     int idx = 0;
     while (iter.hasNext() && (idx < len)) {
       arrayOfISOCountry[idx++] = iter.next();
     }
     if (idx < len) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Collection iterator did not fully populate the array copy");
     }
     if (iter.hasNext()) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Collection iterator had left over items when done populating array copy");
     }
     Arrays.sort(arrayOfISOCountry, compareISOCountryByQualName);
   }
   PickerTableModel tblDataModel = getDataModel();
   if (tblDataModel != null) {
     tblDataModel.fireTableDataChanged();
   }
 }
 @Override
 public Figure findFigureInside(Point2D.Double p) {
   Collection<Figure> c = quadTree.findContains(p);
   for (Figure f : getFiguresFrontToBack()) {
     if (c.contains(f) && f.contains(p)) {
       return f.findFigureInside(p);
     }
   }
   return null;
 }
 /** Implementation note: Sorting can not be done for orphaned children. */
 public java.util.List<Figure> sort(Collection<Figure> c) {
   ensureSorted();
   ArrayList<Figure> sorted = new ArrayList<Figure>(c.size());
   for (Figure f : children) {
     if (c.contains(f)) {
       sorted.add(f);
     }
   }
   return sorted;
 }
Пример #4
0
  /**
   * This method is the access point to the planning procedure. Initially, it adds all variables
   * from axioms to the set of found vars, then does the linear planning. If lp does not solve the
   * problem and there are subtasks, goal-driven recursive planning with backtracking is invoked.
   * Planning is performed until no new variables are introduced into the algorithm.
   */
  public EvaluationAlgorithm invokePlaning(Problem problem, boolean _computeAll) {
    long startTime = System.currentTimeMillis();

    computeAll = _computeAll;
    EvaluationAlgorithm algorithm = new EvaluationAlgorithm();

    PlanningContext context = problem.getCurrentContext();

    // add all axioms at the beginning of an algorithm
    Collection<Var> flattened = new HashSet<Var>();
    for (Iterator<Rel> axiomIter = problem.getAxioms().iterator(); axiomIter.hasNext(); ) {
      Rel rel = axiomIter.next();

      unfoldVarsToSet(rel.getOutputs(), flattened);

      // do not overwrite values of variables that come via args of compute() or as inputs of
      // independent subtasks
      if (!problem.getAssumptions().containsAll(flattened)
      // do not overwrite values of already known variables.
      // typically this is the case when a value of a variable
      // is given in a scheme via a properties window
      //                    && !problem.getKnownVars().containsAll( flattened )
      ) {
        algorithm.addRel(rel);
      }
      axiomIter.remove();
      context.getKnownVars().addAll(flattened);
      flattened.clear();
    }

    context.getFoundVars().addAll(context.getKnownVars());

    // remove all known vars with no relations
    for (Iterator<Var> varIter = context.getKnownVars().iterator(); varIter.hasNext(); ) {
      if (varIter.next().getRels().isEmpty()) {
        varIter.remove();
      }
    }

    // start planning
    if (problem.getRelsWithSubtasks().isEmpty()
        && linearForwardSearch(context, algorithm, computeAll)) {
      if (isLinearLoggingOn()) logger.debug("Problem solved without subtasks");
    } else if (!problem.getRelsWithSubtasks().isEmpty() && subtaskPlanning(problem, algorithm)) {
      if (isLinearLoggingOn()) logger.debug("Problem solved with subtasks");
    } else if (!computeAll) {
      if (isLinearLoggingOn()) logger.debug("Problem not solved");
    }

    if (!nested) {
      logger.info("Planning time: " + (System.currentTimeMillis() - startTime) + "ms.");
    }
    return algorithm;
  }
 public Figure findFigureBehind(Point2D.Double p, Collection<Figure> figures) {
   int inFrontOf = figures.size();
   for (Figure f : getFiguresFrontToBack()) {
     if (inFrontOf == 0) {
       if (f.isVisible() && f.contains(p)) {
         return f;
       }
     } else {
       if (figures.contains(f)) {
         inFrontOf--;
       }
     }
   }
   return null;
 }
Пример #6
0
  private TreeModel buildModel(Object[] resolvers) {
    TreeModel fullModel = null;
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(Tr.t("root"));

    try {
      cpos = null;
      for (Object resolver : resolvers) {
        if (resolver instanceof ColorPository) {
          cpos = (ColorPository) resolver;
          GraphCellRenderer graphCellRenderer = new GraphCellRenderer(cpos);
          colors.setCellRenderer(graphCellRenderer);
          break;
        }
      }
      Collection<ColorPository.ClassRecord> classes = cpos.getClasses();
      String[] classNames = new String[classes.size()];
      Iterator<ColorPository.ClassRecord> it = classes.iterator();
      int count = 0;
      while (it.hasNext()) {
        classNames[count] = it.next().name;
        count++;
      }
      Arrays.sort(classNames);

      for (String className : classNames) {
        ColorPository.ColorRecord[] colors = cpos.enumerateColors(className);
        String[] colorNames = new String[colors.length];
        for (int a = 0; a < colorNames.length; a++) {
          colorNames[a] = colors[a].name;
        }
        Arrays.sort(colorNames);

        DefaultMutableTreeNode tn = new DefaultMutableTreeNode(className);
        top.add(tn);
        for (String colorName : colorNames) {
          tn.add(new DefaultMutableTreeNode(colorName));
        }
      }

      fullModel = new DefaultTreeModel(top);
    } catch (Exception e) {
      fullModel = new DefaultTreeModel(new DefaultMutableTreeNode(Tr.t("root.failed")));
      // e.printStackTrace();
    }
    return fullModel;
  }
 public Figure findFigure(Point2D.Double p) {
   Collection<Figure> c = quadTree.findContains(p);
   switch (c.size()) {
     case 0:
       return null;
     case 1:
       {
         Figure f = c.iterator().next();
         return (f.contains(p)) ? f : null;
       }
     default:
       {
         for (Figure f : getFiguresFrontToBack()) {
           if (c.contains(f) && f.contains(p)) return f;
         }
         return null;
       }
   }
 }
  public Object getChild(Object parent, int index) {
    Collection c = null;

    if (parent instanceof IProject) {
      if (activeOnly()) c = CurrentProject.getTaskList().getActiveSubTasks(null, CurrentDate.get());
      else c = CurrentProject.getTaskList().getTopLevelTasks();
    } else {
      ITask t = (ITask) parent;
      if (activeOnly())
        c = CurrentProject.getTaskList().getActiveSubTasks(t.getID(), CurrentDate.get());
      else c = t.getSubTasks();
    }

    Object array[] = c.toArray();
    Arrays.sort(array, comparator);
    if (opposite) {
      return array[array.length - index - 1];
    }
    return array[index];
  }
 public Figure findFigureExcept(Point2D.Double p, Collection ignore) {
   Collection<Figure> c = quadTree.findContains(p);
   switch (c.size()) {
     case 0:
       {
         return null;
       }
     case 1:
       {
         Figure f = c.iterator().next();
         return (!ignore.contains(f) || !f.contains(p)) ? null : f;
       }
     default:
       {
         for (Figure f : getFiguresFrontToBack()) {
           if (!ignore.contains(f) && f.contains(p)) return f;
         }
         return null;
       }
   }
 }
Пример #10
0
    protected void loadAirspacesFromPath(String path, Collection<Airspace> airspaces) {
      File file = ExampleUtil.saveResourceToTempFile(path, ".zip");
      if (file == null) return;

      try {
        ZipFile zipFile = new ZipFile(file);

        ZipEntry entry = null;
        for (Enumeration<? extends ZipEntry> e = zipFile.entries();
            e.hasMoreElements();
            entry = e.nextElement()) {
          if (entry == null) continue;

          String name = WWIO.getFilename(entry.getName());

          if (!(name.startsWith("gov.nasa.worldwind.render.airspaces") && name.endsWith(".xml")))
            continue;

          String[] tokens = name.split("-");

          try {
            Class c = Class.forName(tokens[0]);
            Airspace airspace = (Airspace) c.newInstance();
            BufferedReader input =
                new BufferedReader(new InputStreamReader(zipFile.getInputStream(entry)));
            String s = input.readLine();
            airspace.restoreState(s);
            airspaces.add(airspace);

            if (tokens.length >= 2) {
              airspace.setValue(AVKey.DISPLAY_NAME, tokens[1]);
            }
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
Пример #11
0
 /**
  * Removes the given <tt>TextFieldChangeListener</tt> from the list of listeners notified on
  * changes of the text contained in this field.
  *
  * @param l the <tt>TextFieldChangeListener</tt> to add
  */
 public void removeTextChangeListener(TextFieldChangeListener l) {
   synchronized (changeListeners) {
     changeListeners.remove(l);
   }
 }
Пример #12
0
 /**
  * Adds the given <tt>TextFieldChangeListener</tt> to the list of listeners notified on changes of
  * the text contained in this field.
  *
  * @param l the <tt>TextFieldChangeListener</tt> to add
  */
 public void addTextChangeListener(TextFieldChangeListener l) {
   synchronized (changeListeners) {
     changeListeners.add(l);
   }
 }