APIdia Launch Partner
Top Fields Constructors Methods
sun.font

public final Class BidiUtils

extends Object
Class Inheritance
Imports
java.text.Bidi

Field Summary

Modifier and TypeField and Description
pack-priv static final char

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static int[]
computeContiguousOrder(int[] values, int start, int limit)

Compute a contiguous order for the range start, limit.

public static int[]

Returns:

the contiguous values
createContiguousOrder
(int[]
an array containing the discontiguous values
values
)

Return an array containing contiguous values from 0 to length having the same ordering as the source array.

public static int[]

Returns:

the inverse array
createInverseMap
(int[]
the source ordering array
values
)

Return the inverse position map.

public static int[]

Returns:

the normalized map
createNormalizedMap
(int[]
the source mapping
values
,
byte[]
the levels corresponding to the values
levels
,
int
the starting offset in the values and levels arrays
start
,
int
the limiting offset in the values and levels arrays
limit
)

Return an array containing the data in the values array from start up to limit, normalized to fall within the range from 0 up to limit - start.

public static int[]

Returns:

the mapping array from visual to logical
createVisualToLogicalMap
(byte[]
the levels array
levels
)

Given level data, compute a visual to logical mapping.

public static void
getLevels(Bidi bidi, byte[]
the array to receive the character levels
levels
,
int
the starting offset into the array
start
)

Return the level of each character into the levels array starting at start.

public static byte[]

Returns:

an array containing the level of each character, in logical order.
getLevels
(Bidi bidi)

Return an array containing the resolved bidi level of each character, in logical order.

public static void
reorderVisually(byte[]
an array representing the bidi level of each object
levels
,
Object[]
the array of objects to be reordered into visual order
objects
)

Reorder the objects in the array into visual order based on their levels.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NUMLEVELSback to summary
pack-priv static final char NUMLEVELS

Constructor Detail

BidiUtilsback to summary
public BidiUtils()

Method Detail

computeContiguousOrderback to summary
private static int[] computeContiguousOrder(int[] values, int start, int limit)

Compute a contiguous order for the range start, limit.

createContiguousOrderback to summary
public static int[] createContiguousOrder(int[] values)

Return an array containing contiguous values from 0 to length having the same ordering as the source array. If this would be a canonical ltr ordering, return null. The data in values[] is NOT required to be a permutation, but elements in values are required to be distinct.

Parameters
values:int[]

an array containing the discontiguous values

Returns:int[]

the contiguous values

createInverseMapback to summary
public static int[] createInverseMap(int[] values)

Return the inverse position map. The source array must map one-to-one (each value is distinct and the values run from zero to the length of the array minus one). For example, if values[i] = j, then inverse[j] = i.

Parameters
values:int[]

the source ordering array

Returns:int[]

the inverse array

createNormalizedMapback to summary
public static int[] createNormalizedMap(int[] values, byte[] levels, int start, int limit)

Return an array containing the data in the values array from start up to limit, normalized to fall within the range from 0 up to limit - start. If this would be a canonical ltr ordering, return null.

Note

This method assumes that values[] is a logical to visual map generated from levels[].

Parameters
values:int[]

the source mapping

levels:byte[]

the levels corresponding to the values

start:int

the starting offset in the values and levels arrays

limit:int

the limiting offset in the values and levels arrays

Returns:int[]

the normalized map

createVisualToLogicalMapback to summary
public static int[] createVisualToLogicalMap(byte[] levels)

Given level data, compute a visual to logical mapping. The leftmost (or topmost) character is at visual index zero. The logical index of the character is derived from the visual index by the expression li = map[vi];.

Parameters
levels:byte[]

the levels array

Returns:int[]

the mapping array from visual to logical

getLevelsback to summary
public static void getLevels(Bidi bidi, byte[] levels, int start)

Return the level of each character into the levels array starting at start. This is a convenience method for clients who prefer to use an explicit levels array instead of iterating over the runs.

Parameters
levels:byte[]

the array to receive the character levels

start:int

the starting offset into the array

Exceptions
IndexOutOfBoundsException:
if start is less than 0 or start + getLength() is greater than levels.length.
getLevelsback to summary
public static byte[] getLevels(Bidi bidi)

Return an array containing the resolved bidi level of each character, in logical order.

Returns:byte[]

an array containing the level of each character, in logical order.

reorderVisuallyback to summary
public static void reorderVisually(byte[] levels, Object[] objects)

Reorder the objects in the array into visual order based on their levels. This is a utility function to use when you have a collection of objects representing runs of text in logical order, each run containing text at a single level. The elements in the objects array will be reordered into visual order assuming each run of text has the level provided by the corresponding element in the levels array.

Parameters
levels:byte[]

an array representing the bidi level of each object

objects:Object[]

the array of objects to be reordered into visual order