public class ExtentToArrange extends Object implements Comparable<ExtentToArrange>
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 and Description |
---|
ExtentToArrange(int index,
Extent extent)
Create with a particular index and size.
|
Modifier and Type | Method and Description |
---|---|
double |
aspectRatioInverted()
Returns the ratio of *image height to width*.
|
int |
compareTo(ExtentToArrange other)
Sorts in descending order by
extent . |
boolean |
equals(Object other)
To correspond to
compareTo(ExtentToArrange) . |
double |
getAspectRatio()
The aspect-ratio: width of
extent divided by height. |
Extent |
getExtent()
The
Extent . |
int |
getIndex()
Index position.
|
double |
getScaleRoundingError()
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 underlying
Extent by adding growBy pixels. |
int |
hashCode()
To correspond to
equals(Object) . |
int |
scaleToMatchRow(double sumAspectRatios,
int rowWidth)
Changes the size of the image to match a row that has a total width of
rowWidth ,
preserving aspect-ratio. |
String |
toString() |
int |
width()
The size in the X-dimension.
|
public ExtentToArrange(int index, Extent extent)
index
- the index (from zero upwards).extent
- the size.public int scaleToMatchRow(double sumAspectRatios, int rowWidth)
rowWidth
,
preserving aspect-ratio.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.public void growWidth(int growBy)
Extent
by adding growBy
pixels.growBy
- how many pixels are added to the width of the existing Extent
. This may
also be negative.public int width()
public double aspectRatioInverted()
This is the inversion of the aspect-ratio, which is the ratio of *image width to height*.
public int compareTo(ExtentToArrange other)
extent
.compareTo
in interface Comparable<ExtentToArrange>
public boolean equals(Object other)
compareTo(ExtentToArrange)
.public int hashCode()
equals(Object)
.public int getIndex()
public double getAspectRatio()
extent
divided by height.public double getScaleRoundingError()
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.
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.