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 TypeMethodDescriptiondouble
Returns the ratio of *image height to width*.int
compareTo
(ExtentToArrange other) Sorts in descending order byextent
.boolean
To correspond tocompareTo(ExtentToArrange)
.double
The aspect-ratio: width ofextent
divided by height.TheExtent
.int
getIndex()
Index position.double
Stores the difference that occurs between a discretized scaled width and what it should ideally be.void
growWidth
(int growBy) Changes the width of the underlyingExtent
by addinggrowBy
pixels.int
hashCode()
To correspond toequals(Object)
.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.toString()
int
width()
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 underlyingExtent
by addinggrowBy
pixels.- 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:
compareTo
in 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 ofextent
divided 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.
-