Enum Class ShapedText.Direction
- All Implemented Interfaces:
Serializable,Comparable<ShapedText.Direction>,Constable
- Enclosing class:
ShapedText
There is deliberately no third constant meaning "decide later". Direction is
resolved from the text before anything is shaped, and by the time a ShapedText exists
the answer is known — so a constant standing for the question would be a value a widget
could store in a field, hand back through ShapedText.baseDirection(), and compare
against. Stating a direction and declining to state one are different acts, and they are
spelled as different shape overloads on TextRuler rather than as two values of
one type.
This is the direction of a run of text, which is why it lives here. Direction as a layout axis — leading and trailing insets, mirrored ink, arrow semantics, popup anchoring — is a separate decision that has not been taken, and pre-empting it with a type in the drawing package would put a text-shaping concern in every layout signature it touches.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic ShapedText.Directionof(String text, ShapedText.Direction whenNeutral) The base direction oftextunder the Unicode Bidirectional Algorithm's first-strong-character rule, asjava.text.Bidiimplements it.static ShapedText.DirectionReturns the enum constant of this class with the specified name.static ShapedText.Direction[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
LTR
Left to right: Latin, Greek, Cyrillic, the CJK scripts as this toolkit sets them, and the answer for a string with no strong character at all. -
RTL
Right to left: Arabic, Hebrew.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
of
The base direction oftextunder the Unicode Bidirectional Algorithm's first-strong-character rule, asjava.text.Bidiimplements it.The rule lives here, in one place with no backend under it, so that every ruler resolves a paragraph the same way and a test can pin it with nothing installed.
whenNeutralis returned for text with no strong character at all ("42","(...)", the empty string), which is the one case the rule cannot answer. It is a parameter rather than a constant because the right answer there is the direction of the surrounding user interface, which nothing in this package owns yet; passingLTRreproduces the behaviour of a toolkit with no direction axis, and this parameter is the seam where that gets fixed.- Parameters:
text- the paragraph to inspectwhenNeutral- what to return whentextcontains no strong character- Throws:
NullPointerException- if either argument is null
-