Marked the row with avereage values with bold font

This commit is contained in:
nifi 2010-10-14 06:45:45 +00:00
parent a5fe4ae1c3
commit c522b9333c

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: NodeInfoPanel.java,v 1.10 2010/10/14 06:31:38 nifi Exp $ * $Id: NodeInfoPanel.java,v 1.11 2010/10/14 06:45:45 nifi Exp $
* *
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* *
@ -34,14 +34,15 @@
* *
* Authors : Joakim Eriksson, Niclas Finne * Authors : Joakim Eriksson, Niclas Finne
* Created : 6 sep 2010 * Created : 6 sep 2010
* Updated : $Date: 2010/10/14 06:31:38 $ * Updated : $Date: 2010/10/14 06:45:45 $
* $Revision: 1.10 $ * $Revision: 1.11 $
*/ */
package se.sics.contiki.collect.gui; package se.sics.contiki.collect.gui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Font;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -198,6 +199,7 @@ public class NodeInfoPanel extends JPanel implements Visualizer, Configurable {
nodeModel = new NodeModel(columns); nodeModel = new NodeModel(columns);
table = new JTable(nodeModel) { table = new JTable(nodeModel) {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Font fontForAverage;
protected JTableHeader createDefaultTableHeader() { protected JTableHeader createDefaultTableHeader() {
return new JTableHeader(columnModel) { return new JTableHeader(columnModel) {
@ -210,6 +212,20 @@ public class NodeInfoPanel extends JPanel implements Visualizer, Configurable {
} }
}; };
} }
public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
int row = convertRowIndexToModel(rowIndex);
if (row == nodeModel.getRowCount() - 1) {
if (fontForAverage == null) {
fontForAverage = c.getFont().deriveFont(Font.BOLD);
}
// Last line is average
c.setFont(fontForAverage);
}
return c;
}
}; };
// Do not sort column when clicking between the columns (resizing) // Do not sort column when clicking between the columns (resizing)
@ -487,7 +503,7 @@ public class NodeInfoPanel extends JPanel implements Visualizer, Configurable {
public static abstract class TableData extends AbstractAction { public static abstract class TableData extends AbstractAction {
private static final long serialVersionUID = -3045755073722516926L; private static final long serialVersionUID = -3045755073722516926L;
private final static Node AVERAGE_NODE = new Node("Average"); private final static Node AVERAGE_NODE = new Node("Avg");
public final String name; public final String name;
public final Class<?> dataClass; public final Class<?> dataClass;