Example usage for java.util Vector size

List of usage examples for java.util Vector size

Introduction

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

Prototype

public synchronized int size() 

Source Link

Document

Returns the number of components in this vector.

Usage

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SpeedometerMultiValue.java

/**
 * Creates a chart of type speedometer.// w  ww.  j a v a2 s.c  om
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart speedometer.
 */

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    JFreeChart chart = null;
    try {
        MyDialPlot plot = new MyDialPlot();

        HashMap hmDataset = datasets.getDatasets();
        Set keyDataset = hmDataset.keySet();
        int i = 0;

        Iterator itDataset = keyDataset.iterator();
        while (itDataset.hasNext()) {
            String key = (String) itDataset.next();
            Dataset dataset = (Dataset) hmDataset.get(key);
            plot.setDataset(i, (ValueDataset) dataset);
            if (key.indexOf("__") > 0)
                setName(key.substring(0, key.indexOf("__")));
            else
                setName(key);
            i++;
        }

        plot.setDialFrame(new StandardDialFrame());

        plot.setBackground(new DialBackground());

        if (dialtextuse) {
            DialTextAnnotation annotation1 = new DialTextAnnotation(dialtext);
            annotation1.setFont(styleTitle.getFont());
            annotation1.setRadius(0.7);

            plot.addLayer(annotation1);
        }

        StandardDialScale scale = new StandardDialScale(lower, upper, -120, -300, 10.0, 4);

        if (!(increment > 0)) {
            logger.warn("increment cannot be less than 0, put default to 0.1 ");
            increment = 0.1;
        }

        scale.setMajorTickIncrement(increment);
        scale.setMinorTickCount(minorTickCount);
        scale.setTickRadius(0.88);
        scale.setTickLabelOffset(0.15);
        //set tick label style
        scale.setTickLabelsVisible(true);
        Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize());
        scale.setTickLabelFont(tickLabelsFont);
        scale.setTickLabelPaint(labelsTickStyle.getColor());

        plot.addScale(0, scale);

        DialCap cap = new DialCap();
        plot.setCap(cap);

        // sets intervals
        for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
            KpiInterval interval = (KpiInterval) iterator.next();
            StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                    interval.getColor());
            range.setInnerRadius(0.50);
            range.setOuterRadius(0.85);

            range.setPaint(interval.getColor());

            plot.addLayer(range);

        }

        plot.setBackground(new DialBackground());

        logger.debug("Set values color");
        Vector arValuesName = getValuesNames();
        legendItems = new LegendItemCollection();
        for (int j = 0; j < arValuesName.size(); j++) {
            DialPointer.Pin p = new DialPointer.Pin(j);
            if (colorMap != null) {
                String valueName = (String) arValuesName.get(j);
                Color color = (Color) colorMap.get(valueName);
                if (color != null)
                    p.setPaint(color);

                if (serieLegend.equalsIgnoreCase(name)) {
                    if (j < arValuesName.size()) {
                        LegendItem item = new LegendItem(valueName, "", "", "",
                                new Ellipse2D.Double(-3, -5, 8, 8), color);
                        if (item != null) {
                            legendItems.add(item);
                        }
                    }
                    if (legend)
                        super.height = super.height + (super.height * 12 / 100);
                }
            }
            plot.addLayer(p);
        }

        plot.setLegendItems(legendItems);
        chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

        TextTitle title = setStyleTitle(name, styleTitle);
        chart.setTitle(title);
        if (subName != null && !subName.equals("")) {
            TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
            chart.addSubtitle(subTitle);
        }

        chart.setBackgroundPaint(color);
        if (legend == true)
            drawLegend(chart);

    } catch (Exception ex) {
        logger.debug("Error while creating speedometer multivalue: " + ex);
    }
    logger.debug("OUT");
    return chart;
}

From source file:edu.umd.cfar.lamp.viper.util.StringHelp.java

/**
 * Divides a String by its whitespace./*from   w  w w  .  ja  va  2s. com*/
 *
 * @param line The String to divide.
 * @return An Array of Strings taken from between the whitespace characters.
 */
public static String[] splitSpaces(String line) {
    if (line == null)
        return (new String[0]);

    int start, end;

    Vector vec = new Vector();

    end = 0;
    while (true) {
        start = findNonBlank(line, end);
        if (start == -1)
            break;
        end = findBlank(line, start);
        if (end == -1) {
            vec.addElement(line.substring(start));
            break;
        } else {
            vec.addElement(line.substring(start, end));
        }
    }

    String[] result = new String[vec.size()];
    for (int j = 0; j < vec.size(); j++) {
        result[j] = (String) vec.elementAt(j);
    }

    return (result);
}

From source file:de.mogwai.common.web.component.renderkit.html.common.TableRenderer.java

@Override
public void encodeBegin(FacesContext aContext, UIComponent aComponent) throws IOException {

    TableComponent theTableComponent = (TableComponent) aComponent;

    ResponseWriter theWriter = aContext.getResponseWriter();

    boolean hasId = false;

    if (theTableComponent.hasFunctions()) {
        theWriter.startElement("table", aComponent);
        theWriter.writeAttribute("id", theTableComponent.getClientId(aContext), null);
        theWriter.writeAttribute("cellspacing", "0", null);
        theWriter.writeAttribute("cellpadding", "0", null);
        theWriter.writeAttribute("border", "0", null);
        theWriter.startElement("tr", aComponent);
        theWriter.startElement("td", aComponent);
        hasId = true;/*  w  w  w  . j av  a  2 s  .  com*/
    }

    theWriter.startElement("table", aComponent);
    if (!hasId) {
        theWriter.writeAttribute("id", theTableComponent.getClientId(aContext), null);
    }
    theWriter.writeAttribute("cellspacing", "0", null);
    theWriter.writeAttribute("cellpadding", "0", null);
    theWriter.writeAttribute("border", "0", null);
    theWriter.writeAttribute("class", "mogwaiTable", null);

    Vector<UIColumn> theColumns = ListAwareUtils.getColumns(theTableComponent);
    GridbagLayoutSizeDefinitionVector theCols = theTableComponent.getCols();

    // Render the table definition
    theWriter.startElement("colgroup", theTableComponent);
    for (int i = 0; i < theColumns.size(); i++) {

        String theWidth = GridBagLayoutUtils.getSizeForColumn(theTableComponent, theCols, i);

        theWriter.startElement("col", aComponent);
        theWriter.writeAttribute("width", theWidth, null);
        theWriter.endElement("col");

    }
    theWriter.endElement("colgroup");

}

From source file:info.guardianproject.gpg.KeyListFragment.java

public void handleIntent(String action, Bundle extras) {
    // Why doesn't java have default parameters :(
    if (extras == null)
        extras = new Bundle();

    mCurrentAction = action;// ww w  .  ja  va2s .  c  o  m
    mCurrentExtras = extras;

    String searchString = null;
    if (Intent.ACTION_SEARCH.equals(action)) {
        searchString = extras.getString(SearchManager.QUERY);
        if (searchString != null && searchString.trim().length() == 0) {
            searchString = null;
        }
    }

    long selectedKeyIds[] = null;
    selectedKeyIds = extras.getLongArray(Apg.EXTRA_SELECTION);

    if (selectedKeyIds == null) {
        Vector<Long> vector = new Vector<Long>();
        for (int i = 0; i < mListView.getCount(); ++i) {
            if (mListView.isItemChecked(i)) {
                vector.add(mListView.getItemIdAtPosition(i));
            }
        }
        selectedKeyIds = new long[vector.size()];
        for (int i = 0; i < vector.size(); ++i) {
            selectedKeyIds[i] = vector.get(i);
        }
    }

    if (action.equals(Action.FIND_KEYS)) {
        if (mKeyserverAdapter == null)
            mKeyserverAdapter = new KeyListKeyserverAdapter(mListView, searchString);
        setListAdapter(mKeyserverAdapter);
    } else {
        mShowKeysAdapter = new KeyListContactsAdapter(mListView, action, searchString, selectedKeyIds);
        setListAdapter(mShowKeysAdapter);
        if (selectedKeyIds != null) {
            for (int i = 0; i < mShowKeysAdapter.getCount(); ++i) {
                long keyId = mShowKeysAdapter.getItemId(i);
                for (int j = 0; j < selectedKeyIds.length; ++j) {
                    if (keyId == selectedKeyIds[j]) {
                        mListView.setItemChecked(i, true);
                        break;
                    }
                }
            }
        }
    }
}

From source file:com.sshtools.common.automate.RemoteIdentification.java

/**
 *
 *
 * @param ident/*from   ww w. j  a va2 s  .  co m*/
 *
 * @return
 *
 * @throws RemoteIdentificationException
 */
public String getName(String ident) throws RemoteIdentificationException {
    boolean pass = false;
    Iterator it = rules.iterator();
    Vector passed = new Vector();
    RemoteIdentificationRule rule;
    String rulename = null;

    // Check all the rules
    while (it.hasNext()) {
        rule = (RemoteIdentificationRule) it.next();

        if (rule.testRule(ident)) {
            passed.add(rule);
        }
    }

    if (passed.size() > 0) {
        // Select the highest priority rule where 0=highest 10=lowest
        it = passed.iterator();

        RemoteIdentificationRule ret = null;

        while (it.hasNext()) {
            rule = (RemoteIdentificationRule) it.next();

            if (ret == null) {
                ret = rule;
            } else {
                if (rule.getPriority() < ret.getPriority()) {
                    ret = rule;
                }
            }
        }

        if (ret.getName() != null) {
            return ret.getName();
        } else {
            return defaultName;
        }
    } else {
        throw new RemoteIdentificationException(
                "No rules exist to identify the remote host with ident string " + ident);
    }
}

From source file:net.java.sen.tools.DictionaryMaker.java

int getIdList(String csv[], Vector result, int parent) {
    result.setSize(ruleList.size());/*  w w  w  .jav  a 2  s  . c o  m*/

    for (int j = 0; j < ruleList.size(); j++)
        result.set(j, new Integer(j));
    //    System.out.println("in:ruleList.size()=" + ruleList.size());
    //    System.out.println("ruleList size="+ruleList.size());
    //    System.out.println("result size="+result.size());
    //    pass

    for (int j = 0; j < csv.length; j++) {
        int k = 0;
        for (int n = 0; n < result.size(); n++) {
            int i = ((Integer) result.get(n)).intValue();
            String rl_ij = ((String[]) ruleList.get(i))[j];
            if ((parent == 0 && csv[j].charAt(0) == '*') || (parent == 1 && rl_ij.charAt(0) == '*')
                    || rl_ij.equals(csv[j])) {

                result.set(k++, result.get(n));
            }
        }
        result.setSize(k);
    }
    return result.size();
}

From source file:eionet.meta.exports.ods.Ods.java

/**
 *
 * @return total column count/*from   w w  w. j  a  v  a 2 s  . c  o m*/
 */
protected final int getTotalColumnCount() {

    int count = 0;
    for (int i = 0; tables != null && i < tables.size(); i++) {
        Table table = (Table) tables.get(i);
        Vector cols = table.getTableColumns();
        if (cols != null)
            count = count + cols.size();
    }

    return count;
}

From source file:imapi.IMAPIClass.java

public void printResultInstances(Hashtable<Float, Vector<ResultSourceTargetPair>> resultInstances) {

    int resultsCounter = 0;
    if (resultInstances.size() == 0) {
        System.out.println("0 results found.");
    } else {//from   w  ww. j  a  va 2s .  c  o  m

        Vector<Float> sortBySimilarityVec = new Vector<Float>(resultInstances.keySet());
        Collections.sort(sortBySimilarityVec);
        Collections.reverse(sortBySimilarityVec);

        for (int i = 0; i < sortBySimilarityVec.size(); i++) {
            float sim = sortBySimilarityVec.get(i);
            Vector<ResultSourceTargetPair> stPairs = resultInstances.get(sim);
            Collections.sort(stPairs);

            for (int k = 0; k < stPairs.size(); k++) {
                ResultSourceTargetPair resultInfo = stPairs.get(k);
                SourceTargetPair pair = resultInfo.getSourceTargetPair();
                SequenceSimilarityResultVector tripVec = resultInfo.getSimilarityResultsVector();

                System.out.println((++resultsCounter) + ".\t" + Utilities.df.format(sim) + "\t"
                        + pair.getSourceInstance().getSourceName() + "    "
                        + pair.getSourceInstance().getInstanceUri() + "    "
                        + pair.getTargetInstance().getSourceName() + "    "
                        + pair.getTargetInstance().getInstanceUri());

                //check if uri similarity is encoutered

                if (pair.getSourceInstance().getInstanceUri()
                        .equals(pair.getTargetInstance().getInstanceUri())) {
                    System.out.println("\t\t\turi similarity 1\n");
                    continue;
                } else {
                    this.printSimilaritiesData(tripVec);
                }

                System.out.println();

            }
        }
    }

}

From source file:de.fhg.fokus.odp.middleware.unittest.xTestCKANGateway.java

/**
 * Test the getRevisions and getUpdatedSets method.
 *//*  w  w  w  .  j a  v  a 2 s . c om*/
@Test
public void testGetRevisionsAndGetUpdatesSets() {
    log.fine("########### GET REVISIONS AND UPDATES ###########");
    String revisionsStr = ckanGW.getRevisions("Europe/Berlin", 200000000);
    log.fine(revisionsStr);
    Vector<String> revisionsDetails = ckanGW.getUpdatedDatasets(revisionsStr);
    @SuppressWarnings("unchecked")
    Vector<Map> dataSetDetails = ckanGW.getUpdatedDataSetsDetails(revisionsDetails);
    Vector<Map> categoriesDetails = ckanGW.getUpdatedCategoriesDetails(revisionsDetails);
    for (int i = 0; i < categoriesDetails.size(); i++) {
        log.fine(categoriesDetails.get(i).toString());
    }
    assertTrue(revisionsDetails.size() >= 1);
    assertTrue(dataSetDetails.size() >= 1);
    assertTrue(categoriesDetails.size() >= 1);

}

From source file:gda.scan.ConcurrentScanChild.java

/**
 * Asynchronously, readout detectors using parallel threads into ScanDataPoint and add to pipeline for possible
 * completion and publishing. Call {@link ConcurrentScanChild#waitForDetectorReadoutAndPublishCompletion()} to wait
 * for this task to complete, or {@link #cancelReadoutAndPublishCompletion()} to cancel and interrupt it.
 * <p>/* w ww .  jav  a 2  s.c  om*/
 * If the property {@link LocalProperties#GDA_SCAN_CONCURRENTSCAN_READOUT_CONCURRENTLY} is its default false value
 * then simply block while reading out each detector in series and then adding the ScanDataPoint to the pipeline.
 * 
 * @param point
 * @throws Exception
 */
@Override
protected void readoutDetectorsAndPublish(final ScanDataPoint point) throws Exception {

    final boolean lastPointInLine = (getPointPositionInLine() == PointPositionInLine.LAST); // latch value

    if (!isReadoutConcurrent()) {
        super.readoutDetectorsAndPublish(point);
        return;
    }

    // Make sure the previous point has read been published
    // (If the scan contains a detector this method will already have been called)
    waitForDetectorReadoutAndPublishCompletion();

    final String threadName = "ConcurrentScanChild.readoutDetectorsAndPublish(point '" + point.toString()
            + "')";
    detectorReadoutTask = new FutureTask<Void>(new Callable<Void>() {

        List<Future<Object>> readoutTasks;

        /**
         * Readout each detector in a thread, add the resulting data to the ScanDataPoint and publish.
         */
        @Override
        public Void call() throws Exception {

            try {
                Vector<Detector> detectors = point.getDetectors();

                // if there are detectors then readout in parallel threads
                if (detectors.size() != 0) {

                    readoutTasks = new ArrayList<Future<Object>>(detectors.size());

                    // Start readout tasks
                    for (Detector detector : point.getDetectors()) {
                        FutureTask<Object> readoutTask = new FutureTask<Object>(new ReadoutDetector(detector));
                        new Thread(readoutTask, threadName + ": readout '" + detector.getName() + "'").start();
                        readoutTasks.add(readoutTask);
                    }

                    // Wait for readout results and put into point
                    for (int i = 0; i < detectors.size(); i++) {
                        checkThreadInterrupted();
                        Object data = readoutTasks.get(i).get();
                        point.addDetectorData(data, ScannableUtils.getExtraNamesFormats(detectors.get(i)));
                    }

                }

                // Put point onto pipeline
                checkThreadInterrupted(); // probably voodoo and not required here
                scanDataPointPipeline.put(point); // may block
                checkThreadInterrupted(); // probably voodoo and not required here

                // The main scan thread cannot call atPointEnd (and subsequently atPointStart) in the correct order
                // with respect to readout so call these here instead.

                for (Detector detector : detectors) {
                    detector.atPointEnd();
                }

                // unless this is the last point in the line, call atPointStart hooks for the next point (the one
                // that main scan thread is now working on.
                if (!lastPointInLine) {
                    for (Detector detector : detectors) {
                        detector.atPointStart();
                    }
                }

            } catch (Exception e) {
                // could be the normal result of cancelling this task
                // (detector.readout() unfortunately doesn't distinguish InteruptedException from DeviceException
                logger.info("'" + representThrowable(e)
                        + "' --- while reading out detectors. *Canceling any remaining readout tasks.*");
                for (Future<Object> task : readoutTasks) {
                    task.cancel(true);
                }
                throw e;
            }
            return null;
        }
    });

    new Thread(detectorReadoutTask, threadName).start();
}