protected int invoke(String methodName, String arg1, String arg2, String arg3) {
   Vector<String> args = new Vector<String>();
   args.add(arg1);
   args.add(arg2);
   args.add(arg3);
   return invokeInternal(methodName, args);
 }
Exemple #2
0
  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);
  }
Exemple #3
0
  // 判断坦克是否被击中
  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);
        }
    }
  }
  /** INTERNAL: */
  public Vector getForeignKeyRows(AbstractRecord row) {
    Vector subRows = new Vector();
    if (getForeignKeyGroupingElement() == null) {
      if (this.getSourceForeignKeyFields().size() > 0) {
        Object values = row.getValues((DatabaseField) this.getSourceForeignKeyFields().get(0));

        if (values != null) {
          if (values instanceof Vector) {
            int valuesSize = ((Vector) values).size();
            for (int j = 0; j < valuesSize; j++) {
              XMLRecord newRecord = new DOMRecord("test");
              newRecord.setSession(((XMLRecord) row).getSession());
              newRecord.put(this.getSourceForeignKeyFields().get(0), ((Vector) values).get(j));
              subRows.add(newRecord);
            }
          } else {
            XMLRecord newRecord = new DOMRecord("test");
            newRecord.setSession(((XMLRecord) row).getSession());
            newRecord.put(getSourceForeignKeyFields().get(0), values);
            subRows.add(newRecord);
          }
        }
      }
    } else {
      subRows = (Vector) row.getValues(getForeignKeyGroupingElement());
    }
    return subRows;
  }
Exemple #5
0
  /**
   * Returns a vector with column names of the dataset, listed in "list". If a column cannot be
   * found or the list is empty the ones from the default list are returned.
   *
   * @param list comma-separated list of attribute names
   * @param defaultList the default list of attribute names
   * @param inst the instances to get the attribute names from
   * @return a vector containing attribute names
   */
  protected Vector determineColumnNames(String list, String defaultList, Instances inst) {
    Vector result;
    Vector atts;
    StringTokenizer tok;
    int i;
    String item;

    // get attribute names
    atts = new Vector();
    for (i = 0; i < inst.numAttributes(); i++) atts.add(inst.attribute(i).name().toLowerCase());

    // process list
    result = new Vector();
    tok = new StringTokenizer(list, ",");
    while (tok.hasMoreTokens()) {
      item = tok.nextToken().toLowerCase();
      if (atts.contains(item)) {
        result.add(item);
      } else {
        result.clear();
        break;
      }
    }

    // do we have to return defaults?
    if (result.size() == 0) {
      tok = new StringTokenizer(defaultList, ",");
      while (tok.hasMoreTokens()) result.add(tok.nextToken().toLowerCase());
    }

    return result;
  }
 @Override
 public Vector<Object> getAllCurfewRecord(String DMID)
     throws DataBaseException, QueryResultIsNullException {
   Statement stmt = DB.CreateStatement();
   String sql = "select *from Curfew where Dormid=" + DMID + "order by StuId asc";
   try {
     ResultSet rs = stmt.executeQuery(sql);
     if (rs != null && !rs.next()) {
       throw new QueryResultIsNullException();
     }
     Vector<Object> vectors = new Vector<Object>();
     Vector<Object> vector = new Vector<Object>();
     for (int i = 1; i <= 10; i++) {
       vector.add(rs.getString(i));
     }
     vectors.add(vector);
     while (rs.next()) {
       vector = new Vector<Object>();
       for (int i = 1; i <= 10; i++) {
         vector.add(rs.getString(i));
       }
       vectors.add(vector);
     }
     return vectors;
   } catch (SQLException e) {
     e.printStackTrace();
     throw new DataBaseException();
   }
 }
Exemple #7
0
  public static void draw3dAxis(
      Mat frame, CameraParameters cp, Scalar color, double height, Mat Rvec, Mat Tvec) {
    //		Mat objectPoints = new Mat(4,3,CvType.CV_32FC1);
    MatOfPoint3f objectPoints = new MatOfPoint3f();
    Vector<Point3> points = new Vector<Point3>();
    points.add(new Point3(0, 0, 0));
    points.add(new Point3(height, 0, 0));
    points.add(new Point3(0, height, 0));
    points.add(new Point3(0, 0, height));
    objectPoints.fromList(points);

    MatOfPoint2f imagePoints = new MatOfPoint2f();
    Calib3d.projectPoints(
        objectPoints, Rvec, Tvec, cp.getCameraMatrix(), cp.getDistCoeff(), imagePoints);
    List<Point> pts = new Vector<Point>();
    Converters.Mat_to_vector_Point(imagePoints, pts);

    Core.line(frame, pts.get(0), pts.get(1), color, 2);
    Core.line(frame, pts.get(0), pts.get(2), color, 2);
    Core.line(frame, pts.get(0), pts.get(3), color, 2);

    Core.putText(frame, "X", pts.get(1), Core.FONT_HERSHEY_SIMPLEX, 0.5, color, 2);
    Core.putText(frame, "Y", pts.get(2), Core.FONT_HERSHEY_SIMPLEX, 0.5, color, 2);
    Core.putText(frame, "Z", pts.get(3), Core.FONT_HERSHEY_SIMPLEX, 0.5, color, 2);
  }
  public boolean correctCriticals(StringBuffer buff) {
    Vector<Mounted> unallocated = new Vector<Mounted>();
    boolean correct = true;

    for (Mounted mount : tank.getMisc()) {
      if (mount.getLocation() == Entity.LOC_NONE && !(mount.getType().getCriticals(tank) == 0)) {
        unallocated.add(mount);
      }
    }
    for (Mounted mount : tank.getWeaponList()) {
      if (mount.getLocation() == Entity.LOC_NONE) {
        unallocated.add(mount);
      }
    }
    for (Mounted mount : tank.getAmmo()) {
      int ammoType = ((AmmoType) mount.getType()).getAmmoType();
      if ((mount.getLocation() == Entity.LOC_NONE)
          && (mount.getUsableShotsLeft() > 1 || ammoType == AmmoType.T_CRUISE_MISSILE)) {
        unallocated.add(mount);
      }
    }

    if (!unallocated.isEmpty()) {
      buff.append("Unallocated Equipment:\n");
      for (Mounted mount : unallocated) {
        buff.append(mount.getType().getInternalName()).append("\n");
      }
      correct = false;
    }

    return correct;
  }
  /**
   * 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()));
  }
  /** {@inheritDoc} */
  public Vector<Score> sortedClasses(Gesture g) {
    Vector<Score> sortedClasses = new Vector<Score>();

    Vector<Point2D> inputPointsResampled = new Vector<Point2D>();
    GestureUtils.resample(g.getPoints(), nbPoints, inputPointsResampled);
    GestureUtils.rotateToZero(inputPointsResampled, inputPointsResampled);
    GestureUtils.scaleToSquare(inputPointsResampled, sizeScaleToSquare, inputPointsResampled);
    GestureUtils.translateToOrigin(inputPointsResampled, inputPointsResampled);

    double score;
    double minClassScore = 0;
    for (int nc = 0; nc < classes.size(); nc++) {
      minClassScore = Integer.MAX_VALUE;
      for (Iterator<Vector<Point2D>> gesturesIterator =
              classes.get(nc).getResampledGestures().iterator();
          gesturesIterator.hasNext(); ) {
        Vector<Point2D> gesturePoints = gesturesIterator.next();
        score =
            GestureUtils.distanceAtBestAngle(
                inputPointsResampled, gesturePoints, -theta, theta, deltaTheta);
        if (score < minClassScore) minClassScore = score;
      }
      if (nc == 0) {
        sortedClasses.add(new Score(classes.get(nc).getName(), minClassScore));
      } else {
        int i = 0;
        while (i < sortedClasses.size() && sortedClasses.get(i).getScore() < minClassScore) i++;
        sortedClasses.add(i, new Score(classes.get(nc).getName(), minClassScore));
      }
    }

    return sortedClasses;
  }
Exemple #11
0
  // {{{ createMacrosMenu() method
  private void createMacrosMenu(JMenu menu, Vector vector, int start) {
    Vector<JMenuItem> menuItems = new Vector<JMenuItem>();
    int maxItems = jEdit.getIntegerProperty("menu.spillover", 20);
    JMenu subMenu = null;
    for (int i = start; i < vector.size(); i++) {
      if (i != start && i % maxItems == 0) {
        subMenu = new JMenu(jEdit.getProperty("common.more"));
        createMacrosMenu(subMenu, vector, i);
        break;
      }
      Object obj = vector.elementAt(i);
      if (obj instanceof String) {
        menuItems.add(
            new EnhancedMenuItem(
                jEdit.getProperty(obj + ".label"), (String) obj, jEdit.getActionContext()));
      } else if (obj instanceof Vector) {
        Vector subvector = (Vector) obj;
        String name = (String) subvector.elementAt(0);
        JMenu submenu = new JMenu(jEdit.getProperty("macros.folder." + name + ".label", name));
        createMacrosMenu(submenu, subvector, 1);
        if (submenu.getMenuComponentCount() != 0) menuItems.add(submenu);
      }
    }

    Collections.sort(menuItems, new MenuItemTextComparator());

    if (subMenu != null) menuItems.add(subMenu);

    for (int i = 0; i < menuItems.size(); i++) {
      menu.add(menuItems.get(i));
    }
  } // }}}
 void m() {
   Vector<String> vector = new Vector<String>();
   vector.add("Hello");
   Vector<CharSequence> v2 = new Vector<CharSequence>();
   v2.add((CharSequence) null);
   v2.addAll(vector);
 }
  public void actualizarTablaProductos(Object objeto) {

    tabla = new Tabla();

    tabla.addColumn("ID_PROD.");
    tabla.addColumn("PRECIO");
    tabla.addColumn("CANT.");

    if (objeto != null) {
      List<TProductoDePedido> lista = (List<TProductoDePedido>) objeto;

      for (TProductoDePedido tproducto_pedido : lista) {

        fila = new Vector();

        fila.add(tproducto_pedido.getProducto());
        fila.add(tproducto_pedido.getPrecio());
        fila.add(tproducto_pedido.getCantidad());

        tabla.addRow(fila);
      }
    }

    tbProductos.setModel(tabla);

    repaint();
  }
  public void rellenarTablaPedidos(Object object) {

    tabla = new Tabla();

    tabla.addColumn("ID_PED");
    tabla.addColumn("ID_PROV");
    tabla.addColumn("REALIZ.");
    tabla.addColumn("ENTREG.");
    tabla.addColumn("CANCEL.");

    if (object != null) {

      List<TPedido> lista = (List<TPedido>) object;

      for (TPedido tpedido : lista) {

        fila = new Vector();

        fila.add(tpedido.getId_pedido());
        fila.add(tpedido.getId_proveedor());
        fila.add(tpedido.getFechaRealizado());
        fila.add(tpedido.getFechaEntregado());
        fila.add(tpedido.getFechaCancelado());

        tabla.addRow(fila);
      }
    }

    tbPedidos.setModel(tabla);

    tbPedidos.getColumnModel().getColumn(0).setMaxWidth(60); // ajusta el ancho de las columnas ID
    tbPedidos.getColumnModel().getColumn(1).setMaxWidth(60);

    repaint();
  }
  @Override
  public Vector<Object> getAllExpressInfo(String dmid)
      throws DataBaseException, QueryResultIsNullException {
    Statement stmt = DB.CreateStatement();
    String sql = "select *from ExpressTransceiver where DormId = '" + dmid + "'";
    ResultSet rs = null;
    Vector<Object> vector = null;
    Vector<Object> vectors = new Vector<Object>();
    try {
      rs = stmt.executeQuery(sql);
      if (rs != null && !rs.next()) {
        throw new QueryResultIsNullException();
      }
      vector = new Vector<Object>();
      for (int i = 1; i <= 11; i++) {

        vector.add(rs.getString(i));
      }
      vectors.add(vector);
      while (rs.next()) {
        vector = new Vector<Object>();
        for (int i = 1; i <= 11; i++) {

          vector.add(rs.getString(i));
        }
        vectors.add(vector);
      }
    } catch (SQLException e) {
      e.printStackTrace();
      throw new DataBaseException();
    }

    return vectors;
  }
Exemple #16
0
        public void handle(SubscribeRequest msg) {
          // messages++;
          //			System.out.println("  Server received subscription " + msg.getTopic());

          if (subcriptionRepository.containsKey(msg.getTopic())) {
            Vector<Address> subscriberlist =
                (Vector<Address>) subcriptionRepository.get(msg.getTopic());

            // to avoid duplicate subscriber
            if (!subscriberlist.contains(msg.getSource())) {
              subscriberlist.add(msg.getSource()); // Will this mutate the
              // instant in the object
              // inside?

              subcriptionRepository.remove(msg.getTopic());
              subcriptionRepository.put(msg.getTopic(), subscriberlist);
            }

            //				System.out.println("  Subscriber list for topic id "
            //						+ msg.getTopic() + " : " + subscriberlist.toString());

          } else {
            Vector<Address> subscriberlist = new Vector<Address>();
            subscriberlist.add(msg.getSource());
            //				System.out.println("  Address source: " + msg.getSource());
            subcriptionRepository.put(msg.getTopic(), subscriberlist);

            System.out.println(
                "  Subscriber list for topic id (new topic)"
                    + msg.getTopic()
                    + " : "
                    + subscriberlist.toString());
          }
        }
  @Override
  public Vector<Object> getAllStudentInfo(String dmid)
      throws QueryResultIsNullException, DataBaseException {
    Statement stmt = DB.CreateStatement();
    String sql = "select * from View_Student_College_StuDormRoom where DormId = '" + dmid + "'";
    // String sql = "select * from View_Student_College " ;
    // System.out.println(sql);

    try {
      ResultSet rs = stmt.executeQuery(sql);
      if (rs != null && !rs.next()) {
        throw new QueryResultIsNullException();
      }
      Vector<Object> vectors = new Vector<Object>();
      Vector<Object> vector = new Vector<Object>();
      for (int i = 1; i <= 9; i++) {
        vector.add(rs.getObject(i));
      }
      vectors.add(vector);
      while (rs.next()) {
        vector = new Vector<Object>();
        for (int i = 1; i <= 9; i++) {
          vector.add(rs.getObject(i));
        }
        vectors.add(vector);
      }
      return vectors;
    } catch (SQLException e) {
      e.printStackTrace();
      throw new DataBaseException();
    }
  }
Exemple #18
0
  public static Vector filterDistinct(Vector tupels, String key) {
    Vector res = new Vector();
    key = key.toLowerCase();

    for (int i = 0; i < tupels.size(); i++) {
      DB_Tupel tupel = (DB_Tupel) tupels.get(i);
      Object o = tupel.get(key);

      if (o instanceof String) {
        String s = (String) o;
        boolean found = false;
        for (int j = 0; j < res.size(); j++) {
          String t = (String) res.get(j);
          if (s.equalsIgnoreCase(t)) {
            found = true;
            break;
          }
        }
        if (!found) res.add(s);
      } else {
        if (!res.contains(o)) res.add(o);
      }
    }

    return res;
  }
 @Override
 public Vector<Object> getAllLeaveComeStu(String DormId)
     throws DataBaseException, QueryResultIsNullException {
   Statement stmt = DB.CreateStatement();
   String sql = "select *from LeaveComeStu where DormId='" + DormId + "'";
   //	System.err.println(sql);
   try {
     ResultSet rs = stmt.executeQuery(sql);
     if (rs != null && !rs.next()) {
       throw new QueryResultIsNullException();
     }
     Vector<Object> vectors = new Vector<Object>();
     Vector<Object> vector = new Vector<Object>();
     for (int i = 1; i <= 9; i++) {
       vector.add(rs.getString(i));
     }
     vectors.add(vector);
     while (rs.next()) {
       vector = new Vector<Object>();
       for (int i = 1; i <= 9; i++) {
         vector.add(rs.getString(i));
       }
       vectors.add(vector);
     }
     return vectors;
   } catch (SQLException e) {
     e.printStackTrace();
     throw new DataBaseException();
   }
 }
Exemple #20
0
 public void dbAddElement(String testo, String valore) {
   lm.addElement(testo);
   dbItems.add((Object) testo);
   dbItemsK.add((Object) valore);
   dbItemsK2.add(null);
   this.setModel(lm);
 }
  private int generateIndex(String content, int docid) {
    Scanner s = new Scanner(content); // Uses white space by default.
    int totalcount = 0;
    while (s.hasNext()) {
      ++_totalTermFrequency;
      ++totalcount;
      String token = s.next();
      // decrement the size() by 1 as the real doc id
      // int did=_documents.size()-1;

      Vector<Integer> plist = _index.get(token);
      if (plist != null) {
        if (plist.lastElement() != docid) {
          plist.add(docid);
          _index.put(token, plist);
        }
      } else {
        // _terms.add(token);
        Vector<Integer> p = new Vector<Integer>();
        p.add(docid);
        _index.put(token, p);
      }
    }

    return totalcount;
  }
Exemple #22
0
 public void dbAddElement(Object testo, Object valore, Object valore2) {
   lm.addElement(testo);
   dbItems.add(testo);
   dbItemsK.add(valore);
   dbItemsK2.add(valore2);
   this.setModel(lm);
 }
  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);
  }
Exemple #24
0
 public static Vector<AniosDispositivo> leerDatosVector3(String consulta3) {
   Vector<AniosDispositivo> aniosd = new Vector<AniosDispositivo>();
   AniosDispositivo anid = null;
   if (con == null) con = mysql.getConnect();
   anid = new AniosDispositivo();
   anid.setIdhistorialvisitadispositivo(0);
   anid.setFechahoravisitadispositivo("--Escoja un año--");
   // ani.setidDispositivo("");
   aniosd.add(anid);
   try {
     sent = con.createStatement();
     ResultSet rs = sent.executeQuery(consulta3);
     while (rs.next()) {
       anid = new AniosDispositivo();
       anid.setIdhistorialvisitadispositivo(rs.getInt(1));
       anid.setFechahoravisitadispositivo(rs.getString(2));
       aniosd.add(anid);
     }
     sent.close();
     rs.close();
   } catch (Exception e) {
     System.out.println(e.toString());
     e.printStackTrace();
   }
   return aniosd;
 }
 JComboBox makeDebugLevelDropdown() {
   String levelName = Base.preferences.get("replicatorg.debuglevel", Level.INFO.getName());
   Level l = Level.parse(levelName);
   if (l == null) {
     l = Level.INFO;
   }
   Vector<Level> levels = new Vector<Level>();
   levels.add(Level.ALL);
   levels.add(Level.FINEST);
   levels.add(Level.FINER);
   levels.add(Level.FINE);
   levels.add(Level.INFO);
   levels.add(Level.WARNING);
   final ComboBoxModel model = new DefaultComboBoxModel(levels);
   model.setSelectedItem(l);
   JComboBox cb = new JComboBox(model);
   cb.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
           Level level = (Level) (model.getSelectedItem());
           Base.preferences.put("replicatorg.debuglevel", level.getName());
           Base.logger.setLevel(level);
         }
       });
   return cb;
 }
Exemple #26
0
 public static Vector<Categorias> leerDatosVector1(String consulta1) {
   Vector<Categorias> categorias = new Vector<Categorias>();
   Categorias cat = null;
   if (con == null) con = mysql.getConnect();
   cat = new Categorias();
   cat.setIdCategoria(0);
   cat.setNombreCategoria("--Seleccione una categoria--");
   cat.setDescripcionCategoria("");
   categorias.add(cat);
   try {
     sent = con.createStatement();
     ResultSet rs = sent.executeQuery(consulta1);
     while (rs.next()) {
       cat = new Categorias();
       cat.setIdCategoria(rs.getInt(1));
       cat.setNombreCategoria(rs.getString(2));
       cat.setDescripcionCategoria(rs.getString(3));
       categorias.add(cat);
     }
     sent.close();
     rs.close();
   } catch (Exception e) {
     System.out.println(e.toString());
     e.printStackTrace();
   }
   return categorias;
 }
  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();
    }
  }
Exemple #28
0
 public static Vector<Anios> leerDatosVector2(String consulta2) {
   Vector<Anios> anios = new Vector<Anios>();
   Anios ani = null;
   if (con == null) con = mysql.getConnect();
   ani = new Anios();
   ani.setIdHistorialVisita(0);
   ani.setfechaHoraVisita("--Escoja un año--");
   // ani.setidDispositivo("");
   anios.add(ani);
   try {
     sent = con.createStatement();
     ResultSet rs = sent.executeQuery(consulta2);
     while (rs.next()) {
       ani = new Anios();
       ani.setIdHistorialVisita(rs.getInt(1));
       ani.setfechaHoraVisita(rs.getString(2));
       // ani.setidDispositivo(rs.getString(3));
       anios.add(ani);
     }
     sent.close();
     rs.close();
   } catch (Exception e) {
     System.out.println(e.toString());
     e.printStackTrace();
   }
   return anios;
 }
  /** @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);
  }
Exemple #30
0
  /**
   * Compute and store statistics required for generating artificial data.
   *
   * @param data training instances
   * @exception Exception if statistics could not be calculated successfully
   */
  protected void computeStats(Instances data) throws Exception {
    int numAttributes = data.numAttributes();
    m_AttributeStats = new Vector(numAttributes); // use to map attributes to their stats

    for (int j = 0; j < numAttributes; j++) {
      if (data.attribute(j).isNominal()) {
        // Compute the probability of occurence of each distinct value
        int[] nomCounts = (data.attributeStats(j)).nominalCounts;
        double[] counts = new double[nomCounts.length];
        if (counts.length < 2)
          throw new Exception("Nominal attribute has less than two distinct values!");
        // Perform Laplace smoothing
        for (int i = 0; i < counts.length; i++) counts[i] = nomCounts[i] + 1;
        Utils.normalize(counts);
        double[] stats = new double[counts.length - 1];
        stats[0] = counts[0];
        // Calculate cumulative probabilities
        for (int i = 1; i < stats.length; i++) stats[i] = stats[i - 1] + counts[i];
        m_AttributeStats.add(j, stats);
      } else if (data.attribute(j).isNumeric()) {
        // Get mean and standard deviation from the training data
        double[] stats = new double[2];
        stats[0] = data.meanOrMode(j);
        stats[1] = Math.sqrt(data.variance(j));
        m_AttributeStats.add(j, stats);
      } else System.err.println("Decorate can only handle numeric and nominal values.");
    }
  }