package hirondelle.stocks.table;
import javax.swing.table.*;
import hirondelle.stocks.quotes.Stock;
import hirondelle.stocks.util.Util;
final class RenderStockName extends DefaultTableCellRenderer {
@Override public void setValue(Object aValue) {
Object result = aValue;
if ((aValue != null) && (aValue instanceof Stock)) {
Stock stock = (Stock) aValue;
result = stock.getName();
setTooltip(stock);
}
super.setValue(result);
}
private void setTooltip(Stock aStock) {
StringBuilder tooltip = new StringBuilder("Yahoo Ticker: ");
tooltip.append(aStock.getTicker());
String suffix = aStock.getExchange().getTickerSuffix();
if (Util.textHasContent(suffix)) {
tooltip.append(".");
tooltip.append(suffix);
}
setToolTipText(tooltip.toString());
}
}