public class Fill extends StackArranger
Montages Extents together to completely fill the available space, while preserving aspect ratio.

Inspired by this Python implementation by Jesse Crocker, which is in turn apparently inspired originally from https://www.crispymtn.com/stories/the-algorithm-for-a-perfectly-balanced-photo-gallery collage.py.

Author:
Owen Feehan
  • Constructor Details

    • Fill

      public Fill(int rows)
      Create with a particular number of rows.
      Parameters:
      rows - the number of rows to use the montage, when sufficient images are available.
    • Fill

      public Fill()
    • Fill

      public Fill(int numberRows, boolean varyNumberImagesPerRow, int width, double widthRatio)
      Creates a new Fill instance.
      Parameters:
      numberRows - The number of rows to use the montage, when sufficient images are available.

      If fewer Extents are passed, then a row is created for each Extent, so much as possible.

      varyNumberImagesPerRow - When true the number of Extents per row is allowed vary, to sensibly fill space.

      When false, the total number of Extents per row is kept uniform, apart from the final occupied row (if there are insufficient images to fully populate it).

      In both cases, the sizes of the images are allowed to vary, to maximally fill the available space.

      width - The width of the combined image in pixels.

      When 0, this is disabled.

      At least one of both width and widthRatio must be enabled. If both are, the minimum width is used.

      widthRatio - What fraction of the natural width of the elements should be used to determine the final width.

      The natural width of the elements, is the average-width of an entire row after partitioning.

      When 0.0, this is disabled.

      At least one of both width and widthRatio must be enabled. If both are, the minimum width is used.

  • Method Details

    • checkMisconfigured

      public void checkMisconfigured(BeanInstanceMap defaultInstances) throws BeanMisconfiguredException
      Description copied from class: AnchorBean
      Checks that a bean's properties conform to expectations.
      Overrides:
      checkMisconfigured in class AnchorBean<StackArranger>
      Parameters:
      defaultInstances - all available default instances if the DefaultInstance annotation is used
      Throws:
      BeanMisconfiguredException - if the bean has not been configured properly as XML
    • arrangeStacks

      public StackArrangement arrangeStacks(Iterator<Extent> extents, OperationContext context) throws ArrangeStackException
      Description copied from class: StackArranger
      Arranges stacks to that they fit together in a single raster.
      Specified by:
      arrangeStacks in class StackArranger
      Parameters:
      extents - the size of each respective stack for the arrangement.
      context - objects for the operation.
      Returns:
      bounding-boxes for each respective RGBStack in the unified plane.
      Throws:
      ArrangeStackException - if a bounding-box cannot be determined for any stack.
    • getNumberRows

      public int getNumberRows()
      The number of rows to use the montage, when sufficient images are available.

      If fewer Extents are passed, then a row is created for each Extent, so much as possible.

    • setNumberRows

      public void setNumberRows(int numberRows)
      The number of rows to use the montage, when sufficient images are available.

      If fewer Extents are passed, then a row is created for each Extent, so much as possible.

    • isVaryNumberImagesPerRow

      public boolean isVaryNumberImagesPerRow()
      When true the number of Extents per row is allowed vary, to sensibly fill space.

      When false, the total number of Extents per row is kept uniform, apart from the final occupied row (if there are insufficient images to fully populate it).

      In both cases, the sizes of the images are allowed to vary, to maximally fill the available space.

    • setVaryNumberImagesPerRow

      public void setVaryNumberImagesPerRow(boolean varyNumberImagesPerRow)
      When true the number of Extents per row is allowed vary, to sensibly fill space.

      When false, the total number of Extents per row is kept uniform, apart from the final occupied row (if there are insufficient images to fully populate it).

      In both cases, the sizes of the images are allowed to vary, to maximally fill the available space.

    • getWidth

      public int getWidth()
      The width of the combined image in pixels.

      When 0, this is disabled.

      At least one of both width and widthRatio must be enabled. If both are, the minimum width is used.

    • setWidth

      public void setWidth(int width)
      The width of the combined image in pixels.

      When 0, this is disabled.

      At least one of both width and widthRatio must be enabled. If both are, the minimum width is used.

    • getWidthRatio

      public double getWidthRatio()
      What fraction of the natural width of the elements should be used to determine the final width.

      The natural width of the elements, is the average-width of an entire row after partitioning.

      When 0.0, this is disabled.

      At least one of both width and widthRatio must be enabled. If both are, the minimum width is used.

    • setWidthRatio

      public void setWidthRatio(double widthRatio)
      What fraction of the natural width of the elements should be used to determine the final width.

      The natural width of the elements, is the average-width of an entire row after partitioning.

      When 0.0, this is disabled.

      At least one of both width and widthRatio must be enabled. If both are, the minimum width is used.