Example usage for java.util Vector Vector

List of usage examples for java.util Vector Vector

Introduction

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

Prototype

public Vector() 

Source Link

Document

Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.

Usage

From source file:netplot.TimeSeriesPlotPanel.java

public void init() {
    finalize();/*w ww .  j ava  2s  .  c  o  m*/
    timeSeriesList = new Vector<TimeSeries>();
    chart = createChart(null);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    add(chartPanel);
}

From source file:edu.umn.cs.spatialHadoop.util.Parallel.java

public static <T> List<T> forEach(int start, int end, RunnableRange<T> r, int parallelism)
        throws InterruptedException {
    Vector<T> results = new Vector<T>();
    if (end <= start)
        return results;
    final Vector<Throwable> exceptions = new Vector<Throwable>();
    Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread th, Throwable ex) {
            exceptions.add(ex);/*ww w  .ja va  2 s  .  c o m*/
        }
    };

    // Put an upper bound on parallelism to avoid empty ranges
    if (parallelism > (end - start))
        parallelism = end - start;
    if (parallelism == 1) {
        // Avoid creating threads
        results.add(r.run(start, end));
    } else {
        LOG.info("Creating " + parallelism + " threads");
        final int[] partitions = new int[parallelism + 1];
        for (int i_thread = 0; i_thread <= parallelism; i_thread++)
            partitions[i_thread] = i_thread * (end - start) / parallelism + start;
        final Vector<RunnableRangeThread<T>> threads = new Vector<RunnableRangeThread<T>>();
        for (int i_thread = 0; i_thread < parallelism; i_thread++) {
            RunnableRangeThread<T> thread = new RunnableRangeThread<T>(r, partitions[i_thread],
                    partitions[i_thread + 1]);
            thread.setUncaughtExceptionHandler(h);
            threads.add(thread);
            threads.lastElement().start();
        }
        for (int i_thread = 0; i_thread < parallelism; i_thread++) {
            threads.get(i_thread).join();
            results.add(threads.get(i_thread).getResult());
        }
        if (!exceptions.isEmpty())
            throw new RuntimeException(exceptions.size() + " unhandled exceptions", exceptions.firstElement());
    }
    return results;
}

From source file:com.googlecode.gmaps4jsf.jsfplugin.digester.Component.java

public Component() {
    attributes = new Vector();
}

From source file:netplot.XYPlotPanel.java

public void init() {
    xySeriesList = new Vector<XYSeries>();
    chart = createChart(null);/* www .  j av a  2 s. c  o  m*/
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    itemCountList = new Vector<Integer>();
    add(chartPanel);
}

From source file:Main.java

public Main() throws Exception {
    ArrayList columnNames = new ArrayList();
    ArrayList data = new ArrayList();
    String url = "jdbc:mysql://localhost:3306/yourdb";
    String userid = "root";
    String password = "sesame";
    String sql = "SELECT * FROM animals";

    Connection connection = DriverManager.getConnection(url, userid, password);
    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery(sql);
    ResultSetMetaData md = rs.getMetaData();
    int columns = md.getColumnCount();
    for (int i = 1; i <= columns; i++) {
        columnNames.add(md.getColumnName(i));
    }/*from   w w  w  . jav  a2s  .  co  m*/
    while (rs.next()) {
        ArrayList row = new ArrayList(columns);
        for (int i = 1; i <= columns; i++) {
            row.add(rs.getObject(i));
        }
        data.add(row);
    }
    Vector columnNamesVector = new Vector();
    Vector dataVector = new Vector();
    for (int i = 0; i < data.size(); i++) {
        ArrayList subArray = (ArrayList) data.get(i);
        Vector subVector = new Vector();
        for (int j = 0; j < subArray.size(); j++) {
            subVector.add(subArray.get(j));
        }
        dataVector.add(subVector);
    }
    for (int i = 0; i < columnNames.size(); i++)
        columnNamesVector.add(columnNames.get(i));
    JTable table = new JTable(dataVector, columnNamesVector) {
        public Class getColumnClass(int column) {
            for (int row = 0; row < getRowCount(); row++) {
                Object o = getValueAt(row, column);
                if (o != null) {
                    return o.getClass();
                }
            }
            return Object.class;
        }
    };
    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane);
    JPanel buttonPanel = new JPanel();
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
}

From source file:controller.DistributorManagerController.java

private void initData(ModelMap mm) {
    Vector data = new Vector();
    Vector column = new Vector();
    List<Distributor> list = disModel.getAll();
    if (list.size() == 0) {
        Distributor dis = new Distributor("Auto genarate", "Auto genarate", "Auto genarate", "Auto genarate",
                Byte.valueOf("0"), "Auto genarate", "Auto genarate", new HashSet());
        disModel.addOrUpdate(dis);//w ww .  j  av  a2  s  .  c o  m
        list = disModel.getAll();
    }

    column.add("ID");
    column.add("Name");
    column.add("Address");
    column.add("Email");
    column.add("Phone");
    column.add("Status");

    for (Distributor dis : list) {
        Vector tmp = new Vector();
        tmp.add(dis.getDistributorId());
        tmp.add("id://" + dis.getDistributorId());
        tmp.add(dis.getDisName());
        tmp.add(dis.getDisAddress());
        tmp.add(dis.getDisEmail());
        tmp.add(dis.getDisPhone());
        tmp.add(dis.getStatus() == 1 ? "Active" : "Non-Active");
        data.add(tmp);
    }
    mm.put("column", column);
    mm.put("data", data);
}

From source file:com.cloudbase.datacommands.CBDataAggregationCommandProject.java

public CBDataAggregationCommandProject() {
    this.includeFields = new Vector();
    this.excludeFields = new Vector();

    this.setCommandType(CBDataAggregationCommandType.CBDataAggregationProject);
}

From source file:genepi.db.ListHandler.java

public List<Object> toBeanList(ResultSet rs) throws SQLException {
    List<Object> result = new Vector<Object>();

    int row = 0;/*from   w  ww  .jav  a  2s. c  o  m*/
    while (rs.next()) {
        Object value = mapper.mapRow(rs, row);
        if (value != null) {
            result.add(value);
        }
        row++;
    }

    return result;
}

From source file:edu.umn.cs.spatialHadoop.mapred.FileSplitUtil.java

/**
 * Combines a number of file splits into one CombineFileSplit. If number of
 * splits to be combined is one, it returns this split as is without creating
 * a CombineFileSplit./* w ww .j a  va 2  s  .co  m*/
 * @param splits
 * @param startIndex
 * @param count
 * @return
 * @throws IOException 
 */
public static InputSplit combineFileSplits(JobConf conf, List<FileSplit> splits, int startIndex, int count)
        throws IOException {
    if (count == 1) {
        return splits.get(startIndex);
    } else {
        Path[] paths = new Path[count];
        long[] starts = new long[count];
        long[] lengths = new long[count];
        Vector<String> vlocations = new Vector<String>();
        while (count > 0) {
            paths[count - 1] = splits.get(startIndex).getPath();
            starts[count - 1] = splits.get(startIndex).getStart();
            lengths[count - 1] = splits.get(startIndex).getLength();
            vlocations.addAll(Arrays.asList(splits.get(startIndex).getLocations()));
            count--;
            startIndex++;
        }
        String[] locations = prioritizeLocations(vlocations);
        if (locations.length > 3) {
            String[] topLocations = new String[3];
            System.arraycopy(locations, 0, topLocations, 0, topLocations.length);
            locations = topLocations;
        }
        return new CombineFileSplit(conf, paths, starts, lengths, locations);
    }
}

From source file:grafix.telas.PanelMolduras.java

private void criarMolduras() {
    molduras = new Vector<MolduraAreaDados>();
    Vector<Eixo> eixosVisiveis = getJanela().getConfiguracoesJanela().getEixosVisiveis();
    int contador = 0;
    this.setIgnoreRepaint(true);
    for (Eixo eixo : eixosVisiveis) {
        MolduraAreaDados novaMoldura = new MolduraAreaDados(this, eixo, contador++);
        getMolduras().add(novaMoldura);/*from www.j  ava 2 s . c om*/
        add(novaMoldura);
    }
    this.setIgnoreRepaint(false);
}