changeset 3652:a702113db3bb

StackPane.layoutChildren() optimization
author Radko Najman <radko.najman@oracle.com>
date Wed, 22 May 2013 15:41:35 +0200
parents ad014e2245f6
children 2255fb807e7b
files javafx-ui-common/src/javafx/scene/layout/StackPane.java
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/layout/StackPane.java	Tue May 21 17:30:13 2013 -0700
+++ b/javafx-ui-common/src/javafx/scene/layout/StackPane.java	Wed May 22 15:41:35 2013 +0200
@@ -39,6 +39,7 @@
 import javafx.scene.Node;
 import com.sun.javafx.css.converters.EnumConverter;
 import javafx.css.Styleable;
+import javafx.geometry.HPos;
 
 /**
  *
@@ -329,22 +330,26 @@
     @Override protected void layoutChildren() {
         List<Node> managed = getManagedChildren();
         Pos align = getAlignmentInternal();
+        HPos alignHpos = align.getHpos();
+        VPos alignVpos = align.getVpos();
         double width = getWidth();
         double height = getHeight();
         double top = getInsets().getTop();
         double right = getInsets().getRight();
         double left = getInsets().getLeft();
         double bottom = getInsets().getBottom();
-        double baselineOffset = align.getVpos() == VPos.BASELINE ? getMaxBaselineOffset(managed)
+        double baselineOffset = alignVpos == VPos.BASELINE ? getMaxBaselineOffset(managed)
                                     : height/2;
+        double contentWidth = width - left - right;
+        double contentHeight = height - top - bottom;
         for (int i = 0, size = managed.size(); i < size; i++) {
             Node child = managed.get(i);
             Pos childAlignment = StackPane.getAlignment(child);
             layoutInArea(child, left, top,
-                           width - left - right, height - top - bottom,
+                           contentWidth, contentHeight,
                            baselineOffset, getMargin(child),
-                           childAlignment != null? childAlignment.getHpos() : align.getHpos(),
-                           childAlignment != null? childAlignment.getVpos() : align.getVpos());
+                           childAlignment != null? childAlignment.getHpos() : alignHpos,
+                           childAlignment != null? childAlignment.getVpos() : alignVpos);
         }
     }