Example usage for org.apache.commons.collections.map LinkedMap keySet

List of usage examples for org.apache.commons.collections.map LinkedMap keySet

Introduction

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

Prototype

public Set keySet() 

Source Link

Document

Gets the keySet view of the map.

Usage

From source file:net.rptools.maptool.client.ui.MapToolFrame.java

private Timer newChatTimer() {
    // Set up the Chat timer to listen for changes
    Timer tm = new Timer(500, new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            long currentTime = System.currentTimeMillis();
            LinkedMap chatTimers = chatTyperTimers.getChatTypers();
            List<String> removeThese = new ArrayList<String>(chatTimers.size());

            @SuppressWarnings("unchecked")
            Set<String> playerTimers = chatTimers.keySet();
            for (String player : playerTimers) {
                long playerTime = (Long) chatTimers.get(player);
                if (currentTime - playerTime >= (chatNotifyDuration * 1000)) {
                    // set up a temp place and remove them after the loop
                    removeThese.add(player);
                }// w  w w  .  j ava 2s  .  c  o m
            }
            for (String remove : removeThese) {
                chatTyperTimers.removeChatTyper(remove);
            }
        }
    });
    tm.start();
    return tm;
}

From source file:net.rptools.maptool.client.ui.ChatTypingNotification.java

/**
 * This component is only made visible when there are notifications to be displayed. That means the first couple of
 * IF statements in this method are redundant since paintComponent() will not be called unless the component is
 * visible, and it will only be visible when there are notifications...
 *//*w w  w  . ja va2 s  . c  o m*/
@Override
protected void paintComponent(Graphics g) {
    //      System.out.println("Chat panel is painting itself...");
    if (AppPreferences.getTypingNotificationDuration() == 0) {
        return;
    }
    LinkedMap chatTypers = MapTool.getFrame().getChatNotificationTimers().getChatTypers();
    if (chatTypers == null || chatTypers.isEmpty()) {
        return;
    }
    Boolean showBackground = AppPreferences.getChatNotificationShowBackground();

    Graphics2D statsG = (Graphics2D) g.create();

    Font boldFont = AppStyle.labelFont.deriveFont(Font.BOLD);
    Font font = AppStyle.labelFont;
    FontMetrics valueFM = g.getFontMetrics(font);
    FontMetrics keyFM = g.getFontMetrics(boldFont);

    int PADDING7 = 7;
    int PADDING3 = 3;
    int PADDING2 = 2;

    BufferedImage img = AppStyle.panelTexture;
    int rowHeight = Math.max(valueFM.getHeight(), keyFM.getHeight());

    setBorder(null);
    int width = AppStyle.miniMapBorder.getRightMargin() + AppStyle.miniMapBorder.getLeftMargin();
    int height = getHeight() - PADDING2 + AppStyle.miniMapBorder.getTopMargin()
            + AppStyle.miniMapBorder.getBottomMargin();

    statsG.setFont(font);
    SwingUtil.useAntiAliasing(statsG);
    Rectangle bounds = new Rectangle(AppStyle.miniMapBorder.getLeftMargin(),
            height - getHeight() - AppStyle.miniMapBorder.getTopMargin(), getWidth() - width,
            getHeight() - AppStyle.miniMapBorder.getBottomMargin() - AppStyle.miniMapBorder.getTopMargin()
                    + PADDING2);

    int y = bounds.y + rowHeight;
    rowHeight = Math.max(rowHeight, AppStyle.chatImage.getHeight());

    setSize(getWidth(), ((chatTypers.size() * (PADDING3 + rowHeight)) + AppStyle.miniMapBorder.getTopMargin()
            + AppStyle.miniMapBorder.getBottomMargin()));

    if (showBackground) {
        g.drawImage(img, 0, 0, getWidth(), getHeight() + PADDING7, this);
        AppStyle.miniMapBorder.paintAround(statsG, bounds);
    }
    Rectangle rightRow = new Rectangle(AppStyle.miniMapBorder.getLeftMargin() + PADDING7,
            AppStyle.miniMapBorder.getTopMargin() + PADDING7, AppStyle.chatImage.getWidth(),
            AppStyle.chatImage.getHeight());

    Set<?> keySet = chatTypers.keySet();
    @SuppressWarnings("unchecked")
    Set<String> playerTimers = (Set<String>) keySet;
    for (String playerNamer : playerTimers) {
        if (showBackground) {
            statsG.setColor(new Color(249, 241, 230, 140));
            statsG.fillRect(bounds.x + PADDING3, y - keyFM.getAscent(),
                    (bounds.width - PADDING7 / 2) - PADDING3, rowHeight);
            statsG.setColor(new Color(175, 163, 149));
            statsG.drawRect(bounds.x + PADDING3, y - keyFM.getAscent(),
                    (bounds.width - PADDING7 / 2) - PADDING3, rowHeight);
        }
        g.drawImage(AppStyle.chatImage, bounds.x + 5, y - keyFM.getAscent(), (int) rightRow.getWidth(),
                (int) rightRow.getHeight(), this);

        // Values
        statsG.setColor(MapTool.getFrame().getChatTypingLabelColor());
        statsG.setFont(boldFont);
        statsG.drawString(I18N.getText("msg.commandPanel.liveTyping", playerNamer),
                bounds.x + AppStyle.chatImage.getWidth() + PADDING7 * 2, y + 5);

        y += PADDING2 + rowHeight;
    }
    if (showBackground) {
        AppStyle.shadowBorder.paintWithin(statsG, bounds);
    } else {
        setOpaque(false);
    }
}

From source file:org.lockss.test.FuncCommons.java

public void testLinkedMap() {
    LinkedMap lm = new LinkedMap();
    lm.put("foo", "1");
    lm.put("bar", null);
    assertIsomorphic(ListUtil.list("foo", "bar").iterator(), lm.keySet().iterator());
    assertIsomorphic(ListUtil.list("1", null).iterator(), lm.values().iterator());
}