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;
}
}