|
@@ -19,38 +19,55 @@ public class TemplateUtils {
|
|
|
System.out.println("--------------room is not exist !!");
|
|
|
return;
|
|
|
}
|
|
|
+ drawTemplateName(template,g);
|
|
|
drawTemplateSelf(template,g);
|
|
|
drawShadow(template,g);
|
|
|
}
|
|
|
+
|
|
|
+ private static void drawTemplateName(TemplateConfig template, Graphics g) {
|
|
|
+ int x1 = room.getX()+template.getX()+template.getLength()/2;
|
|
|
+ int y1 = room.getY()+template.getY()+template.getWidth()/2;
|
|
|
+
|
|
|
+ g.drawString(template.getName(), x1, y1);
|
|
|
+ }
|
|
|
+
|
|
|
private static void drawTemplateSelf(TemplateConfig template, Graphics g){
|
|
|
int x1 = room.getX()+template.getX();
|
|
|
int y1 = room.getY()+template.getY();
|
|
|
int x2 = x1+template.getLength();
|
|
|
int y2 = y1+template.getWidth();
|
|
|
- g.drawRect(x1,y1,template.getLength(),template.getWidth());
|
|
|
+ Graphics2D g2d = (Graphics2D) g.create();
|
|
|
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
+ g2d.setColor(Color.RED);
|
|
|
+ g2d.drawRect(x1,y1,template.getLength(),template.getWidth());
|
|
|
+ g2d.dispose();
|
|
|
}
|
|
|
private static void drawShadow(TemplateConfig template, Graphics g){
|
|
|
TemplateShadowConfig shadow = template.getShadow();
|
|
|
int cx = room.getX()+shadow.getX();
|
|
|
int cy = room.getY()+shadow.getY();
|
|
|
int x1,y1,x2,y2;
|
|
|
+ Graphics2D g2d = (Graphics2D) g.create();
|
|
|
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
+ g2d.setColor(Color.GRAY);
|
|
|
switch (shadow.getDirect()){
|
|
|
case 0:
|
|
|
x1 = cx;
|
|
|
y1 = cy - template.getWidth()/2;
|
|
|
x2 = cx+shadow.getRadis();
|
|
|
y2 = cy + template.getWidth()/2;
|
|
|
- g.fillRect(x1,y1,shadow.getRadis(),template.getWidth());
|
|
|
+ g2d.fillRect(x1,y1,shadow.getRadis(),template.getWidth());
|
|
|
break;
|
|
|
case 90:
|
|
|
x1 = cx-shadow.getRadis()/2;
|
|
|
y1 = cy;
|
|
|
x2 = cx+shadow.getRadis();
|
|
|
y2 = cy + template.getWidth()/2;
|
|
|
- g.fillRect(x1,y1,shadow.getRadis(),shadow.getRadis());
|
|
|
+ g2d.fillRect(x1,y1,shadow.getRadis(),shadow.getRadis());
|
|
|
break;
|
|
|
default:break;
|
|
|
}
|
|
|
+ g2d.dispose();
|
|
|
}
|
|
|
|
|
|
public static RoomConfig getRoom() {
|