Package math
Class Size
java.lang.Object
math.Size
public class Size
extends java.lang.Object
- Author:
- GBEMIRO
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description DimensiongetAWTDimension()doublegetHeight()SizegetScaledInstance(double scaleFactor)returns a new Size object scaled to the value given by scaleFactorSizegetScaledInstance(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.SizegetSize()doublegetWidth()voidscale(double scaleFactor)voidsetHeight(double height)voidsetSize(double width, double height)voidsetSize(Size size)voidsetWidth(double width)java.lang.StringtoString()
-
Field Details
-
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
Creates a Size object from a java.awt.Dimension object.- Parameters:
dim- The givem Dimension object.
-
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 objectheight- sets the height attribute of this object
-
setSize
- Parameters:
size- sets the size of object of this class using an already known one.
-
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
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
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:
toStringin classjava.lang.Object
-
getAWTDimension
- Returns:
- the Dimension object closest in value to this Size object.
-