@ -53,7 +53,7 @@ class Letters {
private ColorRGBA baseColor = null ;
private ColorRGBA baseColor = null ;
private float baseAlpha = - 1 ;
private float baseAlpha = - 1 ;
private String plainText ;
private String plainText ;
Letters ( BitmapFont font , StringBlock bound , boolean rightToLeft ) {
Letters ( BitmapFont font , StringBlock bound , boolean rightToLeft ) {
final String text = bound . getText ( ) ;
final String text = bound . getText ( ) ;
this . block = bound ;
this . block = bound ;
@ -78,10 +78,10 @@ class Letters {
// Give the letter a default color if
// Give the letter a default color if
// one has been provided.
// one has been provided.
l . setColor ( baseColor ) ;
l . setColor ( baseColor ) ;
}
}
}
}
}
}
LinkedList < Range > ranges = colorTags . getTags ( ) ;
LinkedList < Range > ranges = colorTags . getTags ( ) ;
if ( ! ranges . isEmpty ( ) ) {
if ( ! ranges . isEmpty ( ) ) {
for ( int i = 0 ; i < ranges . size ( ) - 1 ; i + + ) {
for ( int i = 0 ; i < ranges . size ( ) - 1 ; i + + ) {
@ -92,7 +92,7 @@ class Letters {
Range end = ranges . getLast ( ) ;
Range end = ranges . getLast ( ) ;
setColor ( end . start , plainText . length ( ) , end . color ) ;
setColor ( end . start , plainText . length ( ) , end . color ) ;
}
}
invalidate ( ) ;
invalidate ( ) ;
}
}
@ -103,17 +103,17 @@ class Letters {
LetterQuad getTail ( ) {
LetterQuad getTail ( ) {
return tail ;
return tail ;
}
}
void update ( ) {
void update ( ) {
LetterQuad l = head ;
LetterQuad l = head ;
int lineCount = 1 ;
int lineCount = 1 ;
BitmapCharacter ellipsis = font . getCharSet ( ) . getCharacter ( block . getEllipsisChar ( ) ) ;
BitmapCharacter ellipsis = font . getCharSet ( ) . getCharacter ( block . getEllipsisChar ( ) ) ;
float ellipsisWidth = ellipsis ! = null ? ellipsis . getWidth ( ) * getScale ( ) : 0 ;
float ellipsisWidth = ellipsis ! = null ? ellipsis . getWidth ( ) * getScale ( ) : 0 ;
while ( ! l . isTail ( ) ) {
while ( ! l . isTail ( ) ) {
if ( l . isInvalid ( ) ) {
if ( l . isInvalid ( ) ) {
l . update ( block ) ;
l . update ( block ) ;
if ( l . isInvalid ( block ) ) {
if ( l . isInvalid ( block ) ) {
switch ( block . getLineWrapMode ( ) ) {
switch ( block . getLineWrapMode ( ) ) {
case Character :
case Character :
@ -144,7 +144,7 @@ class Letters {
}
}
}
}
break ;
break ;
case NoWrap :
case NoWrap :
LetterQuad cursor = l . getPrevious ( ) ;
LetterQuad cursor = l . getPrevious ( ) ;
while ( cursor . isInvalid ( block , ellipsisWidth ) & & ! cursor . isLineStart ( ) ) {
while ( cursor . isInvalid ( block , ellipsisWidth ) & & ! cursor . isLineStart ( ) ) {
cursor = cursor . getPrevious ( ) ;
cursor = cursor . getPrevious ( ) ;
@ -158,10 +158,10 @@ class Letters {
cursor = cursor . getNext ( ) ;
cursor = cursor . getNext ( ) ;
}
}
break ;
break ;
case Clip :
case Clip :
// Clip the character that falls out of bounds
// Clip the character that falls out of bounds
l . clip ( block ) ;
l . clip ( block ) ;
// Clear the rest up to the next line feed.
// Clear the rest up to the next line feed.
for ( LetterQuad q = l . getNext ( ) ; ! q . isTail ( ) & & ! q . isLineFeed ( ) ; q = q . getNext ( ) ) {
for ( LetterQuad q = l . getNext ( ) ; ! q . isTail ( ) & & ! q . isLineFeed ( ) ; q = q . getNext ( ) ) {
q . setBitmapChar ( null ) ;
q . setBitmapChar ( null ) ;
@ -178,12 +178,12 @@ class Letters {
}
}
l = l . getNext ( ) ;
l = l . getNext ( ) ;
}
}
align ( ) ;
align ( ) ;
block . setLineCount ( lineCount ) ;
block . setLineCount ( lineCount ) ;
rewind ( ) ;
rewind ( ) ;
}
}
private void align ( ) {
private void align ( ) {
final Align alignment = block . getAlignment ( ) ;
final Align alignment = block . getAlignment ( ) ;
final VAlign valignment = block . getVerticalAlignment ( ) ;
final VAlign valignment = block . getVerticalAlignment ( ) ;
@ -233,7 +233,7 @@ class Letters {
l . invalidate ( ) ;
l . invalidate ( ) ;
l . update ( block ) ; // TODO: update from l
l . update ( block ) ; // TODO: update from l
}
}
float getCharacterX0 ( ) {
float getCharacterX0 ( ) {
return current . getX0 ( ) ;
return current . getX0 ( ) ;
}
}
@ -241,54 +241,54 @@ class Letters {
float getCharacterY0 ( ) {
float getCharacterY0 ( ) {
return current . getY0 ( ) ;
return current . getY0 ( ) ;
}
}
float getCharacterX1 ( ) {
float getCharacterX1 ( ) {
return current . getX1 ( ) ;
return current . getX1 ( ) ;
}
}
float getCharacterY1 ( ) {
float getCharacterY1 ( ) {
return current . getY1 ( ) ;
return current . getY1 ( ) ;
}
}
float getCharacterAlignX ( ) {
float getCharacterAlignX ( ) {
return current . getAlignX ( ) ;
return current . getAlignX ( ) ;
}
}
float getCharacterAlignY ( ) {
float getCharacterAlignY ( ) {
return current . getAlignY ( ) ;
return current . getAlignY ( ) ;
}
}
float getCharacterWidth ( ) {
float getCharacterWidth ( ) {
return current . getWidth ( ) ;
return current . getWidth ( ) ;
}
}
float getCharacterHeight ( ) {
float getCharacterHeight ( ) {
return current . getHeight ( ) ;
return current . getHeight ( ) ;
}
}
public boolean nextCharacter ( ) {
public boolean nextCharacter ( ) {
if ( current . isTail ( ) )
if ( current . isTail ( ) )
return false ;
return false ;
current = current . getNext ( ) ;
current = current . getNext ( ) ;
return true ;
return true ;
}
}
public int getCharacterSetPage ( ) {
public int getCharacterSetPage ( ) {
return current . getBitmapChar ( ) . getPage ( ) ;
return current . getBitmapChar ( ) . getPage ( ) ;
}
}
public LetterQuad getQuad ( ) {
public LetterQuad getQuad ( ) {
return current ;
return current ;
}
}
public void rewind ( ) {
public void rewind ( ) {
current = head ;
current = head ;
}
}
public void invalidate ( ) {
public void invalidate ( ) {
invalidate ( head ) ;
invalidate ( head ) ;
}
}
public void invalidate ( LetterQuad cursor ) {
public void invalidate ( LetterQuad cursor ) {
totalWidth = - 1 ;
totalWidth = - 1 ;
totalHeight = - 1 ;
totalHeight = - 1 ;
@ -298,7 +298,7 @@ class Letters {
cursor = cursor . getNext ( ) ;
cursor = cursor . getNext ( ) ;
}
}
}
}
float getScale ( ) {
float getScale ( ) {
return block . getSize ( ) / font . getCharSet ( ) . getRenderedSize ( ) ;
return block . getSize ( ) / font . getCharSet ( ) . getRenderedSize ( ) ;
}
}
@ -306,7 +306,7 @@ class Letters {
public boolean isPrintable ( ) {
public boolean isPrintable ( ) {
return current . getBitmapChar ( ) ! = null ;
return current . getBitmapChar ( ) ! = null ;
}
}
float getTotalWidth ( ) {
float getTotalWidth ( ) {
validateSize ( ) ;
validateSize ( ) ;
return totalWidth ;
return totalWidth ;
@ -316,7 +316,7 @@ class Letters {
validateSize ( ) ;
validateSize ( ) ;
return totalHeight ;
return totalHeight ;
}
}
void validateSize ( ) {
void validateSize ( ) {
if ( totalWidth < 0 ) {
if ( totalWidth < 0 ) {
LetterQuad l = head ;
LetterQuad l = head ;
@ -371,11 +371,11 @@ class Letters {
cursor = cursor . getNext ( ) ;
cursor = cursor . getNext ( ) ;
}
}
}
}
float getBaseAlpha ( ) {
float getBaseAlpha ( ) {
return baseAlpha ;
return baseAlpha ;
}
}
void setBaseAlpha ( float alpha ) { this . baseAlpha = alpha ;
void setBaseAlpha ( float alpha ) { this . baseAlpha = alpha ;
colorTags . setBaseAlpha ( alpha ) ;
colorTags . setBaseAlpha ( alpha ) ;
@ -409,7 +409,7 @@ class Letters {
setColor ( end . start , plainText . length ( ) , end . color ) ;
setColor ( end . start , plainText . length ( ) , end . color ) ;
}
}
}
}
invalidate ( ) ;
invalidate ( ) ;
}
}