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

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

Introduction

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

Prototype

public Set<K> keySet() 

Source Link

Usage

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

/**
 * Constructor.//from ww  w  .  jav  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);
        }
    }
}