Example #1
0
 static void writeDoc1(Document doc, PrintStream out) throws IOException {
   Vector<Annotation> entities = doc.annotationsOfType("entity");
   if (entities == null) {
     System.err.println("No Entity: " + doc);
     return;
   }
   Iterator<Annotation> entityIt = entities.iterator();
   int i = 0;
   while (entityIt.hasNext()) {
     Annotation entity = entityIt.next();
     Vector mentions = (Vector) entity.get("mentions");
     Iterator mentionIt = mentions.iterator();
     String nameType = (String) entity.get("nameType");
     while (mentionIt.hasNext()) {
       Annotation mention1 = (Annotation) mentionIt.next();
       Annotation mention2 = new Annotation("refobj", mention1.span(), new FeatureSet());
       mention2.put("objid", Integer.toString(i));
       if (nameType != null) {
         mention2.put("netype", nameType);
       }
       doc.addAnnotation(mention2);
     }
     i++;
   }
   // remove other annotations.
   String[] annotypes = doc.getAnnotationTypes();
   for (i = 0; i < annotypes.length; i++) {
     String t = annotypes[i];
     if (!(t.equals("tagger") || t.equals("refobj") || t.equals("ENAMEX"))) {
       doc.removeAnnotationsOfType(t);
     }
   }
   writeDocRaw(doc, out);
   return;
 }
  /**
   * Divide a phrase in lines
   *
   * @param concordancia If is 'E' (exact) don't divide
   * @return Iteraror A set of words
   * @param line phrase to search
   * @param titleKeys
   * @param relationship
   * @param wildCard
   */
  public Iterator parseValues(String line, String titleKeys, String relationship, String wildCard) {
    Vector values = new Vector();

    if (titleKeys == null) {
      titleKeys = EXACT_WORDS;
    }

    if (titleKeys.equals(EXACT_WORDS)) {
      values.add(line);
      return values.iterator();
    }
    StringTokenizer doubleQuotesTokenizer = new StringTokenizer(line, "\"", true);
    boolean inside = false;
    while (doubleQuotesTokenizer.hasMoreTokens()) {
      String token = doubleQuotesTokenizer.nextToken();
      if (token.equals("\"")) {
        inside = !inside;
      } else if (inside) {
        if (relationship.compareTo(FilterEncoding.PROPERTY_IS_LIKE) == 0) {
          token = wildCard + token + wildCard;
        }
        values.add(token);
      } else {
        StringTokenizer spaceTokenizer = new StringTokenizer(token, " ");
        while (spaceTokenizer.hasMoreTokens()) {
          String value = spaceTokenizer.nextToken();
          if (relationship.compareTo(FilterEncoding.PROPERTY_IS_LIKE) == 0) {
            value = wildCard + value + wildCard;
          }
          values.add(value);
        }
      }
    }
    return values.iterator();
  }
 /** A clean way to specify which tests run on which platforms. */
 public boolean isPlatformSupported(DatabasePlatform platform) {
   boolean supported = false;
   boolean notSupported = false;
   if ((unsupportedPlatforms == null) && (supportedPlatforms == null)) {
     return true;
   }
   if (supportedPlatforms != null) {
     for (Iterator iterator = supportedPlatforms.iterator(); iterator.hasNext(); ) {
       Class platformClass = (Class) iterator.next();
       if (platformClass.isInstance(platform)) {
         supported = true;
       }
     }
   } else {
     supported = true;
   }
   if (unsupportedPlatforms != null) {
     for (Iterator iterator = unsupportedPlatforms.iterator(); iterator.hasNext(); ) {
       Class platformClass = (Class) iterator.next();
       if (platformClass.isInstance(platform)) {
         notSupported = true;
       }
     }
   }
   return supported && (!notSupported);
 }
Example #4
0
  void timingTests() {
    final int timingcount = 5000;
    long t0, t1, t2;

    // exercise the algorithm to let hot-spot do some compiling
    for (int i = 0; i < timingcount; i++)
      for (final Iterator it = testlist.iterator(); it.hasNext(); ) {
        final Record rec = (Record) it.next();
        dotime(rec, /*dry=*/ false);
      }
    t0 = System.currentTimeMillis();
    for (int i = 0; i < timingcount; i++)
      for (final Iterator it = testlist.iterator(); it.hasNext(); ) {
        final Record rec = (Record) it.next();
        dotime(rec, /*dry=*/ true);
      }
    t1 = System.currentTimeMillis();
    for (int i = 0; i < timingcount; i++)
      for (final Iterator it = testlist.iterator(); it.hasNext(); ) {
        final Record rec = (Record) it.next();
        dotime(rec, /*dry=*/ false);
      }
    t2 = System.currentTimeMillis();
    final int n = timingcount * testlist.size();
    System.out.println("\ntime=" + 1000.0 * (t2 - t1 - (t1 - t0)) / n + " usec");
  }
Example #5
0
  private void exhaustiveCheck(
      final Record rec, final Vector3d offset, final PolyTree ptree1, final PolyTree ptree2) {
    final Matrix4dX X21 = new Matrix4dX(rec.X21);
    final Matrix4dX X12 = new Matrix4dX();

    X21.m03 += offset.x;
    X21.m13 += offset.y;
    X21.m23 += offset.z;

    X12.invert(X21);

    final Vector flist1 = getAllPolyhdreonFeatures(ptree1.getPolyhedron());
    final Vector flist2 = getAllPolyhdreonFeatures(ptree2.getPolyhedron());
    for (final Iterator it1 = flist1.iterator(); it1.hasNext(); ) {
      final Feature f1 = (Feature) it1.next();
      for (final Iterator it2 = flist2.iterator(); it2.hasNext(); ) {
        final Feature f2 = (Feature) it2.next();

        if (!(f1.type == Feature.FACE && f2.type == Feature.FACE)) {
          final FeaturePair featurePair = new FeaturePair(f1, f2);
          final PolyTreePair ptreePair = new PolyTreePair(ptree1, ptree2);
          closestFeaturesHT.put(ptreePair, featurePair);

          final DistanceReport rep = rec.createDistanceReport();
          final double d = ptree1.vclip(rep, ptree2, X21, MAX_DIST, closestFeaturesHT);
          rep.transformSecondPoints(X21);
          checkVclipResults(rec, offset, rep, d, featurePair);
        }
      }
    }
  }
  /**
   * Z-Sorts and draws all 3D objects which have been added to the collection of objects to draw via
   * the add3DObject() method.
   *
   * @param g the Graphics on which to draw the 3D objects.
   */
  public void drawObjectsOnThis(Graphics g) {
    synchronized (objects) {
      // calculate all rotations
      for (Iterator<Object3D> it = objects.iterator(); it.hasNext(); ) {
        Object3D currentObject = it.next();
        // very rarely, when the "objects" list is being modified by
        // another thread, "currentObject" is null here
        if (currentObject != null) currentObject.calculateRotation(window);
        else
          // if we are here, then that strange thread error has
          // occurred, and it causes an exception to be thrown
          // when
          // Collections.sort() is called later, so just
          // return now to prevent further errors
          return;
      }

      // Z-Sort
      Collections.sort(objects, depthComparator);

      // Draw all objects
      Graphics2D g2D = (Graphics2D) g;
      for (Iterator<Object3D> it = objects.iterator(); it.hasNext(); ) it.next().drawOnThis(g2D);
    }
  }
  /** @param container */
  public void closeContainer(SshToolsApplicationContainer container) {
    if (log.isDebugEnabled()) {
      log.debug("Asking " + container + " if it can close");
    }

    if (container.getApplicationPanel().canClose()) {
      if (log.isDebugEnabled()) {
        log.debug("Closing");

        for (Iterator i = containers.iterator(); i.hasNext(); ) {
          log.debug(i.next() + " is currently open");
        }
      }

      container.getApplicationPanel().close();
      container.closeContainer();
      containers.removeElement(container);

      if (containers.size() == 0) {
        exit(true);
      } else {
        log.debug("Not closing completely because there are containers still open");

        for (Iterator i = containers.iterator(); i.hasNext(); ) {
          log.debug(i.next() + " is still open");
        }
      }
    }
  }
Example #8
0
  public void print_sendc_Method(PrintWriter ps, String classname) {
    /* in some cases generated name have an underscore prepended for the
    mapped java name. On the wire, we must use the original name */

    String idl_name = (name.startsWith("_") ? name.substring(1) : name);

    ps.print("\tpublic void sendc_" + name + "(");

    ps.print("AMI_" + classname + "Handler ami_handler");

    for (Iterator i = paramDecls.iterator(); i.hasNext(); ) {
      ParamDecl p = (ParamDecl) i.next();
      if (p.paramAttribute != ParamDecl.MODE_OUT) {
        ps.print(", ");
        p.asIn().print(ps);
      }
    }

    ps.print(")" + Environment.NL);
    ps.println("\t{");
    ps.println("\t\twhile(true)");
    ps.println("\t\t{");
    ps.println("\t\t\ttry");
    ps.println("\t\t\t{");
    ps.print("\t\t\t\torg.omg.CORBA.portable.OutputStream _os = _request( \"" + idl_name + "\",");

    if (opAttribute == NO_ATTRIBUTE) ps.println(" true);");
    else ps.println(" false);");

    //  arguments..

    for (Iterator i = paramDecls.iterator(); i.hasNext(); ) {
      ParamDecl p = ((ParamDecl) i.next());
      if (p.paramAttribute != ParamDecl.MODE_OUT)
        ps.println("\t\t\t\t" + p.asIn().printWriteStatement("_os"));
    }

    ps.println(
        "\t\t\t\t((org.jacorb.orb.Delegate)_get_delegate()).invoke(this, _os, ami_handler);");
    ps.println("\t\t\t\treturn;");

    /* catch exceptions */

    ps.println("\t\t\t}");
    ps.println("\t\t\tcatch( org.omg.CORBA.portable.RemarshalException _rx )");
    ps.println("\t\t\t{");
    ps.println("\t\t\t}");

    ps.println("\t\t\tcatch( org.omg.CORBA.portable.ApplicationException _ax )");
    ps.println("\t\t\t{");
    ps.println("\t\t\t}");

    ps.println("\t\t}" + Environment.NL); // end while
    ps.println("\t}" + Environment.NL); // end method
  }
Example #9
0
 public void logModel(DefaultTableModel dtm) {
   Vector vector = dtm.getDataVector();
   Iterator it = vector.iterator();
   while (it.hasNext()) {
     Vector v = (Vector) it.next();
     Iterator i = v.iterator();
     StringBuilder row = new StringBuilder();
     while (i.hasNext()) {
       row.append(i.next());
     }
     LOG.info(row.toString());
   }
 }
  /*
   * Turns the vector into an Array of ICompletionProposal objects
   */
  protected ICompletionProposal[] turnProposalVectorIntoAdaptedArray(WordPartDetector word) {
    ICompletionProposal[] result = new ICompletionProposal[proposalList.size()];

    int index = 0;

    for (Iterator i = proposalList.iterator(); i.hasNext(); ) {
      String keyWord = (String) i.next();

      IContextInformation info = new ContextInformation(keyWord, getContentInfoString(keyWord));
      // Creates a new completion proposal.
      result[index] =
          new CompletionProposal(
              keyWord, // replacementString
              word.getOffset(),
              // replacementOffset the offset of the text to be replaced
              word.getString().length(),
              // replacementLength the length of the text to be replaced
              keyWord.length(),
              // cursorPosition the position of the cursor following the insert relative to
              // replacementOffset
              null, // image to display
              keyWord, // displayString the string to be displayed for the proposal
              info,
              // contntentInformation the context information associated with this proposal
              getContentInfoString(keyWord));
      index++;
    }
    // System.out.println("result : " + result.length);
    proposalList.removeAllElements();
    return result;
  }
Example #11
0
  public void assignTracks(final String primaryTrack, final Vector<String> secondaryTracks) {
    // ok - find the matching tracks/
    final Object theP = _theLayers.findLayer(primaryTrack);
    if (theP != null) {
      if (theP instanceof WatchableList) {
        _thePrimary = (WatchableList) theP;
      }
    }

    // do we have secondaries?
    if (secondaryTracks != null) {
      // and now the secs
      final Vector<Layer> secs = new Vector<Layer>(0, 1);
      final Iterator<String> iter = secondaryTracks.iterator();
      while (iter.hasNext()) {
        final String thisS = iter.next();
        final Layer theS = _theLayers.findLayer(thisS);
        if (theS != null)
          if (theS instanceof WatchableList) {
            secs.add(theS);
          }
      }

      if (secs.size() > 0) {
        _theSecondaries = new WatchableList[] {};
        _theSecondaries = secs.toArray(_theSecondaries);
      }
    }
  }
 public void removeUserAction(UserAction action) {
   Vector userEvents = action.getUserEvents();
   for (Iterator iterator = userEvents.iterator(); iterator.hasNext(); ) {
     UserEvent userEvent = (UserEvent) iterator.next();
     if (action.mustStartAndStop()) {
       if (userEvent.isMouseActivated()) {
         if (userEvent.isMouseWheelEvent()) {
           mouseWheelEvents.removeElement(userEvent);
         } else {
           mousePressedEvents.removeElement(userEvent);
           mouseReleasedEvents.removeElement(userEvent);
         }
       } else {
         keyPressedEvents.removeElement(userEvent);
         keyReleasedEvents.removeElement(userEvent);
       }
     } else {
       if (userEvent.isMouseActivated()) {
         if (userEvent.isMouseWheelEvent()) {
           mouseWheelEvents.removeElement(userEvent);
         } else {
           mousePressedEvents.removeElement(userEvent);
         }
       } else {
         keyPressedEvents.removeElement(userEvent);
       }
     }
   }
 }
 void fireLoginCanceled(final LoginEvent source) {
   Iterator iter = listenerList.iterator();
   while (iter.hasNext()) {
     LoginListener listener = (LoginListener) iter.next();
     listener.loginCanceled(source);
   }
 }
 public static void areEqual(Object[] expected, Iterator iterator) {
   Vector v = new Vector();
   for (int i = 0; i < expected.length; i++) {
     v.add(expected[i]);
   }
   areEqual(v.iterator(), iterator);
 }
 public void mouseWheelMoved(ShrimpMouseEvent e) {
   // @tag Shrimp.MouseWheel
   if (handleAnyMouseEvent(e)) {
     for (Iterator iter = mouseWheelEvents.iterator(); iter.hasNext(); ) {
       UserEvent userEvent = (UserEvent) iter.next();
       if ((isShiftPressed == userEvent.isShiftRequired())
           && (isCtrlPressed == userEvent.isControlRequired())
           && (isAltPressed == userEvent.isAltRequired())) {
         if (e.isUpWheelRotation() && (userEvent.getKeyOrButton() == UserEvent.MOUSE_WHEEL_UP)) {
           if (userEvent.getAction().mustStartAndStop()) {
             startAction(userEvent.getAction());
             stopAction(userEvent.getAction());
           } else {
             startAction(userEvent.getAction());
           }
         } else if (e.isDownWheelRotation()
             && (userEvent.getKeyOrButton() == UserEvent.MOUSE_WHEEL_DOWN)) {
           if (userEvent.getAction().mustStartAndStop()) {
             startAction(userEvent.getAction());
             stopAction(userEvent.getAction());
           } else {
             startAction(userEvent.getAction());
           }
         }
       }
     }
   }
 }
Example #16
0
 /*
  * Verifica se o cavalo está dando cheque mate.
  */
 private boolean cavaloDaChequeMate(Peca reiBranco) {
   Vector casasTemp = new Vector();
   casasTemp.add(this.getCasa(reiBranco.getPosicaoX() - 1, reiBranco.getPosicaoY() - 2));
   casasTemp.add(this.getCasa(reiBranco.getPosicaoX() + 1, reiBranco.getPosicaoY() - 2));
   casasTemp.add(this.getCasa(reiBranco.getPosicaoX() - 2, reiBranco.getPosicaoY() + 1));
   casasTemp.add(this.getCasa(reiBranco.getPosicaoX() - 2, reiBranco.getPosicaoY() - 1));
   casasTemp.add(this.getCasa(reiBranco.getPosicaoX() + 2, reiBranco.getPosicaoY() + 1));
   casasTemp.add(this.getCasa(reiBranco.getPosicaoX() + 2, reiBranco.getPosicaoY() - 1));
   casasTemp.add(this.getCasa(reiBranco.getPosicaoX() - 1, reiBranco.getPosicaoY() + 2));
   casasTemp.add(this.getCasa(reiBranco.getPosicaoX() + 1, reiBranco.getPosicaoY() + 2));
   Iterator it = casasTemp.iterator();
   Casa casaTemp;
   while (it.hasNext()) {
     casaTemp = (Casa) it.next();
     if (reiBranco.getCor() == Color.WHITE) {
       if (casaTemp != null
           && casaTemp.getPeca() != null
           && (casaTemp.getPeca() instanceof CavaloPretoGUI)) {
         if (!((CasaGUI) casaTemp).isAtaqueBranco()) return true;
       }
     } else {
       if (casaTemp != null
           && casaTemp.getPeca() != null
           && (casaTemp.getPeca() instanceof CavaloBrancoGUI)) {
         if (!((CasaGUI) casaTemp).isAtaquePreto()) return true;
       }
     }
   }
   return false;
 }
Example #17
0
  public static String[] parseString(String text, String seperator) {
    Vector vResult = new Vector();
    if (text == null || "".equals(text)) {
      return null;
    }
    String tempStr = text.trim();
    String currentLabel = null;
    int index = tempStr.indexOf(seperator);
    while (index != -1) {
      currentLabel = tempStr.substring(0, index).trim();

      if (!"".equals(currentLabel)) {
        vResult.addElement(currentLabel);
      }
      tempStr = tempStr.substring(index + 1);
      index = tempStr.indexOf(seperator);
    } // Last label
    currentLabel = tempStr.trim();
    if (!"".equals(currentLabel)) {
      vResult.addElement(currentLabel);
    }
    String[] re = new String[vResult.size()];
    Iterator it = vResult.iterator();
    index = 0;
    while (it.hasNext()) {
      re[index] = (String) it.next();
      index++;
    }
    return re;
  }
Example #18
0
  /** ****************** update functions ****************** */
  public void addObject(String objStr, boolean bFirstRound) {
    String predStr;
    String paramStr;
    boolean bObjectFound = false;
    int bracketIdx = objStr.indexOf('(');
    int bracket2Idx = objStr.indexOf(')');

    predStr = objStr.substring(0, bracketIdx);
    paramStr = objStr.substring(bracketIdx + 1, bracket2Idx);

    Iterator It = modelObjects.iterator();

    while (It.hasNext()) {
      ModelObject modelObject = (ModelObject) It.next();
      //	    System.out.println("modelObject.getName(): " + modelObject.getName());
      if (modelObject.getName().equals(predStr)) {
        bObjectFound = true;
        modelObject.add(paramStr, bFirstRound);
      }
    }

    //
    // Object not found - create new modelObject
    if (!bObjectFound) {
      // TODO: put this in a file for reading
      int numInst;
      if (predStr.equals("player")) numInst = 21;
      else numInst = 1;

      ModelObject newObject = new ModelObject(predStr, numInst);
      newObject.add(paramStr, bFirstRound);
      //	    System.out.println("Adding new object: " + predStr + ", param: " + paramStr);
      modelObjects.add(newObject);
    }
  }
Example #19
0
 protected void layoutFooter(Page page) {
   ServletUtil.doLayoutFooter(
       page, (footnotes == null ? null : footnotes.iterator()), getLockssApp().getVersionInfo());
   if (footnotes != null) {
     footnotes.removeAllElements();
   }
 }
  void writeFiles(Vector allConfigs) {

    Hashtable allFiles = computeAttributedFiles(allConfigs);

    Vector allConfigNames = new Vector();
    for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
      allConfigNames.add(((BuildConfig) i.next()).get("Name"));
    }

    TreeSet sortedFiles = sortFiles(allFiles);

    startTag("Files", null);

    for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) {
      doWriteFiles(sortedFiles, allConfigNames, (NameFilter) i.next());
    }

    startTag(
        "Filter",
        new String[] {
          "Name", "Resource Files",
          "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
        });
    endTag("Filter");

    endTag("Files");
  }
Example #21
0
  private void findUnitClusters(int[] clusterassoc, double[][] lkvalues, int[][] neighbors) {
    Vector<ObjectComparablePair> topunitterms = new Vector<ObjectComparablePair>();
    // sort units according to their highest value -> order to find clusters
    for (int i = 0; i < lkvalues.length; i++) {
      double max = Stat.max(lkvalues[i]);
      if (max <= 0.) continue;
      topunitterms.addElement(new ObjectComparablePair(new Integer(i), new Double(max)));
    }
    Collections.sort(topunitterms);
    Collections.reverse(topunitterms);

    Iterator<ObjectComparablePair> ocpit = topunitterms.iterator();
    while (ocpit.hasNext()) {
      int curunit = ((Integer) (ocpit.next().getObject())).intValue();
      floodFillSimilarClusters(curunit, clusterassoc, lkvalues, neighbors, curunit);
    }

    // join all empty units
    int firstemptyindex = -1;
    for (int i = 0; i < lkvalues.length; i++) {
      if (Stat.max(lkvalues[i]) <= 0.) {
        if (firstemptyindex == -1) firstemptyindex = i;
        else clusterassoc[i] = firstemptyindex;
      }
    }
  }
 public void notifyObservers() {
   Iterator<Observer> iterator = vector.iterator();
   while (iterator.hasNext()) {
     Observer observer = iterator.next();
     observer.update();
   }
 }
  private static void viewCalendar() {
    Iterator<iCalEvent> schedule = calendar.iterator();
    String lastDate = null;
    String lastComment = null;

    if (calendar.isEmpty()) {
      System.out.println("Calendar is empty!  You do not have any events planned.");
    } else {
      System.out.println("Here is your calendar of events!");
    }
    while (schedule.hasNext()) {
      iCalEvent temp = schedule.next();
      if (temp.getTotalDate().equals(lastDate)) {
        System.out.println(
            "\t" + temp.getStartTime() + " - " + temp.getEndTime() + " : " + temp.getName());
        System.out.println("\t\t" + "Location: " + temp.getLocation());
        if (lastComment != null) {
          System.out.println("\t\t" + "Comment: " + lastComment);
        }
      } else {
        System.out.println();
        System.out.println(temp.getMonth() + "/" + temp.getDay() + "/" + temp.getYear());
        System.out.println(
            "\t" + temp.getStartTime() + " - " + temp.getEndTime() + " : " + temp.getName());
        System.out.println("\t\t" + "Location: " + temp.getLocation());
      }

      lastDate = temp.getTotalDate();
      lastComment = temp.getComment();
    }
    System.out.println();
  }
Example #24
0
  private void showDialogOfSuggestedContacts(final Vector<Contact> vector) {
    if (vector != null) {
      // create content for alert
      ArrayList<String> array = new ArrayList<String>();
      Iterator<Contact> it = vector.iterator();
      while (it.hasNext()) {
        Contact contact = it.next();
        array.add(contact.getDisplayName() + "\n" + contact.getPhoneNumber());
      }

      AlertDialog.Builder alertContacts = new AlertDialog.Builder(this);
      alertContacts.setTitle("Suggessted Contacts : Pick One");
      alertContacts.setSingleChoiceItems(
          array.toArray(new String[] {}),
          -1,
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
              dialog.cancel();

              Contact tempContact = vector.get(which);
              showMessage("Calling " + tempContact.getDisplayName());
              callPhone(tempContact.getPhoneNumber());
            }
          });

      alertContacts.create();
      alertContacts.show();
    }
  }
Example #25
0
  /**
   * This method finds all the countries which contains a given region.
   *
   * @param regionCode Region code. Note: If you specify 'any' as the regions string, it will return
   *     all of the countries available.
   * @return A non-null List object containing the list of countries.
   */
  public Iterator findCountriesForRegion(String regionCode) {
    List _countryCodes = null;

    if (regionCode.equals("any")) { // Do the find for any region -> this means return all countries
      _countryCodes = findAllCountriesCodes();
    } else {
      try {
        _countryCodes =
            new Chm62edtCountryBiogeoregionDomain()
                .findWhere("CODE_BIOGEOREGION='" + regionCode + "'");
      } catch (Exception e) {
        e.printStackTrace();
        _countryCodes = new ArrayList();
      }
    }
    Vector _countries = new Vector();
    Iterator _it = _countryCodes.iterator();

    try {
      while (_it.hasNext()) {
        Chm62edtCountryBiogeoregionPersist _aRegion =
            (Chm62edtCountryBiogeoregionPersist) _it.next();

        _countries.addElement(
            new CountryWrapper(
                countryCode2Name(_aRegion.getCodeCountry()), _aRegion.getCodeCountry(), ""));
      }
    } catch (ClassCastException ex) {
      ex.printStackTrace();
      return _it;
    }
    new SortList().sort(_countries, SortList.SORT_ASCENDING);
    return _countries.iterator();
  }
Example #26
0
  /**
   * This method exports the single pattern decision instance to the XML. It MUST be called by an
   * XML exporter, as this will not have a complete header.
   *
   * @param ratDoc The ratDoc generated by the XML exporter
   * @return the SAX representation of the object.
   */
  public Element toXML(Document ratDoc) {
    Element decisionE;
    RationaleDB db = RationaleDB.getHandle();

    // Now, add pattern to doc
    String entryID = db.getRef(this);
    if (entryID == null) {
      entryID = db.addPatternDecisionRef(this);
    }

    decisionE = ratDoc.createElement("DR:patternDecision");
    decisionE.setAttribute("rid", entryID);
    decisionE.setAttribute("name", name);
    decisionE.setAttribute("type", type.toString());
    decisionE.setAttribute("phase", devPhase.toString());
    decisionE.setAttribute("status", status.toString());
    // decisionE.setAttribute("artifact", artifact);

    Element descE = ratDoc.createElement("description");
    Text descText = ratDoc.createTextNode(description);
    descE.appendChild(descText);
    decisionE.appendChild(descE);

    // Add child pattern references...
    Iterator<Pattern> cpi = candidatePatterns.iterator();
    while (cpi.hasNext()) {
      Pattern cur = cpi.next();
      Element curE = ratDoc.createElement("refChildPattern");
      Text curText = ratDoc.createTextNode("p" + new Integer(cur.getID()).toString());
      curE.appendChild(curText);
      decisionE.appendChild(curE);
    }

    return decisionE;
  }
  /**
   * Compute which element should be quizzed next from the given set of elements UID, according to
   * the statistics of each elements.
   *
   * @param elementsUID Set of elementsUID from which to found the next element.
   * @return String Element Unique ID
   */
  public String getNextElement(Vector<String> elementsUID) {
    String currentElementUID = null;
    float bestScore = Float.NEGATIVE_INFINITY;
    float currentScore = bestScore;
    Vector<String> bestsUIDs = new Vector<String>();

    Iterator<String> itElements = elementsUID.iterator();
    while (itElements.hasNext()) {
      currentElementUID = itElements.next();

      if (!statistics.containsKey(currentElementUID)) {
        KanjiNoSensei.log(
            Level.WARNING,
            Messages.getString("LearningProfile.LearningProfile.WarningNeverSeenElement")
                + " : \""
                + currentElementUID
                + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        return currentElementUID;
      }

      currentScore = statistics.get(currentElementUID).getNeedScore();
      if (currentScore > bestScore) {
        bestsUIDs.removeAllElements();
        bestsUIDs.add(currentElementUID);
        bestScore = currentScore;
      } else if (currentScore == bestScore) {
        bestsUIDs.add(currentElementUID);
      }
    }

    return bestsUIDs.get(random.nextInt(bestsUIDs.size()));
  }
Example #28
0
 protected void exportSelectedRowsAndClose() {
   int[] selectedRows = timeTable.getSelectedRows();
   Vector selectedNodes = new Vector();
   for (int i = 0; i < selectedRows.length; i++) {
     int row = selectedRows[i];
     selectedNodes.add(getMindMapNode(row));
   }
   // create new map:
   MindMap newMap = getMindMapController().newMap();
   MindMapController newMindMapController = (MindMapController) newMap.getModeController();
   // Tools.BooleanHolder booleanHolder = new Tools.BooleanHolder();
   // booleanHolder.setValue(false);
   for (Iterator iter = selectedNodes.iterator(); iter.hasNext(); ) {
     MindMapNode node = (MindMapNode) iter.next();
     // MindMapNode newNode = newMindMapController.addNewNode(
     // newMap.getRootNode(), 0, booleanHolder);
     // // copy style:
     // freemind.controller.actions.generated.instance.Pattern pattern =
     // StylePatternFactory.createPatternFromNode(node);
     // newMindMapController.applyPattern(newNode, pattern);
     // // copy text:
     // newMindMapController.setNodeText(newNode, node.getText());
     MindMapNode copy = node.shallowCopy();
     if (copy != null) {
       newMindMapController.insertNodeInto(copy, newMap.getRootNode());
     }
   }
   disposeDialog();
 }
Example #29
0
  /**
   * Send whole buffer - this will be the task which will be run periodically
   *
   * @throws InterruptedException
   */
  public void sendBuffer(Vector<data.Data> dataToSend, Long duration)
      throws IOException, BCDPrecisionException, InterruptedException {
    Iterator<data.Data> iDataToSend = dataToSend.iterator();

    /* Duration as BCD */
    Long durationBCD = Long.parseLong(duration.toString(), 16);

    /* Send start byte */
    outputStream.write(0xFF);

    /* Send duration */
    outputStream.write(Data.intToByteArray(durationBCD));

    /* For each element */
    while (iDataToSend.hasNext()) {
      /* Get current data */
      data.Data current = iDataToSend.next();

      /* Send single data */
      send(current);

      /* Wait as it was specified by the user */
      Thread.sleep(5);
    }

    /* Send finish byte */
    outputStream.write(0xAA);
  }
 public ActiviteGraphique getAct(int x, int y) {
   for (Iterator it = rectActivites.iterator(); it.hasNext(); ) {
     ActiviteGraphique act = (ActiviteGraphique) it.next();
     if (act.inRect(x, y)) return act;
   }
   return null;
 }