Class RelativeSize

  • All Implemented Interfaces:
    Size

    public class RelativeSize
    extends java.lang.Object
    implements Size
    Calculates the size of an enclosed object relative to the enclosing object.
    Since:
    0.3.4
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double scalingFactor
      The scaling factor to use for the enclosed object.
    • Constructor Summary

      Constructors 
      Constructor Description
      RelativeSize​(double scalingFactor)
      Instantiates an object which calculates the size of an object, using the given scaling factor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Dimension calculate​(int width, int height)
      Calculates the size of the object.
      java.lang.String toString()
      Returns a String representation of this object.
      • Methods inherited from class java.lang.Object

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

      • scalingFactor

        private final double scalingFactor
        The scaling factor to use for the enclosed object.
    • Constructor Detail

      • RelativeSize

        public RelativeSize​(double scalingFactor)
        Instantiates an object which calculates the size of an object, using the given scaling factor.
        Parameters:
        scalingFactor - The scaling factor to use to determine the size of the enclosing object.
        Throws:
        java.lang.IllegalArgumentException - When the scaling factor is not within the range of 0.0d and 1.0d, inclusive.
    • Method Detail

      • calculate

        public java.awt.Dimension calculate​(int width,
                                            int height)
        Description copied from interface: Size
        Calculates the size of the object.
        Specified by:
        calculate in interface Size
        Parameters:
        width - Width of the object which encloses the object for which the size should be determined.
        height - Height of the object which encloses the object for which the size should be determined.
        Returns:
        Calculated size of the object.
      • toString

        public java.lang.String toString()
        Returns a String representation of this object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String representation of this object.