Example usage for java.util Vector contains

List of usage examples for java.util Vector contains

Introduction

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

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this vector contains the specified element.

Usage

From source file:com.globalsight.everest.webapp.pagehandler.edit.inctxrv.EditorPageHandler.java

/**
 * Initializes editor state from a job, i.e. when the editor is opened by an
 * Admin or PM.//  w w  w . j  av a 2 s  .c o  m
 */
private void initializeFromJob(EditorState p_state, HttpServletRequest p_request, String p_jobId,
        String p_srcPageId, String p_trgPageId, Locale p_uiLocale, User p_user) throws EnvoyServletException {
    p_state.setUserIsPm(true);
    HttpSession session = p_request.getSession();
    SessionManager sessionMgr = (SessionManager) session.getAttribute(WebAppConstants.SESSION_MANAGER);
    PermissionSet perms = (PermissionSet) p_request.getSession().getAttribute(WebAppConstants.PERMISSIONS);
    // Reset all options because the state may be inherited from a
    // previous page.
    EditorHelper.initEditorOptions(p_state, p_request.getSession());
    // Initializes pages, target locales, excluded items, and termbases
    EditorHelper.initializeFromJob(p_state, p_jobId, p_srcPageId, p_uiLocale, p_user.getUserId(), perms);

    if (p_trgPageId != null && p_trgPageId.length() > 0) {
        // If the PM requests a specific target page...

        setCurrentPage(p_request.getSession(), p_state, p_srcPageId, p_trgPageId);

        EditorState.PagePair currentPage = p_state.getCurrentPage();

        p_state.setTargetViewLocale(currentPage.getTargetPageLocale(new Long(p_trgPageId)));
    } else {
        // No target page/locale requested, find a suitable one.

        setCurrentPage(p_request.getSession(), p_state, p_srcPageId);

        // If no locale is set or the set locale doesn't exist in the
        // list of target locales in the job (fix for def_5545),
        // determine the default locale to display in target window.
        GlobalSightLocale viewLocale = p_state.getTargetViewLocale();
        Vector trgLocales = p_state.getJobTargetLocales();
        GlobalSightLocale local = (GlobalSightLocale) sessionMgr.getAttribute("targetLocale");
        if (viewLocale == null || !trgLocales.contains(viewLocale)) {
            if (trgLocales.contains(local)) {
                Iterator it = trgLocales.iterator();
                while (it.hasNext()) {
                    GlobalSightLocale trgLocale = (GlobalSightLocale) it.next();
                    if (local.getLocale().equals(trgLocale.getLocale())) {

                        p_state.setTargetViewLocale((GlobalSightLocale) trgLocale);
                    }
                }
            } else {
                p_state.setTargetViewLocale((GlobalSightLocale) trgLocales.elementAt(0));
            }
        }
    }

    // When coming from job page, target page is read only.
    // Fri Feb 20 20:18:44 2004 CvdL: Patch for HP: PMs can edit
    // all target pages any time at their own risk.
    if (s_pmCanEditTargetPages && EditorHelper.pmCanEditCurrentPage(p_state)) {
        p_state.setReadOnly(false);
        p_state.setAllowEditAll(true);
        p_state.setEditAllState(EDIT_ALL);
    } else {
        p_state.setReadOnly(true);
    }

    // Mon Jan 31 18:56:04 2005 CvdL: PM can edit snippets too (12665)
    p_state.setAllowEditSnippets(s_pmCanEditSnippets);

    // Indicate that main editor is in 'viewer' mode -- see
    // dispatchJsp for switching to review mode.
    // Comments are turned ON by default in popup editor from Job detail
    // page
    p_state.setReviewMode();
}

From source file:org.opencastproject.util.ZipUtilTest.java

@Test
public void zipRecStrFile() throws Exception {

    File destFile = new File(destDir, "recStrFile.zip");

    Vector<String> names = new Vector<String>();
    names.add(srcFileName);//www .  j av a  2 s .  c  o  m
    names.add(nestedSrcDirName + File.separator);
    names.add(nestedSrcDirName + File.separator + nestedSrcFileName);

    String[] filenames = srcDir.list();
    for (int i = 0; i < filenames.length; i++)
        filenames[i] = srcDir.getCanonicalPath() + File.separator + filenames[i];

    File test = ZipUtil.zip(filenames, destFile, true, ZipUtil.NO_COMPRESSION);
    Assert.assertTrue(test.exists());
    ZipFile zip = new ZipFile(test);
    Assert.assertEquals(3, zip.size());
    Enumeration<? extends ZipEntry> entries = zip.entries();

    try {
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            // The 'replace' method is used because the filesystem directory separator may not be the same as the Zip
            // files's
            Assert.assertTrue(names.contains(entry.getName().replace('/', File.separatorChar)));
        }
    } catch (AssertionError ae) {
        zip.close();
        throw ae;
    }

    zip.close();
}

From source file:org.opencastproject.util.ZipUtilTest.java

@Test
public void zipRecStrStr() throws Exception {

    File destFile = new File(destDir, "recStrStr.zip");

    Vector<String> names = new Vector<String>();
    names.add(srcFileName);/*  w  w  w.  ja  va  2 s .co m*/
    names.add(nestedSrcDirName + File.separator);
    names.add(nestedSrcDirName + File.separator + nestedSrcFileName);

    String[] filenames = srcDir.list();
    for (int i = 0; i < filenames.length; i++)
        filenames[i] = srcDir.getCanonicalPath() + File.separator + filenames[i];

    File test = ZipUtil.zip(filenames, destFile.getCanonicalPath(), true, ZipUtil.NO_COMPRESSION);
    Assert.assertTrue(test.exists());
    ZipFile zip = new ZipFile(test);
    Assert.assertEquals(3, zip.size());
    Enumeration<? extends ZipEntry> entries = zip.entries();

    try {
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            // The 'replace' method is used because the filesystem directory separator may not be the same as the Zip
            // files's
            Assert.assertTrue(names.contains(entry.getName().replace('/', File.separatorChar)));
        }
    } catch (AssertionError ae) {
        zip.close();
        throw ae;
    }

    zip.close();
}

From source file:no.met.jtimeseries.chart.XYHybridSplineRenderer.java

/**
 * Add cardinal spline control points in points vector
 * @param points The points vector//w w w .  jav a2 s.co m
 * @param tension The tension value to construct cardinal spline
 * @return Cardinal spline control points
 */
private Vector<ControlPoint> addCardinalSplinePoints(Vector<ControlPoint> points, float tension) {
    Vector<ControlPoint> cardinalPoints = new Vector<ControlPoint>();
    // construct spline

    // set the minimum resolution
    int minimumN = 1;
    // set the maximum resolution
    int maximumN = 4;

    // add two more points at the top and the end for drawing the curve
    // between the first two and last two points
    points.add(0, points.get(0));
    points.add(points.get(points.size() - 1));

    // set the minimum distance when using minimumN
    double smallDistance = Math.pow(
            Math.pow(points.get(3).x - points.get(0).x, 2) + Math.pow(points.get(3).y - points.get(0).y, 2),
            0.5);

    double currentDistance;
    // number of intervals (i.e. parametric curve would be
    // evaluted currentN times)
    double currentN;

    List<ControlPoint> newPoints;
    for (int i = 0; i < points.size() - 3; i++) {
        currentDistance = Math.pow(Math.pow(points.get(i + 3).x - points.get(i).x, 2)
                + Math.pow(points.get(i + 3).y - points.get(i).y, 2), 0.5);
        currentN = minimumN * currentDistance / smallDistance;
        currentN = currentN > maximumN ? maximumN : currentN;
        newPoints = evaluateCardinal2DAtNplusOneValues(points.get(i), points.get(i + 1), points.get(i + 2),
                points.get(i + 3), tension, (int) currentN);
        for (int j = 0; j < newPoints.size(); j++) {
            if (!cardinalPoints.contains(newPoints.get(j)))
                cardinalPoints.add(new ControlPoint(newPoints.get(j).x, newPoints.get(j).y));
        }
    }
    // change a small value of the last point in points and add it to control points
    // for the purpose of spline the line between last two points
    cardinalPoints.add(
            new ControlPoint(points.get(points.size() - 1).x + 0.01f, points.get(points.size() - 1).y + 0.01f));
    return cardinalPoints;
}

From source file:org.jopac2.jbal.iso2709.Unimarc.java

public Vector<String> getAuthors() {
    Vector<Tag> v = getTags("700");
    v.addAll(getTags("701"));
    v.addAll(getTags("702"));
    Vector<String> r = new Vector<String>();
    String k = "";
    if (v.size() > 0) {
        for (int i = 0; i < v.size(); i++) {
            k = "";
            k += Utils.ifExists("", v.elementAt(i).getField("a"));
            //k=v.elementAt(i).getField("a").getContent();
            k += Utils.ifExists(" ", v.elementAt(i).getField("b"));
            //k+=" "+v.elementAt(i).getField("b").getContent();
            if (!r.contains(k))
                r.addElement(k);//  w w  w  .j  a  v a  2s . c  om
        }
    }
    return r;
}

From source file:org.apache.rampart.util.RampartUtil.java

public static Vector getPartsAndElements(boolean sign, SOAPEnvelope envelope, boolean includeBody, Vector parts,
        Vector elements, Set namespaces) {

    Vector found = new Vector();
    Vector result = new Vector();

    // check body
    if (includeBody) {
        if (sign) {
            result.add(new WSEncryptionPart(addWsuIdToElement(envelope.getBody()), null,
                    WSConstants.PART_TYPE_BODY));
        } else {//from w w w. j av a2 s . com
            result.add(new WSEncryptionPart(addWsuIdToElement(envelope.getBody()), "Content",
                    WSConstants.PART_TYPE_BODY));
        }
        found.add(envelope.getBody());
    }

    // Search envelope header for 'parts' from Policy (SignedParts/EncryptedParts)

    SOAPHeader header = envelope.getHeader();

    for (int i = 0; i < parts.size(); i++) {
        WSEncryptionPart wsep = (WSEncryptionPart) parts.get(i);
        if (wsep.getName() == null) {
            // NO name - search by namespace
            ArrayList headerList = header.getHeaderBlocksWithNSURI(wsep.getNamespace());

            for (int j = 0; j < headerList.size(); j++) {
                SOAPHeaderBlock shb = (SOAPHeaderBlock) headerList.get(j);

                // find reference in envelope
                OMElement e = header.getFirstChildWithName(shb.getQName());

                if (!found.contains(e)) {
                    // found new
                    found.add(e);

                    if (sign) {
                        result.add(new WSEncryptionPart(e.getLocalName(), wsep.getNamespace(), "Content",
                                WSConstants.PART_TYPE_HEADER));
                    } else {

                        WSEncryptionPart encryptedHeader = new WSEncryptionPart(e.getLocalName(),
                                wsep.getNamespace(), "Element", WSConstants.PART_TYPE_HEADER);
                        OMAttribute wsuId = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));

                        if (wsuId != null) {
                            encryptedHeader.setEncId(wsuId.getAttributeValue());
                        }

                        result.add(encryptedHeader);
                    }
                }
            }
        } else {
            // try to find
            OMElement e = header.getFirstChildWithName(new QName(wsep.getNamespace(), wsep.getName()));
            if (e != null) {
                if (!found.contains(e)) {
                    // found new (reuse wsep)
                    found.add(e);
                    wsep.setType(WSConstants.PART_TYPE_HEADER);
                    OMAttribute wsuId = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));

                    if (wsuId != null) {
                        wsep.setEncId(wsuId.getAttributeValue());
                    }

                    result.add(wsep);
                }
            }
        }
    }

    // ?? Search for 'Elements' here

    // decide what exactly is going to be used - only the default namespaces, or the list of all declared namespaces in the message !

    Iterator elementsIter = elements.iterator();
    while (elementsIter.hasNext()) {
        String expression = (String) elementsIter.next();
        try {
            XPath xp = new AXIOMXPath(expression);
            Iterator nsIter = namespaces.iterator();

            while (nsIter.hasNext()) {
                OMNamespace tmpNs = (OMNamespace) nsIter.next();
                xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());
            }

            List selectedNodes = xp.selectNodes(envelope);

            Iterator nodesIter = selectedNodes.iterator();
            while (nodesIter.hasNext()) {
                OMElement e = (OMElement) nodesIter.next();
                String localName = e.getLocalName();
                String namespace = e.getNamespace() != null ? e.getNamespace().getNamespaceURI() : null;

                if (sign) {
                    WSEncryptionPart encryptedElem = new WSEncryptionPart(localName, namespace, "Content",
                            WSConstants.PART_TYPE_ELEMENT);
                    encryptedElem.setXpath(expression);
                    result.add(encryptedElem);

                } else {

                    WSEncryptionPart encryptedElem = new WSEncryptionPart(localName, namespace, "Element",
                            WSConstants.PART_TYPE_ELEMENT);
                    encryptedElem.setXpath(expression);

                    OMAttribute wsuId = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));

                    if (wsuId != null) {
                        encryptedElem.setEncId(wsuId.getAttributeValue());
                    }

                    result.add(encryptedElem);
                }
            }

        } catch (JaxenException e) {
            // This has to be changed to propagate an instance of a RampartException up
            throw new RuntimeException(e);
        }
    }

    return result;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.CombinedCategoryBar.java

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");

    // recover the datasets
    DefaultCategoryDataset datasetBarFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-bar");
    DefaultCategoryDataset datasetBarSecondAxis = (DefaultCategoryDataset) datasets.getDatasets().get("2-bar");
    DefaultCategoryDataset datasetLineFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-line");
    DefaultCategoryDataset datasetLineSecondAxis = (DefaultCategoryDataset) datasets.getDatasets()
            .get("2-line");

    // create the two subplots
    CategoryPlot subPlot1 = new CategoryPlot();
    CategoryPlot subPlot2 = new CategoryPlot();
    CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot();

    subPlot1.setDataset(0, datasetBarFirstAxis);
    subPlot2.setDataset(0, datasetBarSecondAxis);

    subPlot1.setDataset(1, datasetLineFirstAxis);
    subPlot2.setDataset(1, datasetLineSecondAxis);

    // localize numbers on y axis
    NumberFormat nf = (NumberFormat) NumberFormat.getNumberInstance(locale);

    // Range Axis 1
    NumberAxis rangeAxis = new NumberAxis(getValueLabel());
    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis/*  w  w w .ja  v a  2 s  . co m*/
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());
    rangeAxis.setUpperMargin(0.10);
    rangeAxis.setNumberFormatOverride(nf);
    subPlot1.setRangeAxis(rangeAxis);
    if (rangeIntegerValues == true) {
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    // Range Axis 2
    NumberAxis rangeAxis2 = new NumberAxis(secondAxisLabel);
    rangeAxis2.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis2.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis2
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis2.setTickLabelPaint(styleXaxesLabels.getColor());
    rangeAxis2.setUpperMargin(0.10);
    rangeAxis2.setNumberFormatOverride(nf);
    subPlot2.setRangeAxis(rangeAxis2);
    if (rangeIntegerValues == true) {
        rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    // Category Axis
    CategoryAxis domainAxis = new CategoryAxis(getCategoryLabel());
    domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setLabelPaint(styleYaxesLabels.getColor());
    domainAxis
            .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());
    domainAxis.setUpperMargin(0.10);
    plot.setDomainAxis(domainAxis);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);

    // Add subplots to main plot
    plot.add(subPlot1, 1);
    plot.add(subPlot2, 2);

    MyStandardCategoryItemLabelGenerator generator = null;

    // value labels and additional values are mutually exclusive
    if (showValueLabels == true)
        additionalLabels = false;

    if (additionalLabels) {
        generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance());
    }

    //      Create Renderers!
    CategoryItemRenderer barRenderer1 = new BarRenderer();
    CategoryItemRenderer barRenderer2 = new BarRenderer();
    LineAndShapeRenderer lineRenderer1 = (useLinesRenderers == true) ? new LineAndShapeRenderer() : null;
    LineAndShapeRenderer lineRenderer2 = (useLinesRenderers == true) ? new LineAndShapeRenderer() : null;

    subPlot1.setRenderer(0, barRenderer1);
    subPlot2.setRenderer(0, barRenderer2);

    if (useLinesRenderers == true) {
        subPlot1.setRenderer(1, lineRenderer1);
        subPlot2.setRenderer(1, lineRenderer2);

        // no shapes for line_no_shapes  series
        for (Iterator iterator = lineNoShapeSeries1.iterator(); iterator.hasNext();) {
            String ser = (String) iterator.next();
            // if there iS a abel associated search for that
            String label = null;
            if (seriesLabelsMap != null) {
                label = (String) seriesLabelsMap.get(ser);
            }
            if (label == null)
                label = ser;
            int index = datasetLineFirstAxis.getRowIndex(label);
            if (index != -1) {
                lineRenderer1.setSeriesShapesVisible(index, false);
            }
        }
        for (Iterator iterator = lineNoShapeSeries2.iterator(); iterator.hasNext();) {
            String ser = (String) iterator.next();
            // if there iS a abel associated search for that

            String label = null;
            if (seriesLabelsMap != null) {
                label = (String) seriesLabelsMap.get(ser);
            }
            if (label == null)
                label = ser;
            int index = datasetLineSecondAxis.getRowIndex(label);
            if (index != -1) {
                lineRenderer2.setSeriesShapesVisible(index, false);
            }
        }

    }

    // add tooltip if enabled
    if (enableToolTips) {
        MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips,
                seriesTooltip, categoriesTooltip, seriesCaptions);
        barRenderer1.setToolTipGenerator(generatorToolTip);
        barRenderer2.setToolTipGenerator(generatorToolTip);
        if (useLinesRenderers) {
            lineRenderer1.setToolTipGenerator(generatorToolTip);
            lineRenderer2.setToolTipGenerator(generatorToolTip);
        }
    }

    subPlot1.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    subPlot2.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    // COnfigure renderers: I do in extensive way so will be easier to add customization in the future

    if (maxBarWidth != null) {
        ((BarRenderer) barRenderer1).setMaximumBarWidth(maxBarWidth.doubleValue());
        ((BarRenderer) barRenderer2).setMaximumBarWidth(maxBarWidth.doubleValue());
    }

    // Values or addition Labels for first BAR Renderer
    if (showValueLabels) {
        barRenderer1.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
        barRenderer1.setBaseItemLabelsVisible(true);
        barRenderer1.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        barRenderer1.setBaseItemLabelPaint(styleValueLabels.getColor());

        barRenderer1.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

        barRenderer1.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

        barRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
        barRenderer2.setBaseItemLabelsVisible(true);
        barRenderer2.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        barRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor());

        barRenderer2.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

        barRenderer2.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

    } else if (additionalLabels) {
        barRenderer1.setBaseItemLabelGenerator(generator);
        barRenderer2.setBaseItemLabelGenerator(generator);

        double orient = (-Math.PI / 2.0);
        if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) {
            orient = 0.0;
        }

        barRenderer1.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));
        barRenderer1.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));
        barRenderer2.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));
        barRenderer2.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));

    }

    // Values or addition Labels for line Renderers if requested
    if (useLinesRenderers == true) {
        if (showValueLabels) {
            lineRenderer1.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
            lineRenderer1.setBaseItemLabelsVisible(true);
            lineRenderer1.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
            lineRenderer1.setBaseItemLabelPaint(styleValueLabels.getColor());
            lineRenderer1.setBasePositiveItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            lineRenderer1.setBaseNegativeItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            lineRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
            lineRenderer2.setBaseItemLabelsVisible(true);
            lineRenderer2.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
            lineRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor());
            lineRenderer2.setBasePositiveItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            lineRenderer2.setBaseNegativeItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

        } else if (additionalLabels) {
            lineRenderer1.setBaseItemLabelGenerator(generator);
            lineRenderer2.setBaseItemLabelGenerator(generator);
            double orient = (-Math.PI / 2.0);
            if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) {
                orient = 0.0;
            }
            lineRenderer1.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            lineRenderer1.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            lineRenderer2.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            lineRenderer2.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));

        }
    }

    // Bar Dataset Colors!
    if (colorMap != null) {
        int idx = -1;
        for (Iterator iterator = datasetBarFirstAxis.getRowKeys().iterator(); iterator.hasNext();) {
            idx++;
            String serName = (String) iterator.next();
            String labelName = "";
            int index = -1;

            if (seriesCaptions != null && seriesCaptions.size() > 0) {
                labelName = serName;
                serName = (String) seriesCaptions.get(serName);
                index = datasetBarFirstAxis.getRowIndex(labelName);
            } else
                index = datasetBarFirstAxis.getRowIndex(serName);

            Color color = (Color) colorMap.get(serName);
            if (color != null) {
                barRenderer1.setSeriesPaint(index, color);
            }
        }

        for (Iterator iterator = datasetBarSecondAxis.getRowKeys().iterator(); iterator.hasNext();) {
            idx++;
            String serName = (String) iterator.next();
            String labelName = "";
            int index = -1;

            if (seriesCaptions != null && seriesCaptions.size() > 0) {
                labelName = serName;
                serName = (String) seriesCaptions.get(serName);
                index = datasetBarSecondAxis.getRowIndex(labelName);
            } else
                index = datasetBarSecondAxis.getRowIndex(serName);

            Color color = (Color) colorMap.get(serName);
            if (color != null) {
                barRenderer2.setSeriesPaint(index, color);
            }
        }
    }

    // LINE Dataset Colors!
    if (useLinesRenderers == true) {
        if (colorMap != null) {
            int idx = -1;
            for (Iterator iterator = datasetLineFirstAxis.getRowKeys().iterator(); iterator.hasNext();) {
                idx++;
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetLineFirstAxis.getRowIndex(labelName);
                } else
                    index = datasetLineFirstAxis.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    lineRenderer1.setSeriesPaint(index, color);
                }
            }

            for (Iterator iterator = datasetLineSecondAxis.getRowKeys().iterator(); iterator.hasNext();) {
                idx++;
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetLineSecondAxis.getRowIndex(labelName);
                } else
                    index = datasetLineSecondAxis.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    lineRenderer2.setSeriesPaint(index, color);
                }
            }
        }
    }

    //defines url for drill
    boolean document_composition = false;
    if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))
        document_composition = true;

    logger.debug("Calling Url Generation");

    MyCategoryUrlGenerator mycatUrl = null;
    if (super.rootUrl != null) {
        logger.debug("Set MycatUrl");
        mycatUrl = new MyCategoryUrlGenerator(super.rootUrl);

        mycatUrl.setDocument_composition(document_composition);
        mycatUrl.setCategoryUrlLabel(super.categoryUrlName);
        mycatUrl.setSerieUrlLabel(super.serieUrlname);
        mycatUrl.setDrillDocTitle(drillDocTitle);
        mycatUrl.setTarget(target);
    }
    if (mycatUrl != null) {
        barRenderer1.setItemURLGenerator(mycatUrl);
        barRenderer2.setItemURLGenerator(mycatUrl);
        if (useLinesRenderers) {
            lineRenderer1.setItemURLGenerator(mycatUrl);
            lineRenderer2.setItemURLGenerator(mycatUrl);
        }

    }

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);

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

    //      I want to re order the legend
    LegendItemCollection legends = plot.getLegendItems();
    // legend Temp 
    HashMap<String, LegendItem> legendTemp = new HashMap<String, LegendItem>();
    Vector<String> alreadyInserted = new Vector<String>();
    for (int i = 0; i < legends.getItemCount(); i++) {
        LegendItem item = legends.get(i);
        String label = item.getLabel();
        legendTemp.put(label, item);
    }
    LegendItemCollection newLegend = new LegendItemCollection();
    // force the order of the ones specified
    for (Iterator iterator = seriesOrder.iterator(); iterator.hasNext();) {
        String serie = (String) iterator.next();
        if (legendTemp.keySet().contains(serie)) {
            newLegend.add(legendTemp.get(serie));
            alreadyInserted.add(serie);
        }
    }
    // check that there are no serie not specified, otherwise add them
    for (Iterator iterator = legendTemp.keySet().iterator(); iterator.hasNext();) {
        String serie = (String) iterator.next();
        if (!alreadyInserted.contains(serie)) {
            newLegend.add(legendTemp.get(serie));
        }
    }

    plot.setFixedLegendItems(newLegend);

    if (legend == true)
        drawLegend(chart);
    logger.debug("OUT");

    return chart;

}

From source file:org.hyperimage.service.search.HIIndexer.java

public Vector<Long> fieldSearch(List<String> fields, List<String> contents, HIProject project,
        String language) {//  w  w w  .jav a  2s  . com
    Vector<Long> results = new Vector<Long>();

    HIHitCollector collector = new HIHitCollector();
    QueryParser parser = new QueryParser("all", new StandardAnalyzer());

    String queryString = "";
    for (int i = 0; i < fields.size(); i++) {
        // sanitize user input
        String field = fields.get(i);
        String content = contents.get(i);
        field = field.replaceAll("[^a-zA-Z0-9.]", "");
        content = content.replaceAll("\"", "\\\\\"");
        // convert displayable ids to DB id for id search
        if (field.equalsIgnoreCase("id"))
            content = content.replaceAll("[^0-9]", "");

        if (!field.equalsIgnoreCase("project")) {
            if (queryString.length() > 0)
                queryString = queryString + " AND ";
            if (field.equalsIgnoreCase("id")) // dont add language to id search
                queryString = queryString + field + ":\"" + content + "\"";
            else
                queryString = queryString + field + "." + language + ":\"" + content + "\"";
        }
    }
    queryString = queryString.trim();
    if (queryString.length() == 0)
        return results;

    try {
        prepDir(project);
        Query query = parser.parse(queryString);
        IndexSearcher searcher = new IndexSearcher(getDir(project));
        searcher.search(query, collector);

        IndexReader reader = IndexReader.open(getDir(project));
        for (int doc : collector.getDocs()) {
            long baseID = Long.parseLong(reader.document(doc).get("id"));
            if (!results.contains(baseID))
                results.addElement(baseID);
        }
        searcher.close();
        reader.close();
    } catch (ParseException e) {
        e.printStackTrace();
    } catch (CorruptIndexException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return results;
}

From source file:org.ecoinformatics.seek.datasource.eml.eml2.Eml200DataSource.java

private void removeResultRecordDetailsAtrribute() throws IllegalActionException, NameDuplicationException {
    // System.out.println("at begining");
    List list = this.attributeList();
    if (list != null) {
        // System.out.println("attribute list is not null");
        for (int j = 0; j < list.size(); j++) {
            // System.out.println("the attribute list's size is "+recordDetailList.size());
            ptolemy.kernel.util.Attribute att = (ptolemy.kernel.util.Attribute) list.get(j);
            String attName = att.getName();
            // System.out.println("------- the attribute "+att.getName());
            Vector recordDetailList = this.getRecordDetailList();

            if (recordDetailList != null && attName != null && recordDetailList.contains(attName)) {
                // System.out.println("------- remove the attribute "+att.getName());
                att.setContainer(null);//from w  ww.j a  va  2s . c o  m

            }
        }
    }

}

From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java

/**
 * Return a list of the current column headers
 *
 * @param needColNo - if the column number is needed, a Col: n is prepended to the column name, where n is the column number.
 * @param unique    - if unique is true, then only unique columns are sent back. doens't make sense when needColNo is set to true.
 * @return A vector of strings containing headers - set to vector since the values will be instantly suitable for a ComboBox for example.
 *//*from   ww  w. j  a  v a  2  s.  c o m*/
public Vector<String> getHeaders(boolean needColNo, boolean unique) {
    Vector<String> headerList = new Vector<String>();

    for (int i = 0; i < spreadsheetModel.getColumnCount(); i++) {
        String h;

        if (!spreadsheetModel.getColumnName(i).equals(TableReferenceObject.ROW_NO_TEXT)) {
            if (needColNo) {
                h = "Col: " + i + " " + spreadsheetModel.getColumnName(i);
            } else {
                h = spreadsheetModel.getColumnName(i);
            }

            if (unique) {
                if (!headerList.contains(h)) {
                    headerList.add(h);
                }
            } else {
                headerList.add(h);
            }
        }
    }

    return headerList;
}