source:
advance-wars/src/com/medievaltech/gui/Text.java
Last change on this file was abe7b3d, checked in by , 14 years ago | |
---|---|
|
|
File size: 614 bytes |
Rev | Line | |
---|---|---|
[abe7b3d] | 1 | package com.medievaltech.gui; |
[205f525] | 2 | |
3 | import android.graphics.Canvas; | |
4 | import android.graphics.Paint; | |
5 | ||
6 | public class Text extends GUIObject { | |
7 | private String text; | |
8 | private Paint textPaint; | |
9 | private float vOffset; | |
10 | ||
11 | public Text(String newText, int newX, int newY, int newWidth, int newHeight, Paint textPaint) { | |
12 | super(newX, newY, newWidth, newHeight, null); | |
13 | ||
14 | this.textPaint = textPaint; | |
15 | text = newText; | |
16 | vOffset = -(textPaint.getFontMetrics().ascent+textPaint.getFontMetrics().descent)/2; | |
17 | } | |
18 | ||
19 | public void draw(Canvas c) { | |
20 | c.drawText(text, x+width/2, y+height/2+vOffset, textPaint); | |
21 | } | |
22 | } |
Note:
See TracBrowser
for help on using the repository browser.