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:net.java.sip.communicator.impl.history.HistoryReaderImpl.java

/**
 * Returns the supplied number of recent messages
 * containing all <tt>keywords</tt>.
 *
 * @param count messages count/* w  ww .  j av  a  2  s  .c  om*/
 * @param keywords array of keywords we search for
 * @param field the field where to look for the keyword
 * @param caseSensitive is keywords search case sensitive
 * @return the found records
 * @throws RuntimeException
 */
public synchronized QueryResultSet<HistoryRecord> findLast(int count, String[] keywords, String field,
        boolean caseSensitive) throws RuntimeException {
    // the files are supposed to be ordered from oldest to newest
    Vector<String> filelist = filterFilesByDate(this.historyImpl.getFileList(), null, null);

    TreeSet<HistoryRecord> result = new TreeSet<HistoryRecord>(new HistoryRecordComparator());
    int leftCount = count;
    int currentFile = filelist.size() - 1;

    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
    while (leftCount > 0 && currentFile >= 0) {
        Document doc = this.historyImpl.getDocumentForFile(filelist.get(currentFile));

        if (doc == null) {
            currentFile--;
            continue;
        }

        // will get nodes and construct a List of nodes
        // so we can easily get sublist of it
        List<Node> nodes = new ArrayList<Node>();
        NodeList nodesList = doc.getElementsByTagName("record");
        for (int i = 0; i < nodesList.getLength(); i++) {
            nodes.add(nodesList.item(i));
        }

        List<Node> lNodes = null;

        if (nodes.size() > leftCount) {
            lNodes = nodes.subList(nodes.size() - leftCount, nodes.size());
            leftCount = 0;
        } else {
            lNodes = nodes;
            leftCount -= nodes.size();
        }

        Iterator<Node> i = lNodes.iterator();
        while (i.hasNext()) {
            Node node = i.next();

            NodeList propertyNodes = node.getChildNodes();

            Date timestamp;
            String ts = node.getAttributes().getNamedItem("timestamp").getNodeValue();
            try {
                timestamp = sdf.parse(ts);
            } catch (ParseException e) {
                timestamp = new Date(Long.parseLong(ts));
            }

            HistoryRecord record = filterByKeyword(propertyNodes, timestamp, keywords, field, caseSensitive);

            if (record != null) {
                result.add(record);
            }
        }

        currentFile--;
    }

    return new OrderedQueryResultSet<HistoryRecord>(result);
}

From source file:net.sf.mzmine.modules.peaklistmethods.identification.metamsecorrelate.MetaMSEcorrelateTask.java

/**
 * does not check maxCharge-delete afterwards
 * @param adducts//from   w  ww.  java2s. co  m
 * @param maxCombination
 * @param maxCharge
 * @param run init with 1
 */
private void combineAdducts(Vector<ESIAdductType> targetList, ESIAdductType[] selectedList,
        final Vector<ESIAdductType> adducts, int maxCombination, int run, boolean zeroChargeAllowed) {
    Vector<ESIAdductType> newAdducts = new Vector<ESIAdductType>();
    for (int i = 0; i < adducts.size(); i++) {
        ESIAdductType a1 = adducts.get(i);
        for (int k = 0; k < selectedList.length; k++) {
            ESIAdductType a2 = selectedList[k];
            ESIAdductType na = new ESIAdductType(a1, a2);
            if ((zeroChargeAllowed || na.getCharge() != 0) && !isContainedIn(targetList, na)) {
                newAdducts.add(na);
                targetList.add(na);
            }
        }
    }
    // first run = combination of two
    if (run + 1 < maxCombination) {
        combineAdducts(targetList, selectedList, newAdducts, maxCombination, run + 1, zeroChargeAllowed);
    }
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetPlatformsListener.java

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setPlatformsUI.getValues();
    Vector<String> samples = this.setPlatformsUI.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
        this.setPlatformsUI.displayMessage("Error: no subject to sample mapping file");
    }// w  w w .j  a v a 2s .  c o m
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(stsmf));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String platform;
                if (samples.contains(sample)) {
                    platform = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + platform
                        + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.setPlatformsUI.displayMessage("Error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setPlatformsUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setPlatformsUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setPlatformsUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetAttribute1Listener.java

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setAttribute1UI.getValues();
    Vector<String> samples = this.setAttribute1UI.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
        this.setAttribute1UI.displayMessage("Error: no subject to sample mapping file");
    }//  w  ww.ja va 2  s  .c  o  m
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(stsmf));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String attribute;
                if (samples.contains(sample)) {
                    attribute = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4]
                        + "\t" + fields[5] + "\t" + attribute + "\t" + fields[7] + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            setAttribute1UI.displayMessage("File error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setAttribute1UI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setAttribute1UI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setAttribute1UI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetAttribute2Listener.java

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setAttribute2UI.getValues();
    Vector<String> samples = this.setAttribute2UI.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
        this.setAttribute2UI.displayMessage("Error: no subject to sample mapping file");
    }//from w w w .j a  va 2 s  .co m
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(stsmf));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String attribute;
                if (samples.contains(sample)) {
                    attribute = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4]
                        + "\t" + fields[5] + "\t" + fields[6] + "\t" + attribute + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.setAttribute2UI.displayMessage("File error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setAttribute2UI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setAttribute2UI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setAttribute2UI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:net.java.sip.communicator.impl.history.HistoryReaderImpl.java

/**
 * Returns the supplied number of recent messages before the given date
 *
 * @param date messages before date/*  w  w w  .j av a2s.c  om*/
 * @param count messages count
 * @return QueryResultSet the found records
 * @throws RuntimeException
 */
public QueryResultSet<HistoryRecord> findLastRecordsBefore(Date date, int count) throws RuntimeException {
    // the files are supposed to be ordered from oldest to newest
    Vector<String> filelist = filterFilesByDate(this.historyImpl.getFileList(), null, date);

    TreeSet<HistoryRecord> result = new TreeSet<HistoryRecord>(new HistoryRecordComparator());
    int leftCount = count;

    int currentFile = filelist.size() - 1;

    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
    while (leftCount > 0 && currentFile >= 0) {
        Document doc = this.historyImpl.getDocumentForFile(filelist.get(currentFile));

        if (doc == null) {
            currentFile--;
            continue;
        }

        NodeList nodes = doc.getElementsByTagName("record");

        Node node;
        for (int i = nodes.getLength() - 1; i >= 0 && leftCount > 0; i--) {
            node = nodes.item(i);
            NodeList propertyNodes = node.getChildNodes();

            Date timestamp;
            String ts = node.getAttributes().getNamedItem("timestamp").getNodeValue();
            try {
                timestamp = sdf.parse(ts);
            } catch (ParseException e) {
                timestamp = new Date(Long.parseLong(ts));
            }

            if (!isInPeriod(timestamp, null, date))
                continue;

            ArrayList<String> nameVals = new ArrayList<String>();

            boolean isRecordOK = true;
            int len = propertyNodes.getLength();
            for (int j = 0; j < len; j++) {
                Node propertyNode = propertyNodes.item(j);
                if (propertyNode.getNodeType() == Node.ELEMENT_NODE) {
                    // Get nested TEXT node's value
                    Node nodeValue = propertyNode.getFirstChild();

                    if (nodeValue != null) {
                        nameVals.add(propertyNode.getNodeName());
                        nameVals.add(nodeValue.getNodeValue());
                    } else
                        isRecordOK = false;
                }
            }

            // if we found a broken record - just skip it
            if (!isRecordOK)
                continue;

            String[] propertyNames = new String[nameVals.size() / 2];
            String[] propertyValues = new String[propertyNames.length];
            for (int j = 0; j < propertyNames.length; j++) {
                propertyNames[j] = nameVals.get(j * 2);
                propertyValues[j] = nameVals.get(j * 2 + 1);
            }

            HistoryRecord record = new HistoryRecord(propertyNames, propertyValues, timestamp);

            result.add(record);
            leftCount--;
        }

        currentFile--;
    }

    return new OrderedQueryResultSet<HistoryRecord>(result);
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetTissueTypeListener.java

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setTissueTypeUI.getValues();
    Vector<String> samples = this.setTissueTypeUI.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
        this.setTissueTypeUI.displayMessage("Error: no subject to sample mapping file");
    }// w w w  . j  av a 2s .  com
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(stsmf));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String tissueType;
                if (samples.contains(sample)) {
                    tissueType = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4]
                        + "\t" + tissueType + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.setTissueTypeUI.displayMessage("File error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setTissueTypeUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setTissueTypeUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setTissueTypeUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:edu.stanford.cfuller.imageanalysistools.fitting.CentroidImageObject.java

/**
  * "Fits" this object to a position by finding its intensity-weighted
  * centroid.  Does not compute error estimates, numbers of photons, etc.
  * /*from   www .ja  v a  2 s .  co  m*/
  * @param p     The parameters for the current analysis.
  */
@Override
public void fitPosition(ParameterDictionary p) {

    if (this.sizeInPixels == 0) {
        this.nullifyImages();
        return;
    }

    this.fitParametersByChannel = new java.util.ArrayList<FitParameters>();
    this.fitR2ByChannel = new java.util.ArrayList<Double>();
    this.fitErrorByChannel = new java.util.ArrayList<Double>();
    this.nPhotonsByChannel = new java.util.ArrayList<Double>();

    int numChannels = 0;

    if (p.hasKey("num_wavelengths")) {
        numChannels = p.getIntValueForKey("num_wavelengths");
    } else {
        numChannels = this.parent.getDimensionSizes().get(ImageCoordinate.C);
    }

    for (int channelIndex = 0; channelIndex < numChannels; channelIndex++) {

        this.parentBoxMin.set(ImageCoordinate.C, channelIndex);
        this.parentBoxMax.set(ImageCoordinate.C, channelIndex + 1);

        this.boxImages();

        java.util.Vector<Double> x = new java.util.Vector<Double>();
        java.util.Vector<Double> y = new java.util.Vector<Double>();
        java.util.Vector<Double> z = new java.util.Vector<Double>();
        java.util.Vector<Float> f = new java.util.Vector<Float>();

        for (ImageCoordinate ic : this.parent) {
            x.add((double) ic.get(ImageCoordinate.X));
            y.add((double) ic.get(ImageCoordinate.Y));
            z.add((double) ic.get(ImageCoordinate.Z));
            if (((int) this.mask.getValue(ic)) == this.label) {
                f.add(parent.getValue(ic));
            } else {
                f.add(0.0f);
            }
        }

        xValues = new double[x.size()];
        yValues = new double[y.size()];
        zValues = new double[z.size()];
        functionValues = new double[f.size()];

        double xCentroid = 0;
        double yCentroid = 0;
        double zCentroid = 0;
        double totalCounts = 0;

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

            xValues[i] = x.get(i);
            yValues[i] = y.get(i);
            zValues[i] = z.get(i);
            functionValues[i] = f.get(i);
            xCentroid += xValues[i] * functionValues[i];
            yCentroid += yValues[i] * functionValues[i];
            zCentroid += zValues[i] * functionValues[i];
            totalCounts += functionValues[i];
        }

        xCentroid /= totalCounts;
        yCentroid /= totalCounts;
        zCentroid /= totalCounts;

        RealVector position = new ArrayRealVector(3, 0.0);

        position.setEntry(0, xCentroid);
        position.setEntry(1, yCentroid);
        position.setEntry(2, zCentroid);

        this.positionsByChannel.add(position);

    }

    this.hadFittingError = false;
    this.nullifyImages();

}

From source file:edu.umn.cs.spatialHadoop.nasa.MultiHDFPlot.java

public static boolean multiplot(Path[] input, Path output, OperationsParams params)
        throws IOException, InterruptedException, ClassNotFoundException, ParseException {
    String timeRange = params.get("time");
    final Date dateFrom, dateTo;
    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
    try {//from   ww w  .  j  a  v a2  s  .com
        String[] parts = timeRange.split("\\.\\.");
        dateFrom = dateFormat.parse(parts[0]);
        dateTo = dateFormat.parse(parts[1]);
    } catch (ArrayIndexOutOfBoundsException e) {
        System.err.println("Use the seperator two periods '..' to seperate from and to dates");
        return false; // To avoid an error that causes dateFrom to be uninitialized
    } catch (ParseException e) {
        System.err.println("Illegal date format in " + timeRange);
        return false;
    }
    // Number of frames to combine in each image
    int combine = params.getInt("combine", 1);
    // Retrieve all matching input directories based on date range
    Vector<Path> matchingPathsV = new Vector<Path>();
    for (Path inputFile : input) {
        FileSystem inFs = inputFile.getFileSystem(params);
        FileStatus[] matchingDirs = inFs.listStatus(input, new PathFilter() {
            @Override
            public boolean accept(Path p) {
                String dirName = p.getName();
                try {
                    Date date = dateFormat.parse(dirName);
                    return date.compareTo(dateFrom) >= 0 && date.compareTo(dateTo) <= 0;
                } catch (ParseException e) {
                    LOG.warn("Cannot parse directory name: " + dirName);
                    return false;
                }
            }
        });
        for (FileStatus matchingDir : matchingDirs)
            matchingPathsV.add(new Path(matchingDir.getPath(), "*.hdf"));
    }
    if (matchingPathsV.isEmpty()) {
        LOG.warn("No matching directories to given input");
        return false;
    }

    Path[] matchingPaths = matchingPathsV.toArray(new Path[matchingPathsV.size()]);
    Arrays.sort(matchingPaths);

    // Clear all paths to ensure we set our own paths for each job
    params.clearAllPaths();

    // Create a water mask if we need to recover holes on write
    if (params.get("recover", "none").equals("write")) {
        // Recover images on write requires a water mask image to be generated first
        OperationsParams wmParams = new OperationsParams(params);
        wmParams.setBoolean("background", false);
        Path wmImage = new Path(output, new Path("water_mask"));
        HDFPlot.generateWaterMask(wmImage, wmParams);
        params.set(HDFPlot.PREPROCESSED_WATERMARK, wmImage.toString());
    }
    // Start a job for each path
    int imageWidth = -1;
    int imageHeight = -1;
    boolean overwrite = params.getBoolean("overwrite", false);
    boolean pyramid = params.getBoolean("pyramid", false);
    FileSystem outFs = output.getFileSystem(params);
    Vector<Job> jobs = new Vector<Job>();
    boolean background = params.getBoolean("background", false);
    Rectangle mbr = new Rectangle(-180, -90, 180, 90);
    for (int i = 0; i < matchingPaths.length; i += combine) {
        Path[] inputPaths = new Path[Math.min(combine, matchingPaths.length - i)];
        System.arraycopy(matchingPaths, i, inputPaths, 0, inputPaths.length);
        Path outputPath = new Path(output, inputPaths[0].getParent().getName() + (pyramid ? "" : ".png"));
        if (overwrite || !outFs.exists(outputPath)) {
            // Need to plot
            Job rj = HDFPlot.plotHeatMap(inputPaths, outputPath, params);
            if (imageHeight == -1 || imageWidth == -1) {
                if (rj != null) {
                    imageHeight = rj.getConfiguration().getInt("height", 1000);
                    imageWidth = rj.getConfiguration().getInt("width", 1000);
                    mbr = (Rectangle) OperationsParams.getShape(rj.getConfiguration(), "mbr");
                } else {
                    imageHeight = params.getInt("height", 1000);
                    imageWidth = params.getInt("width", 1000);
                    mbr = (Rectangle) OperationsParams.getShape(params, "mbr");
                }
            }
            if (background && rj != null)
                jobs.add(rj);
        }
    }
    // Wait until all jobs are done
    while (!jobs.isEmpty()) {
        Job firstJob = jobs.firstElement();
        firstJob.waitForCompletion(false);
        if (!firstJob.isSuccessful()) {
            System.err.println("Error running job " + firstJob.getJobID());
            System.err.println("Killing all remaining jobs");
            for (int j = 1; j < jobs.size(); j++)
                jobs.get(j).killJob();
            throw new RuntimeException("Error running job " + firstJob.getJobID());
        }
        jobs.remove(0);
    }

    // Draw the scale in the output path if needed
    String scalerange = params.get("scalerange");
    if (scalerange != null) {
        String[] parts = scalerange.split("\\.\\.");
        double min = Double.parseDouble(parts[0]);
        double max = Double.parseDouble(parts[1]);
        String scale = params.get("scale", "none").toLowerCase();
        if (scale.equals("vertical")) {
            MultiHDFPlot.drawVerticalScale(new Path(output, "scale.png"), min, max, 64, imageHeight, params);
        } else if (scale.equals("horizontal")) {
            MultiHDFPlot.drawHorizontalScale(new Path(output, "scale.png"), min, max, imageWidth, 64, params);
        }
    }
    // Add the KML file
    createKML(outFs, output, mbr, params);
    return true;
}

From source file:edu.ku.brc.af.core.SchemaI18NService.java

/**
 * @param includeSepLocale//from w w w.  j av a  2 s. c  om
 * @return
 */
public Vector<Locale> getStdLocaleList(final boolean includeSepLocale) {
    /*for (Locale l : locales)
    {
    System.out.println(String.format("%s - %s, %s, %s", l.getDisplayName(), l.getLanguage(), l.getCountry(), l.getVariant()));
    }*/

    Vector<Locale> freqLocales = new Vector<Locale>();
    int i = 0;
    while (i < priorityLocales.length) {
        String lang = priorityLocales[i++];
        String ctry = priorityLocales[i++];
        String vari = priorityLocales[i++];
        Locale l = getLocaleByLangCountry(lang, ctry, vari);
        if (l != null) {
            freqLocales.add(l);
        }
    }
    HashSet<String> freqSet = new HashSet<String>();
    for (Locale l : freqLocales) {
        freqSet.add(l.getDisplayName());
    }
    Vector<Locale> stdLocaleList = new Vector<Locale>();
    for (Locale l : locales) {
        if (!freqSet.contains(l.getDisplayName())) {
            stdLocaleList.add(l);
        }
    }

    if (includeSepLocale) {
        stdLocaleList.insertElementAt(new Locale("-", "-", "-"), 0);
    }

    for (i = freqLocales.size() - 1; i > -1; i--) {
        stdLocaleList.insertElementAt(freqLocales.get(i), 0);
    }
    return stdLocaleList;
}