Closed GoogleCodeExporter closed 9 years ago
Here is the (ugly ?) hack I made in order to support text highlighing:
private void printItem(TextGraphics graphics, int x, int y, int index) {
String asText = createItemString(index);
if(asText.length() > graphics.getWidth())
asText = asText.substring(0, graphics.getWidth());
if (asText.startsWith("*")) {
graphics.setBoldMask(true);
asText = asText.substring(1, asText.length());
}
if (asText.contains("#red#")) {
int i=0;
for (String pieceOfString: asText.split("#red#")) {
if (((i++) % 2) == 0) {
graphics.drawString(x, y, pieceOfString);
x += pieceOfString.length();
}
else {
Color previousColor = graphics.getBackgroundColor();
graphics.setBackgroundColor(Color.RED);
graphics.drawString(x, y, pieceOfString);
x += pieceOfString.length();
graphics.setBackgroundColor(previousColor);
}
}
}
else
graphics.drawString(x, y, asText);
}
Original comment by jli...@gmail.com
on 3 Jan 2013 at 4:13
I've changed it to protected in the upcoming 2.1.2 release and on default branch
Original comment by mab...@gmail.com
on 4 Jan 2013 at 2:15
Thanks :)
Original comment by jli...@gmail.com
on 4 Jan 2013 at 2:17
Original issue reported on code.google.com by
jli...@gmail.com
on 3 Jan 2013 at 4:12