Example usage for org.apache.commons.collections15.map ListOrderedMap get

List of usage examples for org.apache.commons.collections15.map ListOrderedMap get

Introduction

In this page you can find the example usage for org.apache.commons.collections15.map ListOrderedMap get.

Prototype

public K get(int index) 

Source Link

Document

Gets the key at the specified index.

Usage

From source file:edu.brown.benchmark.seats.util.GenerateHistograms.java

public static GenerateHistograms generate(File input) throws Exception {
    GenerateHistograms gh = new GenerateHistograms();

    final ListOrderedMap<String, Integer> columns_xref = new ListOrderedMap<String, Integer>();
    CSVReader reader = new CSVReader(FileUtil.getReader(input));
    String row[] = null;/*  w  ww  . j  a v a2s  . c om*/
    boolean first = true;
    while ((row = reader.readNext()) != null) {
        if (first) {
            for (int i = 0; i < row.length; i++) {
                columns_xref.put(row[i].toUpperCase(), i);
            } // FOR
            first = false;
            continue;
        }
        if (row[0].equalsIgnoreCase("Year"))
            continue;

        String airline_code = row[columns_xref.get("UNIQUECARRIER")];
        String depart_airport_code = row[columns_xref.get("ORIGIN")];
        String arrival_airport_code = row[columns_xref.get("DEST")];
        String depart_time = row[columns_xref.get("CRSDEPTIME")];

        // Flights Per Airline
        gh.flights_per_airline.put(airline_code);

        // Flights Per Time
        // Convert the time into "HH:MM" and round to the nearest 15 minutes
        int hour = Integer.parseInt(depart_time.substring(0, 2));
        int minute = Integer.parseInt(depart_time.substring(2, 4));
        minute = (minute / 15) * 15;
        gh.flights_per_time.put(String.format("%02d:%02d", hour, minute));

        // Flights Per Airport
        // DepartAirport -> Histogram<ArrivalAirport>
        ObjectHistogram<String> h = gh.flights_per_airport.get(depart_airport_code);
        if (h == null) {
            h = new ObjectHistogram<String>();
            gh.flights_per_airport.put(depart_airport_code, h);
        }
        h.put(arrival_airport_code);
    } // WHILE
    reader.close();
    return (gh);
}

From source file:lu.lippmann.cdb.common.gui.MultiPanel.java

/**
 * Constructor.//from   ww w  .j av  a  2 s  .c o  m
 */
public MultiPanel(final ListOrderedMap<JComponent, Integer> mapPanels, final int w, final int h,
        final boolean withWeight) {

    final int total = mapPanels.keySet().size();

    if (!withWeight)
        setLayout(new GridLayout(0, 1));

    final int w2 = w - 10 * total;
    final int h2 = h - 75;

    final Map<JComponent, Color> choosedColor = new HashMap<JComponent, Color>();

    int i = 0;
    for (final JComponent p : mapPanels.keySet()) {
        final Dimension size = new Dimension((int) (w2 * (mapPanels.get(p) / 100.0)), h2);
        p.setPreferredSize(size);
        choosedColor.put(p, COLORS[i]);
        p.setBackground(COLORS[i]);
        p.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        add(p);
        i++;
    }

    if (withWeight) {
        /** add percents **/
        for (final JComponent p : mapPanels.keySet()) {
            final int perc = mapPanels.get(p);
            final int percent = (int) (w2 * (mapPanels.get(p) / 100.0));
            final Dimension size = new Dimension(percent, 20);
            final JPanel arrow = new JPanel();
            arrow.setPreferredSize(size);
            final JLabel label = new JLabel(perc + "%");
            label.setForeground(choosedColor.get(p).darker());
            arrow.add(label);
            add(arrow);
        }
    }
}