| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| InviterNameRenderer |
|
| 1.75;1.75 |
| 1 | /****************************************************************************** | |
| 2 | * InviterListPopupMenu.java - The context menu on the inviter table | |
| 3 | * $Id$ | |
| 4 | * | |
| 5 | * BuckoFIBS - Backgammon by BuckoSoft | |
| 6 | * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp. | |
| 7 | * | |
| 8 | * $Log$ | |
| 9 | * Revision 1.2 2010/03/03 12:19:49 inim | |
| 10 | * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010. | |
| 11 | * | |
| 12 | * Revision 1.1 2010/02/04 05:57:53 inim | |
| 13 | * Mavenized project folder layout | |
| 14 | * | |
| 15 | * Revision 1.3 2009/02/14 15:46:36 dick | |
| 16 | * BuckoFIBS is released under the GNU license. | |
| 17 | * | |
| 18 | * Revision 1.2 2009/02/02 08:39:48 dick | |
| 19 | * Don't display the name in the default bold. | |
| 20 | * | |
| 21 | * Revision 1.1 2009/02/01 09:01:49 dick | |
| 22 | * PlayerNameRenderer becomes InviterNameRenderer in this package. | |
| 23 | * | |
| 24 | * Revision 1.1 2009/01/28 19:39:15 dick | |
| 25 | * package com.buckosoft.fibs.gui.inviterList becomes com.buckosoft.fibs.BuckoFIBS.gui.inviterList. | |
| 26 | * | |
| 27 | * Revision 1.1 2009/01/27 19:16:53 dick | |
| 28 | * playerName gets a custom renderer so we can display warnings. | |
| 29 | */ | |
| 30 | ||
| 31 | /* | |
| 32 | * This program is free software: you can redistribute it and/or modify | |
| 33 | * it under the terms of the GNU General Public License as published by | |
| 34 | * the Free Software Foundation, either version 3 of the License, or | |
| 35 | * (at your option) any later version. | |
| 36 | * | |
| 37 | * This program is distributed in the hope that it will be useful, | |
| 38 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 39 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 40 | * GNU General Public License for more details. | |
| 41 | * | |
| 42 | * You should have received a copy of the GNU General Public License | |
| 43 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 44 | * | |
| 45 | * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>. | |
| 46 | * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp. | |
| 47 | * | |
| 48 | */ | |
| 49 | package com.buckosoft.fibs.BuckoFIBS.gui.inviterList; | |
| 50 | ||
| 51 | import java.awt.Color; | |
| 52 | import java.awt.Component; | |
| 53 | import java.awt.Dimension; | |
| 54 | import java.awt.Font; | |
| 55 | import java.awt.GridBagConstraints; | |
| 56 | import java.awt.GridBagLayout; | |
| 57 | import java.awt.Insets; | |
| 58 | ||
| 59 | import javax.swing.ImageIcon; | |
| 60 | import javax.swing.JLabel; | |
| 61 | import javax.swing.JPanel; | |
| 62 | import javax.swing.JTable; | |
| 63 | import javax.swing.table.TableCellRenderer; | |
| 64 | ||
| 65 | import com.buckosoft.fibs.domain.Player; | |
| 66 | ||
| 67 | /** Draw the player name and any icons in the inviter table | |
| 68 | * @author Dick Balaska | |
| 69 | * @since 2009/01/27 | |
| 70 | * @version $Revision$ <br> $Date$ | |
| 71 | * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/com/buckosoft/fibs/BuckoFIBS/gui/inviterList/InviterNameRenderer.java">cvs InviterNameRenderer.java</a> | |
| 72 | */ | |
| 73 | public class InviterNameRenderer extends JPanel implements TableCellRenderer { | |
| 74 | private static final long serialVersionUID = 1L; | |
| 75 | private Color selectedBackgroundColor; | |
| 76 | 0 | private JLabel jLabel = null; |
| 77 | 0 | private JLabel jLabelIcon = null; |
| 78 | 0 | private ImageIcon warningIcon = new ImageIcon(getClass().getResource("/g/caution.png")); |
| 79 | ||
| 80 | /** | |
| 81 | * This method initializes | |
| 82 | * | |
| 83 | */ | |
| 84 | public InviterNameRenderer() { | |
| 85 | 0 | super(); |
| 86 | 0 | initialize(); |
| 87 | 0 | } |
| 88 | ||
| 89 | /** | |
| 90 | * This method initializes this | |
| 91 | * | |
| 92 | */ | |
| 93 | private void initialize() { | |
| 94 | 0 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
| 95 | 0 | gridBagConstraints1.insets = new Insets(0, 0, 0, 0); |
| 96 | 0 | gridBagConstraints1.gridx = 1; |
| 97 | 0 | gridBagConstraints1.gridy = 0; |
| 98 | 0 | gridBagConstraints1.anchor = GridBagConstraints.EAST; |
| 99 | 0 | gridBagConstraints1.weightx = 0.2; |
| 100 | 0 | gridBagConstraints1.gridheight = 1; |
| 101 | 0 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
| 102 | 0 | gridBagConstraints.insets = new Insets(0, 0, 0, 0); |
| 103 | 0 | gridBagConstraints.gridx = 0; |
| 104 | 0 | gridBagConstraints.gridy = 0; |
| 105 | 0 | gridBagConstraints.anchor = GridBagConstraints.WEST; |
| 106 | 0 | gridBagConstraints.gridheight = 1; |
| 107 | 0 | jLabelIcon = new JLabel(); |
| 108 | 0 | jLabel = new JLabel(); |
| 109 | 0 | jLabel.setFont(new Font("Dialog", Font.PLAIN, 12)); |
| 110 | 0 | jLabel.setText("JLabel"); |
| 111 | 0 | this.setLayout(new GridBagLayout()); |
| 112 | 0 | this.setSize(new Dimension(79, 22)); |
| 113 | 0 | this.add(jLabel, gridBagConstraints); |
| 114 | 0 | this.add(jLabelIcon, gridBagConstraints1); |
| 115 | 0 | } |
| 116 | ||
| 117 | public void setSelectedBackground(Color color) { | |
| 118 | 0 | selectedBackgroundColor = color; |
| 119 | 0 | } |
| 120 | ||
| 121 | /* (non-Javadoc) | |
| 122 | * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) | |
| 123 | */ | |
| 124 | @Override | |
| 125 | public Component getTableCellRendererComponent(JTable table, Object value, | |
| 126 | boolean isSelected, boolean hasFocus, int row, int column) { | |
| 127 | 0 | Player p = (Player)value; |
| 128 | 0 | this.setOpaque(true); |
| 129 | 0 | this.jLabel.setOpaque(true); |
| 130 | 0 | if (isSelected) { |
| 131 | 0 | this.setBackground(selectedBackgroundColor); |
| 132 | 0 | this.jLabel.setBackground(selectedBackgroundColor); |
| 133 | } else { | |
| 134 | 0 | this.setBackground(Color.white); |
| 135 | 0 | this.jLabel.setBackground(Color.white); |
| 136 | } | |
| 137 | 0 | this.jLabel.setText(p.getName()); |
| 138 | 0 | this.jLabel.setOpaque(true); |
| 139 | 0 | if (p.getBfStatus() != null && p.getBfStatus().length() > 0) { |
| 140 | 0 | this.jLabelIcon.setIcon(warningIcon); |
| 141 | 0 | this.setToolTipText(p.getBfStatus()); |
| 142 | } else { | |
| 143 | 0 | this.jLabelIcon.setIcon(null); |
| 144 | 0 | this.setToolTipText(null); |
| 145 | ||
| 146 | } | |
| 147 | 0 | return this; |
| 148 | } | |
| 149 | ||
| 150 | } // @jve:decl-index=0:visual-constraint="10,10" |