用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

花花shij    -  云代码空间

——

坦克

2017-11-08|1053阅||

摘要:package ObjectT; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Point; import MapT.ObjectPanel

package ObjectT;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import MapT.ObjectPanel;
/**
 * 画字符串的构件
 *
 */
public class ObjString {
 private Point location;
 private String content;
 
 private static Color color=Color.white;
 private static Font font=new Font("方正少儿_GBK", Font.BOLD, 20);
 private Color mcolor=null;
 private Font mfont=null;
 
 
 private final ObjectPanel objp;
 
 private boolean drawNow=true;
 
 public ObjString(Point location,String content,ObjectPanel objp) {
  this.location=location;
  this.objp=objp;
  this.content=content;
 }
 /**
  * 画字符串
  *
  */
 public void Draw(Graphics g){
  
  
  if(mcolor==null&&g.getColor()!=color)g.setColor(color);
  else if(mcolor!=null)g.setColor(mcolor);
  if(mfont==null&&g.getFont()!=font)g.setFont(font);
  else if(mfont!=null)g.setFont(mfont);
  g.drawString(content, location.x, location.y);
 }
 /**
  * 重画
  */
 public void repaint(){
  if(drawNow){
   objp.reDraw();
  }
 }
 public static Color getColor() {
  return color;
 }
 public static void setColor(Color color0) {
  color = color0;
 }
 public Point getLocation() {
  return location;
 }
 public void setLocation(Point location) {
  this.location.setLocation(location);
  repaint();
 }
 public void setLocation(int x,int y) {
  this.location.setLocation(x,y);
  repaint();
 }
 
 public void setX(int x) {
  this.location.x = x;
  repaint();
 }
 public void setY(int y) {
  this.location.y = y;
  repaint();
 }
 public int getX() {
  return this.location.x;
 }
 public int getY() {
  return this.location.y;
 }
 public ObjectPanel getObjp() {
  return objp;
 }
 public boolean isDrawNow() {
  return drawNow;
 }
 public void setDrawNow(boolean drawNow) {
  this.drawNow = drawNow;
  repaint();
 }
 public void setContent(String content) {
  this.content = content;
  repaint();
 }
 public String getContent() {
  return content;
 }
 public static void setFont(Font font0) {
  font = font0;
 }
 public static Font getFont() {
  return font;
 }
 public void setMcolor(Color mcolor) {
  this.mcolor = mcolor;
 }
 public Color getMcolor() {
  return mcolor;
 }
 public void setMfont(Font mfont) {
  this.mfont = mfont;
 }
 public Font getMfont() {
  return mfont;
 }
}
顶 0踩 0收藏
文章评论
    发表评论

    个人资料

    • 昵称: 花花shij
    • 等级: 初级程序员
    • 积分: 12
    • 代码: 0 个
    • 文章: 7 篇
    • 随想: 0 条
    • 访问: 4 次
    • 关注

    人气文章

    人气代码

      最新提问

        站长推荐