Class BoundsCalculator

java.lang.Object
org.jhotdraw8.geom.BoundsCalculator

public class BoundsCalculator extends Object
A state object for finding the combined bounds of a stream of Bounds objects.

This class is designed to work with a (parallel) stream of Bounds objects with:


 Stream<Bounds> boundsStream = ... ;
 BoundsCalculator stats = boundsStream.collect(BoundsCalculator::new,
                                                    BoundsCalculator::accept,
                                                     BoundsCalculator::combine);
 

The BoundsCalculator can be used as a reduction

 
 BoundsCalculator stats = figures.stream()
     .collect(BoundsCalculator.collectBounds(Figure::getBoundsInWorld));
 
Author:
Werner Randelshofer
  • Constructor Details

    • BoundsCalculator

      public BoundsCalculator()
      Constructs a new instance with initially empty bounds.
  • Method Details

    • accept

      public void accept(javafx.geometry.Bounds value)
      Adds another value to the bounds.
      Parameters:
      value - the input value
    • combine

      public void combine(BoundsCalculator other)
      Combines the state of another BoundsCalculator into this one.
      Parameters:
      other - another BoundsCalculator
      Throws:
      NullPointerException - if other is null
    • getBounds

      public javafx.geometry.Bounds getBounds()
      Getter.
      Returns:
      the calculated bounds