国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Canvas中使用Font

2019-11-18 15:33:59
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
import javax.microedition.lcdui.*;

public class FontCanvas  extends Canvas {

  PRivate Font mSystemFont, mMonospaceFont, mProportionalFont;
  
  public FontCanvas() { this(Font.STYLE_PLAIN); }
  
  public FontCanvas(int style) { setStyle(style); }
  
  public void setStyle(int style) {
    mSystemFont = Font.getFont(Font.FACE_SYSTEM,
        style, Font.SIZE_MEDIUM);
    mMonospaceFont = Font.getFont(Font.FACE_MONOSPACE,
        style, Font.SIZE_MEDIUM);
    mProportionalFont = Font.getFont(Font.FACE_PROPORTIONAL,
        style, Font.SIZE_MEDIUM);
  }
  
  public boolean isBold() {
    return mSystemFont.isBold();
  }
  public boolean isItalic() {
    return mSystemFont.isItalic();
  }
  public boolean isUnderline() {
    return mSystemFont.isUnderlined();
  }
  
  public void paint(Graphics g) {
    int w = getWidth();
    int h = getHeight();
    
    // Clear the Canvas.
    g.setGrayScale(255);
    g.fillRect(0, 0, w - 1, h - 1);
    g.setGrayScale(0);
    g.drawRect(0, 0, w - 1, h - 1);
    
    int x = w / 2;
    int y = 20;
    
    y += showFont(g, "System", x, y, mSystemFont);
    y += showFont(g, "Monospace", x, y, mMonospaceFont);
    y += showFont(g, "Proportional", x, y, mProportionalFont);
  }

  private int showFont(Graphics g, String s, int x, int y, Font f) {
    g.setFont(f);
    g.drawString(s, x, y, Graphics.TOP  Graphics.HCENTER);
    return f.getHeight();
  }
}進(jìn)入討論組討論。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临邑县| 泌阳县| 阜阳市| 三台县| 静海县| 裕民县| 麻城市| 大厂| 慈溪市| 新乡县| 儋州市| 始兴县| 荣昌县| 江达县| 昂仁县| 福建省| 江孜县| 余江县| 兴和县| 连云港市| 玛曲县| 新巴尔虎右旗| 营山县| 凤城市| 牡丹江市| 柘城县| 石阡县| 昌宁县| 江永县| 塔河县| 奇台县| 赫章县| 汤原县| 丹巴县| 崇礼县| 临沂市| 新蔡县| 章丘市| 韶山市| 三门县| 石景山区|