コード例 #1
2
ファイル: KMeansTest.java プロジェクト: adriansidor/med
  @Test
  public void kmeans_test() throws IOException {
    File file = new File(filename);
    FileReader fr = new FileReader(file);
    BufferedReader br = new BufferedReader(fr);
    String line;
    List<Vector<Double>> vectors = new ArrayList<Vector<Double>>();
    List<Integer> oc = new ArrayList<Integer>();
    while ((line = br.readLine()) != null) {
      String[] values = line.split(separator);
      Vector<Double> vector = new Vector<Double>(values.length - 1);
      for (int i = 0; i < values.length - 1; i++) {
        vector.add(i, Double.valueOf(values[i]));
      }
      vectors.add(vector);

      String clazz = values[values.length - 1];
      if (clazz.equals("Iris-setosa")) {
        oc.add(0);
      } else if (clazz.equals("Iris-versicolor")) {
        oc.add(1);
      } else {
        oc.add(2);
      }
    }
    br.close();
    fr.close();
    Matrix matrix = new Matrix(vectors);
    KMeansClustering kmeans = new KMeansClustering();
    int[] clusters = kmeans.cluster(matrix, 3);
    int[][] classMatrix = new int[3][3];
    for (int i = 0; i < oc.size(); i++) {
      classMatrix[oc.get(i)][clusters[i]]++;
    }
    System.out.println("	   setosa versicolor virginica");
    System.out.println(
        "setosa       "
            + classMatrix[0][0]
            + "       "
            + classMatrix[0][1]
            + " 	"
            + classMatrix[0][2]);
    System.out.println(
        "versicolor    "
            + classMatrix[1][0]
            + "       "
            + classMatrix[1][1]
            + " 	"
            + classMatrix[1][2]);
    System.out.println(
        "virginica     "
            + classMatrix[2][0]
            + "       "
            + classMatrix[2][1]
            + " 	"
            + classMatrix[2][2]);

    System.out.println(
        "Rand index: " + new RandIndex().calculate(oc.toArray(new Integer[oc.size()]), clusters));
  }
コード例 #2
1
  /**
   * Returns an enumeration describing the available options.
   *
   * @return an enumeration of all the available options.
   */
  public Enumeration listOptions() {

    Vector newVector = new Vector(2);

    newVector.addElement(
        new Option(
            "\tNumber of folds used for cross validation (default 10).",
            "X",
            1,
            "-X <number of folds>"));
    newVector.addElement(
        new Option(
            "\tClassifier parameter options.\n"
                + "\teg: \"N 1 5 10\" Sets an optimisation parameter for the\n"
                + "\tclassifier with name -N, with lower bound 1, upper bound\n"
                + "\t5, and 10 optimisation steps. The upper bound may be the\n"
                + "\tcharacter 'A' or 'I' to substitute the number of\n"
                + "\tattributes or instances in the training data,\n"
                + "\trespectively. This parameter may be supplied more than\n"
                + "\tonce to optimise over several classifier options\n"
                + "\tsimultaneously.",
            "P",
            1,
            "-P <classifier parameter>"));

    Enumeration enu = super.listOptions();
    while (enu.hasMoreElements()) {
      newVector.addElement(enu.nextElement());
    }
    return newVector.elements();
  }
コード例 #3
1
  private void filterChange(final BamView bamView, final JComboBox flagCheck[]) {
    int nflags = SAMRecordFlagPredicate.FLAGS.length;
    int flagCombined = 0;
    Vector<SAMRecordPredicate> predicates = new Vector<SAMRecordPredicate>();

    for (int j = 0; j < nflags; j++) {
      String opt = (String) flagCheck[j].getSelectedItem();
      if (opt.equals("HIDE")) flagCombined = flagCombined | SAMRecordFlagPredicate.FLAGS[j];
      else if (opt.equals("SHOW"))
        predicates.add(new SAMRecordFlagPredicate(SAMRecordFlagPredicate.FLAGS[j], false));
    }

    if (flagCombined == 0 && predicates.size() == 0) bamView.setSamRecordFlagPredicate(null);
    else {
      final SAMRecordPredicate predicate;
      if (predicates.size() == 0) predicate = new SAMRecordFlagPredicate(flagCombined);
      else if (flagCombined == 0) {
        predicate =
            new SAMRecordFlagConjunctionPredicate(predicates, SAMRecordFlagConjunctionPredicate.OR);
      } else {
        SAMRecordFlagPredicate p1 = new SAMRecordFlagPredicate(flagCombined);
        SAMRecordFlagConjunctionPredicate p2 =
            new SAMRecordFlagConjunctionPredicate(predicates, SAMRecordFlagConjunctionPredicate.OR);

        predicate =
            new SAMRecordFlagConjunctionPredicate(p1, p2, SAMRecordFlagConjunctionPredicate.OR);
      }
      bamView.setSamRecordFlagPredicate(predicate);
    }
    bamView.repaint();
  }
コード例 #4
1
ファイル: TankGame3.java プロジェクト: yifei325325/TankGame
  @Override
  public void run() {
    // TODO Auto-generated method stub
    while (true) {
      try {
        Thread.sleep(100);
      } catch (Exception e) {
        // TODO: handle exception
      }
      //			判断每一粒子弹和每一辆敌人的坦克都是否有重合(击中)
      for (int i = 0; i < hero.bombs.size(); i++) {
        //				取出每个子弹
        Bomb myBomb = hero.bombs.get(i);
        //				子弹必须得存活才有判断的意义
        if (myBomb.isLive) {
          for (int j = 0; j < ets.size(); j++) {
            //						取出每辆坦克
            EnemyTank et = ets.get(j);
            if (et.isLive) {
              this.isHit(myBomb, et);
            }
          }
        }
      }

      this.repaint();
    }
  }
コード例 #5
1
  /** Creates new form SessionLog */
  public SessionLog() {
    initComponents();

    try {
      Connection con = DBConnection.getConnection();
      String query = "select * from user_session where user_id=?";
      PreparedStatement psmt = con.prepareStatement(query);
      psmt.setString(1, "ababab");
      ResultSet rs = psmt.executeQuery();
      ResultSetMetaData rsmd;
      rsmd = rs.getMetaData();
      Vector column = new Vector();
      int count = rsmd.getColumnCount();
      DefaultTableModel dtm = new DefaultTableModel();
      for (int i = 1; i <= count; i++) {
        column.addElement(rsmd.getColumnName(i));
      }
      dtm.setColumnIdentifiers(column);
      while (rs.next()) {
        Vector row = new Vector();
        for (int i = 1; i <= count; i++) {
          row.addElement(rs.getString(i));
        }
        dtm.addRow(row);
      }
      jTable1.setModel(dtm);

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #6
1
  public static InformalArgument_c[] getManyMSG_IAsOnR1013(
      MessageArgument_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new InformalArgument_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(InformalArgument_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      InformalArgument_c source =
          (InformalArgument_c) targets[i].backPointer_IsSubtypeInformalArgumentIsSubtype_R1013;
      if (source != null && (test == null || test.evaluate(source))) {
        matches.add(source);
      }
    }
    if (matches.size() > 0) {
      InformalArgument_c[] ret_set = new InformalArgument_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new InformalArgument_c[0];
    }
  }
コード例 #7
1
ファイル: RepeatQtnsDef.java プロジェクト: krfox/koboform
  private void copyQuestions(Vector<IFormElement> questions) {
    if (questions == null) return;

    this.questions = new Vector<IFormElement>();
    for (int i = 0; i < questions.size(); i++)
      this.questions.addElement(new QuestionDef((QuestionDef) questions.elementAt(i), qtnDef));
  }
コード例 #8
1
ファイル: Lisp.java プロジェクト: pboothe/Lispy-Animator
  private static void replace(Tree code, String data, Tree replacement) {
    System.out.println("Trying to replace" + data + " with " + replacement + " in " + code);
    if (code.getData().equals(data)) {
      System.out.println("Replacing " + data + " with " + replacement);
      code.removeChildren(false);
      for (Tree t : replacement.getChildren()) {
        code.addChild(new Tree(t), false);
      }
      code.setData(replacement.getData());
    } else if (code.getData().equals(FUN)) {
      // Shadowing
      Vector<Tree> fn = code.getChildren();
      Vector<Tree> args = fn.get(0).getChildren();

      for (Tree t : args) {
        if (t.getData().equals(data)) {
          return;
        }
      }

      // If we made it here, the replacement term is not in the args
      replace(fn.get(1), data, replacement);
    } else {
      for (Tree t : code.getChildren()) {
        replace(t, data, replacement);
      }
    }
  }
コード例 #9
1
ファイル: TestCFG2_2013.java プロジェクト: pabloloyola/soot
 protected void resolve() {
   boolean consistent = true;
   for (int i = 0; i < queue.size() && i < 10; i++) {
     ccr.app.Context ctx = (ccr.app.Context) queue.get(i);
     if (filterLocCons2Stay(ctx, candidate) && !funcLocDistOk(ctx, candidate)) {
       consistent = false;
       break;
     }
     if (filterLocCons2Walk(ctx, candidate) && !funcLocWalkAdjVeloOk(ctx, candidate)) {
       consistent = false;
       break;
     }
     if (filterLocSkip1Stay(ctx, candidate) && !funcLocDistOk(ctx, candidate)) {
       consistent = false;
       break;
     }
     if (filterLocSkip1Walk(ctx, candidate) && !funcLocWalkSkipVeloOk(ctx, candidate)) {
       consistent = false;
       break;
     }
     if (filterLocSkip1Mix(ctx, candidate) && !funcLocMixVeloOk(ctx, candidate)) {
       consistent = false;
       break;
     }
   }
   if (consistent) {
     queue.add(0, candidate);
   } else {
     candidate = (ccr.app.Context) queue.get(0);
   }
 }
コード例 #10
0
  private void getNewNodes() {
    Vector levelNodes = new Vector();
    Vector nextLevelNodes = new Vector();
    Vector passedNodes = new Vector();
    levelNodes.add(centerNode.name);
    for (int level = 0; level <= Config.navigationDepth; level++) {
      for (Enumeration e = levelNodes.elements(); e.hasMoreElements(); ) {
        String nodeName = (String) e.nextElement();

        if (!passedNodes.contains(nodeName)) {
          passedNodes.add(nodeName);

          Node node = graph.nodeFromName(nodeName);
          if (node == null) {
            node = xmlReader.getNode(nodeName);
            graph.add(node);
          }
          node.passed = true;

          Set linkSet = node.links.keySet();
          for (Iterator it = linkSet.iterator(); it.hasNext(); ) {
            String neighbourName = (String) it.next();
            if (!passedNodes.contains(neighbourName) && !levelNodes.contains(neighbourName)) {
              nextLevelNodes.add(neighbourName);
            }
          }
        }
      }
      levelNodes = nextLevelNodes;
      nextLevelNodes = new Vector();
    }
  }
コード例 #11
0
ファイル: ExpCalc.java プロジェクト: heroyuy/systar
 //    private byte getType(String res) {
 //        byte type = ERROR;//默认是错误
 //        if (res.startsWith("$")) {
 //            type = VAR;
 //        } else if (res.startsWith("\"") && res.endsWith("\"")) {
 //            type = STRING;
 //        } else if (res.equals("true") || res.equals("false")) {
 //            type = BOOLEAN;
 //        } else {
 //            try {
 //                Integer.parseInt(res);
 //                type = INT;
 //            } catch (Exception e) {
 //                type = ERROR;
 //            }
 //        }
 //        return type;
 //
 //    }
 //
 //    private String getValueOfVar(String name) {
 //        String value = null;
 //        if (name.startsWith("$SWITCH[") && name.endsWith("]")) {
 //            value = interpreter.getDataHandler().getSwitch(Integer.parseInt(name.substring(8,
 // name.length() - 1))) + "";
 //        } else if (name.startsWith("$VAR[") && name.endsWith("]")) {
 //            value = interpreter.getDataHandler().getVar(Integer.parseInt(name.substring(5,
 // name.length() - 1))) + "";
 //        } else if (name.equals("$EXP")) {
 //            value = interpreter.getDataHandler().getExp() + "";
 //        } else if (name.equals("$MONEY")) {
 //            value = interpreter.getDataHandler().getMoney() + "";
 //        } else if (name.equals("$LEV")) {
 //            value = interpreter.getDataHandler().getLevel() + "";
 //        } else if (name.equals("$MAXHP")) {
 //            value = interpreter.getDataHandler().getMaxHp() + "";
 //        } else if (name.equals("$HP")) {
 //            value = interpreter.getDataHandler().getHp() + "";
 //        } else if (name.equals("$MAXSP")) {
 //            value = interpreter.getDataHandler().getMaxSp() + "";
 //        } else if (name.equals("$SP")) {
 //            value = interpreter.getDataHandler().getSp() + "";
 //        } else if (name.equals("$STRE")) {
 //            value = interpreter.getDataHandler().getStre() + "";
 //        } else if (name.equals("$AGIL")) {
 //            value = interpreter.getDataHandler().getAgil() + "";
 //        } else if (name.equals("$INTE")) {
 //            value = interpreter.getDataHandler().getInte() + "";
 //        } else if (name.startsWith("$ITEM[") && name.endsWith("]")) {
 //            value = interpreter.getDataHandler().getItemNum(Integer.parseInt(name.substring(6,
 // name.length() - 1))) + "";
 //        } else if (name.startsWith("$EQUIP[") && name.endsWith("]")) {
 //            value = interpreter.getDataHandler().getEquipNum(Integer.parseInt(name.substring(7,
 // name.length() - 1))) + "";
 //        } else if (name.startsWith("$SKILL[") && name.endsWith("]")) {
 //            value =
 // interpreter.getDataHandler().getSkillStatus(Integer.parseInt(name.substring(7, name.length() -
 // 1))) + "";
 //        }
 //        return value;
 //    }
 private void printExpVector() {
   System.out.println("*********************************************");
   for (int i = 0; i < expVector.size(); i++) {
     System.out.print(expVector.elementAt(i) + " ");
   }
   System.out.println("#############################################");
 }
コード例 #12
0
ファイル: DataModel.java プロジェクト: xerial/xerial-java
  public void save(SQLiteAccess query) throws DBException {
    if (query.hasTable("node")) query.dropTable("node");
    if (query.hasTable("edge")) query.dropTable("edge");

    Relation nodeRelation = new Relation();
    nodeRelation.add(new DataTypeBase("id", TypeName.INTEGER, true, true));
    nodeRelation.add(new DataTypeBase("name", TypeName.STRING));
    query.createTable("node", nodeRelation);

    Relation edgeRelation = new Relation();
    edgeRelation.add(new DataTypeBase("id", TypeName.INTEGER, true, true));
    edgeRelation.add(new DataTypeBase("src", TypeName.INTEGER));
    edgeRelation.add(new DataTypeBase("dest", TypeName.INTEGER));
    edgeRelation.add(new DataTypeBase("relationship", TypeName.INTEGER));
    query.createTable("edge", edgeRelation);

    Vector<NodeData> nodeList = new Vector<NodeData>();
    for (int nodeID : _graph.getNodeIDSet()) {
      nodeList.add(new NodeData(nodeID, _graph.getNodeLabel(nodeID)));
    }

    Vector<EdgeData> edgeList = new Vector<EdgeData>();
    for (Edge edge : _graph.getEdgeSet()) {
      edgeList.add(
          new EdgeData(
              _graph.getEdgeID(edge),
              edge.getSourceNodeID(),
              edge.getDestNodeID(),
              _graph.getEdgeLabel(edge)));
    }

    for (NodeData node : nodeList) query.insert("node", node);
    for (EdgeData edge : edgeList) query.insert("edge", edge);
  }
コード例 #13
0
    public void startElement(String uri, String localName, String qName, Attributes atts) {

      logger.log(
          LogService.LOG_DEBUG,
          "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$
              + qName);
      if (!_isParsedDataValid) return;

      String name = getName(localName, qName);
      if (name.equalsIgnoreCase(OPTION)) {
        OptionHandler optionHandler = new OptionHandler(this);
        optionHandler.init(name, atts);
        if (optionHandler._isParsedDataValid) {
          // Only add valid Option
          _optionLabel_vector.addElement(optionHandler._label_val);
          _optionValue_vector.addElement(optionHandler._value_val);
        }
      } else {
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.UNEXPECTED_ELEMENT,
                new Object[] {
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
      }
    }
コード例 #14
0
ファイル: Login2HRM.java プロジェクト: josefloso/FunsoftHMIS
  public java.lang.Object[] getSystemMenuItems2Enable(java.lang.String[] menus2enable) {

    java.lang.Object[] menuList2enable = null;

    java.util.Vector menuListVector = new java.util.Vector(1, 1);

    for (int i = 0; i < menus2enable.length; i++) {

      try {

        java.sql.Statement stmtDB = connDB.createStatement();

        java.sql.ResultSet rSet =
            stmtDB.executeQuery(
                "SELECT menu_item FROM menu_item_list WHERE item_desc='"
                    + menus2enable[i]
                    + "' AND app_name = 'hospital_hr'");

        while (rSet.next()) {

          menuListVector.addElement(rSet.getString(1));
        }

      } catch (java.sql.SQLException sqlExec) {

        javax.swing.JOptionPane.showMessageDialog(this, sqlExec.getLocalizedMessage());
      }
    }

    return menuList2enable = menuListVector.toArray();
  }
コード例 #15
0
ファイル: ResultsPanel.java プロジェクト: huangwen87/mdrill
  /** sets the currently selected Tester-Class. */
  protected void setTester() {
    Tester tester;
    Tester t;
    int i;

    if (m_TesterClasses.getSelectedItem() == null) return;

    tester = null;

    // find display name
    try {
      for (i = 0; i < m_Testers.size(); i++) {
        t = (Tester) ((Class) m_Testers.get(i)).newInstance();
        if (t.getDisplayName().equals(m_TesterClasses.getSelectedItem())) {
          tester = t;
          break;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (tester == null) {
      tester = new PairedCorrectedTTester(); // default
      m_TesterClasses.setSelectedItem(tester.getDisplayName());
    }

    tester.assign(m_TTester);
    m_TTester = tester;
    m_PerformBut.setToolTipText(m_TTester.getToolTipText());
    System.out.println("Tester set to: " + m_TTester.getClass().getName());
  }
コード例 #16
0
ファイル: TankGame3.java プロジェクト: yifei325325/TankGame
  // 判断坦克是否被击中
  public void isHit(Bomb bomb, EnemyTank et) {
    //		敌人的坦克有四个方向,每个方向的坐标不同
    switch (et.getDirection()) {
        //		朝上和朝下效果一样
      case 0:
      case 2:
        // 子弹的坐标和坦克的坐标重合即为击中
        if (bomb.x > et.getX()
            && bomb.x < et.getX() + 25
            && bomb.y < et.getY() + 30
            && bomb.y > et.getY()) {
          // 子弹死亡,敌人坦克死亡
          bomb.isLive = false;
          et.isLive = false;
          BaoZha bz = new BaoZha(et.getX(), et.getY());

          baozhas.add(bz);
        }
        //		敌人坦克朝左右两边
      case 1:
      case 3:
        if (bomb.x > et.getX()
            && bomb.x < et.getX() + 30
            && bomb.y > et.getY()
            && bomb.y < et.getY() + 25) {
          // 子弹死亡,敌人坦克死亡
          bomb.isLive = false;
          et.isLive = false;
          BaoZha bz = new BaoZha(et.getX(), et.getY());
          baozhas.add(bz);
        }
    }
  }
コード例 #17
0
  public Vector getAllValidTemplates() {
    // Return templates if no imported/included stylesheets
    if (_includedStylesheets == null) {
      return _templates;
    }

    // Is returned value cached?
    if (_allValidTemplates == null) {
      Vector templates = new Vector();
      templates.addAll(_templates);
      int size = _includedStylesheets.size();
      for (int i = 0; i < size; i++) {
        Stylesheet included = (Stylesheet) _includedStylesheets.elementAt(i);
        templates.addAll(included.getAllValidTemplates());
      }
      // templates.addAll(_templates);

      // Cache results in top-level stylesheet only
      if (_parentStylesheet != null) {
        return templates;
      }
      _allValidTemplates = templates;
    }

    return _allValidTemplates;
  }
コード例 #18
0
ファイル: SendMailJob.java プロジェクト: rahnas/pagavcs
  private void sendBody() throws IOException {
    // here you are supposed to send your username
    readWriteLine("HELO muCommander");
    // warning : some mail server validate the sender address and will fail is an invalid
    // address is provided
    readWriteLine("MAIL FROM: " + fromAddress);

    Vector<String> recipients = new Vector<String>();
    recipientString = splitRecipientString(recipientString, recipients);
    int nbRecipients = recipients.size();
    for (int i = 0; i < nbRecipients; i++)
      readWriteLine("RCPT TO: <" + recipients.elementAt(i) + ">");
    readWriteLine("DATA");
    writeLine("MIME-Version: 1.0");
    writeLine("Subject: " + this.mailSubject);
    writeLine("From: " + this.fromName + " <" + this.fromAddress + ">");
    writeLine("To: " + recipientString);
    writeLine("Content-Type: multipart/mixed; boundary=\"" + boundary + "\"");
    writeLine("\r\n--" + boundary);

    // Send the body
    //        writeLine( "Content-Type: text/plain; charset=\"us-ascii\"\r\n");
    writeLine("Content-Type: text/plain; charset=\"utf-8\"\r\n");
    writeLine(this.mailBody + "\r\n\r\n");
    writeLine("\r\n--" + boundary);
  }
コード例 #19
0
ファイル: JMainFrame.java プロジェクト: miho/ExtJ3D
 @Override
 public Enumeration getApplets() {
   // Just yields this applet.
   Vector v = new Vector();
   v.addElement(applet);
   return v.elements();
 }
コード例 #20
0
  @Override
  protected Void doInBackground(Long... params) {
    long movieId = params[0];

    WebService webService = new WebService();
    List<Trailer> trailers = webService.getMovieTrailers(movieId);

    Vector<ContentValues> cVVector = new Vector<ContentValues>(trailers.size());
    for (int i = 0; i < trailers.size(); i++) {
      Trailer trailer = trailers.get(i);
      ContentValues values = trailer.asContentValues();
      values.put(MovieContract.TrailerEntry.COLUMN_MOVIE_ID, movieId);
      cVVector.add(values);
    }

    // add to database
    int inserted = 0;
    if (cVVector.size() > 0) {
      ContentValues[] contentValues = new ContentValues[cVVector.size()];
      cVVector.toArray(contentValues);
      inserted =
          mContext
              .getContentResolver()
              .bulkInsert(MovieContract.TrailerEntry.CONTENT_URI, contentValues);
    }
    Log.d(TAG, "FetchTrailersTask Complete. " + inserted + " Inserted");

    return null;
  }
コード例 #21
0
  /**
   * Constructor. The first time an RJavaClassLoader is created, it is cached as the primary loader.
   *
   * @param path path of the rJava package
   * @param libpath lib sub directory of the rJava package
   */
  public RJavaClassLoader(String path, String libpath) {
    super(new URL[] {});
    // respect rJava.debug level
    String rjd = System.getProperty("rJava.debug");
    if (rjd != null && rjd.length() > 0 && !rjd.equals("0")) verbose = true;
    if (verbose) System.out.println("RJavaClassLoader(\"" + path + "\",\"" + libpath + "\")");
    if (primaryLoader == null) {
      primaryLoader = this;
      if (verbose) System.out.println(" - primary loader");
    } else {
      if (verbose)
        System.out.println(" - NOT primrary (this=" + this + ", primary=" + primaryLoader + ")");
    }
    libMap = new HashMap /*<String,UnixFile>*/();

    classPath = new Vector /*<UnixFile>*/();
    classPath.add(new UnixDirectory(path + "/java"));

    rJavaPath = path;
    rJavaLibPath = libpath;

    /* load the rJava library */
    UnixFile so = new UnixFile(rJavaLibPath + "/rJava.so");
    if (!so.exists()) so = new UnixFile(rJavaLibPath + "/rJava.dll");
    if (so.exists()) libMap.put("rJava", so);

    /* load the jri library */
    UnixFile jri = new UnixFile(path + "/jri/libjri.so");
    String rarch = System.getProperty("r.arch");
    if (rarch != null && rarch.length() > 0) {
      UnixFile af = new UnixFile(path + "/jri" + rarch + "/libjri.so");
      if (af.exists()) jri = af;
      else {
        af = new UnixFile(path + "/jri" + rarch + "/jri.dll");
        if (af.exists()) jri = af;
      }
    }
    if (!jri.exists()) jri = new UnixFile(path + "/jri/libjri.jnilib");
    if (!jri.exists()) jri = new UnixFile(path + "/jri/jri.dll");
    if (jri.exists()) {
      libMap.put("jri", jri);
      if (verbose) System.out.println(" - registered JRI: " + jri);
    }

    /* if we are the primary loader, make us the context loader so
    projects that rely on the context loader pick us */
    if (primaryLoader == this) Thread.currentThread().setContextClassLoader(this);

    if (verbose) {
      System.out.println("RJavaClassLoader initialized.\n\nRegistered libraries:");
      for (Iterator entries = libMap.keySet().iterator(); entries.hasNext(); ) {
        Object key = entries.next();
        System.out.println("  " + key + ": '" + libMap.get(key) + "'");
      }
      System.out.println("\nRegistered class paths:");
      for (Enumeration e = classPath.elements(); e.hasMoreElements(); )
        System.out.println("  '" + e.nextElement() + "'");
      System.out.println("\n-- end of class loader report --");
    }
  }
コード例 #22
0
  /** @param args */
  public static void main(String[] args) {
    Vector<String> names = new Vector<String>(2);
    names.add("Row");
    names.add("Random");

    JTable table = new JTable(getIntData(), names);
    table.setAutoCreateRowSorter(true);
    System.err.println("Sorting JTable (ints):");

    testJTable(table, 4);

    JXTable xTable = new JXTable(table.getModel());
    System.err.println("\nSorting JXTable (ints):");

    testJXTable(xTable, 4);

    table = new JTable(getStringData(), names);
    table.setAutoCreateRowSorter(true);
    System.err.println("\nSorting JTable (strings):");

    testJTable(table, 4);

    xTable = new JXTable(table.getModel());
    System.err.println("\nSorting JXTable (strings):");

    testJXTable(xTable, 4);
  }
コード例 #23
0
  /**
   * @param appAlert
   * @param targetUsers
   */
  public static void addAlert(AlertEntry appAlert, List<User> targetUsers) {
    AlertEntry clone;
    if (appAlert != null && targetUsers != null && targetUsers.size() > 0) {
      for (User targetUser : targetUsers) {
        Vector<AlertEntry> userAlerts = alerts.get(targetUser.getUID());
        if (userAlerts == null) {
          alerts.put(targetUser.getUID(), userAlerts = new Vector<AlertEntry>());
        }

        // Get the clone so that each user will have separate copy of the alert
        clone = appAlert.getClone();
        userAlerts.add(clone);

        Collections.sort(
            userAlerts,
            new Comparator<AlertEntry>() {
              public int compare(AlertEntry arg0, AlertEntry arg1) {
                return arg1.getTimeStamp().compareTo(arg0.getTimeStamp());
              }
            });

        SessionRendererHelper.render(SessionRendererHelper.getPortalSessionRendererId(targetUser));
      }
    }
  }
コード例 #24
0
ファイル: Controller.java プロジェクト: onyxbits/ScenePainter
  @Override
  public void valueChanged(TreeSelectionEvent e) {
    if (e.getSource() == colors && !locked) {
      TreeSelectionModel tsm = colors.getSelectionModel();
      TreePath tp[] = tsm.getSelectionPaths();
      if (tp == null) return;
      Vector<ClassedItem> tmp = new Vector<ClassedItem>();
      for (TreePath element : tp) {
        try {
          Object[] path = element.getPath();
          ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString());
          tmp.add(ci);
        } catch (Exception exp) {
          // User did not select a leafnode
        }
      }

      if (sceneElement instanceof NenyaImageSceneElement) {
        ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaTileSceneElement) {
        ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaComponentSceneElement) {
        ((NenyaComponentSceneElement) sceneElement)
            .getComponents()[itemList.getSelectedIndex()].setColorList(
                tmp.toArray(new ClassedItem[0]));
      }

      submitElement(sceneElement, null);
    } else {
      super.valueChanged(e);
    }
  }
コード例 #25
0
  /**
   * Sets up transcriptComboBox (pulldown list) with transcript and its parent gene's other
   * transcripts, with transcript selected
   */
  private void setupTranscriptComboBox(AnnotatedFeatureI annot) {
    // could also check for gene change before doing a removeAll
    if (transcriptComboBox.getSelectedItem() == annot) return;
    // adding and removing items causes item events to fire so need to remove
    // listener here - is there any other way to supress firing?
    transcriptComboBox.removeItemListener(transItemListener);
    transcriptComboBox.removeAllItems();
    if (annot == null) {
      transcriptComboBox.addItem("<no feature selected>");
      return;
    }

    // 1 LEVEL ANNOT
    if (annot.isAnnotTop()) {
      transcriptComboBox.addItem(annot);
      return;
    }

    // TRANSCRIPT
    SeqFeatureI gene = annot.getRefFeature();
    Vector transcripts = gene.getFeatures();
    for (int i = 0; i < transcripts.size(); i++)
      transcriptComboBox.addItem(transcripts.elementAt(i));
    transcriptComboBox.setSelectedItem(annot); // transcript
    transcriptComboBox.addItemListener(transItemListener);
  }
コード例 #26
0
 protected void finished() {
   logger.log(LogService.LOG_DEBUG, "Here is OcdHandler():finished()"); // $NON-NLS-1$
   if (!_isParsedDataValid) return;
   if (_ad_vector.size() == 0) {
     // Schema defines at least one AD is required.
     _isParsedDataValid = false;
     logger.log(
         LogService.LOG_ERROR,
         NLS.bind(
             MetaTypeMsg.MISSING_ELEMENT,
             new Object[] {
               AD,
               OCD,
               elementId,
               _dp_url,
               _dp_bundle.getBundleId(),
               _dp_bundle.getSymbolicName()
             }));
     return;
   }
   // OCD gets all parsed ADs.
   Enumeration<AttributeDefinitionImpl> adKey = _ad_vector.elements();
   while (adKey.hasMoreElements()) {
     AttributeDefinitionImpl ad = adKey.nextElement();
     _ocd.addAttributeDefinition(ad, ad._isRequired);
   }
   _ocd.setIcons(icons);
   _parent_OCDs_hashtable.put(_refID, _ocd);
 }
コード例 #27
0
 @Override
 public void run() {
   while (running) {
     if (queue.size() == 0) {
       try {
         Thread.sleep(20);
       } catch (InterruptedException ex) {
         // üres
       }
       continue;
     }
     Token aToken = queue.remove(0);
     try {
       objectOutput.writeObject(aToken.outputMsg);
       objectOutput.flush();
     } catch (IOException e) {
       onException(e);
     }
     /*
      * Értesíteni a szálat ami küldte ezt a "Token"-t, hogy befejeztük a vele kapcsolatos műveletetek
      */
     synchronized (aToken) {
       aToken.notify();
     }
   } // "while" ciklus végét jelző zárójel
 }
コード例 #28
0
  // Read from file
  public void readFile(String fileName) {
    // TODO Auto-generated method stub

    try {
      FileReader frStream = new FileReader(fileName);
      BufferedReader brStream = new BufferedReader(frStream);
      String inputLine;
      int i = 0;
      Vector<Object> currentRow = new Vector<Object>();
      while ((inputLine = brStream.readLine()) != null) {
        // Ignore the file comment
        if (inputLine.startsWith("#")) continue;

        // Extract the column name
        if (inputLine.startsWith("$")) {
          StringTokenizer st1 = new StringTokenizer(inputLine.substring(1), " ");

          while (st1.hasMoreTokens()) colName.addElement(st1.nextToken());
        } else
        // Extract data and put into the row records
        {
          StringTokenizer st1 = new StringTokenizer(inputLine, " ");
          currentRow = new Vector<Object>();
          while (st1.hasMoreTokens()) currentRow.addElement(st1.nextToken());
          data.addElement(currentRow);
        }
      }

      brStream.close();
    } catch (IOException ex) {
      System.out.println("Error in readFile method! " + ex);
    }
  }
コード例 #29
0
  public ShiftEntryDialog(Shift shift) {
    super(Application.getInstance().getBackOfficeWindow(), true);
    setTitle(com.floreantpos.POSConstants.NEW_SHIFT);

    setContentPane(contentPane);
    getRootPane().setDefaultButton(buttonOK);

    hours = new Vector<Integer>();
    for (int i = 1; i <= 12; i++) {
      hours.add(Integer.valueOf(i));
    }

    mins = new Vector<Integer>();
    for (int i = 0; i < 60; i++) {
      mins.add(Integer.valueOf(i));
    }

    startHour.setModel(new DefaultComboBoxModel(hours));
    endHour.setModel(new DefaultComboBoxModel(hours));

    startMin.setModel(new DefaultComboBoxModel(mins));
    endMin.setModel(new DefaultComboBoxModel(mins));

    buttonOK.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onOK();
          }
        });

    buttonCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        });

    // call onCancel() when cross is clicked
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            onCancel();
          }
        });

    // call onCancel() on ESCAPE
    contentPane.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    setSize(350, 250);

    setShift(shift);
  }
コード例 #30
-1
ファイル: dbfShow.java プロジェクト: akerigan/staxer
  public void clearFields() {
    Field f;

    Checkbox c;
    TextField t;

    int i;

    for (i = 1; i <= db.getFieldCount(); i++) {
      try {
        f = db.getField(i);
        if (f.isMemoField()) {
          f.put("");
        } else if (f.getType() == 'L') {
          c = (Checkbox) fldObjects.elementAt(i - 1);
          c.setState(false);
        } else {
          t = (TextField) fldObjects.elementAt(i - 1);
          t.setText("");
        }
      } catch (Exception e1) {
        System.out.println(e1);
        System.exit(3);
      }
    }
  }