public class GlyphSequence
extends java.lang.Object
implements java.lang.Cloneable
A GlyphSequence encapsulates a sequence of character codes, a sequence of glyph codes, and a sequence of character associations, where, for each glyph in the sequence of glyph codes, there is a corresponding character association. Character associations server to relate the glyph codes in a glyph sequence to the specific characters in an original character code sequence with which the glyph codes are associated.
This work was originally authored by Glenn Adams (gadams@apache.org).
Modifier and Type | Class and Description |
---|---|
static class |
GlyphSequence.CharAssociation
A structure class encapsulating an interval of characters
expressed as an offset and count of Unicode scalar values (in
an IntBuffer).
|
Constructor and Description |
---|
GlyphSequence(GlyphSequence gs)
Instantiate a glyph sequence using an existing glyph sequence, where the new glyph sequence shares
the character array of the existing sequence (but not the buffer object), and creates new copies
of glyphs buffer and association list.
|
GlyphSequence(GlyphSequence gs,
int[] bga,
int[] iga,
int[] lga,
GlyphSequence.CharAssociation[] bal,
GlyphSequence.CharAssociation[] ial,
GlyphSequence.CharAssociation[] lal)
Instantiate a glyph sequence using an existing glyph sequence, where the new glyph sequence shares
the character array of the existing sequence (but not the buffer object), but uses the specified
backtrack, input, and lookahead glyph arrays to populate the glyphs, and uses the specified
of glyphs buffer and association list.
|
GlyphSequence(java.nio.IntBuffer characters,
java.nio.IntBuffer glyphs,
java.util.List associations)
Instantiate a glyph sequence, reusing (i.e., not copying) the referenced
character and glyph buffers and associations.
|
GlyphSequence(java.nio.IntBuffer characters,
java.nio.IntBuffer glyphs,
java.util.List associations,
boolean predications)
Instantiate a glyph sequence, reusing (i.e., not copying) the referenced
character and glyph buffers and associations.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
int |
compareGlyphs(java.nio.IntBuffer gb)
Compare glyphs.
|
static java.util.List |
concatAssociations(GlyphSequence.CharAssociation[] baa,
GlyphSequence.CharAssociation[] iaa,
GlyphSequence.CharAssociation[] laa)
Concatenante association arrays.
|
static java.nio.IntBuffer |
concatGlyphs(int[] bga,
int[] iga,
int[] lga)
Concatenante glyph arrays.
|
GlyphSequence.CharAssociation |
getAssociation(int index)
Obtain association at specified index.
|
java.util.List |
getAssociations()
Obtain reference to underlying associations list.
|
GlyphSequence.CharAssociation[] |
getAssociations(int offset,
int count)
Obtain count associations starting at offset.
|
int[] |
getCharacterArray(boolean copy)
Obtain array of characters.
|
int |
getCharacterCount()
Obtain the number of characters in character array, where
each character constitutes a unicode scalar value.
|
java.nio.IntBuffer |
getCharacters()
Obtain reference to underlying character buffer.
|
int |
getGlyph(int index)
Obtain glyph id at specified index.
|
int[] |
getGlyphArray(boolean copy)
Obtain array of glyphs.
|
int |
getGlyphCount()
Obtain the number of glyphs in glyphs array, where
each glyph constitutes a font specific glyph index.
|
java.nio.IntBuffer |
getGlyphs()
Obtain reference to underlying glyph buffer.
|
int[] |
getGlyphs(int offset,
int count)
Obtain count glyphs starting at offset.
|
java.lang.Object |
getPredication(int offset,
java.lang.String key)
Get predication KEY at glyph sequence OFFSET.
|
boolean |
getPredications()
Obtain predications state.
|
static GlyphSequence |
join(GlyphSequence gs,
GlyphSequence[] sa)
Join (concatenate) glyph sequences.
|
static GlyphSequence |
reorder(GlyphSequence gs,
int source,
int count,
int target)
Reorder sequence such that [SOURCE,SOURCE+COUNT) is moved just prior to TARGET.
|
static boolean |
sameGlyphs(int[] ga1,
int[] ga2)
Determine if two arrays of glyphs are identical.
|
void |
setGlyph(int index,
int gi)
Set glyph id at specified index.
|
void |
setPredication(int offset,
java.lang.String key,
java.lang.Object value)
Set predication
|
void |
setPredications(boolean enable)
Enable or disable predications.
|
java.lang.String |
toString() |
public GlyphSequence(java.nio.IntBuffer characters, java.nio.IntBuffer glyphs, java.util.List associations, boolean predications)
characters
- a (possibly null) buffer of associated (originating) charactersglyphs
- a (possibly null) buffer of glyphsassociations
- a (possibly null) array of glyph to character associationspredications
- true if predications are enabledpublic GlyphSequence(java.nio.IntBuffer characters, java.nio.IntBuffer glyphs, java.util.List associations)
characters
- a (possibly null) buffer of associated (originating) charactersglyphs
- a (possibly null) buffer of glyphsassociations
- a (possibly null) array of glyph to character associationspublic GlyphSequence(GlyphSequence gs)
gs
- an existing glyph sequencepublic GlyphSequence(GlyphSequence gs, int[] bga, int[] iga, int[] lga, GlyphSequence.CharAssociation[] bal, GlyphSequence.CharAssociation[] ial, GlyphSequence.CharAssociation[] lal)
gs
- an existing glyph sequencebga
- backtrack glyph arrayiga
- input glyph arraylga
- lookahead glyph arraybal
- backtrack association listial
- input association listlal
- lookahead association listpublic java.nio.IntBuffer getCharacters()
public int[] getCharacterArray(boolean copy)
copy
is true, then
a newly instantiated array is returned, otherwise a reference to
the underlying buffer's array is returned. N.B. in case a reference
to the undelying buffer's array is returned, the length
of the array is not necessarily the number of characters in array.
To determine the number of characters, use getCharacterCount()
.copy
- true if to return a newly instantiated array of characterspublic int getCharacterCount()
public int getGlyph(int index) throws java.lang.IndexOutOfBoundsException
index
- to obtain glyphjava.lang.IndexOutOfBoundsException
- if index is less than zero
or exceeds last valid positionpublic void setGlyph(int index, int gi) throws java.lang.IndexOutOfBoundsException
index
- to set glyphgi
- glyph indexjava.lang.IndexOutOfBoundsException
- if index is greater or equal to
the limit of the underlying glyph bufferpublic java.nio.IntBuffer getGlyphs()
public int[] getGlyphs(int offset, int count)
count
is
negative, then it is treated as if the number of available glyphs
were specified.offset
- into glyph sequencecount
- of glyphs to obtain starting at offset, or negative,
indicating all avaialble glyphs starting at offsetpublic int[] getGlyphArray(boolean copy)
copy
is true, then
a newly instantiated array is returned, otherwise a reference to
the underlying buffer's array is returned. N.B. in case a reference
to the undelying buffer's array is returned, the length
of the array is not necessarily the number of glyphs in array.
To determine the number of glyphs, use getGlyphCount()
.copy
- true if to return a newly instantiated array of glyphspublic int getGlyphCount()
public GlyphSequence.CharAssociation getAssociation(int index) throws java.lang.IndexOutOfBoundsException
index
- into associations arrayjava.lang.IndexOutOfBoundsException
- if index is less than zero
or exceeds last valid positionpublic java.util.List getAssociations()
public GlyphSequence.CharAssociation[] getAssociations(int offset, int count)
offset
- into glyph sequencecount
- of associations to obtain starting at offset, or negative,
indicating all avaialble associations starting at offsetpublic void setPredications(boolean enable)
enable
- true if predications are to be enabled; otherwise false to disablepublic boolean getPredications()
public void setPredication(int offset, java.lang.String key, java.lang.Object value)
offset
- offset (index) into glyph sequencekey
- predication keyvalue
- predication valuepublic java.lang.Object getPredication(int offset, java.lang.String key)
offset
- offset (index) into glyph sequencekey
- predication keypublic int compareGlyphs(java.nio.IntBuffer gb)
gb
- buffer containing glyph indices with which this glyph sequence's glyphs are to be comparedpublic java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static boolean sameGlyphs(int[] ga1, int[] ga2)
ga1
- first glyph arrayga2
- second glyph arraypublic static java.nio.IntBuffer concatGlyphs(int[] bga, int[] iga, int[] lga)
bga
- backtrack glyph arrayiga
- input glyph arraylga
- lookahead glyph arraypublic static java.util.List concatAssociations(GlyphSequence.CharAssociation[] baa, GlyphSequence.CharAssociation[] iaa, GlyphSequence.CharAssociation[] laa)
baa
- backtrack association arrayiaa
- input association arraylaa
- lookahead association arraypublic static GlyphSequence join(GlyphSequence gs, GlyphSequence[] sa)
gs
- original glyph sequence from which to reuse character array referencesa
- array of glyph sequences, whose glyph arrays and association lists are to be concatenatedpublic static GlyphSequence reorder(GlyphSequence gs, int source, int count, int target)
gs
- input sequencesource
- index of sub-sequence to reordercount
- length of sub-sequence to reordertarget
- index to which source sub-sequence is to be movedCopyright 1999-2012 The Apache Software Foundation. All Rights Reserved.