Class Size

java.lang.Object
math.Size

public class Size extends Object
  • Field Details

    • width

      public double width
    • height

      public double height
  • Constructor Details

    • Size

      public Size(double width, double height)
      Creates a new object of this class.
      Parameters:
      width - Stores the width.
      height - Stores the height.
    • Size

      public Size(Dimension dim)
      Creates a Size object from a java.awt.Dimension object.
      Parameters:
      dim - The givem Dimension object.
    • Size

      public Size(Size size)
      Creates a new Size object from a given Size object. The created object is exactly similar in value to the given one, but is not the same as that one.It is a sort of twin.
      Parameters:
      size - The given Size object.
  • Method Details

    • getHeight

      public double getHeight()
      Returns:
      The height
    • setHeight

      public void setHeight(double height)
      Parameters:
      height - sets the height
    • getWidth

      public double getWidth()
      Returns:
      the width
    • setWidth

      public void setWidth(double width)
      Parameters:
      width - sets the height
    • setSize

      public void setSize(double width, double height)
      Parameters:
      width - sets the width attribute of this object
      height - sets the height attribute of this object
    • setSize

      public void setSize(Size size)
      Parameters:
      size - sets the size of object of this class using an already known one.
    • getSize

      public Size getSize()
      Returns:
      a new instance of Size containing information about the size of this object
    • scale

      public void scale(double scaleFactor)
      Parameters:
      scaleFactor - the factor by which this Size object is to be scaled.
    • getScaledInstance

      public Size getScaledInstance(double scaleFactor)
      returns a new Size object scaled to the value given by scaleFactor
      Parameters:
      scaleFactor - the factor by which this Size object is to be scaled.
    • getScaledInstance

      public Size getScaledInstance(double scaleWidth, double scaleHeight)
      returns a new Size object scaled to the value given by scaleWidth and scaleHeight, both being muktipliers for the width and the height.
      Parameters:
      scaleWidth - the factor by which the width of this Size object is to be scaled.
      scaleHeight - the factor by which the height of this Size object is to be scaled.
    • toString

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

      public Dimension getAWTDimension()
      Returns:
      the Dimension object closest in value to this Size object.