Example #1
0
  private List<Run> getRuns(double maxRunLength) {
    if (runs == null || maxRunLength != lastMaxRunLength) {
      computingRuns = true;
      lastMaxRunLength = maxRunLength;
      runs = new ArrayList();
      double runLength = 0;
      double runOffset = 0;
      Run run = new Run();
      double vgap = snapSpace(this.getVgap());
      double hgap = snapSpace(this.getHgap());

      final List<Node> children = getChildren();
      for (int i = 0, size = children.size(); i < size; i++) {
        Node child = children.get(i);
        if (child.isManaged()) {
          LayoutRect nodeRect = new LayoutRect();
          nodeRect.node = child;
          Insets margin = getMargin(child);
          nodeRect.width = computeChildPrefAreaWidth(child, margin);
          nodeRect.height = computeChildPrefAreaHeight(child, margin);
          double nodeLength = getOrientation() == HORIZONTAL ? nodeRect.width : nodeRect.height;
          if (runLength + nodeLength > maxRunLength && runLength > 0) {
            // wrap to next run *unless* its the only node in the run
            normalizeRun(run, runOffset);
            if (getOrientation() == HORIZONTAL) {
              // horizontal
              runOffset += run.height + vgap;
            } else {
              // vertical
              runOffset += run.width + hgap;
            }
            runs.add(run);
            runLength = 0;
            run = new Run();
          }
          if (getOrientation() == HORIZONTAL) {
            // horizontal
            nodeRect.x = runLength;
            runLength += nodeRect.width + hgap;
          } else {
            // vertical
            nodeRect.y = runLength;
            runLength += nodeRect.height + vgap;
          }
          run.rects.add(nodeRect);
        }
      }
      // insert last run
      normalizeRun(run, runOffset);
      runs.add(run);
      computingRuns = false;
    }
    return runs;
  }
Example #2
0
 private int getRowCount(GridPane pane) {
   int numRows = pane.getRowConstraints().size();
   for (int i = 0; i < pane.getChildren().size(); i++) {
     Node child = pane.getChildren().get(i);
     if (child.isManaged()) {
       Integer rowIndex = GridPane.getRowIndex(child);
       if (rowIndex != null) {
         numRows = Math.max(numRows, rowIndex + 1);
       }
     }
   }
   return numRows;
 }
Example #3
0
 @Override
 protected double computeMinHeight(double width) {
   if (getContentBias() == VERTICAL) {
     double maxPref = 0;
     final List<Node> children = getChildren();
     for (int i = 0, size = children.size(); i < size; i++) {
       Node child = children.get(i);
       if (child.isManaged()) {
         maxPref = Math.max(maxPref, child.prefHeight(-1));
       }
     }
     final Insets insets = getInsets();
     return insets.getTop() + snapSize(maxPref) + insets.getBottom();
   }
   return computePrefHeight(width);
 }
Example #4
0
 @Override
 protected double computeMinWidth(double height) {
   if (getContentBias() == HORIZONTAL) {
     double maxPref = 0;
     final List<Node> children = getChildren();
     for (int i = 0, size = children.size(); i < size; i++) {
       Node child = children.get(i);
       if (child.isManaged()) {
         maxPref = Math.max(maxPref, child.prefWidth(-1));
       }
     }
     final Insets insets = getInsets();
     return insets.getLeft() + snapSize(maxPref) + insets.getRight();
   }
   return computePrefWidth(height);
 }