|
@@ -2,10 +2,10 @@ package utils;
|
|
|
|
|
|
import config.subConfig.AxisConfig;
|
|
|
import config.subConfig.TemplateConfig;
|
|
|
-import config.subConfig.TemplateShadowConfig;
|
|
|
import constant.Constant;
|
|
|
import model.Room;
|
|
|
import model.template.Template;
|
|
|
+import model.template.TemplateShadow;
|
|
|
|
|
|
import java.awt.*;
|
|
|
import java.util.ArrayList;
|
|
@@ -40,8 +40,14 @@ public class TemplateUtils {
|
|
|
int width = template.getWidth();
|
|
|
int x1 = room.getX()+template.getX();
|
|
|
int y1 = room.getY()+template.getY();
|
|
|
- int x2 = x1+length;
|
|
|
- int y2 = y1+width;
|
|
|
+ if(length < 0){
|
|
|
+ length=-length;
|
|
|
+ x1 = x1-length;
|
|
|
+ }
|
|
|
+ if(width < 0){
|
|
|
+ width=-width;
|
|
|
+ y1=y1-width;
|
|
|
+ }
|
|
|
Graphics2D g2d = (Graphics2D) g.create();
|
|
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
g2d.setColor(Color.RED);
|
|
@@ -74,7 +80,7 @@ public class TemplateUtils {
|
|
|
* @param rotateRange
|
|
|
*/
|
|
|
private static void drawTemplateSelfByRotate(Template template, Graphics g,int rotateRange){
|
|
|
- routeTemplateConfig(template,rotateRange);
|
|
|
+ routeTemplate(template,rotateRange);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -82,22 +88,49 @@ public class TemplateUtils {
|
|
|
* @param template
|
|
|
* @param rotateRange
|
|
|
*/
|
|
|
- private static void routeTemplateConfig(Template template, int rotateRange) {
|
|
|
+ public static void routeTemplate(Template template, int rotateRange) {
|
|
|
int length = template.getLength();
|
|
|
int width = template.getWidth();
|
|
|
changeTemplateAlignWall(template,rotateRange);
|
|
|
switch (rotateRange){
|
|
|
case 1:
|
|
|
- template.setY(template.getY()-length);
|
|
|
template.setLength(width);
|
|
|
+ template.setWidth(-length);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ template.setLength(-length);
|
|
|
+ template.setWidth(-width);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ template.setLength(-width);
|
|
|
template.setWidth(length);
|
|
|
break;
|
|
|
+ }
|
|
|
+ routeTemplateShadow(template,rotateRange);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void routeTemplateShadow(Template template, int rotateRange) {
|
|
|
+ TemplateShadow shadow = template.getShadow();
|
|
|
+ int routeX = template.getX();
|
|
|
+ int routeY = template.getY();
|
|
|
+ int shadowX = shadow.getX();
|
|
|
+ int shadowY = shadow.getY();
|
|
|
+ switch (rotateRange){
|
|
|
+ case 1:
|
|
|
+ shadow.setX(-shadowY);
|
|
|
+ shadow.setY(shadowX);
|
|
|
+ break;
|
|
|
case 2:
|
|
|
- template.setX(template.getX()-length);
|
|
|
- template.setY(template.getY()-width);
|
|
|
+ shadow.setX(-shadowX);
|
|
|
+ shadow.setY(-shadowY);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ shadow.setX(shadowY);
|
|
|
+ shadow.setY(-shadowX);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void changeTemplateAlignWall(Template template,int rotateRange){
|
|
|
List<Integer> list = template.getAlignWall();
|
|
|
List<Integer> newlist = new ArrayList<>();
|
|
@@ -113,14 +146,14 @@ public class TemplateUtils {
|
|
|
* @param template
|
|
|
* @param x,y
|
|
|
*/
|
|
|
- private static void routeTemplateConfig(TemplateConfig template, int x,int y) {
|
|
|
+ private static void routeTemplate(TemplateConfig template, int x, int y) {
|
|
|
x = x*Constant.ENLARGE/Constant.NARROW;
|
|
|
y = y*Constant.ENLARGE/Constant.NARROW;
|
|
|
template.setX(template.getX()+x);
|
|
|
template.setY(template.getY()+y);
|
|
|
}
|
|
|
private static void drawShadow(Template template, Graphics g){
|
|
|
- TemplateShadowConfig shadow = template.getShadow();
|
|
|
+ TemplateShadow shadow = template.getShadow();
|
|
|
int cx = room.getX()+template.getX()+shadow.getX();
|
|
|
int cy = room.getY()+template.getY()+shadow.getY();
|
|
|
int x1,y1,x2,y2;
|