changeset 1633:e40fc78d21fa

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/2u/dev/jfx//rt
author Martin Sladecek <martin.sladecek@oracle.com>
date Tue, 18 Jun 2013 11:03:49 +0200
parents 6a223e588b64 6dd9f40e495c
children 862dcc768d3a
files
diffstat 1 files changed, 87 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/layout/GridPane.java	Fri Jun 14 16:01:29 2013 -0400
+++ b/javafx-ui-common/src/javafx/scene/layout/GridPane.java	Tue Jun 18 11:03:49 2013 +0200
@@ -1427,10 +1427,12 @@
     }
 
     double[] getColumnWidths() {
+        doLayout(false);
         return columnWidths;
     }
 
     double[] getRowHeights() {
+        doLayout(false);
         return rowHeights;
     }
 
@@ -1458,87 +1460,10 @@
         }
         super.requestLayout();
     }
-
+    
     @Override protected void layoutChildren() {
         performingLayout = true;
-        final double snaphgap = snapSpace(getHgap());
-        final double snapvgap = snapSpace(getVgap());
-        final double top = snapSpace(getInsets().getTop());
-        final double bottom = snapSpace(getInsets().getBottom());
-        final double left = snapSpace(getInsets().getLeft());
-        final double right = snapSpace(getInsets().getRight());
-
-        final double width = getWidth();
-        final double height = getHeight();
-        final double contentHeight = height - top - bottom;
-        final double contentWidth = width - left - right;
-        double columnTotal = 0;
-        double rowTotal = 0;
-        computeGridMetrics();
-
-        Orientation contentBias = getContentBias();
-        if (contentBias == null) {
-            rowTotal = adjustRowHeights(rowPrefHeight, height);
-            columnTotal = adjustColumnWidths(columnPrefWidth, width);
-        } else if (contentBias == Orientation.HORIZONTAL) {
-            columnTotal = adjustColumnWidths(columnPrefWidth, width);
-            computeRowMetrics(rowHeights.length, columnWidths);
-            rowTotal = adjustRowHeights(rowPrefHeight, height);
-        } else if (contentBias == Orientation.VERTICAL) {
-            rowTotal = adjustRowHeights(rowPrefHeight, height);
-            computeColumnMetrics(columnWidths.length, rowHeights);
-            columnTotal = adjustColumnWidths(columnPrefWidth, width);
-        }
-
-        final double x = left + computeXOffset(contentWidth, columnTotal, getAlignment().getHpos());
-        final double y = top + computeYOffset(contentHeight, rowTotal, getAlignment().getVpos());
-        for (int i = 0; i < getChildren().size(); i++) {
-            Node child = getChildren().get(i);
-            if (child.isManaged()) {
-                int rowIndex = getNodeRowIndex(child);
-                int columnIndex = getNodeColumnIndex(child);
-                int colspan = getNodeColumnSpan(child);
-                if (colspan == REMAINING) {
-                    colspan = columnWidths.length - columnIndex;
-                }
-                int rowspan = getNodeRowSpan(child);
-                if (rowspan == REMAINING) {
-                    rowspan = rowHeights.length - rowIndex;
-                }
-                double areaX = x;
-                for (int j = 0; j < columnIndex; j++) {
-                    areaX += columnWidths[j] + snaphgap;
-                }
-                double areaY = y;
-                for (int j = 0; j < rowIndex; j++) {
-                    areaY += rowHeights[j] + snapvgap;
-                }
-                double areaW = columnWidths[columnIndex];
-                for (int j = 2; j <= colspan; j++) {
-                    areaW += columnWidths[columnIndex+j-1] + snaphgap;
-                }
-                double areaH = rowHeights[rowIndex];
-                for (int j = 2; j <= rowspan; j++) {
-                    areaH += rowHeights[rowIndex+j-1] + snapvgap;
-                }
-
-                HPos halign = getHalignment(child);
-                VPos valign = getValignment(child);
-                Insets margin = getMargin(child);
-                if (margin != null && valign == VPos.BASELINE) {
-                    // The top margin has already added to rowBaseline[] in computeRowMetric()
-                    // we do not need to add it again in layoutInArea.
-                    margin = new Insets(0, margin.getRight(), margin.getBottom(), margin.getLeft());
-                }
-                //System.out.println("layoutNode("+child.toString()+" row/span="+rowIndex+"/"+rowspan+" col/span="+columnIndex+"/"+colspan+" area="+areaX+","+areaY+" "+areaW+"x"+areaH+""+" rowBaseline="+rowBaseline[rowIndex]);
-                layoutInArea(child, areaX, areaY, areaW, areaH, rowBaseline[rowIndex],
-                        margin,
-                        shouldColumnFillWidth(columnIndex), shouldRowFillHeight(rowIndex),
-                        halign != null? halign : getColumnHalignment(columnIndex),
-                        valign != null? valign : getRowValignment(rowIndex));
-            }
-        }
-        layoutGridLines(x, y, rowTotal, columnTotal);
+        doLayout(true);
         performingLayout = false;
     }
 
@@ -1792,6 +1717,89 @@
         return "Grid hgap="+getHgap()+", vgap="+getVgap()+", alignment="+getAlignment();
     }
 
+    private void doLayout(boolean withPositioning) {
+        final double snaphgap = snapSpace(getHgap());
+        final double snapvgap = snapSpace(getVgap());
+        final double top = snapSpace(getInsets().getTop());
+        final double bottom = snapSpace(getInsets().getBottom());
+        final double left = snapSpace(getInsets().getLeft());
+        final double right = snapSpace(getInsets().getRight());
+
+        final double width = getWidth();
+        final double height = getHeight();
+        final double contentHeight = height - top - bottom;
+        final double contentWidth = width - left - right;
+        double columnTotal = 0;
+        double rowTotal = 0;
+        computeGridMetrics();
+        
+        Orientation contentBias = getContentBias();
+        if (contentBias == null) {
+            rowTotal = adjustRowHeights(rowPrefHeight, height);
+            columnTotal = adjustColumnWidths(columnPrefWidth, width);
+        } else if (contentBias == Orientation.HORIZONTAL) {
+            columnTotal = adjustColumnWidths(columnPrefWidth, width);
+            computeRowMetrics(rowHeights.length, columnWidths);
+            rowTotal = adjustRowHeights(rowPrefHeight, height);
+        } else if (contentBias == Orientation.VERTICAL) {
+            rowTotal = adjustRowHeights(rowPrefHeight, height);
+            computeColumnMetrics(columnWidths.length, rowHeights);
+            columnTotal = adjustColumnWidths(columnPrefWidth, width);
+        }
+
+        if (withPositioning) {
+            final double x = left + computeXOffset(contentWidth, columnTotal, getAlignment().getHpos());
+            final double y = top + computeYOffset(contentHeight, rowTotal, getAlignment().getVpos());
+            for (int i = 0; i < getChildren().size(); i++) {
+                Node child = getChildren().get(i);
+                if (child.isManaged()) {
+                    int rowIndex = getNodeRowIndex(child);
+                    int columnIndex = getNodeColumnIndex(child);
+                    int colspan = getNodeColumnSpan(child);
+                    if (colspan == REMAINING) {
+                        colspan = columnWidths.length - columnIndex;
+                    }
+                    int rowspan = getNodeRowSpan(child);
+                    if (rowspan == REMAINING) {
+                        rowspan = rowHeights.length - rowIndex;
+                    }
+                    double areaX = x;
+                    for (int j = 0; j < columnIndex; j++) {
+                        areaX += columnWidths[j] + snaphgap;
+                    }
+                    double areaY = y;
+                    for (int j = 0; j < rowIndex; j++) {
+                        areaY += rowHeights[j] + snapvgap;
+                    }
+                    double areaW = columnWidths[columnIndex];
+                    for (int j = 2; j <= colspan; j++) {
+                        areaW += columnWidths[columnIndex+j-1] + snaphgap;
+                    }
+                    double areaH = rowHeights[rowIndex];
+                    for (int j = 2; j <= rowspan; j++) {
+                        areaH += rowHeights[rowIndex+j-1] + snapvgap;
+                    }
+
+                    HPos halign = getHalignment(child);
+                    VPos valign = getValignment(child);
+                    Insets margin = getMargin(child);
+                    if (margin != null && valign == VPos.BASELINE) {
+                        // The top margin has already added to rowBaseline[] in computeRowMetric()
+                        // we do not need to add it again in layoutInArea.
+                        margin = new Insets(0, margin.getRight(), margin.getBottom(), margin.getLeft());
+                    }
+                    //System.out.println("layoutNode("+child.toString()+" row/span="+rowIndex+"/"+rowspan+" col/span="+columnIndex+"/"+colspan+" area="+areaX+","+areaY+" "+areaW+"x"+areaH+""+" rowBaseline="+rowBaseline[rowIndex]);
+                    layoutInArea(child, areaX, areaY, areaW, areaH, rowBaseline[rowIndex],
+                            margin,
+                            shouldColumnFillWidth(columnIndex), shouldRowFillHeight(rowIndex),
+                            halign != null? halign : getColumnHalignment(columnIndex),
+                            valign != null? valign : getRowValignment(rowIndex));
+                }
+            }
+            layoutGridLines(x, y, rowTotal, columnTotal);
+        }
+    }
+
     /***************************************************************************
      *                                                                         *
      *                         Stylesheet Handling                             *