| 1 |
package org.astrogrid.samp.gui; |
| 2 |
|
| 3 |
import java.awt.Component; |
| 4 |
import java.awt.Graphics; |
| 5 |
import javax.swing.Icon; |
| 6 |
|
| 7 |
/** |
| 8 |
* CellRenderer for transmission objects. |
| 9 |
* |
| 10 |
* @author Mark Taylor |
| 11 |
* @since 27 Nov 2008 |
| 12 |
*/ |
| 13 |
class TransmissionCellRenderer implements IconBox.CellRenderer { |
| 14 |
|
| 15 |
public Icon getIcon( IconBox iconBox, Object value, int index ) { |
| 16 |
final int size = iconBox.getTransverseSize(); |
| 17 |
if ( value instanceof Transmission ) { |
| 18 |
return ((Transmission) value).getStatus().getIcon( size ); |
| 19 |
} |
| 20 |
else { |
| 21 |
return new Icon() { |
| 22 |
public void paintIcon( Component c, Graphics g, int x, int y ) { |
| 23 |
int s = size - 3 + ( size % 2 ); |
| 24 |
g.drawOval( x + 1, y + 1, s, s ); |
| 25 |
} |
| 26 |
public int getIconWidth() { |
| 27 |
return size; |
| 28 |
} |
| 29 |
public int getIconHeight() { |
| 30 |
return size; |
| 31 |
} |
| 32 |
}; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
public String getToolTipText( IconBox iconBox, Object value, int index ) { |
| 37 |
if ( value instanceof Transmission ) { |
| 38 |
return ((Transmission) value).getMessage().getMType(); |
| 39 |
} |
| 40 |
else { |
| 41 |
return null; |
| 42 |
} |
| 43 |
} |
| 44 |
} |