Example usage for java.util TreeMap get

List of usage examples for java.util TreeMap get

Introduction

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

Prototype

public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:org.apache.roller.weblogger.business.jpa.JPAWeblogEntryManagerImpl.java

private Map getWeblogEntryMap(Weblog website, Date startDate, Date endDate, String catName, List tags,
        String status, boolean stringsOnly, String locale, int offset, int length) throws WebloggerException {

    TreeMap map = new TreeMap(reverseComparator);

    List entries = getWeblogEntries(website, null, // user
            startDate, endDate, catName, tags, status, null, // text
            null, // sortBy
            null, // sortOrder
            locale, offset, length);//www.j  a va  2s.  c o  m

    Calendar cal = Calendar.getInstance();
    if (website != null) {
        cal.setTimeZone(website.getTimeZoneInstance());
    }

    SimpleDateFormat formatter = DateUtil.get8charDateFormat();
    for (Iterator wbItr = entries.iterator(); wbItr.hasNext();) {
        WeblogEntry entry = (WeblogEntry) wbItr.next();
        Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
        if (stringsOnly) {
            if (map.get(sDate) == null)
                map.put(sDate, formatter.format(sDate));
        } else {
            List dayEntries = (List) map.get(sDate);
            if (dayEntries == null) {
                dayEntries = new ArrayList();
                map.put(sDate, dayEntries);
            }
            dayEntries.add(entry);
        }
    }
    return map;
}

From source file:com.sfs.whichdoctor.webservice.RotationXmlOutputImpl.java

/**
 * Builds a list of rotations in the second-gen XML format.
 *
 * @param rotations the rotation array//w  w  w .  ja v  a2 s  . co  m
 * @param personIdentifier the person identifier
 * @param division the division
 * @param currentRotations the current rotations
 *
 * @return the rotations in XML format
 */
public final String getSecondGenRotations(final List<RotationBean> rotations, final int personIdentifier,
        final String division, final Collection<RotationBean> currentRotations) {

    Element xml = new Element("trainee");
    xml.setAttribute("MIN", String.valueOf(personIdentifier));

    // Process the current organisations
    TreeMap<String, Element> siteMap = new TreeMap<String, Element>();

    for (RotationBean rtn : currentRotations) {
        if (StringUtils.isNotBlank(rtn.getOrganisation1Name())) {
            Element site = new Element("site");
            String type = "primary";
            if (!StringUtils.equalsIgnoreCase(type, rtn.getOrganisation1TypeMapping())) {
                // If not primary set the type to training
                type = "training";
            }
            site.setAttribute("type", "current_" + type);
            site.setAttribute("state", loadOrgCity(rtn.getOrganisation1Id()));
            site.setAttribute("name", rtn.getOrganisation1Name());

            siteMap.put(type, site);
        }
        if (StringUtils.isNotBlank(rtn.getOrganisation2Name())) {
            Element site = new Element("site");
            String type = "training";
            if (siteMap.containsKey(type)) {
                // Set to primary if the training key exists
                type = "primary";
            }
            site.setAttribute("type", "current_" + type);
            site.setAttribute("state", loadOrgCity(rtn.getOrganisation2Id()));
            site.setAttribute("name", rtn.getOrganisation2Name());

            siteMap.put(type, site);
        }
    }

    if (siteMap.size() == 1) {
        for (String type : siteMap.keySet()) {
            Element site = siteMap.get(type);
            Element site2 = (Element) site.clone();

            String secondType = "training";
            if (StringUtils.equalsIgnoreCase(type, "training")) {
                secondType = "primary";
            }
            site2.setAttribute("type", "current_" + secondType);

            siteMap.put(secondType, site2);
        }
    }

    Element sitesElement = new Element("sites");

    for (String type : siteMap.keySet()) {
        Element site = siteMap.get(type);
        sitesElement.addContent(site);
    }
    xml.addContent(sitesElement);

    Element rtnsXml = new Element("rotations");
    rtnsXml.setAttribute("min", String.valueOf(personIdentifier));

    for (RotationBean rtn : rotations) {

        rtnsXml.addContent(RotationXmlHelper.getSecondGenRotationInfo(rtn, division,
                loadOrgCity(rtn.getOrganisation1Id()), loadOrgCity(rtn.getOrganisation2Id())));
    }
    xml.addContent(rtnsXml);

    XMLOutputter outputter = new XMLOutputter();
    Format format = Format.getCompactFormat();
    format.setOmitDeclaration(true);

    outputter.setFormat(format);

    return outputter.outputString(new Document(xml));
}

From source file:org.loklak.geo.GeoNames.java

public LinkedHashSet<String> suggest(String q, int count, int distance) {
    TreeMap<Long, String> a = new TreeMap<>();
    String ql = normalize(q);// ww  w . j  a  v a 2s .  c  om
    boolean exact = false;
    String exactTerm = null;
    seekloop: for (GeoLocation g : id2loc.values()) {
        termloop: for (String n : g.getNames()) {
            if (n.length() > 3 && n.length() < ql.length() * 4) {
                String nn = normalize(n);
                if (!exact && nn.equals(ql)) {
                    exact = true;
                    exactTerm = n;
                    continue seekloop;
                }
                // starts-with:
                if (nn.startsWith(ql)) {
                    a.put(g.getPopulation() + a.size(), n);
                    if (a.size() > count * 2)
                        break seekloop;
                }
                // distance

                if (nn.length() == ql.length()) {
                    int errorcount = 0;
                    for (int i = 0; i < nn.length(); i++) {
                        if (nn.charAt(i) != ql.charAt(i)) {
                            errorcount++;
                            if (errorcount > distance)
                                continue termloop;
                        }
                    }
                    a.put(g.getPopulation() + a.size(), n);
                    if (a.size() > count * 2)
                        break seekloop;
                }
            }
        }
    }
    // order by population
    LinkedHashSet<String> list = new LinkedHashSet<>();
    int i = 0;
    if (exact) {
        list.add(exactTerm);
    }
    for (Long p : a.descendingKeySet()) {
        list.add(a.get(p));
        if (i >= list.size())
            break;
    }
    return list;
}

From source file:davmail.imap.ImapConnection.java

/**
 * Send expunge untagged response for removed IMAP message uids.
 *
 * @param previousImapUidList uid list before refresh
 * @param imapUidList         uid list after refresh
 * @throws IOException on error// w  ww.  j a v  a 2  s.c  om
 */
private void handleRefresh(TreeMap<Long, String> previousImapFlagMap, TreeMap<Long, String> imapFlagMap)
        throws IOException {
    // send deleted message expunge notification
    int index = 1;
    for (long previousImapUid : previousImapFlagMap.keySet()) {
        if (!imapFlagMap.keySet().contains(previousImapUid)) {
            sendClient("* " + index + " EXPUNGE");
        } else {
            // send updated flags
            if (!previousImapFlagMap.get(previousImapUid).equals(imapFlagMap.get(previousImapUid))) {
                sendClient("* " + index + " FETCH (UID " + previousImapUid + " FLAGS ("
                        + imapFlagMap.get(previousImapUid) + "))");
            }
            index++;
        }
    }

    sendClient("* " + currentFolder.count() + " EXISTS");
    sendClient("* " + currentFolder.recent + " RECENT");
}

From source file:org.archive.url.UsableURIFactoryTest.java

/**
 * Tests from rfc2396 with amendments to accomodate differences
 * intentionally added to make our URI handling like IEs.
 *
 * <pre>/*w ww. j av  a2 s.c  o  m*/
 *       g:h           =  g:h
 *       g             =  http://a/b/c/g
 *       ./g           =  http://a/b/c/g
 *       g/            =  http://a/b/c/g/
 *       /g            =  http://a/g
 *       //g           =  http://g
 *       ?y            =  http://a/b/c/?y
 *       g?y           =  http://a/b/c/g?y
 *       #s            =  (current document)#s
 *       g#s           =  http://a/b/c/g#s
 *       g?y#s         =  http://a/b/c/g?y#s
 *       ;x            =  http://a/b/c/;x
 *       g;x           =  http://a/b/c/g;x
 *       g;x?y#s       =  http://a/b/c/g;x?y#s
 *       .             =  http://a/b/c/
 *       ./            =  http://a/b/c/
 *       ..            =  http://a/b/
 *       ../           =  http://a/b/
 *       ../g          =  http://a/b/g
 *       ../..         =  http://a/
 *       ../../        =  http://a/
 *       ../../g       =  http://a/g
 * </pre>
 *
 * @throws URIException
 */
public final void testRFC2396Relative() throws URIException {
    UsableURI base = UsableURIFactory.getInstance("http://a/b/c/d;p?q");
    TreeMap<String, String> m = new TreeMap<String, String>();
    m.put("..", "http://a/b/");
    m.put("../", "http://a/b/");
    m.put("../g", "http://a/b/g");
    m.put("../..", "http://a/");
    m.put("../../", "http://a/");
    m.put("../../g", "http://a/g");
    m.put("g#s", "http://a/b/c/g#s");
    m.put("g?y#s ", "http://a/b/c/g?y#s");
    m.put(";x", "http://a/b/c/;x");
    m.put("g;x", "http://a/b/c/g;x");
    m.put("g;x?y#s", "http://a/b/c/g;x?y#s");
    m.put(".", "http://a/b/c/");
    m.put("./", "http://a/b/c/");
    m.put("g", "http://a/b/c/g");
    m.put("./g", "http://a/b/c/g");
    m.put("g/", "http://a/b/c/g/");
    m.put("/g", "http://a/g");
    m.put("//g", "http://g");
    // CHANGED BY RFC3986
    // m.put("?y", "http://a/b/c/?y");
    m.put("g?y", "http://a/b/c/g?y");
    // EXTRAS beyond the RFC set.
    // TODO: That these resolve to a path of /a/g might be wrong.  Perhaps
    // it should be '/g'?.
    m.put("/../../../../../../../../g", "http://a/g");
    m.put("../../../../../../../../g", "http://a/g");
    m.put("../G", "http://a/b/G");
    for (Iterator<String> i = m.keySet().iterator(); i.hasNext();) {
        String key = (String) i.next();
        String value = (String) m.get(key);
        UsableURI uuri = UsableURIFactory.getInstance(base, key);
        assertTrue("Unexpected " + key + " " + value + " " + uuri,
                uuri.equals(UsableURIFactory.getInstance(value)));
    }
}

From source file:com.jaeksoft.searchlib.learning.StandardLearner.java

private void fieldClassify(String fieldName, Float boost, String data,
        TreeMap<String, LearnerResultItem> targetMap) throws SearchLibException, IOException {
    AbstractSearchRequest searchRequest = (AbstractSearchRequest) learnerClient.getNewRequest(REQUEST_SEARCH);
    BooleanQuery booleanQuery = getBooleanQuery(fieldName, data);
    if (booleanQuery == null || booleanQuery.getClauses() == null || booleanQuery.getClauses().length == 0)
        return;/*from   w  w  w.ja v  a  2  s  .c o m*/
    int start = 0;
    final int rows = 1000;
    List<String[]> termVectors = new ArrayList<String[]>(rows);
    List<String> stringIndexTerms = new ArrayList<String>(rows);
    for (;;) {
        termVectors.clear();
        stringIndexTerms.clear();
        searchRequest.setStart(start);
        searchRequest.setRows(rows);
        searchRequest.setBoostedComplexQuery(booleanQuery);
        ResultSearchSingle result = (ResultSearchSingle) learnerClient.request(searchRequest);
        if (result.getDocumentCount() == 0)
            break;
        int end = start + result.getDocumentCount();
        int[] docIds = ArrayUtils.subarray(ResultDocument.getDocIds(result.getDocs()), start, end);
        learnerClient.getIndex().putTermVectors(docIds, FIELD_SOURCE_TARGET, termVectors);
        learnerClient.getIndex().getStringIndex(FIELD_SOURCE_NAME).putTerms(docIds, stringIndexTerms);
        int i = -1;
        for (int pos = start; pos < end; pos++) {
            i++;
            String[] terms = termVectors.get(i);
            if (terms == null)
                continue;
            double docScore = result.getScore(pos);
            if (boost != null)
                docScore = docScore * boost;
            String name = stringIndexTerms.get(i);
            for (String value : terms) {
                if (value == null)
                    continue;
                LearnerResultItem learnerResultItem = targetMap.get(value);
                if (learnerResultItem == null) {
                    learnerResultItem = new LearnerResultItem(0, -1, value, null, 0, null);
                    targetMap.put(value, learnerResultItem);
                }
                learnerResultItem.addScoreInstance(docScore, 1, name);
            }
        }
        searchRequest.reset();
        start += rows;
    }
}

From source file:gemlite.shell.admin.dao.AdminDao.java

/**
 * members/* w w w.  ja va  2s.  c  om*/
 * 
 * @return
 * @throws IOException
 */
private String showMembers(TreeMap<String, String> memberTreeMap) throws IOException {
    do {
        System.out.println("------------------------");
        Map param = new HashMap();
        param.put("beanName", "ListMembersService");

        Execution execution = FunctionService.onServers(clientPool).withArgs(param);
        ResultCollector rc = execution.execute("REMOTE_ADMIN_FUNCTION");
        Object obj = rc.getResult();
        if (obj == null) {
            System.out.println("can't get members list");
            return null;
        }
        ArrayList list = (ArrayList) obj;
        if (!(list.get(0) instanceof HashMap)) {
            System.out.println(list.get(0));
            return null;
        }
        HashMap<String, String> memberMap = new HashMap<String, String>();
        StringBuilder sb = new StringBuilder();
        sb.append("NO.").append("\t").append("memberId").append("\t").append("ip").append("\n");
        int no = 1;
        if (memberTreeMap == null)
            memberTreeMap = new TreeMap<String, String>();
        for (int i = 0; i < list.size(); i++) {
            HashMap map = (HashMap) list.get(i);
            Iterator memberIters = map.keySet().iterator();
            while (memberIters.hasNext()) {
                String memberId = (String) memberIters.next();
                String ip = (String) map.get(memberId);
                memberTreeMap.put(memberId, ip);
            }
        }
        // ?,ip?
        Iterator<String> treeIt = memberTreeMap.keySet().iterator();
        while (treeIt.hasNext()) {
            String memberId = treeIt.next();
            String ip = memberTreeMap.get(memberId);
            sb.append(no).append(" ").append(memberId).append(" ").append(ip).append("\r\n");
            memberMap.put(String.valueOf(no), memberId);
            no++;
        }

        System.out.println(sb.toString());
        System.out.println("------------------------\nmemberId,Your choice,No. or memberId?X to exit");
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String line = bufferedReader.readLine();
        if (line == null) {
            System.out.println("no input memberId!");
        } else if (!"x".equalsIgnoreCase(line.trim()) && !memberMap.entrySet().contains(line.trim())
                && !memberMap.keySet().contains(line.trim())) {
            System.out.println("error input:" + line);
        } else {
            if (memberMap.keySet().contains(line.trim()))
                return memberMap.get(String.valueOf(line.trim()));
            return line.trim();
        }
    } while (true);
}

From source file:com.impetus.ankush2.framework.monitor.AbstractMonitor.java

/**
 * Update rack heat map data./*from  www. ja va 2 s  .  c o m*/
 * 
 * @param rackId
 *            the rack id
 * @param node
 *            the node
 * @param usageValue
 *            the usage value
 * @param status
 *            the status
 * @param heatMapData
 *            the heat map data
 * @return the tree map
 */
public TreeMap updateRackHeatMapData(String rackId, Node node, String usageValue, String status,
        TreeMap heatMapData) {

    // node data map
    TreeMap<String, Object> nodeData = new TreeMap<String, Object>();
    // Setting node and rack info in node data.
    nodeData.put(com.impetus.ankush2.constant.Constant.Keys.ID, node.getId());
    nodeData.put(com.impetus.ankush2.constant.Constant.Keys.NODEIP, node.getPublicIp());
    nodeData.put(com.impetus.ankush2.constant.Constant.Keys.VALUE, usageValue);
    nodeData.put(com.impetus.ankush2.constant.Constant.Keys.STATUS, status.toLowerCase());

    // Getting heat map data for rack
    TreeMap rackHeatMapData = (TreeMap) heatMapData.get(rackId);

    // if its null setting it as empty map.
    if (rackHeatMapData == null) {
        // map assignment.
        rackHeatMapData = new TreeMap();
    }
    // Setting rack id in rack heat map data.
    rackHeatMapData.put(com.impetus.ankush2.constant.Constant.Keys.RACKID, rackId);
    // Getting node data.
    List<TreeMap> rackNodesData = (ArrayList<TreeMap>) rackHeatMapData
            .get(com.impetus.ankush2.constant.Constant.Keys.NODEDATA);
    // If rack node data is null assign an empty list of map.
    if (rackNodesData == null) {
        // assigning nodes data.
        rackNodesData = new ArrayList<TreeMap>();
    }
    // Adding current node data to rack nodes data.
    rackNodesData.add(nodeData);
    // setting node data in rack heat map data.
    rackHeatMapData.put(com.impetus.ankush2.constant.Constant.Keys.NODEDATA, rackNodesData);
    // setting total nodes count.
    rackHeatMapData.put(com.impetus.ankush2.constant.Constant.Keys.TOTALNODES, rackNodesData.size());
    // rack heat map data in main heat map data.
    return rackHeatMapData;
}

From source file:statistic.ca.gui.JCAStatisticPanel.java

private void showDiagramm(String diagrammName) {
    if (diagrammName.equals("Grundinformationen")) {
        String[] columnNames = { "Bezeichnung", "Wert" };
        EvacuationCellularAutomaton tmpCA;
        int nrOfInd = 0;
        double evacSec = 0.0;
        double evacCAStep = 0;
        double notEvac = 0;
        double evac = 0;
        double notEvacNoExit = 0;
        double notEvacNoTime = 0;
        int bestEvacIndex = 0;
        int aveEvacIndex = 0;
        int worseEvacIndex = 0;
        TreeMap<Double, Integer> findMedian = new TreeMap<>();
        for (int i = 0; i < selectedBatchResultEntry.getCa().length; i++) {
            tmpCA = selectedBatchResultEntry.getCa()[i];
            nrOfInd += tmpCA.getInitialIndividualCount();
            evacSec += tmpCA.getSecondsPerStep() * tmpCA.getTimeStep();
            evacCAStep += tmpCA.getTimeStep();
            evac += tmpCA.getInitialIndividualCount() - tmpCA.deadIndividualsCount();
            notEvac += tmpCA.deadIndividualsCount();
            notEvacNoExit += tmpCA.getDeadIndividualCount(DeathCause.ExitUnreachable);// getNrOfExitUnreachableDeadIndividuals();
            notEvacNoTime += tmpCA.getDeadIndividualCount(DeathCause.NotEnoughTime);// getNrOfNotEnoughTimeDeadIndividuals();
            findMedian.put(tmpCA.getTimeStep() * tmpCA.getSecondsPerStep(), i);
        }//  w w w  .  j a  v  a2s .co  m
        bestEvacIndex = findMedian.firstEntry().getValue();
        for (int j = 0; j < findMedian.size() / 2; j++)
            findMedian.remove(findMedian.firstKey());
        aveEvacIndex = findMedian.get(findMedian.firstKey());
        worseEvacIndex = findMedian.get(findMedian.lastKey());
        Object[][] data = { { "Informationen fr Modell", selectedBatchResultEntry.getName() },
                { "Evakuierungszeit in Sekunden", evacSec / selectedBatchResultEntry.getCa().length },
                { "Evakuierungszeit in ZA-Schritten", evacCAStep / selectedBatchResultEntry.getCa().length },
                { "Anzahl Individuen", (double) nrOfInd / selectedBatchResultEntry.getCa().length },
                { "evakuiert", evac / selectedBatchResultEntry.getCa().length },
                { "nicht evakuiert", notEvac / selectedBatchResultEntry.getCa().length },
                { "nicht evakuiert weil kein Ausgang erreichbar",
                        notEvacNoExit / selectedBatchResultEntry.getCa().length },
                { "nicht evakuiert weil die Zeit nicht gereicht hat",
                        notEvacNoTime / selectedBatchResultEntry.getCa().length },
                { "beste Evakuierungszeit (Durchlaufindex,Zeit)", ("(" + (bestEvacIndex + 1) + " - "
                        + (selectedBatchResultEntry.getCa()[bestEvacIndex].getTimeStep()
                                / selectedBatchResultEntry.getCa()[bestEvacIndex].getStepsPerSecond())
                        + ")") },
                { "durchschnit. Evakuierungszeit (Durchlaufindex,Zeit)", ("(" + (aveEvacIndex + 1) + " - "
                        + (selectedBatchResultEntry.getCa()[aveEvacIndex].getTimeStep()
                                / selectedBatchResultEntry.getCa()[bestEvacIndex].getStepsPerSecond())
                        + ")") },
                { "schlechteste Evakuierungszeit (Durchlaufindex,Zeit)",
                        ("(" + (worseEvacIndex + 1) + " - "
                                + (selectedBatchResultEntry.getCa()[worseEvacIndex].getTimeStep()
                                        / selectedBatchResultEntry.getCa()[bestEvacIndex].getStepsPerSecond())
                                + ")") } };
        basicInformationTable = new JTable(data, columnNames);
        basicInformationScrollPane = new JScrollPane(basicInformationTable);
        diagrams.addTable(diagrammName, basicInformationScrollPane, west);
    }

    if ((noIndividualsInAtLeastOneAssignmentIndex) && !(diagrammName.equals("Grundinformationen"))) {
        chartData = new ChartData("bar", "NO INDIVIDUALS in at least one of the choosed dataset(s)", "",
                new ArrayList<>(), new ArrayList<>());
        evakuierungsdauer = ChartFactory.createBarChart(
                "NO INDIVIDUALS in at least one of the choosed dataset(s)", "", chartData.getYAxisLabel(),
                chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true, false);
        diagrams.addChart("NO INDIVIDUALS in at least one of the choosed dataset(s)", evakuierungsdauer, west);
    } else {

        if (diagrammName.equals("Ausgangsverteilung")) {
            chartData = new ChartData("pie",
                    diagrammName + ":" + selectedBatchResultEntry.getName() + "-"
                            + assignmentGroups.get(assignmentIndexToShow.get(0)).toString(),
                    "Ausgnge", categoryDatasetValues, categoryDatasetAssignments);
            ausgangsverteilung = ChartFactory.createPieChart(
                    diagrammName + ":" + selectedBatchResultEntry.getName() + "-"
                            + assignmentGroups.get(assignmentIndexToShow.get(0)).toString(),
                    ChartData.getPieDataSet(), false, true, false);
            diagrams.addChart(diagrammName, ausgangsverteilung, west);
        }

        if (diagrammName.equals("Ankunftskurve")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            ankunftskurve = ChartFactory.createXYLineChart(diagrammName, chartData.getYAxisLabel(),
                    "Individuen", (XYDataset) datasetCollection, PlotOrientation.VERTICAL, true, true, false);
            diagrams.addChart(diagrammName, ankunftskurve, west);
        }

        if (diagrammName.equals("Evakuierungsdauer")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            evakuierungsdauer = ChartFactory.createBarChart(diagrammName, "Belegungen",
                    chartData.getYAxisLabel(), chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true,
                    false);
            diagrams.addChart(diagrammName, evakuierungsdauer, west);
        }

        if (diagrammName.equals("evakuierte Individuen in Prozent")) {
            chartData = new ChartData("pie",
                    diagrammName + ":" + selectedBatchResultEntry.getName() + "-"
                            + assignmentGroups.get(assignmentIndexToShow.get(0)).toString(),
                    "Individuen", categoryDatasetValues, categoryDatasetAssignments);
            evakuierteIndividueninProzent = ChartFactory.createPieChart(
                    diagrammName + ":" + selectedBatchResultEntry.getName() + "-"
                            + assignmentGroups.get(assignmentIndexToShow.get(0)).toString(),
                    ChartData.getPieDataSet(), false, true, false);
            diagrams.addChart(diagrammName, evakuierteIndividueninProzent, west);
        }

        if (diagrammName.equals("maximale Blockadezeit")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            maxblockadezeit = ChartFactory.createBarChart(diagrammName, "Belegungen", chartData.getYAxisLabel(),
                    chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true, false);
            diagrams.addChart(diagrammName, maxblockadezeit, west);
        }

        if (diagrammName.equals("durchschnittliche Blockadezeit")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            aveblockadezeit = ChartFactory.createBarChart(diagrammName, "Belegungen", chartData.getYAxisLabel(),
                    chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true, false);
            diagrams.addChart(diagrammName, aveblockadezeit, west);
        }

        if (diagrammName.equals("minimale Blockadezeit")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            minblockadezeit = ChartFactory.createBarChart(diagrammName, "Belegungen", chartData.getYAxisLabel(),
                    chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true, false);
            diagrams.addChart(diagrammName, minblockadezeit, west);
        }

        if (diagrammName.equals("zurckgelegte Distanz")) {
            chartData = new ChartData("bar", diagrammName, "Meter [m]", categoryDatasetValues,
                    categoryDatasetAssignments);
            zurueckgelegteDistanz = ChartFactory.createBarChart(diagrammName, "Belegungen",
                    chartData.getYAxisLabel(), chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true,
                    false);
            diagrams.addChart(diagrammName, zurueckgelegteDistanz, west);
        }

        if (diagrammName.equals("minimale Distanz zum initialen Ausgang")) {
            chartData = new ChartData("bar", diagrammName, "Meter [m]", categoryDatasetValues,
                    categoryDatasetAssignments);
            minimaleDistanzzuminitialenAusgang = ChartFactory.createBarChart(diagrammName, "Belegungen",
                    chartData.getYAxisLabel(), chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true,
                    false);
            diagrams.addChart(diagrammName, minimaleDistanzzuminitialenAusgang, west);
        }

        if (diagrammName.equals("minimale Distanz zum nchsten Ausgang")) {
            chartData = new ChartData("bar", diagrammName, "Meter [m]", categoryDatasetValues,
                    categoryDatasetAssignments);
            minimaleDistanzzumnaechstenAusgang = ChartFactory.createBarChart(diagrammName, "Belegungen",
                    chartData.getYAxisLabel(), chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true,
                    false);
            diagrams.addChart(diagrammName, minimaleDistanzzumnaechstenAusgang, west);
        }

        if (diagrammName.equals("maximale Zeit bis Safe")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            maxZeitBisSafe = ChartFactory.createBarChart(diagrammName, "Belegungen", chartData.getYAxisLabel(),
                    chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true, false);
            diagrams.addChart(diagrammName, maxZeitBisSafe, west);
        }

        if (diagrammName.equals("durchschnittliche Zeit bis Safe")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            aveZeitBisSafe = ChartFactory.createBarChart(diagrammName, "Belegungen", chartData.getYAxisLabel(),
                    chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true, false);
            diagrams.addChart(diagrammName, aveZeitBisSafe, west);
        }

        if (diagrammName.equals("minimale Zeit bis Safe")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            minZeitBisSafe = ChartFactory.createBarChart(diagrammName, "Belegungen", chartData.getYAxisLabel(),
                    chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true, false);
            diagrams.addChart(diagrammName, minZeitBisSafe, west);
        }

        if (diagrammName.equals("Distanz ber Zeit")) {
            chartData = new ChartData("bar", diagrammName, "Meter [m]", categoryDatasetValues,
                    categoryDatasetAssignments);
            distanzueberZeit = ChartFactory.createXYLineChart(diagrammName, "Zeit [s]",
                    chartData.getYAxisLabel(), (XYDataset) datasetCollection, PlotOrientation.VERTICAL, true,
                    true, false);
            diagrams.addChart(diagrammName, distanzueberZeit, west);
        }

        if (diagrammName.equals("maximale Geschwindigkeit ber Zeit")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            maximaleGeschwindigkeitueberZeit = ChartFactory.createXYLineChart(diagrammName,
                    chartData.getYAxisLabel(), "Meter pro Sekunde [m/s]", (XYDataset) datasetCollection,
                    PlotOrientation.VERTICAL, true, true, false);
            diagrams.addChart(diagrammName, maximaleGeschwindigkeitueberZeit, west);
        }

        if (diagrammName.equals("durschnittliche Geschwindigkeit ber Zeit")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            durschnittlicheGeschwindigkeitueberZeit = ChartFactory.createXYLineChart(diagrammName,
                    chartData.getYAxisLabel(), "Meter pro Sekunde [m/s]", (XYDataset) datasetCollection,
                    PlotOrientation.VERTICAL, true, true, false);
            diagrams.addChart(diagrammName, durschnittlicheGeschwindigkeitueberZeit, west);
        }

        if (diagrammName.equals("maximale Geschwindigkeit")) {
            chartData = new ChartData("bar", diagrammName, "Meter pro Sekunde [m/s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            maximaleGeschwindigkeit = ChartFactory.createBarChart(diagrammName, "Belegungen",
                    chartData.getYAxisLabel(), chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true,
                    false);
            diagrams.addChart(diagrammName, maximaleGeschwindigkeit, west);
        }

        if (diagrammName.equals("durchschnittliche Geschwindigkeit")) {
            chartData = new ChartData("bar", diagrammName, "Meter pro Sekunde [m/s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            durchschnittlicheGeschwindigkeit = ChartFactory.createBarChart(diagrammName, "Belegungen",
                    chartData.getYAxisLabel(), chartData.getCDataSet(), PlotOrientation.VERTICAL, false, true,
                    false);
            diagrams.addChart(diagrammName, durchschnittlicheGeschwindigkeit, west);
        }

        if (diagrammName.equals("Panik ber Zeit")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            panik = ChartFactory.createXYLineChart(diagrammName, chartData.getYAxisLabel(), "Panik",
                    (XYDataset) datasetCollection, PlotOrientation.VERTICAL, true, true, false);
            diagrams.addChart(diagrammName, panik, west);
        }

        if (diagrammName.equals("Erschpfung ber Zeit")) {
            chartData = new ChartData("bar", diagrammName, "Zeit [s]", categoryDatasetValues,
                    categoryDatasetAssignments);
            erschoepfung = ChartFactory.createXYLineChart(diagrammName, chartData.getYAxisLabel(),
                    "Erschpfung", (XYDataset) datasetCollection, PlotOrientation.VERTICAL, true, true, false);
            diagrams.addChart(diagrammName, erschoepfung, west);
        }

    } //end else

    categoryDatasetValues = new ArrayList<>();
    categoryDatasetAssignments = new ArrayList<>();
    //dataset = new XYSeries("");
    datasetCollection = new XYSeriesCollection();
    diagrams.validate();
}

From source file:hudson.model.AbstractProject.java

/**
 * Helper method for getDownstreamRelationship.
 *
 * For each given build, find the build number range of the given project and put that into the map.
 *///from ww  w  .  j a  v  a2s.  c  o m
private void checkAndRecord(AbstractProject that, TreeMap<Integer, RangeSet> r, Collection<R> builds) {
    for (R build : builds) {
        RangeSet rs = build.getDownstreamRelationship(that);
        if (rs == null || rs.isEmpty())
            continue;

        int n = build.getNumber();

        RangeSet value = r.get(n);
        if (value == null)
            r.put(n, rs);
        else
            value.add(rs);
    }
}