Class Fill
Extent
s 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarrangeStacks
(Iterator<Extent> extents, OperationContext context) Arranges stacks to that they fit together in a single raster.void
checkMisconfigured
(BeanInstanceMap defaultInstances) Checks that a bean's properties conform to expectations.int
The number of rows to use the montage, when sufficient images are available.int
getWidth()
The width of the combined image in pixels.double
What fraction of the natural width of the elements should be used to determine the final width.boolean
When true the number ofExtent
s per row is allowed vary, to sensibly fill space.void
setNumberRows
(int numberRows) The number of rows to use the montage, when sufficient images are available.void
setVaryNumberImagesPerRow
(boolean varyNumberImagesPerRow) When true the number ofExtent
s per row is allowed vary, to sensibly fill space.void
setWidth
(int width) The width of the combined image in pixels.void
setWidthRatio
(double widthRatio) What fraction of the natural width of the elements should be used to determine the final width.Methods inherited from class org.anchoranalysis.image.bean.spatial.arrange.StackArranger
combine, combine
Methods inherited from class org.anchoranalysis.bean.AnchorBean
describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
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 newFill
instance.- Parameters:
numberRows
- The number of rows to use the montage, when sufficient images are available.If fewer
Extent
s are passed, then a row is created for eachExtent
, so much as possible.varyNumberImagesPerRow
- When true the number ofExtent
s per row is allowed vary, to sensibly fill space.When false, the total number of
Extent
s 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
andwidthRatio
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
andwidthRatio
must be enabled. If both are, the minimum width is used.
-
-
Method Details
-
checkMisconfigured
Description copied from class:AnchorBean
Checks that a bean's properties conform to expectations.- Overrides:
checkMisconfigured
in classAnchorBean<StackArranger>
- Parameters:
defaultInstances
- all available default instances if theDefaultInstance
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 classStackArranger
- 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() -
setNumberRows
public void setNumberRows(int numberRows) -
isVaryNumberImagesPerRow
public boolean isVaryNumberImagesPerRow()When true the number ofExtent
s per row is allowed vary, to sensibly fill space.When false, the total number of
Extent
s 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 ofExtent
s per row is allowed vary, to sensibly fill space.When false, the total number of
Extent
s 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
andwidthRatio
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
andwidthRatio
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
andwidthRatio
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
andwidthRatio
must be enabled. If both are, the minimum width is used.
-