|
@@ -0,0 +1,63 @@
|
|
|
+package utils;
|
|
|
+
|
|
|
+import config.subConfig.RoomConfig;
|
|
|
+import config.subConfig.TemplateConfig;
|
|
|
+import config.subConfig.TemplateShadowConfig;
|
|
|
+
|
|
|
+import java.awt.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author duh
|
|
|
+ * @create 2018/7/17 20:10
|
|
|
+ * @email duh@elab-plus.com
|
|
|
+ **/
|
|
|
+public class TemplateUtils {
|
|
|
+ private static RoomConfig room;
|
|
|
+
|
|
|
+ public static void drawTemplate(TemplateConfig template, Graphics g){
|
|
|
+ if(null == room){
|
|
|
+ System.out.println("--------------room is not exist !!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ drawTemplateSelf(template,g);
|
|
|
+ drawShadow(template,g);
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ break;
|
|
|
+ default:break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static RoomConfig getRoom() {
|
|
|
+ return room;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void setRoom(RoomConfig room) {
|
|
|
+ TemplateUtils.room = room;
|
|
|
+ }
|
|
|
+}
|