|
@@ -331,14 +331,65 @@ public class TemplateUtils {
|
|
int twoAlignPosition = position.get(2);
|
|
int twoAlignPosition = position.get(2);
|
|
//画2边贴墙
|
|
//画2边贴墙
|
|
drawAlignTwoTemplateWithArrayPosition(g, twoAlignWall, twoAlignPosition);
|
|
drawAlignTwoTemplateWithArrayPosition(g, twoAlignWall, twoAlignPosition);
|
|
|
|
+ drawAlignOneTemplateWithArrayPosition(g,oneAlignWall,position);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void drawAlignOneTemplateWithArrayPosition(Graphics g, List<Template> oneAlignWall, List<Integer> positions) {
|
|
|
|
+ for(int i = 0;i<oneAlignWall.size();i++){
|
|
|
|
+ Template template = oneAlignWall.get(i);
|
|
|
|
+ int position = positions.get(i);
|
|
|
|
+ drawOneAlignTemplateWithPosition(g,template,position);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void drawOneAlignTemplateWithPosition(Graphics g,Template template, int position) {
|
|
|
|
+ //第几条边
|
|
|
|
+ int bianIndex = 0;
|
|
|
|
+ //画的顺序
|
|
|
|
+ int drawIndex = 0;
|
|
|
|
+ //
|
|
|
|
+ if(position < 100){
|
|
|
|
+ bianIndex = position/10;
|
|
|
|
+ }else {
|
|
|
|
+ bianIndex = position/100;
|
|
|
|
+ }
|
|
|
|
+ if(bianIndex != 4){
|
|
|
|
+ routeTemplate(template,bianIndex);
|
|
|
|
+ }
|
|
|
|
+ switch (bianIndex){
|
|
|
|
+ case 1:
|
|
|
|
+ template.setX(room.getBottomUsed());
|
|
|
|
+ room.setBottomUsed(room.getBottomUsed()+Math.abs(template.getWidth()));
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ template.setX(room.getLength());
|
|
|
|
+ template.setY(room.getRightUsed());
|
|
|
|
+ room.setRightUsed(room.getRightUsed()+Math.abs(template.getLength()));
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ int thisUsed = template.getLength();
|
|
|
|
+ if(thisUsed < 0){
|
|
|
|
+ thisUsed = -thisUsed;
|
|
|
|
+ template.setX(thisUsed);
|
|
|
|
+ }
|
|
|
|
+ template.setX(template.getX()+room.getTopUsed());
|
|
|
|
+ template.setY(template.getY()-room.getWidth());
|
|
|
|
+ room.setTopUsed(room.getTopUsed()+thisUsed);
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ template.setY(room.getLeftUsed());
|
|
|
|
+ room.setLeftUsed(room.getLeftUsed()+Math.abs(template.getWidth()));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ drawTemplate(template,g);
|
|
}
|
|
}
|
|
|
|
|
|
private static void drawAlignTwoTemplateWithArrayPosition(Graphics g, List<Template> twoAlignWall, int twoAlignPosition) {
|
|
private static void drawAlignTwoTemplateWithArrayPosition(Graphics g, List<Template> twoAlignWall, int twoAlignPosition) {
|
|
int wallPointIndex = twoAlignPosition%100/10;
|
|
int wallPointIndex = twoAlignPosition%100/10;
|
|
int alignIndex = twoAlignPosition%10;
|
|
int alignIndex = twoAlignPosition%10;
|
|
Template twoAlignWallTemplate = twoAlignWall.get(0);
|
|
Template twoAlignWallTemplate = twoAlignWall.get(0);
|
|
- int templateX = twoAlignWallTemplate.getX();
|
|
|
|
- int templateY = twoAlignWallTemplate.getY();
|
|
|
|
|
|
+ int templateX = 0;
|
|
|
|
+ int templateY = 0;
|
|
System.out.println("drawAlignTwoTemplateWithArrayPosition 1 ="+templateX+","+templateY);
|
|
System.out.println("drawAlignTwoTemplateWithArrayPosition 1 ="+templateX+","+templateY);
|
|
switch (wallPointIndex){
|
|
switch (wallPointIndex){
|
|
case 2:
|
|
case 2:
|
|
@@ -433,4 +484,30 @@ public class TemplateUtils {
|
|
}
|
|
}
|
|
g2d.dispose();
|
|
g2d.dispose();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 翻转
|
|
|
|
+ * @param template
|
|
|
|
+ * @param type 0:x,y 1:x 2:y
|
|
|
|
+ */
|
|
|
|
+ public static void flippingTemplate(Template template,int type){
|
|
|
|
+ TemplateClearance shadow = template.getShadow();
|
|
|
|
+ switch (type){
|
|
|
|
+ case 0:
|
|
|
|
+ routeTemplateShadow(template,2);
|
|
|
|
+ changeTemplateAlignWall(template,2);
|
|
|
|
+ template.setLength(-template.getLength());
|
|
|
|
+ template.setWidth(-template.getWidth());
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ template.setWidth(template.getY()-template.getWidth());
|
|
|
|
+ shadow.setY(template.getY()-shadow.getY());
|
|
|
|
+ shadow.setDirect((shadow.getDirect()+2)%3);
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ template.setLength(template.getX()-template.getLength());
|
|
|
|
+ shadow.setX(template.getX()-shadow.getX());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|