public final class

BidiUtils

extends Object
java.lang.Object
   ↳ sun.font.BidiUtils

Summary

Public Constructors
BidiUtils()
Public Methods
static int[] createContiguousOrder(int[] values)
Return an array containing contiguous values from 0 to length having the same ordering as the source array.
static int[] createInverseMap(int[] values)
Return the inverse position map.
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.
static int[] createVisualToLogicalMap(byte[] levels)
Given level data, compute a a visual to logical mapping.
static byte[] getLevels(Bidi bidi)
Return an array containing the resolved bidi level of each character, in logical order.
static void getLevels(Bidi bidi, byte[] levels, int start)
Return the level of each character into the levels array starting at start.
static void reorderVisually(byte[] levels, Object[] objects)
Reorder the objects in the array into visual order based on their levels.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BidiUtils ()

Public Methods

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 an array containing the discontiguous values
Returns
  • the contiguous values

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 the source ordering array
Returns
  • the inverse array

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 the source mapping
levels the levels corresponding to the values
start the starting offset in the values and levels arrays
limit the limiting offset in the values and levels arrays
Returns
  • the normlized map

public static int[] createVisualToLogicalMap (byte[] levels)

Given level data, compute a 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 the levels array
Returns
  • the mapping array from visual to logical

public static byte[] getLevels (Bidi bidi)

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

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

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 the array to receive the character levels
start the starting offset into the the array
Throws
IndexOutOfBoundsException if start is less than 0 or start + getLength() is greater than levels.length.

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 an array representing the bidi level of each object
objects the array of objects to be reordered into visual order