Example usage for java.util Vector elementAt

List of usage examples for java.util Vector elementAt

Introduction

In this page you can find the example usage for java.util Vector elementAt.

Prototype

public synchronized E elementAt(int index) 

Source Link

Document

Returns the component at the specified index.

Usage

From source file:br.com.scalasoft.alvaro.weather.FetchWeatherTask.java

String[] convertContentValuesToUXFormat(Vector<ContentValues> cvv) {
    // return strings to keep UI functional for now
    String[] resultStrs = new String[cvv.size()];
    for (int i = 0; i < cvv.size(); i++) {
        ContentValues weatherValues = cvv.elementAt(i);
        String highAndLow = formatHighLows(weatherValues.getAsDouble(WeatherEntry.COLUMN_MAX_TEMP),
                weatherValues.getAsDouble(WeatherEntry.COLUMN_MIN_TEMP));
        resultStrs[i] = getReadableDateString(weatherValues.getAsLong(WeatherEntry.COLUMN_DATE)) + " - "
                + weatherValues.getAsString(WeatherContract.WeatherEntry.COLUMN_SHORT_DESC) + " - "
                + highAndLow;//from   w w w.j a v a2  s  . c o m
    }
    return resultStrs;
}

From source file:org.intermine.bio.dataconversion.OrthodbConverter.java

private void processHomologues(List<List<String>> homologueList, String groupId) throws ObjectStoreException {
    int m = 2;/*from   w  w  w  . jav a2s.co m*/
    Vector<List<String>> data = new Vector<List<String>>(homologueList);
    @SuppressWarnings("unchecked")
    Vector<Vector<List<String>>> combns = getAllCombinations(data, m);

    for (int i = 0; i < combns.size(); i++) {

        List<String> record1 = combns.elementAt(i).elementAt(0);
        List<String> record2 = combns.elementAt(i).elementAt(1);

        String taxonId1 = record1.get(0);
        String gene1 = record1.get(1);

        String taxonId2 = record2.get(0);
        String gene2 = record2.get(1);

        if (gene1 == null || gene2 == null) {
            continue;
        }

        // HACK - remove duplicated relationships
        String relationshipStr = gene1.toString() + "-" + gene2.toString();
        String reverseRelationshipStr = gene2.toString() + "-" + gene1.toString();
        if (processedHomologueRelationships.contains(relationshipStr)
                || processedHomologueRelationships.contains(reverseRelationshipStr)) {
            LOG.info("Dup >>> " + relationshipStr);
            continue;
        } else {
            processedHomologueRelationships.add(relationshipStr);
            processedHomologueRelationships.add(reverseRelationshipStr);
        }

        // Create both way relations
        createHomologue(gene1, taxonId1, gene2, taxonId2, groupId);
        createHomologue(gene2, taxonId2, gene1, taxonId1, groupId);
    }
}

From source file:net.nosleep.superanalyzer.analysis.views.GenreView.java

private void refreshDataset() {
    Hashtable genres = _analysis.getHash(Analysis.KIND_GENRE);

    Vector items = new Vector();
    Enumeration e = genres.keys();
    while (e.hasMoreElements()) {
        String genreName = (String) e.nextElement();
        Genre genre = (Genre) genres.get(genreName);
        items.add(new GenreItem(genreName, genre.getStats().getTrackCount()));
    }/* www . j av  a2 s  .co m*/

    Collections.sort(items, new GenreItemComparator());

    for (int i = 0; i < items.size(); i++) {
        GenreItem item = (GenreItem) items.elementAt(i);

        _dataset.addValue(item.Count, Misc.getString("GENRE"), item.GenreName);
    }
}

From source file:org.jboss.dashboard.database.DatabaseAutoSynchronizer.java

private String[] splitString(String str, String delims) {
    if (str == null) {
        return null;
    } else if (str.equals("") || delims == null || delims.length() == 0) {
        return new String[] { str };
    }//ww w . j  a  va  2 s . c  om
    String[] s;
    Vector v = new Vector();
    int pos = 0;
    int newpos = str.indexOf(delims, pos);
    while (newpos != -1) {
        v.addElement(str.substring(pos, newpos));
        pos = newpos + delims.length();
        newpos = str.indexOf(delims, pos);
    }
    v.addElement(str.substring(pos));
    s = new String[v.size()];
    for (int i = 0, cnt = s.length; i < cnt; i++) {
        s[i] = ((String) v.elementAt(i)).trim();
    }
    return s;
}

From source file:org.apache.jasper.compiler.JspUtil.java

/**
 * Splits a string into it's components.
 * @param path String to split/*from www .  j a v  a2  s.  co m*/
 * @param pat Pattern to split at
 * @return the components of the path
 */
private static final String[] split(String path, String pat) {
    Vector comps = new Vector();
    int pos = path.indexOf(pat);
    int start = 0;
    while (pos >= 0) {
        if (pos > start) {
            String comp = path.substring(start, pos);
            comps.add(comp);
        }
        start = pos + pat.length();
        pos = path.indexOf(pat, start);
    }
    if (start < path.length()) {
        comps.add(path.substring(start));
    }
    String[] result = new String[comps.size()];
    for (int i = 0; i < comps.size(); i++) {
        result[i] = (String) comps.elementAt(i);
    }
    return result;
}

From source file:Main.java

DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) {
    DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(dir);
    if (curTop != null) {
        curTop.add(curDir);//ww  w . ja v a  2  s  .  c  o m
    }
    File[] tmp = dir.listFiles();
    Vector<File> ol = new Vector<File>();
    ol.addAll(Arrays.asList(tmp));
    Collections.sort(ol, new Comparator<File>() {
        @Override
        public int compare(File o1, File o2) {
            int result = o1.getName().compareTo(o2.getName());
            if (o1.isDirectory() && o2.isFile()) {
                result = -1;
            } else if (o2.isDirectory() && o1.isFile()) {
                result = 1;
            }
            return result;
        }
    });
    for (int i = 0; i < ol.size(); i++) {
        File file = ol.elementAt(i);
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(file);
        if (file.isDirectory()) {
            addNodes(node, file);
        }
        curDir.add(node);
    }
    return curDir;
}

From source file:Sampler.java

private void createUI() {
    setFont(new Font("Serif", Font.PLAIN, 12));
    setLayout(new BorderLayout());
    // Set our location to the left of the image frame.
    setSize(200, 350);/* w  w w . jav a  2 s.com*/
    Point pt = mImageFrame.getLocation();
    setLocation(pt.x - getSize().width, pt.y);

    final Checkbox accumulateCheckbox = new Checkbox("Accumulate", false);
    final Label statusLabel = new Label("");

    // Make a sorted list of the operators.
    Enumeration e = mOps.keys();
    Vector names = new Vector();
    while (e.hasMoreElements())
        names.addElement(e.nextElement());
    Collections.sort(names);
    final java.awt.List list = new java.awt.List();
    for (int i = 0; i < names.size(); i++)
        list.add((String) names.elementAt(i));
    add(list, BorderLayout.CENTER);

    // When an item is selected, do the corresponding transformation.
    list.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() != ItemEvent.SELECTED)
                return;
            String key = list.getSelectedItem();
            BufferedImageOp op = (BufferedImageOp) mOps.get(key);
            BufferedImage source = mSplitImageComponent.getSecondImage();
            boolean accumulate = accumulateCheckbox.getState();
            if (source == null || accumulate == false)
                source = mSplitImageComponent.getImage();
            String previous = mImageFrame.getTitle() + " + ";
            if (accumulate == false)
                previous = "";
            mImageFrame.setTitle(previous + key);
            statusLabel.setText("Performing " + key + "...");
            list.setEnabled(false);
            accumulateCheckbox.setEnabled(false);
            BufferedImage destination = op.filter(source, null);
            mSplitImageComponent.setSecondImage(destination);
            mSplitImageComponent.setSize(mSplitImageComponent.getPreferredSize());
            mImageFrame.setSize(mImageFrame.getPreferredSize());
            list.setEnabled(true);
            accumulateCheckbox.setEnabled(true);
            statusLabel.setText("Performing " + key + "...done.");
        }
    });

    Button loadButton = new Button("Load...");
    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            FileDialog fd = new FileDialog(Sampler.this);
            fd.show();
            if (fd.getFile() == null)
                return;
            String path = fd.getDirectory() + fd.getFile();
            mSplitImageComponent.setImage(path);
            mSplitImageComponent.setSecondImage(null);
            //            Utilities.sizeContainerToComponent(mImageFrame,
            //               mSplitImageComponent);
            mImageFrame.validate();
            mImageFrame.repaint();
        }
    });

    Panel bottom = new Panel(new GridLayout(2, 1));
    Panel topBottom = new Panel();
    topBottom.add(accumulateCheckbox);
    topBottom.add(loadButton);
    bottom.add(topBottom);
    bottom.add(statusLabel);
    add(bottom, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            mImageFrame.dispose();
            dispose();
            System.exit(0);
        }
    });
}

From source file:org.ecoinformatics.seek.ecogrid.quicksearch.QuickSearchAction.java

private void searchEndPointsVector(Vector searchEndPoints, QueryType quickSearchQuery, String searchValue,
        MetadataSpecificationInterface metadataSpecClass, String namespace) {

    // go through each search end points and get result set
    for (int j = 0; j < searchEndPoints.size(); j++) {

        String url = (String) searchEndPoints.elementAt(j);
        log.debug("============search " + url + " for namespace " + namespace);
        QueryAction doQuery = new QueryAction(this, quickSearchQuery, url, searchValue, metadataSpecClass,
                namespace);//from w  w w.  ja v a 2 s .com
        actionList.addElement(doQuery);

    } // for
      // actionList = new Vector();

}

From source file:FileTree2.java

public boolean expand(DefaultMutableTreeNode parent) {
    DefaultMutableTreeNode flag = (DefaultMutableTreeNode) parent.getFirstChild();
    if (flag == null) // No flag
        return false;
    Object obj = flag.getUserObject();
    if (!(obj instanceof Boolean))
        return false; // Already expanded

    parent.removeAllChildren(); // Remove Flag

    File[] files = listFiles();/*from  w ww.  j  a v a2  s.c o m*/
    if (files == null)
        return true;

    Vector v = new Vector();

    for (int k = 0; k < files.length; k++) {
        File f = files[k];
        if (!(f.isDirectory()))
            continue;

        FileNode newNode = new FileNode(f);

        boolean isAdded = false;
        for (int i = 0; i < v.size(); i++) {
            FileNode nd = (FileNode) v.elementAt(i);
            if (newNode.compareTo(nd) < 0) {
                v.insertElementAt(newNode, i);
                isAdded = true;
                break;
            }
        }
        if (!isAdded)
            v.addElement(newNode);
    }

    for (int i = 0; i < v.size(); i++) {
        FileNode nd = (FileNode) v.elementAt(i);
        IconData idata = new IconData(FileTree2.ICON_FOLDER, FileTree2.ICON_EXPANDEDFOLDER, nd);
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(idata);
        parent.add(node);

        if (nd.hasSubDirs())
            node.add(new DefaultMutableTreeNode(new Boolean(true)));
    }

    return true;
}

From source file:BugTrackerJFace.java

private void saveBugs(Vector v) {
    // Save bugs to a file.
    DataOutputStream out = null;//from  w w w  .  j  a  v a2 s  .  c  o  m
    try {
        File file = new File("bugs.dat");

        out = new DataOutputStream(new FileOutputStream(file));

        for (int i = 0; i < v.size(); i++) {
            Bug bug = (Bug) v.elementAt(i);
            out.writeUTF(bug.id);
            out.writeUTF(bug.summary);
            out.writeUTF(bug.assignedTo);
            out.writeBoolean(bug.isSolved);
        }
    } catch (IOException ioe) {
        // Ignore.
    } finally {
        try {
            if (out != null)
                out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}