Enum Class Gravity
- All Implemented Interfaces:
Enumeration
,Serializable
,Comparable<Gravity>
,Constable
PangoGravity
represents the orientation of glyphs in a segment
of text.
This is useful when rendering vertical text layouts. In those situations,
the layout is rotated using a non-identity Pango.Matrix
, and then
glyph orientation is controlled using PangoGravity
.
Not every value in this enumeration makes sense for every usage of
PangoGravity
; for example, AUTO
only can be passed to
Context.setBaseGravity(org.gnome.pango.Gravity)
and can only be returned by
Context.getBaseGravity()
.
See also: Pango.GravityHint
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Gravity
getForMatrix
(@Nullable Matrix matrix) Finds the gravity that best matches the rotation component in aPangoMatrix
.static Gravity
getForScript
(Script script, Gravity baseGravity, GravityHint hint) Returns the gravity to use in laying out aPangoItem
.static Gravity
getForScriptAndWidth
(Script script, boolean wide, Gravity baseGravity, GravityHint hint) Returns the gravity to use in laying out a single character orPangoItem
.static Type
getType()
Get the GType of the Gravity classint
getValue()
Get the numeric value of this enumstatic Gravity
of
(int value) Create a new Gravity for the provided valuedouble
Converts aPangoGravity
value to its natural rotation in radians.static Gravity
Returns the enum constant of this class with the specified name.static Gravity[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SOUTH
Glyphs stand upright (default) <img align="right" valign="center" src="m-south.png"> -
EAST
Glyphs are rotated 90 degrees counter-clockwise. <img align="right" valign="center" src="m-east.png"> -
NORTH
Glyphs are upside-down. <img align="right" valign="cener" src="m-north.png"> -
WEST
Glyphs are rotated 90 degrees clockwise. <img align="right" valign="center" src="m-west.png"> -
AUTO
Gravity is resolved from the context matrix
-
-
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
Create a new Gravity for the provided value- Parameters:
value
- the enum value- Returns:
- the enum for the provided value
-
getValue
public int getValue()Get the numeric value of this enum- Specified by:
getValue
in interfaceEnumeration
- Returns:
- the enum value
-
getType
-
getForMatrix
-
getForScript
Returns the gravity to use in laying out aPangoItem
.The gravity is determined based on the script, base gravity, and hint.
If
baseGravity
isAUTO
, it is first replaced with the preferred gravity ofscript
. To get the preferred gravity of a script, passAUTO
andGravityHint.STRONG
in.- Parameters:
script
-PangoScript
to querybaseGravity
- base gravity of the paragraphhint
- orientation hint- Returns:
- resolved gravity suitable to use for a run of text
with
script
-
getForScriptAndWidth
public static Gravity getForScriptAndWidth(Script script, boolean wide, Gravity baseGravity, GravityHint hint) Returns the gravity to use in laying out a single character orPangoItem
.The gravity is determined based on the script, East Asian width, base gravity, and hint,
This function is similar to
getForScript(org.gnome.pango.Script, org.gnome.pango.Gravity, org.gnome.pango.GravityHint)
except that this function makes a distinction between narrow/half-width and wide/full-width characters also. Wide/full-width characters always stand *upright*, that is, they always take the base gravity, whereas narrow/full-width characters are always rotated in vertical context.If
baseGravity
isAUTO
, it is first replaced with the preferred gravity ofscript
.- Parameters:
script
-PangoScript
to querywide
-true
for wide characters as returned by g_unichar_iswide()baseGravity
- base gravity of the paragraphhint
- orientation hint- Returns:
- resolved gravity suitable to use for a run of text
with
script
andwide
.
-
toRotation
public double toRotation()Converts aPangoGravity
value to its natural rotation in radians.Note that
Matrix.rotate(double)
takes angle in degrees, not radians. So, to callPango#Matrix,rotate
with the output of this function you should multiply it by (180. / G_PI).- Returns:
- the rotation value corresponding to this Gravity.
-