Object
ExtentToArrange
All Implemented Interfaces:
Comparable<ExtentToArrange>

public class ExtentToArrange extends Object implements 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 Details

    • ExtentToArrange

      public ExtentToArrange(int index, Extent extent)
      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 of rowWidth, 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 underlying Extent by adding growBy pixels.
      Parameters:
      growBy - how many pixels are added to the width of the existing Extent. 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

      public int compareTo(ExtentToArrange other)
      Sorts in descending order by extent.
      Specified by:
      compareTo in interface Comparable<ExtentToArrange>
    • equals

      public boolean equals(Object other)
      To correspond to compareTo(ExtentToArrange).
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      To correspond to equals(Object).
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getIndex

      public int getIndex()
      Index position.
    • getExtent

      public Extent getExtent()
      The Extent.
    • getAspectRatio

      public double getAspectRatio()
      The aspect-ratio: width of extent 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.