Class ExtentToArrange
Object
ExtentToArrange
- All Implemented Interfaces:
Comparable<ExtentToArrange>
A particular
Extent to be arranged, with calculated aspect-ratio, and its unique index
position.
An equality check and ordering is imposed only in terms of the X-size of the extent,
so as to sort in descending order by width.
-
Constructor Summary
ConstructorsConstructorDescriptionExtentToArrange(int index, Extent extent) Create with a particular index and size. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the ratio of *image height to width*.intcompareTo(ExtentToArrange other) Sorts in descending order byextent.booleanTo correspond tocompareTo(ExtentToArrange).doubleThe aspect-ratio: width ofextentdivided by height.TheExtent.intgetIndex()Index position.doubleStores the difference that occurs between a discretized scaled width and what it should ideally be.voidgrowWidth(int growBy) Changes the width of the underlyingExtentby addinggrowBypixels.inthashCode()To correspond toequals(Object).intscaleToMatchRow(double sumAspectRatios, int rowWidth) Changes the size of the image to match a row that has a total width ofrowWidth, preserving aspect-ratio.toString()intwidth()The size in the X-dimension.
-
Constructor Details
-
ExtentToArrange
Create with a particular index and size.- Parameters:
index- the index (from zero upwards).extent- the size.
-
-
Method Details
-
scaleToMatchRow
public int scaleToMatchRow(double sumAspectRatios, int rowWidth) Changes the size of the image to match a row that has a total width ofrowWidth, preserving aspect-ratio.- Parameters:
sumAspectRatios- the sum of the aspect-ratios of all images in the row, including the current image.rowWidth- the desired eventual width of the entire row of images.- Returns:
- int the final selected width;
-
growWidth
public void growWidth(int growBy) Changes the width of the underlyingExtentby addinggrowBypixels.- Parameters:
growBy- how many pixels are added to the width of the existingExtent. This may also be negative.
-
width
public int width()The size in the X-dimension.- Returns:
- the width.
-
aspectRatioInverted
public double aspectRatioInverted()Returns the ratio of *image height to width*.This is the inversion of the aspect-ratio, which is the ratio of *image width to height*.
- Returns:
- the inverted aspect-ratio.
-
compareTo
Sorts in descending order byextent.- Specified by:
compareToin interfaceComparable<ExtentToArrange>
-
equals
To correspond tocompareTo(ExtentToArrange). -
hashCode
public int hashCode()To correspond toequals(Object). -
toString
-
getIndex
public int getIndex()Index position. -
getExtent
TheExtent. -
getAspectRatio
public double getAspectRatio()The aspect-ratio: width ofextentdivided by height. -
getScaleRoundingError
public double getScaleRoundingError()Stores the difference that occurs between a discretized scaled width and what it should ideally be.This value will always lie in the range (-1,1) and a positive value means the discretized version rounded down by the value, and a negative value means the discretized version rounded up by the value.
-