From c522b9333c6f5af8d61e7e904cda0fd63c4c35fd Mon Sep 17 00:00:00 2001 From: nifi Date: Thu, 14 Oct 2010 06:45:45 +0000 Subject: [PATCH] Marked the row with avereage values with bold font --- .../contiki/collect/gui/NodeInfoPanel.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/examples/sky-shell/src/se/sics/contiki/collect/gui/NodeInfoPanel.java b/examples/sky-shell/src/se/sics/contiki/collect/gui/NodeInfoPanel.java index b8dde7c14..03e466d21 100644 --- a/examples/sky-shell/src/se/sics/contiki/collect/gui/NodeInfoPanel.java +++ b/examples/sky-shell/src/se/sics/contiki/collect/gui/NodeInfoPanel.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * 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 * Created : 6 sep 2010 - * Updated : $Date: 2010/10/14 06:31:38 $ - * $Revision: 1.10 $ + * Updated : $Date: 2010/10/14 06:45:45 $ + * $Revision: 1.11 $ */ package se.sics.contiki.collect.gui; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Cursor; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -198,6 +199,7 @@ public class NodeInfoPanel extends JPanel implements Visualizer, Configurable { nodeModel = new NodeModel(columns); table = new JTable(nodeModel) { private static final long serialVersionUID = 1L; + private Font fontForAverage; protected JTableHeader createDefaultTableHeader() { 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) @@ -487,7 +503,7 @@ public class NodeInfoPanel extends JPanel implements Visualizer, Configurable { public static abstract class TableData extends AbstractAction { 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 Class dataClass;