use of com.codename1.ui.geom.Rectangle2D in project CodenameOne by codenameone.
the class AbstractChart method drawString.
/**
* Draw a multiple lines string.
*
* @param canvas the canvas to paint to
* @param text the text to be painted
* @param x the x value of the area to draw to
* @param y the y value of the area to draw to
* @param paint the paint to be used for drawing
*/
protected void drawString(Canvas canvas, String text, float x, float y, Paint paint) {
if (text != null) {
String[] lines = split(text, "\n");
Rectangle2D rect = new Rectangle2D();
int yOff = 0;
int llen = lines.length;
for (int i = 0; i < llen; ++i) {
canvas.drawText(lines[i], x, y + yOff, paint);
paint.getTextBounds(lines[i], 0, lines[i].length(), rect);
// space between lines is 5
yOff = yOff + (int) rect.getHeight() + 5;
}
}
}
use of com.codename1.ui.geom.Rectangle2D in project CodenameOne by codenameone.
the class Paint method getCN1TextBounds.
void getCN1TextBounds(String string, int start, int count, Rectangle2D rect) {
Font f = getTypeface();
if (f != null) {
int w = f.substringWidth(string, start, count);
int h = f.getHeight();
rect.setBounds(0, 0, w, h);
}
}
Aggregations