Package com.pdftools.geometry.units
Class Size
java.lang.Object
com.pdftools.geometry.units.Size
Class that represents a size that is based on a width and height of type Length.
Constructs from standard paper sizes, generates a string representation, and provides conversions to portrait and landscape mode.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSize(double width, double height, Length.Units unit) ConstructSizeobject from width, height and a common unit.ConstructSizeobject from width and height.Size(Size.PaperSizes paperSize) Construct aSizeobject from standard paper sizes defined in enumSize.PaperSizes. -
Method Summary
Modifier and TypeMethodDescriptionbooleandoubleCalculate ratio between height and width.Gets the height (vertical size) asLengthobject.getWidth()Gets the width (horizontal size) asLengthobject.inthashCode()static SizeCreate aSizeobject from a string representation.Switches width and height if the absolute value of height is greater than the the absolute value of width.Switches width and height if the absolute value of the width is greater than the absolute value of the height.toString()Creates a string representation as width-height-pair with associated suitable metric units, "m", "cm" or "mm".toString(Length.Units unit) Creates a string representation as width-height-pair with the specified unit.
-
Constructor Details
-
Size
ConstructSizeobject from width and height. -
Size
ConstructSizeobject from width, height and a common unit.- Parameters:
width- as numerical valueheight- as numerical valueunit- the unit
-
Size
Construct aSizeobject from standard paper sizes defined in enumSize.PaperSizes.- Parameters:
paperSize- enumeration item e.g.Size.PaperSizes.A4, orSize.PaperSizes.LETTER.
-
-
Method Details
-
parse
Create a
Sizeobject from a string representation.Allowed are value-unit pairs of the form "<width_value><width_unit> <height_value><height_unit>" or the name of a standard paper size.
Examples: "12.3cm 23.9mm" or "A4"
- Parameters:
value- the string value- Returns:
-
toString
Creates a string representation as width-height-pair with associated suitable metric units, "m", "cm" or "mm". -
toString
Creates a string representation as width-height-pair with the specified unit. -
toPortrait
Switches width and height if the absolute value of the width is greater than the absolute value of the height. -
toLandscape
Switches width and height if the absolute value of height is greater than the the absolute value of width. -
getAspectRatio
public double getAspectRatio()Calculate ratio between height and width. -
getWidth
Gets the width (horizontal size) asLengthobject. -
getHeight
Gets the height (vertical size) asLengthobject. -
equals
-
hashCode
public int hashCode()
-