You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2010/03/25 20:56:42 UTC

svn commit: r927571 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java

Author: tvolkert
Date: Thu Mar 25 19:56:42 2010
New Revision: 927571

URL: http://svn.apache.org/viewvc?rev=927571&view=rev
Log:
PIVOT-438 :: Account for invisible rows and columns in TablePaneSkin.paint() [grid lines]

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java?rev=927571&r1=927570&r2=927571&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java Thu Mar 25 19:56:42 2010
@@ -690,19 +690,35 @@ public class TablePaneSkin extends Conta
                 gridGraphics.clip(gridClip);
             }
 
+            boolean[][] occupiedCells = getOccupiedCells();
+
             if (showHorizontalGridLines
                 && verticalSpacing > 0
                 && rowCount > 1) {
                 gridGraphics.setPaint(horizontalGridColor);
 
-                int rowY = padding.top + (rowHeights[0] + verticalSpacing);
+                int rowY = padding.top;
+                int visibleRowCount = 0;
+
+                for (int i = 0; i < rowCount; i++) {
+                    boolean rowVisible = false;
+
+                    for (int j = 0; j < columnCount; j++) {
+                        if (occupiedCells[i][j]) {
+                            rowVisible = true;
+                            break;
+                        }
+                    }
 
-                for (int i = 1; i < rowCount; i++) {
-                    int gridY = Math.max(rowY - (int)Math.ceil(verticalSpacing * 0.5f), 0);
-                    GraphicsUtilities.drawLine(gridGraphics, 0, gridY,
-                        width, Orientation.HORIZONTAL);
+                    if (rowVisible) {
+                       if (visibleRowCount++ > 0) {
+                           int gridY = Math.max(rowY - (int)Math.ceil(verticalSpacing * 0.5f), 0);
+                           GraphicsUtilities.drawLine(gridGraphics, 0, gridY,
+                               width, Orientation.HORIZONTAL);
+                       }
 
-                    rowY += (rowHeights[i] + verticalSpacing);
+                       rowY += (rowHeights[i] + verticalSpacing);
+                    }
                 }
             }
 
@@ -711,14 +727,29 @@ public class TablePaneSkin extends Conta
                 && columnCount > 1) {
                 gridGraphics.setPaint(verticalGridColor);
 
-                int columnX = padding.left + (columnWidths[0] + horizontalSpacing);
+                int columnX = padding.left;
+                int visibleColumnCount = 0;
 
-                for (int j = 1; j < columnCount; j++) {
-                    int gridX = Math.max(columnX - (int)Math.ceil(horizontalSpacing * 0.5), 0);
-                    GraphicsUtilities.drawLine(gridGraphics, gridX, 0,
-                        height, Orientation.VERTICAL);
+                for (int j = 0; j < columnCount; j++) {
+                    boolean columnVisible = false;
 
-                    columnX += (columnWidths[j] + horizontalSpacing);
+                    for (int i = 0; i < rowCount; i++) {
+                        if (occupiedCells[i][j]) {
+                            columnVisible = true;
+                            break;
+                        }
+                    }
+
+                    if (columnVisible) {
+                        if (visibleColumnCount++ > 0) {
+                            int gridX = Math.max(columnX -
+                                (int)Math.ceil(horizontalSpacing * 0.5), 0);
+                            GraphicsUtilities.drawLine(gridGraphics, gridX, 0,
+                                height, Orientation.VERTICAL);
+                        }
+
+                        columnX += (columnWidths[j] + horizontalSpacing);
+                    }
                 }
             }