Class DimensionVersion

java.lang.Object
com.aoapps.cdn.data.Version
com.aoapps.cdn.data.DimensionVersion
Direct Known Subclasses:
ImageVersion

public abstract class DimensionVersion extends Version
A version of a resource that has a dimension.
  • Method Details

    • getDimension

      public Dimension getDimension()
      Gets the dimension in pixels.
    • getWidth

      public int getWidth()
      Gets the width in pixels.
    • getHeight

      public int getHeight()
      Gets the height in pixels.
    • scale

      public DimensionVersion scale(Integer width, Integer height) throws IOException
      Scales this version to a different resolution, using cached version if previously scaled.

      This will typically be done on the original version, but can be performed on any version.

      First searches all versions for any of this type and matching dimension. If found, returns it. Tracks which version had the highest resolution while performing this search.

      Will only scale down from the biggest existing resource. A request to scale up will return the highest resolution available.

      Will only perform proportional scaling. If both width and height are specified, returns the largest, possibly scaled, image that fits both the width and the height. The resulting width or height may be less than the requested scaling, but will not be more. The user interface could perform letterboxing if needing to fit into a fix proportion area.

      Locks the resource while performing the search. This search should be very quick, and this locking will prevent duplicate work when performing a new scaling.

      Synchronizes the cluster, but only after releasing the lock. If different nodes create the same version at the same time, the cluster confict will be resolved through standard monitoring and administration.

      Parameters:
      width - The desired width or null for proportional scaling
      height - The desired height or null for proportional scaling
      Returns:
      When both width and height are null, return this. When resulting dimensions match this version, return this. Otherwise return a closest-match scaled version.
      Throws:
      IOException