Class CalculateMinimumDateFieldSize
java.lang.Object
com.github.lgooddatepicker.zinternaltools.CalculateMinimumDateFieldSize
CalculateMinimumDateFieldSize, This class is used to calculate the minimum horizontal size needed
for text fields that hold dates. (Such as the text field in the DatePicker component.)
The size that is returned is designed to be the smallest size that will hold the longest
displayable date under current DatePickerSettings, without cropping the text. The "longest date",
needs to take into account the following factors: The longest (in pixels) month name in the
current locale, the font object for valid dates (including the font type and size), and the
currently set display format for AD dates.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
getFormattedDateWidthInPixels
(DateTimeFormatter formatCE, Locale locale, Font fontValidDate, int numberOfExtraCharacters) getFormattedDateWidthInPixels, This returns the width (in pixels) of the longest formatted date, using the supplied DateTimeFormatter instance, locale, and font.
-
Constructor Details
-
CalculateMinimumDateFieldSize
public CalculateMinimumDateFieldSize()
-
-
Method Details
-
getFormattedDateWidthInPixels
public static int getFormattedDateWidthInPixels(DateTimeFormatter formatCE, Locale locale, Font fontValidDate, int numberOfExtraCharacters) getFormattedDateWidthInPixels, This returns the width (in pixels) of the longest formatted date, using the supplied DateTimeFormatter instance, locale, and font. The month that will be used for the length calculation will be the "longest text month" according to the function getLongestTextMonthInLocale(). You may optionally add extra characters to the longestDateString that is used in the calculation, by supplying a nonzero value for the parameter numberOfExtraCharacters. formatCE: This is the date format that should be used in the calculation. Longer (wider) formats will result in wider printed dates. locale: This is the locale that you wish to use in the calculation. The width of the date string (and the width of the month names) will be different depending on the locale that is used to translate and format the date. fontValidDate: This will be used to generate the font metrics for the calculation. Larger font types, and larger font sizes, will result in wider printed dates. numberOfExtraCharacters: This is the number of "extra" characters that you want to have used in calculating the width of the longest formatted date. If you don't wish for any extra characters to be used in the calculation, please supply zero for this value. If you wish to -shorten- the default date string, you may also supply a negative number of characters for this value. Implementation details: Note that any formatted date could be made longer by using years greater than four digits, or by using BC years. This function assumes four digit Common Era years, in performing its calculations.
-