Example usage for java.util Vector get

List of usage examples for java.util Vector get

Introduction

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

Prototype

public synchronized E get(int index) 

Source Link

Document

Returns the element at the specified position in this Vector.

Usage

From source file:gskproject.Analyze.java

private void ddGraphPersonWiseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ddGraphPersonWiseActionPerformed
    Object obj = evt.getSource();
    if (obj == ddGraphPersonWise) {

        if (ddGraphPersonWise.getSelectedItem().toString().equals("Spread of all Cases among Persons")) {
            DefaultPieDataset pieDataSet = new DefaultPieDataset();

            for (Vector row : tablePersonWise) {
                pieDataSet.setValue(row.get(0).toString(), Double.parseDouble(row.get(1).toString()));
            }//  w  w w  .  j ava  2 s .  com
            JFreeChart chart = ChartFactory.createPieChart("Spread of all Cases among Persons", pieDataSet,
                    true, true, true);

            PiePlot p = (PiePlot) chart.getPlot();
            //p.setForegroundAlpha(TOP_ALIGNMENT);
            ChartFrame frame = new ChartFrame("Pie Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
            //System.out.println("aaa");
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of Cases(As Resposible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {//select the personwise for analysing
                barDataSet.setValue((Double.parseDouble(row.get(2).toString()) / (int) row.get(1)) * 100,
                        "Percentage of Cases(As Resposible Parties)", row.get(0).toString());
            }

            JFreeChart chart = ChartFactory.createBarChart("Percentage of Cases(As Resposible Parties)",
                    "Person", "Percentage of Cases(As Resposible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);

        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of opened cases out of No: of Cases(As Responsible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(3).toString()) / (int) row.get(2)) * 100,
                        "Percentage of opened cases out of No: of Cases(As Responsible Parties)",
                        row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of opened cases out of No: of Cases(As Responsible Parties)", "Person",
                    "Percentage of opened cases out of No: of Cases(As Responsible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of closed cases out of No: of Cases(As Responsible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue(
                        (Double.parseDouble(row.get(2).toString())
                                - (Double.parseDouble(row.get(3).toString())) / (int) row.get(2)) * 100,
                        "Percentage of closed cases out of No: of Cases(As Responsible Parties)",
                        row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of closed cases out of No: of Cases(As Responsible Parties)", "Person",
                    "Percentage of closed cases out of No: of Cases(As Responsible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString().equals("Percentage of Cases(As Observer)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(5).toString()) / (int) row.get(1)) * 100,
                        "Percentage of Cases(As Observer)", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart("Percentage of Cases(As Observer)", "Person",
                    "Percentage of Cases(As Observer)", barDataSet, PlotOrientation.VERTICAL, false, true,
                    false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of opened cases out of No: of Cases(As Observer)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(6).toString()) / (int) row.get(5)) * 100,
                        "Percentage of Closed cases", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of opened cases out of No: of Cases(As Observer)", "Person",
                    "Percentage of opened cases out of No: of Cases(As Observer)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue(
                        ((Double.parseDouble(row.get(5).toString())
                                - (Double.parseDouble(row.get(6).toString()))) / (int) row.get(5)) * 100,
                        "Percentage of closed cases out of No: of Cases(As Observer)", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of closed cases out of No: of Cases(As Observer)", "Person",
                    "Percentage of closed cases out of No: of Cases(As Observer)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        }
    }
}

From source file:ffx.numerics.fft.Complex.java

/**
 * Factor the data length into preferred factors (those with special
 * methods), falling back to odd primes that the general routine must
 * handle.//from  ww  w. j a  v a2 s  .  co  m
 *
 * @return integer factors
 */
private int[] factor() {
    if (n < 2) {
        return null;
    }
    Vector<Integer> v = new Vector<>();
    int ntest = n;
    int factor;
    /**
     * Use the preferred factors first
     */
    for (int i = 0; i < availableFactors.length; i++) {
        factor = availableFactors[i];
        while ((ntest % factor) == 0) {
            ntest /= factor;
            v.add(factor);
        }
    }
    /**
     * Unavailable odd prime factors.
     */
    factor = firstUnavailablePrime;
    while (ntest > 1) {
        while ((ntest % factor) != 0) {
            factor += 2;
        }
        ntest /= factor;
        v.add(factor);
    }
    int product = 1;
    int nf = v.size();
    int ret[] = new int[nf];
    for (int i = 0; i < nf; i++) {
        ret[i] = v.get(i);
        product *= ret[i];
    }
    /**
     * Report a failed factorization.
     */
    if (product != n) {
        StringBuilder sb = new StringBuilder(" FFT factorization failed for " + n + "\n");
        for (int i = 0; i < nf; i++) {
            sb.append(" ");
            sb.append(ret[i]);
        }
        sb.append("\n");
        sb.append(" Factor product = ");
        sb.append(product);
        sb.append("\n");
        logger.severe(sb.toString());
        System.exit(-1);
    } else {
        if (logger.isLoggable(Level.FINEST)) {
            StringBuilder sb = new StringBuilder(" FFT factorization for " + n + " = ");
            for (int i = 0; i < nf - 1; i++) {
                sb.append(ret[i]);
                sb.append(" * ");
            }
            sb.append(ret[nf - 1]);
            logger.fine(sb.toString());
        }
    }
    return ret;
}

From source file:edu.ku.brc.specify.conversion.BasicSQLUtils.java

/**
 * @param conn //  ww w .j  a  v a 2  s  .co  m
 * @param sql
 * @return
 */
@SuppressWarnings("unchecked")
public static <T> T querySingleObj(final Connection conn, final String sql) {
    Vector<Object> list = querySingleCol(conn, sql);
    if (list.size() > 1) {
        log.warn("The query [" + sql + "] returned more than one object.");
    }
    return list.size() > 0 ? (T) list.get(0) : null;
}

From source file:webServices.RestServiceImpl.java

@POST
@Path("/endpoint/charts/instances/{host}/{endpoint}/{port}")
@Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_JSON })
@Produces({ MediaType.TEXT_PLAIN })/*from  w  w  w .ja v  a  2s. c o m*/
public String getInstances(String data, @PathParam("host") String host, @PathParam("endpoint") String endpoint,
        @PathParam("port") int port) throws EndpointCommunicationException {
    Vector<String> results = new Vector<String>();
    String format = "";
    String fixedDim = data.substring(0, data.indexOf("$"));
    String fixedType = data.substring(data.indexOf("$") + 1, data.length());

    results = endpointStore.getInstancesNames(host, endpoint.replaceAll("@@@", "/"), port, fixedDim, fixedType);

    for (int i = 0; i < results.size(); i++) {
        format = format.concat(results.get(i));
        format = format.concat("$");
    }

    return format.concat(fixedType);
}

From source file:net.rim.ejde.internal.packaging.PackagingManager.java

private String composeImportsString(Vector<ImportedJar> vector, String separator, boolean exported) {
    StringBuffer buffer = new StringBuffer();
    if (vector == null) {
        return buffer.toString();
    }//  w ww.  ja v a2s.  c  o m
    boolean first = true;
    for (int i = 0; i < vector.size(); i++) {
        if (vector.get(i).isExported() != exported) {
            continue;
        }
        if (first) {
            buffer.append(vector.get(i).toString());
            first = false;
        } else {
            buffer.append(separator);
            buffer.append(vector.get(i).toString());
        }
    }
    return buffer.toString();
}

From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java

public void instantDownloadFile() {
    startSynchronization();//from  w w w.j  a  va 2s  .c om
    //
    // ContentResolver.
    DataStorageManager strgmanager = getStorageManager();
    if (strgmanager != null) {
        OCFile parent = strgmanager.getFileByPath("/");
        Vector<OCFile> filesInFolder = strgmanager.getDirectoryContent(parent);
        List<OCFile> filesToDownload = new ArrayList<OCFile>();
        int sharedIndicator = 0;
        for (int i = 0; i < filesInFolder.size(); i++) {
            if (filesInFolder.get(i).isDirectory()) {
                if (filesInFolder.get(i).getFileName().equals("Shared"))
                    sharedIndicator = 1;
                else
                    sharedIndicator = 0;
                getFilesinFoldersToDownload(filesInFolder.get(i), filesToDownload, sharedIndicator);
            } else if (!filesInFolder.get(i).isDown()) {
                filesToDownload.add(filesInFolder.get(i));

            } else if (!filesInFolder.get(i).isDirectory() && filesInFolder.get(i)
                    .getLocalModificationTimestamp() < filesInFolder.get(i).getModificationTimestamp()) {
                filesToDownload.add(filesInFolder.get(i));
            }
        }

        for (int i = 0; i < filesToDownload.size(); i++) {
            mWaitingToPreview = filesToDownload.get(i);
            requestForDownload();
            for (int j = 0; j < 10000; j++)
                ;
        }
    }

}

From source file:convcao.com.agent.ConvcaoNeptusInteraction.java

public TransferData localState() {
    TransferData data = new TransferData();
    data.timeStep = this.timestep;
    data.SessionID = sessionID;/* ww  w .  j a  v a2 s .  c o  m*/
    data.Bathymeter = new double[auvs];
    data.Location = new double[auvs][3];

    for (int AUV = 0; AUV < auvs; AUV++) {
        String auvName = nameTable.get(AUV);
        double noptDepth = coords.convertWgsDepthToNoptilusDepth(positions.get(auvName).getDepth());
        data.Bathymeter[AUV] = noptDepth - bathymetry.get(auvName);
        double[] nopCoords = coords.convert(positions.get(auvName));
        if (nopCoords == null) {
            GuiUtils.errorMessage(getConsole(), "ConvCAO", auvName + " is outside operating region");
            return null;
        }

        data.Location[AUV][0] = Math.round(nopCoords[0]);
        data.Location[AUV][1] = Math.round(nopCoords[1]);
        data.Location[AUV][2] = (int) noptDepth;
    }

    LinkedHashMap<EstimatedState, ArrayList<Distance>> samples = new LinkedHashMap<>();

    synchronized (dvlMeasurements) {
        samples.putAll(dvlMeasurements);
        dvlMeasurements.clear();
    }

    Vector<double[]> locations = new Vector<>();
    Vector<Double> bathymetry = new Vector<>();

    for (Entry<EstimatedState, ArrayList<Distance>> beams : samples.entrySet()) {
        for (Distance d : beams.getValue()) {
            double measurement[] = getBeamMeasurement(beams.getKey(), d);
            locations.add(new double[] { measurement[0], measurement[1], measurement[2] });
            bathymetry.add(measurement[3]);
        }
    }

    data.MBSamples = new double[bathymetry.size()];
    data.SampleLocations = new double[bathymetry.size()][3];

    for (int i = 0; i < bathymetry.size(); i++) {
        data.MBSamples[i] = bathymetry.get(i);
        data.SampleLocations[i] = locations.get(i);
    }

    return data;
}

From source file:skoa.helpers.Graficos.java

private void unificarDatosFicheros() {
    Vector<String> nombresFicheros2 = new Vector<String>(nombresFicheros); //Copiamos los nombres
    String nombreFicheroEscogido;
    String nombreFicheroReferencia = nombresFicheros2.get(0); //Se coge el 1 fichero de referencia, al que se le irn aadiendo los datos.
    nombresFicheros2.remove(0);/*  ww w  .  j  a  v a2s .c  o  m*/
    crearFicheroTemporal(nombreFicheroReferencia);
    for (int i = 0; i < nombresFicheros2.size(); i++) {
        nombreFicheroEscogido = nombresFicheros2.elementAt(i);
        File archivo = new File(ruta + nombreFicheroEscogido);
        FileReader fr = null;
        BufferedReader linea = null;
        String line;
        try {
            fr = new FileReader(archivo);
            linea = new BufferedReader(fr);
            while ((line = linea.readLine()) != null) { //Lectura del fichero
                incluirDatos(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (null != fr)
                    fr.close(); //Se cierra si todo va bien.
            } catch (Exception e2) { //Sino salta una excepcion.
                e2.printStackTrace();
            }
        }
    } //fin for
}

From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java

/**
 * @param mi/*from   www .j  av  a 2  s .  c o m*/
 * @param advanceFocus
 * @param idListClosure
 */
protected void itemSelected(final JMenuItem mi, final int advanceFocus, Vector<Integer> idListClosure) {
    hasNewText = false;
    //log.debug("setting hasNewText to true");
    if (advanceFocus != 0)
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                transferFocus(advanceFocus);
            }
        });

    String selectedStr = mi.getText();
    int inx = popupMenu.getComponentIndex(mi);
    if (inx > -1) {
        if (idListClosure.size() > 0 && (!doAddAddItem || inx > 0)) {
            selectedId = idListClosure.get(doAddAddItem ? inx - 1 : inx);
            setText(selectedStr);
        }

        if (listSelectionListeners != null) {
            String value = StringUtils.isEmpty(prevEnteredText) ? cachedPrevText : prevEnteredText;
            notifyListenersOfChange(mi.getText().equals(UIRegistry.getResourceString("TFWQ_ADD_LABEL"))
                    ? new AddItemEvent(value)
                    : mi);
        }
    }
}

From source file:skoa.helpers.Graficos.java

/**
 * FUNCIN ESTADSTICA PARA HALLAR LA EVOLUCIN DE DIFERENCIAS.
 * PORCENTAJE=(v1-v2)/v1*100//from  w w  w.  j  a  v  a  2 s.  co m
 * DIFERENCIA=(v1-v2)
 * En caso de que no se encuentren los dos valores, y slo haya 1 o ninguno, se obvia esa medicion.
 * Vamos a comparar segn un intervalo en minutos. Si en ese intervalo, hay + de 1 medicion, se hace la media.
 * @param i, subopcion: 1=porcentaje y otro=diferencia normal
 */
private void aplicarFormula(int i) {
    Vector<String> nombresFicheros2 = new Vector<String>(nombresFicheros); //Copiamos los nombres
    String freferencia = nombresFicheros2.get(0); //Se coge el 1 fichero de referencia, al que se le irn aadiendo los datos.
    nombresFicheros2.remove(0);
    String fcomparar = nombresFicheros2.get(0);
    compararFicheros(freferencia, fcomparar);
    //Nombre del fichero resultante: n=tipo-intervalo-x-xx-xx-y-yy-yy
    String d1, d2, n;
    n = freferencia.substring(0, 4); //Hasta el segundo '-', es decir coge el tipo de consulta e intervalo
    //d1=freferencia.substring(freferencia.length()-10, freferencia.length()-4);   //La DG del fich referencia (1 columna de valores)
    //d2=fcomparar.substring(fcomparar.length()-10, fcomparar.length()-4);       //La DG del otro fichero    (2 columna de valores)
    d1 = freferencia.substring(freferencia.indexOf(" ") - 6, freferencia.indexOf(" "));
    d2 = fcomparar.substring(fcomparar.indexOf(" ") - 6, fcomparar.indexOf(" "));
    //System.out.println(d1+"-"+d2+".");

    n = n + "-" + d1 + "-" + d2; //Fichero usado para obtener la serie. Es el fichero resultante de aplicarFormulaP()
    FileReader fr = null;
    BufferedReader linea = null;
    String line;
    //Leemos el fichero unificado.txt con los dos valores y les aplicamos la frmula (V1/V2)*100
    File uni = new File(ruta + "unificado.txt");
    try {
        int i1 = 1;
        fr = new FileReader(uni);
        linea = new BufferedReader(fr);
        unidad = "";
        while ((line = linea.readLine()) != null) { //Lectura del fichero
            String v, f, l;
            float v1 = 0, v2;
            f = line.substring(0, line.indexOf("\t"));
            l = line.substring(line.indexOf("\t") + 1); //l tiene hasta los valores.
            if (l.indexOf("0") == 0)
                v1 = 0; //El primer valor es un 0.
            else if (l.indexOf(" ") > 0) { //El 1 valor es distinto de 0, por lo convertimos a int.
                v = l.substring(0, l.indexOf(" "));
                v1 = Float.parseFloat(v);
                if (i1 == 1) {
                    String aux = l.substring(l.indexOf(" ") + 1);
                    if (aux.indexOf("\t") >= 0)
                        aux = aux.substring(0, aux.indexOf("\t"));
                    unidad = unidad + aux;
                    //i1=0;
                }
            }
            if (l.indexOf("\t") >= 0) { //Si encontramos \t, quiere decir que hay un segundo valor !=0
                l = l.substring(l.indexOf("\t") + 1);
                v = l.substring(0, l.indexOf(" "));
                v2 = Float.parseFloat(v);
                /*if (i1==1){
                    //unidad=unidad+l.substring(l.indexOf(" ")+1);
                    i1=0;
                }*/
            } else
                v2 = 0;
            //Una vez tenemos los valores en v1 y v2, aplicamos la formula. Si el numerador y/o denominador es 0
            //entonces el resultado ser directamente 0. En v1, guardamos el resultado (reusamos esta variable)
            if (v1 == 0 || v2 == 0)
                v1 = 0;
            else if (v1 == 0 && v2 == 0)
                v1 = 0;
            else {
                if (i == 1) { //HALLA EL PORCENTAJE.
                    float r = v1 - v2;
                    if (r < 0)
                        r = 0 - r;
                    v1 = (r / v1) * 100;
                } else
                    v1 = v1 - v2; //HALLA EL VALOR de la diferencia, que puede ser negativo.
            }
            guardar(f, v1, n);
            i1 = 0;
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            if (null != fr)
                fr.close(); //Se cierra si todo va bien.
        } catch (Exception e2) { //Sino salta una excepcion.
            e2.printStackTrace();
        }
    }
    if (i == 1)
        unidad = "%" + "\t" + unidad;
    else
        unidad = "ABS" + "\t" + unidad;
}