public void draw(Canvas canvas, float left, float top) { layout(); // System.out.println("Text: " + _block.getText()); Bitmap icon = _style.getIcon(_context); if (icon != null) { canvas.drawBitmap(icon, left + _icon_left, top + _icon_top, null); } _block.draw(canvas, left + _text_left, top + _text_top, _style.getTextAlign()); }
public float getPreferredWidth() { float width = _style.getPaint(_context).measureText(_block.getText()); if (width > FullScreen.getFullScreenWidth(_context)) { width = FullScreen.getFullScreenWidth(_context) * 1.0f; } return width; }
public boolean setStyle(TextStyleDescriptor style) { if (_style == null || (style != null && !_style.equals(style))) { _style = style; _change = true; return true; } else { return false; } }
private void layout() { if (!_change) { return; } _change = false; // System.out.println("layout: width=" + _prefer_width + _block.getText()); _block.setPaint(_style.getPaint(_context)); _block.setWidthBound(_style.getMaxTextWidth(_context, _prefer_width)); _block.setSpacing(_style.getTextSpacing()); _block.setLineCount(_style.getTextLineLimit()); _style.layout(_context, _prefer_width, _prefer_height, _block.getWidth(), _block.getHeight()); _width = _style._width; _height = _style._height; _text_left = _style._text_left; _text_top = _style._text_top; _icon_left = _style._icon_left; _icon_top = _style._icon_top; }