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:com.orange.atk.graphAnalyser.GraphMarker.java

/**
 * draw marker/*from ww  w  .  jav a  2s. c  o  m*/
 */
public final synchronized void drawMarker() {
    setMarkerPosition();
    Vector<Action> listActions = Vectaction;
    for (int i = 0; i < listActions.size(); i++) {
        Action action = listActions.get(i);
        if (action.getMarker() != null)
            xyplot.addDomainMarker(action.getMarker());
        else
            Logger.getLogger(this.getClass())
                    .debug("Erreur ActionName:" + action.getActionName() + " Remove MsgType "
                            + action.getMsgType() + " StartTime " + action.getStartTime() + " EndTime "
                            + action.getEndTime());

        if (action.getAnnotation() != null)
            xyplot.addAnnotation(action.getAnnotation());
        else
            Logger.getLogger(this.getClass())
                    .debug("Erreur ActionName:" + action.getActionName() + " Remove MsgType "
                            + action.getMsgType() + " StartTime " + action.getStartTime() + " EndTime "
                            + action.getEndTime());
    }
    isActivate = true;

}

From source file:eionet.gdem.qa.ListQAScriptsMethodTest.java

@Test
public void testListConversionsXQueryResult() throws Exception {

    ListQueriesMethod qas = new ListQueriesMethod();
    // get all queries (xqueries, xml schemas, xslts)
    Vector listQaResult = qas
            .listQAScripts("http://biodiversity.eionet.europa.eu/schemas/dir9243eec/generalreport.xsd");
    assertTrue(listQaResult.size() == 2);

    Vector ht = (Vector) listQaResult.get(0);

    assertEquals(ht.get(0), "48");
    assertEquals(ht.get(1), "Article 17 - General report species check");
    assertEquals(ht.get(3), "20");
}

From source file:net.sf.jdmf.util.MathCalculator.java

/**
 * Calculates the centroid of all given points in a nD space (assumes that
 * all points have n coordinates). Each coordinate of the centroid is a mean
 * of all values of the same coordinate of each point.
 * /*from   w  ww . java2s . c om*/
 * @param points all points
 * @return the centroid of all given points
 */
public Vector<Double> calculateCentroid(List<Vector<Double>> points) {
    List<Mean> coordinateMeans = new ArrayList<Mean>();

    for (int i = 0; i < points.get(0).size(); ++i) {
        coordinateMeans.add(new Mean());
    }

    for (Vector<Double> point : points) {
        for (int i = 0; i < point.size(); ++i) {
            coordinateMeans.get(i).increment(point.get(i));
        }
    }

    Vector<Double> centroid = new Vector<Double>();

    for (Mean mean : coordinateMeans) {
        centroid.add(mean.getResult());
    }

    return centroid;
}

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

/**
 * @param oldDBConn/*from  w ww.  j a  v a  2 s.  com*/
 * @param newDBConn
 */
public static void moveGTPNameToCEText1(final Connection oldDBConn, final Connection newDBConn) {
    String sql = null;
    try {
        IdMapperIFace ceMapper = IdMapperMgr.getInstance().addTableMapper("collectingevent",
                "CollectingEventID", false);

        Timestamp now = new Timestamp(System.currentTimeMillis());
        PreparedStatement pStmt = newDBConn.prepareStatement(
                "UPDATE collectingeventattribute SET Text3=? WHERE CollectingEventAttributeID=?");

        PreparedStatement pStmt2 = newDBConn.prepareStatement(
                "INSERT INTO collectingeventattribute SET Text3=?, Version=0, DisciplineID=?, TimestampCreated=?, TimestampModified=?",
                Statement.RETURN_GENERATED_KEYS);
        PreparedStatement pStmt3 = newDBConn.prepareStatement(
                "UPDATE collectingevent SET CollectingEventAttributeID=? WHERE CollectingEventID=?");

        int cnt = 0;
        // Query to Create PickList
        sql = "SELECT c.CollectingEventID, g.Name FROM collectingevent AS c "
                + "Inner Join stratigraphy AS s ON c.CollectingEventID = s.StratigraphyID "
                + "Inner Join geologictimeperiod AS g ON s.GeologicTimePeriodID = g.GeologicTimePeriodID ";
        for (Object[] row : BasicSQLUtils.query(oldDBConn, sql)) {
            Integer id = (Integer) row[0];
            Integer newCEId = ceMapper.get(id);
            if (newCEId != null) {
                Vector<Object[]> colList = BasicSQLUtils.query(
                        "SELECT DisciplineID, CollectingEventAttributeID FROM collectingevent WHERE CollectingEventID = "
                                + newCEId);
                Object[] cols = colList.get(0);

                if (cols[1] != null) {
                    pStmt.setString(1, (String) row[1]);
                    pStmt.setInt(2, newCEId);

                    int rv = pStmt.executeUpdate();
                    if (rv != 1) {
                        log.error(String.format("Error updating CEA New Id %d  Old: %d  rv: %d", newCEId, id,
                                rv));
                    }
                } else {
                    Integer disciplineID = (Integer) cols[0];
                    pStmt2.setString(1, (String) row[1]);
                    pStmt2.setInt(2, disciplineID);
                    pStmt2.setTimestamp(3, now);
                    pStmt2.setTimestamp(4, now);

                    int rv = pStmt2.executeUpdate();
                    if (rv == 1) {
                        Integer newCEAId = BasicSQLUtils.getInsertedId(pStmt2);
                        if (newCEAId != null) {
                            pStmt3.setInt(1, newCEAId);
                            pStmt3.setInt(2, newCEId);
                            rv = pStmt3.executeUpdate();
                            if (rv != 1) {
                                log.error(String.format("Error updating CEA New Id %d To CE ID: %d", newCEAId,
                                        newCEId));
                            }
                        } else {
                            log.error("Couldn't get inserted CEAId");
                        }

                    } else {
                        log.error(String.format("Error updating CEA New Id %d  Old: %d  rv: %d", newCEId, id,
                                rv));
                    }
                }
            } else {
                log.error(String.format("No Map for Old CE Id %d", id));
            }
            cnt++;
            if (cnt % 500 == 0) {
                log.debug("Count " + cnt);
            }
        }
        log.debug("Count " + cnt);
        pStmt.close();

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:grafix.graficos.ConstrutorGrafico.java

private XYPlot[] gerarTodosOsPlotsExtras() {
    Vector<EixoExtra> eixosExtras = janela.getConfiguracoesJanela().getEixosExtras();
    XYPlot[] plots = new XYPlot[eixosExtras.size()];
    for (int i = 0; i < plots.length; i++) {
        plots[i] = eixosExtras.get(i).getPlot(janela);
    }//from w  w  w  .  j a  va 2 s  . c  o m
    return plots;
}

From source file:com.orange.atk.graphAnalyser.GraphMarker.java

/**
 * remove marker// w w  w . j av a 2 s.c  om
 */
public void removeMarker() {
    Vector<Action> listActions = Vectaction;
    int size = listActions.size();

    for (int i = 0; i < size; i++) {
        Action action = listActions.get(i);
        if (action.getMarker() != null)
            xyplot.removeDomainMarker(action.getMarker());
        else
            Logger.getLogger(this.getClass())
                    .debug("Erreur ActionName:" + action.getActionName() + " Remove MsgType "
                            + action.getMsgType() + " StartTime " + action.getStartTime() + " EndTime "
                            + action.getEndTime());
        if (action.getAnnotation() != null)
            xyplot.removeAnnotation(action.getAnnotation());
        else
            Logger.getLogger(this.getClass())
                    .debug("Erreur ActionName:" + action.getActionName() + "Remove MsgType "
                            + action.getMsgType() + " StartTime " + action.getStartTime() + " EndTime "
                            + action.getEndTime());
    }
    isActivate = false;

}

From source file:net.sf.jdmf.util.MathCalculator.java

/**
 * Calculates the distance between two points in a nD space (assumes that
 * n = firstPoint.size() = secondPoint.size()). 
 * //from ww w . jav a2  s  .c  o  m
 * @param firstPoint the first point
 * @param secondPoint the second point
 * @return the distance between both points
 */
public Double calculateDistance(Vector<Double> firstPoint, Vector<Double> secondPoint) {
    SumOfSquares sumOfSquares = new SumOfSquares();

    for (int i = 0; i < firstPoint.size(); ++i) {
        sumOfSquares.increment(secondPoint.get(i) - firstPoint.get(i));
    }

    return Math.sqrt(sumOfSquares.getResult());
}

From source file:edu.illinois.cs.comoto.jplag.anonymize.FileAnonymizer.java

/**
 * @param files a vector of file objects
 * @return a string representing the greatest common base directory of all files in the input vector
 */// w w w.  ja  v a 2  s.c o  m
private String getBaseDir(Vector<File> files) {
    String baseDir = null;
    try {
        baseDir = files.get(0).getCanonicalPath();
        for (File f : files) {
            baseDir = getLongestCommonPath(f, baseDir);
        }

    } catch (IOException ioe) {
        System.err.println("Error anonymizing files");
        System.err.println(ioe.getMessage());
        ioe.printStackTrace();
        System.exit(1);
    }
    return baseDir;
}

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

/**
 * @param oldDBConn/*ww  w . j av a  2 s  .  c  o  m*/
 * @param newDBConn
 */
public static void moveStratFieldsToCEA(final Connection oldDBConn, final Connection newDBConn) {
    String sql = null;
    try {
        IdMapperIFace ceMapper = IdMapperMgr.getInstance().addTableMapper("collectingevent",
                "CollectingEventID", false);

        String postFix = " FROM collectingevent ce Inner Join collectingeventattribute AS cea ON ce.CollectingEventAttributeID = cea.CollectingEventAttributeID ";

        /*
        Specify 5 Field ----------> Specify 6 Field
        Stratigraphy.superGroup --> CEA.text3
        Stratigraphy.group      --> CEA.text4
        Stratigraphy.formation  --> CEA.text5
        Stratigraphy.text1      --> CEA.text1
        Stratigraphy.number1    --> CEA.number1
        Stratigraphy.text2      --> CEA.text2
         */

        Timestamp now = new Timestamp(System.currentTimeMillis());
        PreparedStatement pStmt = newDBConn.prepareStatement(
                "UPDATE collectingeventattribute SET Text1=?, Text2=?, Text3=?, Text4=?, Text5=?, Number1=? WHERE CollectingEventAttributeID=?");

        PreparedStatement pStmt2 = newDBConn.prepareStatement(
                "INSERT INTO collectingeventattribute SET Text1=?, Text2=?, Text3=?, Text4=?, Text5=?, Number1=?, Version=0, DisciplineID=?, TimestampCreated=?, TimestampModified=?",
                Statement.RETURN_GENERATED_KEYS);
        PreparedStatement pStmt3 = newDBConn.prepareStatement(
                "UPDATE collectingevent SET CollectingEventAttributeID=? WHERE CollectingEventID=?");

        int cnt = 0;
        // Query to Create PickList
        sql = "SELECT StratigraphyID, Text1, Text2, SuperGroup, `Group`, Formation, Number1 FROM stratigraphy";
        for (Object[] row : BasicSQLUtils.query(oldDBConn, sql)) {
            Integer id = (Integer) row[0];
            Integer newCEId = ceMapper.get(id);
            if (newCEId != null) {
                Vector<Object[]> colList = BasicSQLUtils.query(
                        "SELECT DisciplineID, CollectingEventAttributeID FROM collectingevent WHERE CollectingEventID = "
                                + newCEId);
                Object[] cols = colList.get(0);

                if (cols[1] != null) {
                    pStmt.setString(1, (String) row[1]);
                    pStmt.setString(2, (String) row[2]);
                    pStmt.setString(3, (String) row[3]);
                    pStmt.setString(4, (String) row[4]);
                    pStmt.setString(5, (String) row[5]);
                    pStmt.setString(6, (String) row[6]);
                    pStmt.setInt(7, newCEId);

                    int rv = pStmt.executeUpdate();
                    if (rv != 1) {
                        log.error(String.format("Error updating CEA New Id %d  Old: %d  rv: %d", newCEId, id,
                                rv));
                    }
                } else {
                    Integer disciplineID = (Integer) cols[0];
                    pStmt2.setString(1, (String) row[1]);
                    pStmt2.setString(2, (String) row[2]);
                    pStmt2.setString(3, (String) row[3]);
                    pStmt2.setString(4, (String) row[4]);
                    pStmt2.setString(5, (String) row[5]);
                    pStmt2.setString(6, (String) row[6]);
                    pStmt2.setInt(7, disciplineID);
                    pStmt2.setTimestamp(8, now);
                    pStmt2.setTimestamp(9, now);

                    int rv = pStmt2.executeUpdate();
                    if (rv == 1) {
                        Integer newCEAId = BasicSQLUtils.getInsertedId(pStmt2);
                        if (newCEAId != null) {
                            pStmt3.setInt(1, newCEAId);
                            pStmt3.setInt(2, newCEId);
                            rv = pStmt3.executeUpdate();
                            if (rv != 1) {
                                log.error(String.format("Error updating CEA New Id %d To CE ID: %d", newCEAId,
                                        newCEId));
                            }
                        } else {
                            log.error("Couldn't get inserted CEAId");
                        }

                    } else {
                        log.error(String.format("Error updating CEA New Id %d  Old: %d  rv: %d", newCEId, id,
                                rv));
                    }
                }
            } else {
                log.error(String.format("No Map for Old CE Id %d", id));
            }
            cnt++;
            if (cnt % 500 == 0) {
                log.debug("Count " + cnt);
            }
        }
        log.debug("Count " + cnt);
        pStmt.close();

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:edu.uchc.octane.CalibrationDialogAstigmatism.java

@Override
void setupDialog() {

    addNumericField("Pixel Size (nm)", 160, 0);
    addNumericField("Image resolution (nm)", 300, 0);
    addNumericField("Slice Spacing (nm)", 100, 0);

    addSlider("Noise Threshold", 1, 5000.0, 500);
    Vector<Scrollbar> sliders = (Vector<Scrollbar>) getSliders();
    sliders.get(0).setUnitIncrement(20); // default was 1

}