Package math

Class Size


  • public class Size
    extends java.lang.Object
    Author:
    GBEMIRO
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double height  
      double width  
    • Constructor Summary

      Constructors 
      Constructor Description
      Size​(double width, double height)
      Creates a new object of this class.
      Size​(Size size)
      Creates a new Size object from a given Size object.
      Size​(Dimension dim)
      Creates a Size object from a java.awt.Dimension object.
    • Method Summary

      Modifier and Type Method Description
      Dimension getAWTDimension()  
      double getHeight()  
      Size getScaledInstance​(double scaleFactor)
      returns a new Size object scaled to the value given by scaleFactor
      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.
      Size getSize()  
      double getWidth()  
      void scale​(double scaleFactor)  
      void setHeight​(double height)  
      void setSize​(double width, double height)  
      void setSize​(Size size)  
      void setWidth​(double width)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • width

        public double width
      • height

        public double height
    • Constructor Detail

      • 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 Detail

      • 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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getAWTDimension

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