|
@@ -228,10 +228,43 @@ public class TemplateUtils {
|
|
|
return templateTotalLength<=room.getLength();
|
|
|
}
|
|
|
public static void calcYizhiTemplatesAndDraw(List<TemplateConfig> templateConfigs,Graphics g){
|
|
|
- int roomAlign = 3;
|
|
|
- int positionOff = 0;
|
|
|
+ List<Template> oneAlignWall = new ArrayList<>();
|
|
|
+ List<Template> twoAlignWall = new ArrayList<>();
|
|
|
for (TemplateConfig templateConfig : templateConfigs){
|
|
|
Template template = new Template(templateConfig);
|
|
|
+ List<Integer> alignWall = template.getAlignWall();
|
|
|
+ if(alignWall.size() == 1){
|
|
|
+ oneAlignWall.add(template);
|
|
|
+ }else if(alignWall.size() == 2){
|
|
|
+ twoAlignWall.add(template);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ drawTwoAlignWallTemplates(twoAlignWall,g);
|
|
|
+ drawOneAlignWallTemplates(oneAlignWall,g);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void drawTwoAlignWallTemplates(List<Template> twoAlignWall, Graphics g) {
|
|
|
+ int roomAlign = 3;
|
|
|
+ int positionOff = 0;
|
|
|
+ for(Template template:twoAlignWall){
|
|
|
+ int begin = template.getAlignWall().get(0);
|
|
|
+ int routeTimes = roomAlign-begin-1;
|
|
|
+ if(routeTimes<0){
|
|
|
+ routeTimes += 4;
|
|
|
+ }
|
|
|
+ if(routeTimes!=0){
|
|
|
+ routeTemplate(template,routeTimes);
|
|
|
+ }
|
|
|
+ template.setX(room.getLength());
|
|
|
+ template.setY(template.getY()-room.getWidth());
|
|
|
+ drawTemplate(template,g);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void drawOneAlignWallTemplates(List<Template> templates,Graphics g){
|
|
|
+ int roomAlign = 3;
|
|
|
+ int positionOff = 0;
|
|
|
+ for (Template template : templates){
|
|
|
List<Integer> alignWall = template.getAlignWall();
|
|
|
int templateAlignWall = alignWall.get(0);
|
|
|
int routeTimes = roomAlign-templateAlignWall%4;
|
|
@@ -245,6 +278,15 @@ public class TemplateUtils {
|
|
|
if(template.getLength()<0){
|
|
|
template.setX(template.getX()-template.getLength());
|
|
|
}
|
|
|
+ //放模板后,其他模板需要依次移动positionOff位置
|
|
|
+ template.setX(template.getX()+positionOff);
|
|
|
+ System.out.println("positionOff 1 = " + positionOff);
|
|
|
+ if((templateAlignWall+routeTimes)%2==0){
|
|
|
+ positionOff+=Math.abs(template.getWidth());
|
|
|
+ }else {
|
|
|
+ positionOff+=Math.abs(template.getLength());
|
|
|
+ }
|
|
|
+ System.out.println("positionOff 2 = " + positionOff);
|
|
|
drawTemplate(template,g);
|
|
|
}
|
|
|
}
|