Class Fill
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarrangeStacks(Iterator<Extent> extents, OperationContext context) Arranges stacks to that they fit together in a single raster.voidcheckMisconfigured(BeanInstanceMap defaultInstances) Checks that a bean's properties conform to expectations.intThe number of rows to use the montage, when sufficient images are available.intgetWidth()The width of the combined image in pixels.doubleWhat fraction of the natural width of the elements should be used to determine the final width.booleanWhen true the number ofExtents per row is allowed vary, to sensibly fill space.voidsetNumberRows(int numberRows) The number of rows to use the montage, when sufficient images are available.voidsetVaryNumberImagesPerRow(boolean varyNumberImagesPerRow) When true the number ofExtents per row is allowed vary, to sensibly fill space.voidsetWidth(int width) The width of the combined image in pixels.voidsetWidthRatio(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, combineMethods 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 newFillinstance.- 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 eachExtent, so much as possible.varyNumberImagesPerRow- When true the number ofExtents 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
widthandwidthRatiomust 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
widthandwidthRatiomust be enabled. If both are, the minimum width is used.
-
-
Method Details
-
checkMisconfigured
Description copied from class:AnchorBeanChecks that a bean's properties conform to expectations.- Overrides:
checkMisconfiguredin classAnchorBean<StackArranger>- Parameters:
defaultInstances- all available default instances if theDefaultInstanceannotation 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:StackArrangerArranges stacks to that they fit together in a single raster.- Specified by:
arrangeStacksin classStackArranger- Parameters:
extents- the size of each respective stack for the arrangement.context- objects for the operation.- Returns:
- bounding-boxes for each respective
RGBStackin 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 ofExtents 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 ofExtents 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
widthandwidthRatiomust 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
widthandwidthRatiomust 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
widthandwidthRatiomust 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
widthandwidthRatiomust be enabled. If both are, the minimum width is used.
-