You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@logging.apache.org by sd...@apache.org on 2010/04/18 08:57:10 UTC

svn commit: r935308 - /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java

Author: sdeboy
Date: Sun Apr 18 06:57:10 2010
New Revision: 935308

URL: http://svn.apache.org/viewvc?rev=935308&view=rev
Log:
Multi-line table rendering improvements
 - removing use of FONT textattribute since it appears to cause a significant number of rows to be truncated.  Replaced with use of family and size (size * 1.5) instead, resulting in more rows being fully displayed (with additional space at the bottom of the row on occasion).  

This isn't working 'perfectly' (rows are too tall still in some cases, too short in others)...suggestions to improve rendering appreciated

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java?rev=935308&r1=935307&r2=935308&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java Sun Apr 18 06:57:10 2010
@@ -180,7 +180,11 @@ public class TableColorizingRenderer ext
             int width = tableColumn.getWidth();
             int tableRowHeight = table.getRowHeight(row);
             Map paramMap = new HashMap();
-            paramMap.put(TextAttribute.FONT, msgRenderer.getFont());
+            //using font here causes text to be truncated (height is too small)..using family & a larger size (to ensure all text is displayed) instead
+            paramMap.put(TextAttribute.FAMILY, labelRenderer.getFont().getFamily());
+            //set size to size + 1.5 (will make sure long entries aren't truncated)
+            paramMap.put(TextAttribute.SIZE, new Float(labelRenderer.getFont().getSize() + 1.5));
+
             int preferredHeight = calculateHeight(table.getGraphics(), string, width, paramMap);
             if(preferredHeight != tableRowHeight) {
                 table.setRowHeight(row, preferredHeight);
@@ -370,8 +374,7 @@ public class TableColorizingRenderer ext
      TextLayout layout;
      while (lineMeasurer.getPosition() < paragraph.getEndIndex()) {
        layout = lineMeasurer.nextLayout(width);
-         //add 1 pixel padding per row
-         float layoutHeight = layout.getAscent() + layout.getDescent() + layout.getLeading() + 1;
+         float layoutHeight = layout.getAscent() + layout.getDescent() + layout.getLeading();
          height += layoutHeight;
      }
      //pad total by 4 or default row height