/*
* TotalTableCellRendererDecorator.java
*
* Created on 18 May 2006, 16:57
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ffg.gui.table.renderer;
import static javax.swing.SwingConstants.TRAILING;
import ffg.game.vs.VSGameManager;
import ffg.game.vs.VSGameStats;
import ffg.gui.table.AbstractFFGTable;
/**
* Displays the total scores
* @author eugene
*/
public class TotalTableCellRendererDecorator implements VSTableCellRendererDecorator {
/**
* The singleton instance.
*/
public static final TotalTableCellRendererDecorator INSTANCE = new TotalTableCellRendererDecorator();
private static final String DOUBLE_FORMAT = "%.2f";
/**
* Creates a new instance of TotalTableCellRendererDecorator
*/
private TotalTableCellRendererDecorator() {}
public void decorateLabel(FFGTableCellRenderer renderer, AbstractFFGTable<VSGameStats, VSGameManager<VSGameStats>> table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
renderer.setFont(renderer.getBoldFont());
renderer.setHorizontalAlignment(TRAILING);
if (value instanceof Double) {
Double doubleValue = (Double) value;
renderer.setText(String.format(DOUBLE_FORMAT, doubleValue));
} else {
renderer.setText(value == null ? "" : value.toString());
}
}
}
|