|
@@ -23,7 +23,7 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
private final BigDecimal bw = this.w.add(BigDecimal.valueOf((MaterialsConstant.RESERVE)));
|
|
|
|
|
|
/**
|
|
|
- * 不考虑旋转出血面积
|
|
|
+ * 出血面积
|
|
|
*/
|
|
|
private final BigDecimal bArea = bl.multiply(bw);
|
|
|
|
|
@@ -50,6 +50,8 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
TypeSettingBo demo = fixation3040.next();
|
|
|
System.out.println(JSONObject.toJSONString(demo));
|
|
|
}
|
|
|
+
|
|
|
+ System.out.println(JSONObject.toJSONString(fixation3040));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -59,15 +61,12 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
throw new ServiceException("无法继续排版");
|
|
|
}
|
|
|
|
|
|
- TypeSettingBo typeSettingBo = getTypeSettingBo();
|
|
|
-
|
|
|
- if (typeSettingBo == null) {
|
|
|
- typeSettingBo = new TypeSettingBo(
|
|
|
- this.masterArea, this.bArea, BigDecimal.ONE, BigDecimal.ZERO, BigDecimal.ZERO,
|
|
|
- this.l, this.w, this.bl, false);
|
|
|
-
|
|
|
- setTypeSettingBo(typeSettingBo);
|
|
|
- return typeSettingBo;
|
|
|
+ if (this.typeSettingBo == null) {
|
|
|
+ this.maxLength = this.bl;
|
|
|
+ this.usedArea = this.bArea;
|
|
|
+ this.schedulingNum = BigDecimal.ONE;
|
|
|
+ setNextTypeSettingBo(BigDecimal.ZERO, BigDecimal.ZERO, false);
|
|
|
+ return this.typeSettingBo;
|
|
|
}
|
|
|
|
|
|
// 对比排第一列最大高度小还是第三列最大高度小
|
|
@@ -76,23 +75,21 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
BigDecimal tempMinY3 = this.y3.add(this.bl);
|
|
|
|
|
|
// 排版个数为偶数时,排第二列或者第四列
|
|
|
- if (typeSettingBo.getSchedulingNum().add(BigDecimal.ONE).intValue() % 2 == 0) {
|
|
|
-
|
|
|
+ if (schedulingNum.add(BigDecimal.ONE).intValue() % 2 == 0) {
|
|
|
// 如果第一列和第二列轴不相等,则排第二列
|
|
|
if (this.y1.compareTo(this.y2) != 0) {
|
|
|
- setNextTypeSettingBo(typeSettingBo, this.x2, this.y2, false);
|
|
|
+ setNextTypeSettingBo(this.x2, this.y2, false);
|
|
|
this.y2 = this.y2.add(this.bl);
|
|
|
}
|
|
|
// 否则排第四列
|
|
|
else {
|
|
|
- setNextTypeSettingBo(typeSettingBo, this.x4, this.y4, true);
|
|
|
+ setNextTypeSettingBo(this.x4, this.y4, true);
|
|
|
this.y4 = this.y4.add(this.bw);
|
|
|
}
|
|
|
-
|
|
|
// 判断是否还能继续排版
|
|
|
- if (tempY1.compareTo(masterLength) > 0
|
|
|
- && tempY3.compareTo(masterLength) > 0
|
|
|
- && tempMinY3.compareTo(masterLength) > 0) {
|
|
|
+ if (tempY1.compareTo(this.masterLength) > 0
|
|
|
+ && tempY3.compareTo(this.masterLength) > 0
|
|
|
+ && tempMinY3.compareTo(this.masterLength) > 0) {
|
|
|
this.hasNext = false;
|
|
|
}
|
|
|
}
|
|
@@ -101,62 +98,49 @@ public class Fixation_30_40 extends FixationStrategy {
|
|
|
else {
|
|
|
// 如果第一列后高度小于等于排第三列后高度,则排第一列
|
|
|
if (tempY1.compareTo(tempY3) <= 0) {
|
|
|
- BigDecimal maxLength = tempY1.compareTo(this.y3) > 0 ? tempY1 : this.y3;
|
|
|
- setNextTypeSettingBo(typeSettingBo, this.x1, this.y1, maxLength, false);
|
|
|
+ setNextTypeSettingBo(this.x1, this.y1, false);
|
|
|
this.y1 = tempY1;
|
|
|
+ this.maxLength = this.y1.compareTo(this.y3) > 0 ? this.y1 : this.y3;
|
|
|
}
|
|
|
// 否则排第三列
|
|
|
else {
|
|
|
// 如果第三列高度无法旋转排版,则表示第三列第四列合并排版非选择垫子
|
|
|
if (tempY3.compareTo(masterLength) > 0) {
|
|
|
- setNextTypeSettingBo(typeSettingBo, this.x3, this.y3, false);
|
|
|
+ setNextTypeSettingBo(this.x3, this.y3, false);
|
|
|
this.y3 = tempMinY3;
|
|
|
this.hasNext = false;
|
|
|
}
|
|
|
// 旋转排版
|
|
|
else {
|
|
|
- BigDecimal maxLength = this.y1.compareTo(tempY3) > 0 ? this.y1 : tempY3;
|
|
|
- setNextTypeSettingBo(typeSettingBo, this.x3, this.y3, maxLength, true);
|
|
|
+ setNextTypeSettingBo(this.x3, this.y3, true);
|
|
|
this.y3 = tempY3;
|
|
|
+ this.maxLength = this.y1.compareTo(y3) > 0 ? this.y1 : this.y3;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return getTypeSettingBo();
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 赋值下一个排版参数
|
|
|
- *
|
|
|
- * @param typeSettingBo 当前排版参数
|
|
|
- * @param x x轴
|
|
|
- * @param y y轴
|
|
|
- * @param hasRotate 是否旋转
|
|
|
- */
|
|
|
- private void setNextTypeSettingBo(TypeSettingBo typeSettingBo, BigDecimal x, BigDecimal y, Boolean hasRotate) {
|
|
|
- setNextTypeSettingBo(typeSettingBo, x, y, typeSettingBo.getMaxLength(), hasRotate);
|
|
|
+ this.usedArea = this.usedArea.add(this.bArea);
|
|
|
+ this.schedulingNum = this.schedulingNum.add(BigDecimal.ONE);
|
|
|
+
|
|
|
+ return this.typeSettingBo;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 赋值下一个排版参数
|
|
|
*
|
|
|
- * @param typeSettingBo 当前排版参数
|
|
|
- * @param x x轴
|
|
|
- * @param y y轴
|
|
|
- * @param maxLength 最大长度
|
|
|
- * @param hasRotate 是否旋转
|
|
|
+ * @param x x轴
|
|
|
+ * @param y y轴
|
|
|
+ * @param hasRotate 是否旋转
|
|
|
*/
|
|
|
- private void setNextTypeSettingBo(TypeSettingBo typeSettingBo, BigDecimal x, BigDecimal y, BigDecimal maxLength, Boolean hasRotate) {
|
|
|
- TypeSettingBo nextTypeSettingBo = new TypeSettingBo(
|
|
|
- this.masterArea,
|
|
|
- typeSettingBo.getUsedArea().add(this.bArea),
|
|
|
- typeSettingBo.getSchedulingNum().add(BigDecimal.ONE),
|
|
|
- x, y,
|
|
|
+ private void setNextTypeSettingBo(BigDecimal x, BigDecimal y, Boolean hasRotate) {
|
|
|
+ this.typeSettingBo = new TypeSettingBo(
|
|
|
+ x,
|
|
|
+ y,
|
|
|
hasRotate ? this.w : this.l,
|
|
|
hasRotate ? this.l : this.w,
|
|
|
- maxLength,
|
|
|
- hasRotate);
|
|
|
-
|
|
|
- setTypeSettingBo(nextTypeSettingBo);
|
|
|
+ hasRotate
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
}
|