Example usage for java.util LinkedHashMap get

List of usage examples for java.util LinkedHashMap get

Introduction

In this page you can find the example usage for java.util LinkedHashMap 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:Simulator.PerformanceCalculation.java

public JPanel waitTime1() {
    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime1());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {/* ww w.  j  av a  2  s  . c  o  m*/
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime1());
        }

        no.add(traceObject.getSurgeonId());
    }
    String[] column = new String[no.size()];

    String series1 = "Wait Time 1";
    for (int i = 0; i < no.size(); i++) {
        column[i] = "Surgeon " + (i + 1);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();
    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double total = 0;
        for (Double double1 : arrayList) {
            total += double1;
        }
        average.put(integer, total / arrayList.size());
    }

    for (int i = 1; i <= average.size(); i++) {
        dataset.addValue(Math.round(average.get(i) / 600), series1, column[i - 1]);
    }
    JFreeChart chart = ChartFactory.createBarChart("Wait Time 1", // chart title
            "Surgeon ID", // domain axis label
            "Days", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    return new ChartPanel(chart);
}

From source file:Simulator.PerformanceCalculation.java

public JPanel waitTime2() {
    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime2());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {/*  w w  w  . ja  va 2s.  c  o m*/
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime2());
        }

        no.add(traceObject.getSurgeonId());
    }
    String[] column = new String[no.size()];

    String series1 = "Wait Time 2";
    for (int i = 0; i < no.size(); i++) {
        column[i] = "Surgeon " + (i + 1);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();
    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double total = 0;
        for (Double double1 : arrayList) {
            total += double1;
        }
        average.put(integer, total / arrayList.size());
    }

    for (int i = 1; i <= average.size(); i++) {
        dataset.addValue(Math.round(average.get(i) / 600), series1, column[i - 1]);
    }

    JFreeChart chart = ChartFactory.createBarChart("Wait Time 2", // chart title
            "Surgeon ID", // domain axis label
            "Days", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    return new ChartPanel(chart);
}

From source file:Simulator.PerformanceCalculation.java

public JPanel waitTime() {
    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime1());
            details.add(traceObject.getWaitTime2());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {/*from   w ww .  ja v a  2 s  .  com*/
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime1());
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime2());
        }

        no.add(traceObject.getSurgeonId());
    }
    String[] column = new String[no.size()];

    String series1 = "Wait Time";
    for (int i = 0; i < no.size(); i++) {
        column[i] = "Surgeon " + (i + 1);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();
    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double total = 0;
        for (Double double1 : arrayList) {
            total += double1;
        }
        average.put(integer, total / (arrayList.size() / 2));
    }

    for (int i = 1; i <= average.size(); i++) {
        dataset.addValue(Math.round(average.get(i) / 600), series1, column[i - 1]);
    }
    JFreeChart chart = ChartFactory.createBarChart("Wait Time", // chart title
            "Surgeon ID", // domain axis label
            "Days", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    return new ChartPanel(chart);
}

From source file:Simulator.PerformanceCalculation.java

public JPanel costAnaylsis() {
    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime1());
            details.add(traceObject.getWaitTime2());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {//  www  .j  a va  2  s .co m
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime1());
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime2());
        }

        no.add(traceObject.getSurgeonId());
    }
    String[] column = new String[no.size()];

    String series1 = "Cost";
    for (int i = 0; i < no.size(); i++) {
        column[i] = "Surgeon " + (i + 1);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int totalCost = 0;
    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();
    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double total = 0;
        for (Double double1 : arrayList) {
            total += double1;
        }
        totalCost += total * Configuration.costOfPatientWaiting;
        average.put(integer, total / 600);
    }

    for (int i = 1; i <= average.size(); i++) {
        dataset.addValue(Math.round(average.get(i) * Configuration.costOfPatientWaiting), series1,
                column[i - 1]);
    }
    totalCostClass = totalCost;
    JFreeChart chart = ChartFactory.createBarChart("Cost", // chart title
            "Surgeon ID", // domain axis label
            "$", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    return new ChartPanel(chart);
}

From source file:com.frostwire.gui.components.slides.YouTubeStreamURLExtractor.java

private HashMap<Integer, String[]> getLinks(final String video, final boolean prem, Browser br, int retrycount)
        throws Exception {
    if (retrycount > 2) {
        // do not retry more often than 2 time
        return null;
    }//from   w  w w .j  av  a 2 s. c  o  m
    //        if (br == null) {
    //            br = this.br;
    //        }
    br.setFollowRedirects(true);
    /* this cookie makes html5 available and skip controversy check */
    br.setCookie("youtube.com", "PREF", "f2=40100000");
    br.getHeaders().put("User-Agent", "Wget/1.12");
    br.getPage(video);
    if (br.containsHTML("id=\"unavailable-submessage\" class=\"watch-unavailable-submessage\"")) {
        return null;
    }
    final String VIDEOID = new Regex(video, "watch\\?v=([\\w_\\-]+)").getMatch(0);
    boolean fileNameFound = false;
    String YT_FILENAME = VIDEOID;
    if (br.containsHTML("&title=")) {
        YT_FILENAME = Encoding
                .htmlDecode(br.getRegex("&title=([^&$]+)").getMatch(0).replaceAll("\\+", " ").trim());
        fileNameFound = true;
    }
    final String url = br.getURL();
    boolean ythack = false;
    if (url != null && !url.equals(video)) {
        /* age verify with activated premium? */
        //            if (url.toLowerCase(Locale.ENGLISH).indexOf("youtube.com/verify_age?next_url=") != -1) {
        //                verifyAge = true;
        //            }
        if (url.toLowerCase(Locale.ENGLISH).indexOf("youtube.com/verify_age?next_url=") != -1 && prem) {
            final String session_token = br.getRegex("onLoadFunc.*?gXSRF_token = '(.*?)'").getMatch(0);
            final LinkedHashMap<String, String> p = Request.parseQuery(url);
            final String next = p.get("next_url");
            final Form form = new Form();
            form.setAction(url);
            form.setMethod(MethodType.POST);
            form.put("next_url", "%2F" + next.substring(1));
            form.put("action_confirm", "Confirm+Birth+Date");
            form.put("session_token", Encoding.urlEncode(session_token));
            br.submitForm(form);
            if (br.getCookie("http://www.youtube.com", "is_adult") == null) {
                return null;
            }
        } else if (url.toLowerCase(Locale.ENGLISH).indexOf("youtube.com/index?ytsession=") != -1
                || url.toLowerCase(Locale.ENGLISH).indexOf("youtube.com/verify_age?next_url=") != -1 && !prem) {
            ythack = true;
            br.getPage("http://www.youtube.com/get_video_info?video_id=" + VIDEOID);
            if (br.containsHTML("&title=") && fileNameFound == false) {
                YT_FILENAME = Encoding
                        .htmlDecode(br.getRegex("&title=([^&$]+)").getMatch(0).replaceAll("\\+", " ").trim());
                fileNameFound = true;
            }
        } else if (url.toLowerCase(Locale.ENGLISH).indexOf("google.com/accounts/servicelogin?") != -1) {
            // private videos
            return null;
        }
    }
    /* html5_fmt_map */
    if (br.getRegex(YT_FILENAME_PATTERN).count() != 0 && fileNameFound == false) {
        YT_FILENAME = Encoding.htmlDecode(br.getRegex(YT_FILENAME_PATTERN).getMatch(0).trim());
        fileNameFound = true;
    }
    final HashMap<Integer, String[]> links = new HashMap<Integer, String[]>();
    String html5_fmt_map = br.getRegex("\"html5_fmt_map\": \\[(.*?)\\]").getMatch(0);

    if (html5_fmt_map != null) {
        String[] html5_hits = new Regex(html5_fmt_map, "\\{(.*?)\\}").getColumn(0);
        if (html5_hits != null) {
            for (String hit : html5_hits) {
                String hitUrl = new Regex(hit, "url\": \"(http:.*?)\"").getMatch(0);
                String hitFmt = new Regex(hit, "itag\": (\\d+)").getMatch(0);
                String hitQ = new Regex(hit, "quality\": \"(.*?)\"").getMatch(0);
                if (hitUrl != null && hitFmt != null && hitQ != null) {
                    hitUrl = unescape(hitUrl.replaceAll("\\\\/", "/"));
                    links.put(Integer.parseInt(hitFmt),
                            new String[] { Encoding.htmlDecode(Encoding.urlDecode(hitUrl, true)), hitQ });
                }
            }
        }
    } else {
        /* new format since ca. 1.8.2011 */
        html5_fmt_map = br.getRegex("\"url_encoded_fmt_stream_map\": \"(.*?)\"").getMatch(0);
        if (html5_fmt_map == null) {
            html5_fmt_map = br.getRegex("url_encoded_fmt_stream_map=(.*?)(&|$)").getMatch(0);
            if (html5_fmt_map != null) {
                html5_fmt_map = html5_fmt_map.replaceAll("%2C", ",");
                if (!html5_fmt_map.contains("url=")) {
                    html5_fmt_map = html5_fmt_map.replaceAll("%3D", "=");
                    html5_fmt_map = html5_fmt_map.replaceAll("%26", "&");
                }
            }
        }
        if (html5_fmt_map != null && !html5_fmt_map.contains("signature") && !html5_fmt_map.contains("sig")) {
            Thread.sleep(5000);
            br.clearCookies("youtube.com");
            return getLinks(video, prem, br, retrycount + 1);
        }
        if (html5_fmt_map != null) {
            String[] html5_hits = new Regex(html5_fmt_map, "(.*?)(,|$)").getColumn(0);
            if (html5_hits != null) {
                for (String hit : html5_hits) {
                    hit = unescape(hit);
                    String hitUrl = new Regex(hit, "url=(http.*?)(\\&|$)").getMatch(0);
                    String sig = new Regex(hit, "url=http.*?(\\&|$)(sig|signature)=(.*?)(\\&|$)").getMatch(2);
                    String hitFmt = new Regex(hit, "itag=(\\d+)").getMatch(0);
                    String hitQ = new Regex(hit, "quality=(.*?)(\\&|$)").getMatch(0);
                    if (hitUrl != null && hitFmt != null && hitQ != null) {
                        hitUrl = unescape(hitUrl.replaceAll("\\\\/", "/"));
                        if (hitUrl.startsWith("http%253A")) {
                            hitUrl = Encoding.htmlDecode(hitUrl);
                        }
                        String[] inst = null;
                        if (hitUrl.contains("sig")) {
                            inst = new String[] { Encoding.htmlDecode(Encoding.urlDecode(hitUrl, true)), hitQ };
                        } else {
                            inst = new String[] {
                                    Encoding.htmlDecode(Encoding.urlDecode(hitUrl, true) + "&signature=" + sig),
                                    hitQ };
                        }
                        links.put(Integer.parseInt(hitFmt), inst);
                    }
                }
            }
        }
    }

    /* normal links */
    final HashMap<String, String> fmt_list = new HashMap<String, String>();
    String fmt_list_str = "";
    if (ythack) {
        fmt_list_str = (br.getMatch("&fmt_list=(.+?)&") + ",").replaceAll("%2F", "/").replaceAll("%2C", ",");
    } else {
        fmt_list_str = (br.getMatch("\"fmt_list\":\\s+\"(.+?)\",") + ",").replaceAll("\\\\/", "/");
    }
    final String fmt_list_map[][] = new Regex(fmt_list_str, "(\\d+)/(\\d+x\\d+)/\\d+/\\d+/\\d+,").getMatches();
    for (final String[] fmt : fmt_list_map) {
        fmt_list.put(fmt[0], fmt[1]);
    }
    if (links.size() == 0 && ythack) {
        /* try to find fallback links */
        String urls[] = br.getRegex("url%3D(.*?)($|%2C)").getColumn(0);
        int index = 0;
        for (String vurl : urls) {
            String hitUrl = new Regex(vurl, "(.*?)%26").getMatch(0);
            String hitQ = new Regex(vurl, "%26quality%3D(.*?)%").getMatch(0);
            if (hitUrl != null && hitQ != null) {
                hitUrl = unescape(hitUrl.replaceAll("\\\\/", "/"));
                if (fmt_list_map.length >= index) {
                    links.put(Integer.parseInt(fmt_list_map[index][0]),
                            new String[] { Encoding.htmlDecode(Encoding.urlDecode(hitUrl, false)), hitQ });
                    index++;
                }
            }
        }
    }
    for (Integer fmt : links.keySet()) {
        String fmt2 = fmt + "";
        if (fmt_list.containsKey(fmt2)) {
            String Videoq = links.get(fmt)[1];
            final Integer q = Integer.parseInt(fmt_list.get(fmt2).split("x")[1]);
            if (fmt == 40) {
                Videoq = "240p Light";
            } else if (q > 1080) {
                Videoq = "Original";
            } else if (q > 720) {
                Videoq = "1080p";
            } else if (q > 576) {
                Videoq = "720p";
            } else if (q > 360) {
                Videoq = "480p";
            } else if (q > 240) {
                Videoq = "360p";
            } else {
                Videoq = "240p";
            }
            links.get(fmt)[1] = Videoq;
        }
    }
    if (YT_FILENAME != null) {
        links.put(-1, new String[] { YT_FILENAME });
    }
    return links;
}

From source file:Simulator.PerformanceCalculation.java

private CategoryDataset createDataset() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime1());
            details.add(traceObject.getWaitTime2());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {// w  w  w . j a  v a 2 s.  c  o  m
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime1());
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime2());
        }

        no.add(traceObject.getSurgeonId());
    }
    String[] column = new String[no.size()];

    String series1 = "Minimum Cost";
    String series2 = "Acceptable Cost";
    String series3 = "Actual Cost";

    for (int i = 0; i < no.size(); i++) {
        column[i] = "Surgeon " + (i + 1);
    }

    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();
    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double total = 0;
        for (Double double1 : arrayList) {
            total += double1;
        }
        average.put(integer, total / 600);
    }

    for (int i = 1; i <= average.size(); i++) {
        int costMin = (Configuration.minimumSurgeryTime * (wait1.get(i).size() / 2)
                * Configuration.costOfPatientWaiting);
        int costAccept = (Configuration.acceptedSurgeryTime * (wait1.get(i).size() / 2)
                * Configuration.costOfPatientWaiting);
        int actualCost = (int) Math.round(average.get(i) * Configuration.costOfPatientWaiting);

        int x = actualCost - (costAccept + costMin);
        if (x > actualCost) {
            x = actualCost;
        }
        dataset.addValue(costMin, series1, column[i - 1]);
        dataset.addValue(costAccept - costMin, series2, column[i - 1]);
        dataset.addValue(x, series3, column[i - 1]);
    }

    return dataset;
}

From source file:com.github.shareme.gwschips.library.BaseRecipientAdapter.java

private static void putOneEntry(TemporaryEntry entry, boolean isAggregatedEntry,
        LinkedHashMap<Long, List<RecipientEntry>> entryMap, List<RecipientEntry> nonAggregatedEntries,
        Set<String> existingDestinations) {
    if (existingDestinations.contains(entry.destination)) {
        return;//w  w w . jav  a  2 s .  c  o  m
    }

    existingDestinations.add(entry.destination);

    if (!isAggregatedEntry) {
        nonAggregatedEntries
                .add(RecipientEntry.constructTopLevelEntry(entry.displayName, entry.displayNameSource,
                        entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId,
                        entry.directoryId, entry.dataId, entry.thumbnailUriString, true, entry.lookupKey));
    } else if (entryMap.containsKey(entry.contactId)) {
        // We already have a section for the person.
        final List<RecipientEntry> entryList = entryMap.get(entry.contactId);
        entryList.add(RecipientEntry.constructSecondLevelEntry(entry.displayName, entry.displayNameSource,
                entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId,
                entry.directoryId, entry.dataId, entry.thumbnailUriString, true, entry.lookupKey));
    } else {
        final List<RecipientEntry> entryList = new ArrayList<>();
        entryList.add(RecipientEntry.constructTopLevelEntry(entry.displayName, entry.displayNameSource,
                entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId,
                entry.directoryId, entry.dataId, entry.thumbnailUriString, true, entry.lookupKey));
        entryMap.put(entry.contactId, entryList);
    }
}

From source file:Simulator.PerformanceCalculation.java

JPanel minmaxwaitTime2(boolean minCheck) {
    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime2());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {//from  w  ww  .  ja v a  2  s  .  c o  m
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime2());
        }

        no.add(traceObject.getSurgeonId());
    }

    XYSeriesCollection dataset = new XYSeriesCollection();

    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();

    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double value = 0;
        if (minCheck) {
            value = Collections.min(arrayList);
            value = value / 600;
        } else {
            value = Collections.max(arrayList);
            value = value / 600;
        }

        average.put(integer, value);
    }

    XYSeries series = new XYSeries("Surgeon Minimum Wait Time 2");
    for (int i = 1; i <= average.size(); i++) {
        series.add(i, average.get(i));
    }
    dataset.addSeries(series);
    String name;
    if (minCheck) {
        name = "Minimum";
    } else {
        name = "Maximum";
    }
    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(name + " Wait Time 2 For Patients", // Title
            "Surgeon ID", // x-axis Label
            "Time (Days)", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    XYPlot xyPlot = (XYPlot) chart.getPlot();

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    renderer.setBaseShapesVisible(true);
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setVerticalTickLabels(true);

    return new ChartPanel(chart);
}

From source file:Simulator.PerformanceCalculation.java

JPanel minmaxwaitTime1(boolean minCheck) {
    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime1());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {//from   w  w  w.java  2 s . com
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime1());
        }

        no.add(traceObject.getSurgeonId());
    }

    XYSeriesCollection dataset = new XYSeriesCollection();

    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();

    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double value = 0;
        if (minCheck) {
            value = Collections.min(arrayList);
            value = value / 600;
        } else {
            value = Collections.max(arrayList);
            value = value / 600;
        }

        average.put(integer, value);
    }

    XYSeries series = new XYSeries("Surgeon Minimum Wait Time 1");
    for (int i = 1; i <= average.size(); i++) {
        series.add(i, average.get(i));
    }
    dataset.addSeries(series);
    String name;
    if (minCheck) {
        name = "Minimum";
    } else {
        name = "Maximum";
    }
    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(name + " Wait Time 1 For Patients", // Title
            "Surgeon ID", // x-axis Label
            "Time (Days)", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    XYPlot xyPlot = (XYPlot) chart.getPlot();

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    renderer.setBaseShapesVisible(true);
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setVerticalTickLabels(true);

    return new ChartPanel(chart);
}

From source file:br.com.postalis.folhapgto.service.SvcFolhaPgtoImpl.java

public boolean criarRelatorioResumoDeDifEnviadasEIncorporadas(Date dtRef) throws JRException {
    List<RelatorioDTO> lista = new ArrayList<RelatorioDTO>();
    LinkedHashMap<String, PosGpxConsignacaoPopulisIncorporada> listaIncorp = new LinkedHashMap<String, PosGpxConsignacaoPopulisIncorporada>();

    for (PosGpxConsignacaoPopulisIncorporada incorp : incorporadosRepository
            .findByDtReferenciaGroupByVerbaAndVlLancamentoAndQtLancamento(dtRef)) {
        listaIncorp.put(incorp.getCdVerba(), incorp);
    }//from   w w  w  .  j  a v  a2  s  .  co m

    for (ConsignacaoPopulis env : consignadoRepository
            .findByDtReferenciaEnviadosGroupByCdVerbaAndDsVerba(dtRef)) {
        PosGpxConsignacaoPopulisIncorporada inc = listaIncorp.get(env.getCdVerba());
        RelatorioDTO rel;
        if (inc != null) {
            BigDecimal difValor = env.getVlVerba().subtract(inc.getVlLancamento());
            BigDecimal difQtd = env.getQtVerba().subtract(inc.getQtLancamento());
            rel = new RelatorioDTO(env.getCdVerba(), env.getDsVerba(), env.getVlVerba(), env.getQtVerba(),
                    inc.getVlLancamento(), inc.getQtLancamento(), difValor, difQtd);
        } else {
            rel = new RelatorioDTO(env.getCdVerba(), env.getDsVerba(), env.getVlVerba(), env.getQtVerba(),
                    BigDecimal.ZERO, BigDecimal.ZERO, env.getVlVerba(), env.getQtVerba());
        }

        lista.add(rel);
    }

    if (lista == null || lista.isEmpty()) {
        return false;
    }
    gerarRelatorio("Relatrio de diferenas das rbricas enviadas e incorporadas - Sinttico",
            "RelResumoDifRubEnviadasXIncorporadas", lista, dtRef);
    return true;
}