public ChainsawStatusBar()

in src/main/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java [53:194]


    public ChainsawStatusBar(LogUI logUI) {
        setLayout(new GridBagLayout());
        this.logUI = logUI;
        nf.setMaximumFractionDigits(0);
        nf.setMinimumFractionDigits(0);
        nf.setGroupingUsed(false);

        JPanel statusMsgPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 2));

        statusMsgPanel.add(statusMsg);
        statusMsgPanel.setBorder(statusBarComponentBorder);

        pausedLabel.setBorder(statusBarComponentBorder);
        pausedLabel.setMinimumSize(
            new Dimension(pausedIcon.getIconWidth(), pausedIcon.getIconHeight()));

        pausedLabel.setToolTipText(
            "Shows whether the current Log panel is paused or not");

        receivedEventLabel.setBorder(statusBarComponentBorder);
        receivedEventLabel.setToolTipText(
            "Indicates whether Chainsaw is receiving events, and how fast it is processing them");
        receivedEventLabel.setMinimumSize(
            new Dimension(
                receivedEventLabel.getFontMetrics(receivedEventLabel.getFont())
                    .stringWidth("99999999999.9/s") + 5,
                (int) receivedEventLabel.getPreferredSize().getHeight()));

        eventCountLabel.setBorder(statusBarComponentBorder);
        eventCountLabel.setToolTipText("<# viewable events>:<# total events>");
        eventCountLabel.setMinimumSize(
            new Dimension(
                eventCountLabel.getFontMetrics(eventCountLabel.getFont())
                    .stringWidth("Filtered/Total: 999999999999:999999999999") + 5,
                (int) eventCountLabel.getPreferredSize().getHeight()));

        searchMatchLabel.setBorder(statusBarComponentBorder);
        searchMatchLabel.setToolTipText("<# viewable events>:<# total events>");
        searchMatchLabel.setMinimumSize(
            new Dimension(
                searchMatchLabel.getFontMetrics(eventCountLabel.getFont()).stringWidth("Find matches: 999999999999") + 5,
                (int) searchMatchLabel.getPreferredSize().getHeight()));

        receivedConnectionlabel.setBorder(statusBarComponentBorder);
        receivedConnectionlabel.setToolTipText(
            "Indicates whether Chainsaw has received a remote connection");
        receivedConnectionlabel.setMinimumSize(
            new Dimension(
                netConnectIcon.getIconWidth() + 4,
                (int) receivedConnectionlabel.getPreferredSize().getHeight()));

        lineSelectionLabel.setBorder(statusBarComponentBorder);
        lineSelectionLabel.setMinimumSize(
            new Dimension(
                lineSelectionLabel.getFontMetrics(lineSelectionLabel.getFont())
                    .stringWidth("999999999"),
                (int) lineSelectionLabel.getPreferredSize().getHeight()));
        lineSelectionLabel.setToolTipText(
            "The current line # selected");

        JComponent[] toFix =
            new JComponent[]{
                searchMatchLabel, eventCountLabel,
                receivedConnectionlabel, lineSelectionLabel, receivedEventLabel,
                pausedLabel
            };

        for (JComponent aToFix : toFix) {
            aToFix.setPreferredSize(aToFix.getMinimumSize());
            aToFix.setMaximumSize(aToFix.getMinimumSize());
        }

        statusMsg.setMinimumSize(pausedLabel.getPreferredSize());
        statusMsg.setToolTipText("Shows messages from Chainsaw");

        GridBagConstraints c = new GridBagConstraints();
        c.insets = new Insets(2, 2, 2, 2);
        c.weightx = 1.0;
        c.weighty = 1.0;
        c.ipadx = 2;
        c.ipady = 2;
        c.gridx = 0;
        c.gridy = 0;
        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.WEST;

        add(statusMsgPanel, c);

        c.weightx = 0.0;
        c.weighty = 0.0;
        c.gridx = 1;
        add(receivedConnectionlabel, c);

        c.weightx = 0.0;
        c.weighty = 0.0;
        c.gridx = 2;
        add(lineSelectionLabel, c);

        c.weightx = 0.0;
        c.weighty = 0.0;
        c.gridx = 3;
        add(searchMatchLabel, c);

        c.weightx = 0.0;
        c.weighty = 0.0;
        c.gridx = 4;
        add(eventCountLabel, c);

        c.weightx = 0.0;
        c.weighty = 0.0;
        c.gridx = 5;
        add(receivedEventLabel, c);

        c.weightx = 0.0;
        c.weighty = 0.0;
        c.gridx = 6;

        add(pausedLabel, c);

        connectionThread =
            new Thread(
                () -> {
                    while (true) {
                        try {
                            Thread.sleep(DELAY_PERIOD);
                        } catch (InterruptedException e) {
                        }

                        Icon icon = null;

                        if (
                            (System.currentTimeMillis() - lastReceivedConnection) < DELAY_PERIOD) {
                            icon = netConnectIcon;
                        }

                        final Icon theIcon = icon;
                        SwingUtilities.invokeLater(
                            () -> receivedConnectionlabel.setIcon(theIcon));
                    }
                });
        connectionThread.start();
    }