⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsconfrostertree.java

📁 一款即时通讯软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

        /** Returns nick's presence show */
        public String getShow() {
            return (pi != null)? pi.getShow() : null;
        }

        /** Returns nick's presence show */
        public String getFriendlyShow() {
            return (pi != null)? pi.getFriendlyShow() : null;
        }

        /** Returns nick's presence status */
        public String getStatus() {
            return (pi != null)? pi.getStatus() : null;
        }
    } // BSResourceItem

    /**
     * <code>BSConfRosterRenderer</code> provides conference room roster
     * specific rendering.
     */
    /*public class BSConfRosterRenderer extends DefaultTreeCellRenderer {
        protected ImageIcon onlineIcon = null;
        protected ImageIcon okOnlineIcon = null;
        protected ImageIcon koOnlineIcon = null;
        protected ImageIcon busyIcon = null;
        protected ImageIcon okBusyIcon = null;
        protected ImageIcon koBusyIcon = null;
        protected ImageIcon elsewhereIcon = null;
        protected ImageIcon okElseIcon = null;
        protected ImageIcon koElseIcon = null;
        protected ImageIcon offlineIcon = null;
        protected ImageIcon awayIcon = null;
        protected ImageIcon okAwayIcon = null;
        protected ImageIcon koAwayIcon = null;
        protected ImageIcon xaIcon = null;
        protected ImageIcon okXaIcon = null;
        protected ImageIcon koXaIcon = null;
        protected ImageIcon dndIcon = null;
        protected ImageIcon okDndIcon = null;
        protected ImageIcon koDndIcon = null;
        protected ImageIcon chatIcon = null;
        protected ImageIcon okChatIcon = null;
        protected ImageIcon koChatIcon = null;
        protected ImageIcon handIcon = null;
        protected ImageIcon okHandIcon = null;
        protected ImageIcon koHandIcon = null;
        protected ImageIcon lurkerIcon = null;
        protected ImageIcon onlineMsgIcon = null;
        protected ImageIcon offlineMsgIcon = null;
        protected ImageIcon awayMsgIcon = null;
        protected ImageIcon lurkerMsgIcon = null;
        //protected ImageIcon myselfIcon = null;
        //protected ImageIcon messageIcon = null;

        /** Constructor */
        /*public BSConfRosterRenderer() {
            onlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/confOnline.gif"));
            okOnlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/okOnline.gif"));
            koOnlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/koOnline.gif"));
            busyIcon = new ImageIcon(ClassLoader.getSystemResource("images/confBusy.gif"));
            okBusyIcon = new ImageIcon(ClassLoader.getSystemResource("images/okBusy.gif"));
            koBusyIcon = new ImageIcon(ClassLoader.getSystemResource("images/koBusy.gif"));
            elsewhereIcon = new ImageIcon(ClassLoader.getSystemResource("images/confSwoosh.gif"));
            okElseIcon = new ImageIcon(ClassLoader.getSystemResource("images/okSwoosh.gif"));
            koElseIcon = new ImageIcon(ClassLoader.getSystemResource("images/koSwoosh.gif"));
            offlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/red_light.gif"));
            awayIcon = new ImageIcon(ClassLoader.getSystemResource("images/confAway.gif"));
            okAwayIcon = new ImageIcon(ClassLoader.getSystemResource("images/okAway.gif"));
            koAwayIcon = new ImageIcon(ClassLoader.getSystemResource("images/koAway.gif"));
            lurkerIcon = new ImageIcon(ClassLoader.getSystemResource("images/question.gif"));
            xaIcon = new ImageIcon(ClassLoader.getSystemResource("images/confXa.gif"));
            okXaIcon = new ImageIcon(ClassLoader.getSystemResource("images/okXa.gif"));
            koXaIcon = new ImageIcon(ClassLoader.getSystemResource("images/koXa.gif"));
            dndIcon = new ImageIcon(ClassLoader.getSystemResource("images/confDnd.gif"));
            okDndIcon = new ImageIcon(ClassLoader.getSystemResource("images/okDnd.gif"));
            koDndIcon = new ImageIcon(ClassLoader.getSystemResource("images/koDnd.gif"));
            chatIcon = new ImageIcon(ClassLoader.getSystemResource("images/confChat.gif"));
            okChatIcon = new ImageIcon(ClassLoader.getSystemResource("images/okChat.gif"));
            koChatIcon = new ImageIcon(ClassLoader.getSystemResource("images/koChat.gif"));
            handIcon = new ImageIcon(ClassLoader.getSystemResource("images/confHand.gif"));
            okHandIcon = new ImageIcon(ClassLoader.getSystemResource("images/okHand.gif"));
            koHandIcon = new ImageIcon(ClassLoader.getSystemResource("images/koHand.gif"));
            //myselfIcon = new ImageIcon(ClassLoader.getSystemResource("images/myself.gif"));

            //onlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/online.gif"));
            //offlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/offline.gif"));
            //awayIcon = new ImageIcon(ClassLoader.getSystemResource("images/away.gif"));
            //lurkerIcon = new ImageIcon(ClassLoader.getSystemResource("images/lurker.gif"));
            onlineMsgIcon = new ImageIcon(ClassLoader.getSystemResource("images/online_msg.gif"));
            offlineMsgIcon = new ImageIcon(ClassLoader.getSystemResource("images/offline_msg.gif"));
            awayMsgIcon = new ImageIcon(ClassLoader.getSystemResource("images/away_msg.gif"));
            lurkerMsgIcon = new ImageIcon(ClassLoader.getSystemResource("images/lurker_msg.gif"));
            //messageIcon = new ImageIcon(ClassLoader.getSystemResource("images/message.gif"));
        }

        /** Renders */
        /*public Component getTreeCellRendererComponent(JTree tree, Object value,
                                                      boolean sel, boolean expanded,
                                                      boolean leaf, int row,
                                                      boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, sel, expanded,
                                               leaf, row, hasFocus);
            //if (leaf) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
                if (node instanceof BSNickNode) {

                    BSNickNode nickNode = (BSNickNode) node;
                    String show = nickNode.getShow();
                    String status = nickNode.getStatus();

                    boolean votingYes = false;
                    boolean votingNo = false;
                    if (status != null) {
                        votingNo = (-1 != status.indexOf(BSConfWindow.VOTE_NO_STR));
                        votingYes = (-1 != status.indexOf(BSConfWindow.VOTE_YES_STR));
                    }

                    if (show == null || BSPresenceInfo.SHOW_ONLINE.equals(show)) {
                        if (-1 != status.indexOf(BSConfWindow.presenceStrs[3]))
                            setIcon(votingYes? okBusyIcon :
                                    votingNo? koBusyIcon : busyIcon);
                        else if (-1 != status.indexOf(BSConfWindow.presenceStrs[4]))
                            setIcon(votingYes? okElseIcon :
                                    votingNo? koElseIcon : elsewhereIcon);
                        else
                            setIcon(votingYes? okOnlineIcon :
                                    votingNo? koOnlineIcon : onlineIcon);
                    }
                    else if (BSPresenceInfo.SHOW_CHAT.equals(show)) {
                        if (-1 != status.indexOf(BSConfWindow.presenceStrs[0]))
                            setIcon(votingYes? okHandIcon :
                                    votingNo? koHandIcon : handIcon);
                        else
                            setIcon(votingYes? okChatIcon :
                                    votingNo? koChatIcon : chatIcon);
                    }
                    else if (BSPresenceInfo.SHOW_AWAY.equals(show))
                        setIcon(votingYes? okAwayIcon :
                                votingNo? koAwayIcon : awayIcon);
                    else if (BSPresenceInfo.SHOW_XA.equals(show))
                        setIcon(votingYes? okXaIcon :
                                votingNo? koXaIcon : xaIcon);
                    else if (BSPresenceInfo.SHOW_DND.equals(show))
                        setIcon(votingYes? okDndIcon :
                                votingNo? koDndIcon : dndIcon);
                    else
                        setIcon(votingYes? okXaIcon :
                                votingNo? koXaIcon : lurkerIcon);

                    //setToolTipText(status);
                    String friendlyShow = nickNode.getFriendlyShow();
                    if (friendlyShow == null) friendlyShow = "";
                    if (status == null) status = "";
                    setToolTipText(nickNode.toString()
                                    + " (" + friendlyShow + "-" + status + ")");
                }

                // empty group
                else
                    setToolTipText(null); //no tool tip

            return this;
        }
    } //BSRosterRenderer*/


    public class BSMultiImgTreeRenderer extends JPanel
                                        implements TreeCellRenderer {

        protected Color textSelectionColor;
        protected Color textNonSelectionColor;
        protected Color backgroundSelectionColor;
        protected Color backgroundNonSelectionColor;
        protected Color borderSelectionColor;

        protected ImageIcon onlineIcon = null;
        protected ImageIcon busyIcon = null;
        protected ImageIcon elsewhereIcon = null;
        protected ImageIcon offlineIcon = null;
        protected ImageIcon awayIcon = null;
        protected ImageIcon xaIcon = null;
        protected ImageIcon dndIcon = null;
        protected ImageIcon chatIcon = null;
        protected ImageIcon handIcon = null;
        protected ImageIcon lurkerIcon = null;
        protected ImageIcon okIcon = null;
        protected ImageIcon koIcon = null;
        protected ImageIcon emptyIcon = null;

        protected JLabel mainLabel;
        protected JLabel voteLabel;

        public BSMultiImgTreeRenderer() {
            onlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/green_light.gif"));
            busyIcon = new ImageIcon(ClassLoader.getSystemResource("images/busy.gif"));
            elsewhereIcon = new ImageIcon(ClassLoader.getSystemResource("images/swoosh.gif"));
            offlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/red_light.gif"));
            awayIcon = new ImageIcon(ClassLoader.getSystemResource("images/yellow_light.gif"));
            lurkerIcon = new ImageIcon(ClassLoader.getSystemResource("images/question.gif"));
            xaIcon = new ImageIcon(ClassLoader.getSystemResource("images/xa_light.gif"));
            dndIcon = new ImageIcon(ClassLoader.getSystemResource("images/dnd_light.gif"));
            chatIcon = new ImageIcon(ClassLoader.getSystemResource("images/chat_light.gif"));
            handIcon = new ImageIcon(ClassLoader.getSystemResource("images/hand.gif"));
            okIcon = new ImageIcon(ClassLoader.getSystemResource("images/thumbs_up.gif"));
            koIcon = new ImageIcon(ClassLoader.getSystemResource("images/thumbs_down.gif"));
            emptyIcon = new ImageIcon(ClassLoader.getSystemResource("images/no_vote.gif"));

            textSelectionColor = UIManager.getColor("Tree.selectionForeground");
            textNonSelectionColor = UIManager.getColor("Tree.textForeground");
            backgroundSelectionColor = UIManager.getColor("Tree.selectionBackground");
            backgroundNonSelectionColor = UIManager.getColor("Tree.textBackground");
            borderSelectionColor = UIManager.getColor("Tree.selectionBorderColor");

            mainLabel = new JLabel("lurker", lurkerIcon, JLabel.LEFT);
            voteLabel = new JLabel(emptyIcon);
            //voteLabel.getInsets(new Insets(10,10,10,10));

            FlowLayout fl = new FlowLayout();
            fl.setVgap(0);
            setLayout(fl);
            //setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
        }


        public Component getTreeCellRendererComponent(JTree jTree, Object value,
                                        boolean selected, boolean expanded,
                                        boolean leaf, int row, boolean hasFocus) {

            removeAll();

            String stringValue = tree.convertValueToText(value, selected,
                                                expanded, leaf, row, hasFocus);

            //DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            if (value /*node*/ instanceof BSNickNode) {

                BSNickNode nickNode = (BSNickNode) value /*node*/;
                String show = nickNode.getShow();
                String status = nickNode.getStatus();

                boolean votingYes = false;
                boolean votingNo = false;
                if (status != null) {
                    votingNo = (-1 != status.indexOf(BSConfWindow.VOTE_NO_STR));
                    votingYes = (-1 != status.indexOf(BSConfWindow.VOTE_YES_STR));
                }

                if (show == null || BSPresenceInfo.SHOW_ONLINE.equals(show)) {
                    if (status == null)
                        mainLabel.setIcon(onlineIcon);
                    else if (-1 != status.indexOf(BSConfWindow.presenceStrs[3]))
                        mainLabel.setIcon(busyIcon);
                    else if (-1 != status.indexOf(BSConfWindow.presenceStrs[4]))
                        mainLabel.setIcon(elsewhereIcon);
                    else
                        mainLabel.setIcon(onlineIcon);
                }
                else if (BSPresenceInfo.SHOW_CHAT.equals(show)) {
                    if (status == null)
                        mainLabel.setIcon(chatIcon);
                    else if (-1 != status.indexOf(BSConfWindow.presenceStrs[0]))
                        mainLabel.setIcon(handIcon);
                    else
                        mainLabel.setIcon(chatIcon);
                }
                else if (BSPresenceInfo.SHOW_AWAY.equals(show))
                    mainLabel.setIcon(awayIcon);
                else if (BSPresenceInfo.SHOW_XA.equals(show))
                    mainLabel.setIcon(xaIcon);
                else if (BSPresenceInfo.SHOW_DND.equals(show))
                    mainLabel.setIcon(dndIcon);
                else
                    mainLabel.setIcon(lurkerIcon);

                //setToolTipText(status);
                String friendlyShow = nickNode.getFriendlyShow();
                if (friendlyShow == null) friendlyShow = "";
                if (status == null) status = "";
                /*mainLabel.*/setToolTipText(nickNode.toString()
                                + " (" + friendlyShow + "-" + status + ")");

                mainLabel.setText(stringValue);

                voteLabel.setIcon(votingNo? koIcon : votingYes? okIcon : emptyIcon);
                voteLabel.setForeground(selected? textSelectionColor : textNonSelectionColor);
                voteLabel.setBackground(selected? backgroundSelectionColor : backgroundNonSelectionColor);
                voteLabel.setToolTipText(votingNo? "Voting NO" : votingYes? "Voting YES" : "Not voting");
            }

            // empty group
            else {
                mainLabel.setToolTipText(null); //no tool tip
                mainLabel.setText(stringValue);
                mainLabel.setIcon(lurkerIcon);
            }

            add(voteLabel);
            add(mainLabel);

            mainLabel.setForeground(selected? textSelectionColor : textNonSelectionColor);
            mainLabel.setBackground(selected? backgroundSelectionColor : backgroundNonSelectionColor);
            mainLabel.setFont(jTree.getFont());

            setForeground(selected? textSelectionColor : textNonSelectionColor);
            setBackground(selected? backgroundSelectionColor : backgroundNonSelectionColor);

            //doLayout();

            return this;
        }
    } //BSMultiImgTreeRenderer

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -