📄 normaltext.java
字号:
package com.gameislive.browser.element;
import javax.microedition.lcdui.Graphics;
import com.gameislive.browser.Browser;
/**
* 文本元素
*
* @author pan
*
*/
public class NormalText extends Element{
/**
* 需要渲染的文本
*/
String text;
Browser browser;
int color = 0x000000;
public NormalText(String text,boolean canSelect,int hyperlinkId,int lineId,Browser browser){
super(canSelect,hyperlinkId,lineId,NORMAL_TEXT);
this.text = text;
this.browser = browser;
width = browser.strWidth(text);
height = browser.fontHeight;
}
public void setColor(int color){
this.color = color;
}
public int getWidth(){
return width;
}
public int getHeight(){
return height;
}
public String getString(){
return text;
}
public void draw(int y,int hyperlinks,Graphics g){
// 如果是超链接,则加下划线,且无条件显示为蓝色
if(canSelect){
int w = width;
int h = height;
if(hyperlinksId == hyperlinks){
// 如果当前超链接指向其,则显示超链接背景
g.setColor(0x0000ff);
g.fillRect(x, y, w, h);
g.setColor(0xffffff);
g.drawString(text, x, y, Graphics.TOP|Graphics.LEFT);
}else{
g.setColor(0x0000ff);
g.drawString(text, x, y, Graphics.TOP|Graphics.LEFT);
// y += height;
// g.drawLine(x, y, x+w, y);
}
}else{
// 使用默认的字体颜色
g.setColor(color);
g.drawString(text, x, y, Graphics.TOP|Graphics.LEFT);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -