String comment) {
if (commentLines <= 0)
return;
Tiny2D t2d = getT2D(tile);
TinyFont font = MyArial.getFont();
int commentFontSize = daHeight(tile) / commentLines;
//int commentFontDescent = commentFontSize * font.descent / font.unitsPerEm;
int commentFontAscent = commentFontSize * font.ascent / font.unitsPerEm;
TinyColor fgColor = new TinyColor(commentFgColor);
for (int i = 0; i < tile.pixels32.length; i++)
tile.pixels32[i] = commentBgColor;
int Y = 0; // y position to draw
if (moveStatus != null) {
char[] text = moveStatus.toCharArray();
//#ifdef debug
System.out.println("\t" + moveStatus);
//#endif
int X = daWidth(tile) / 2;
t2d.strokeColor = TinyColor.NONE;
t2d.fillColor = fgColor;
t2d.drawChars(font, commentFontSize, text, 0, text.length, X, Y + commentFontAscent, Tiny2D.TEXT_ANCHOR_MIDDLE);
Y += commentFontSize;
commentLines--;
}
if (commentLines > 0) {
int X = ONE * 2;
// draw move indicator
if (drawSolvedFailedIndicator || drawColorToPlayIndicator) {
t2d.strokeWidth = ONE;
t2d.strokeColor = fgColor;
if (drawSolvedFailedIndicator)
t2d.fillColor = new TinyColor(goodMove ? goodMoveColor : badMoveColor);
else if (drawColorToPlayIndicator)
t2d.fillColor = new TinyColor(black ? blackStoneColor : whiteStoneColor);
t2d.drawOval(X, Y + ONE, commentFontSize - ONE * 2, commentFontSize - ONE * 2);
X = commentFontSize + commentFontSize / 4;
}
if (comment != null) {
char[] text = comment.toCharArray();
//#ifdef debug
System.out.println("\t" + comment);
//#endif
t2d.strokeColor = TinyColor.NONE;
t2d.fillColor = fgColor;
int off = 0; // The current char pointer
int len = 0; // The current length of the line
//int breakOff = -1; // break line at space points
do {
boolean drawChars = len == text.length;
if (!drawChars) {
TinyRect cbox = Tiny2D.charsBounds(font, commentFontSize,
text, off, len, Tiny2D.TEXT_DIR_LR);
if (X + cbox.xmax - cbox.xmin + ONE > daWidth(tile)) {
len--;
drawChars = true;
}
}
if (drawChars){
// Draw the current line
//t2d.matrix = new TinyMatrix();
//if (breakOff <= off || len == text.length)
//breakOff = len;
t2d.drawChars(font, commentFontSize, text, off,
/*breakOff*/len, X, Y + commentFontAscent, Tiny2D.TEXT_ANCHOR_START);
// Advance one line
if (off == 0)
X = ONE;
//off = breakOff + 1;