com.groupdocs.editor.htmlcss.resources.images

Class Dimensions



  • public class Dimensions
    extends Object

    Represents the linear dimensions (width and height) of one raster rectangular image in arbitrary unit. Immutable struct.

    • Constructor Summary

      Constructors 
      Constructor and Description
      Dimensions(int width, int height)
      Creates a new instance from specified width and height
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      Dimensions deepClone()
      Returns a full copy of this instance
      boolean equals(Dimensions other)
      Determines whether this instance is equal with specified "Dimensions" instance
      boolean equals(Object obj)
      Determines whether this instance is equal with specified uncasted object, which presumably is another "Dimensions" instance
      static Dimensions fromSize(Dimension size)
      Generates and returns a new instance from specified System.Drawing.Size instance
      long getArea()
      Returns an area (Width x Height)
      Ratio getAspectRatio()
      Aspect ratio of this dimensions as width/height
      static Dimensions getEmpty()
      Returns an empty Dimensions instance
      int getHeight()
      Returns height of the image
      int getWidth()
      Returns width of the image
      int hashCode()
      Returns a hashcode for this instance, which cannot be changed during its lifetime
      boolean isEmpty()
      Determines whether this "Dimensions" instance is empty and default, i.e.
      boolean isSquare()
      Determines whether specified 'Dimensions' represents square, i.e.
      static boolean op_Equality(Dimensions first, Dimensions second)
      Checks whether two "Dimensions" values are equal, i.e.
      static boolean op_Inequality(Dimensions first, Dimensions second)
      Checks whether two "Dimensions" values are not equal, i.e.
      Dimensions proportionallyResizeForNewHeight(int targetHeight)
      Creates and returns new "Dimensions" instance, which is proportionally resized from current, based on specified height
      Dimensions proportionallyResizeForNewWidth(int targetWidth)
      Creates and returns new "Dimensions" instance, which is proportionally resized from current, based on specified width
      String toString()
      Returns a string representation of this "Dimensions"
    • Constructor Detail

      • Dimensions

        public Dimensions(int width,
                  int height)

        Creates a new instance from specified width and height

        Parameters:
        width - Width of image
        height - Height of image
    • Method Detail

      • deepClone

        public final Dimensions deepClone()

        Returns a full copy of this instance

        Returns:
        New instance, that is a full and deep copy of this one
      • equals

        public final boolean equals(Dimensions other)

        Determines whether this instance is equal with specified "Dimensions" instance

        Parameters:
        other - Other "Dimensions" instance to check on equality
        Returns:
        True if are equal, false if are not equal
      • equals

        public boolean equals(Object obj)

        Determines whether this instance is equal with specified uncasted object, which presumably is another "Dimensions" instance

        Overrides:
        equals in class Object
        Parameters:
        obj - Other object, that is presumably of "Dimensions" type, that should be checked on equality with this
        Returns:
        True if are equal, false if are not equal
      • fromSize

        public static Dimensions fromSize(Dimension size)

        Generates and returns a new instance from specified System.Drawing.Size instance

        Parameters:
        size - Any instance of System.Drawing.Size
        Returns:
        New instance, that has the same width and height, as the specified
      • getArea

        public final long getArea()

        Returns an area (Width x Height)

      • getAspectRatio

        public final Ratio getAspectRatio()

        Aspect ratio of this dimensions as width/height

      • getEmpty

        public static Dimensions getEmpty()

        Returns an empty Dimensions instance

      • getHeight

        public final int getHeight()

        Returns height of the image

      • getWidth

        public final int getWidth()

        Returns width of the image

      • hashCode

        public int hashCode()

        Returns a hashcode for this instance, which cannot be changed during its lifetime

        Overrides:
        hashCode in class Object
        Returns:
        Immutable (for this instance) hash-code as signed 4-byte integer
      • isEmpty

        public final boolean isEmpty()

        Determines whether this "Dimensions" instance is empty and default, i.e. it doesn't store correct width and height

      • isSquare

        public final boolean isSquare()

        Determines whether specified 'Dimensions' represents square, i.e. if width is equal to height

      • op_Equality

        public static boolean op_Equality(Dimensions first,
                          Dimensions second)

        Checks whether two "Dimensions" values are equal, i.e. they have equal width and height, or both are empty

        Parameters:
        first - First instance to check
        second - Second instance to check
        Returns:
        True if are equal, false if are not equal
      • op_Inequality

        public static boolean op_Inequality(Dimensions first,
                            Dimensions second)

        Checks whether two "Dimensions" values are not equal, i.e. their corresponding width and/or height are different

        Parameters:
        first - First instance to check
        second - Second instance to check
        Returns:
        True if are unequal, false if are equal
      • proportionallyResizeForNewHeight

        public final Dimensions proportionallyResizeForNewHeight(int targetHeight)

        Creates and returns new "Dimensions" instance, which is proportionally resized from current, based on specified height

        Parameters:
        targetHeight - New target height, that will be present in resultant Dimension
        Returns:
        New "Dimensions" instance with specified target height and proportionally resized width
      • proportionallyResizeForNewWidth

        public final Dimensions proportionallyResizeForNewWidth(int targetWidth)

        Creates and returns new "Dimensions" instance, which is proportionally resized from current, based on specified width

        Parameters:
        targetWidth - New target width, that will be present in resultant Dimension
        Returns:
        New "Dimensions" instance with specified target width and proportionally resized height
      • toString

        public String toString()

        Returns a string representation of this "Dimensions"


        W640×H480
        Overrides:
        toString in class Object
        Returns:
        String instance, that contains a width and height in W:(width)×H:(height) format