Package com.pdftools.geometry.units
Class Size
- java.lang.Object
-
- com.pdftools.geometry.units.Size
-
public class Size extends java.lang.ObjectClass 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 Modifier and Type Class Description static classSize.PaperSizes
-
Constructor Summary
Constructors Constructor Description Size(double width, double height, Length.Units unit)ConstructSizeobject from width, height and a common unit.Size(Length width, Length height)ConstructSizeobject from width and height.Size(Size.PaperSizes paperSize)Construct aSizeobject from standard paper sizes defined in enumSize.PaperSizes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)doublegetAspectRatio()Calculate ratio between height and width.LengthgetHeight()Gets the height (vertical size) asLengthobject.LengthgetWidth()Gets the width (horizontal size) asLengthobject.inthashCode()static Sizeparse(java.lang.String value)Create aSizeobject from a string representation.SizetoLandscape()Switches width and height if the absolute value of height is greater than the the absolute value of width.SizetoPortrait()Switches width and height if the absolute value of the width is greater than the absolute value of the height.java.lang.StringtoString()Creates a string representation as width-height-pair with associated suitable metric units, "m", "cm" or "mm".java.lang.StringtoString(Length.Units unit)Creates a string representation as width-height-pair with the specified unit.
-
-
-
Constructor Detail
-
Size
public Size(double width, double height, Length.Units unit)ConstructSizeobject from width, height and a common unit.- Parameters:
width- as numerical valueheight- as numerical valueunit- the unit
-
Size
public Size(Size.PaperSizes paperSize)
Construct aSizeobject from standard paper sizes defined in enumSize.PaperSizes.- Parameters:
paperSize- enumeration item e.g.Size.PaperSizes.A4, orSize.PaperSizes.LETTER.
-
-
Method Detail
-
parse
public static Size parse(java.lang.String value)
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
public java.lang.String toString()
Creates a string representation as width-height-pair with associated suitable metric units, "m", "cm" or "mm".- Overrides:
toStringin classjava.lang.Object
-
toString
public java.lang.String toString(Length.Units unit)
Creates a string representation as width-height-pair with the specified unit.
-
toPortrait
public Size toPortrait()
Switches width and height if the absolute value of the width is greater than the absolute value of the height.
-
toLandscape
public Size 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.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-