Commit 1b130e8f by xmh

修改字幕高度计算方式

1 parent 9a899c4e
......@@ -191,11 +191,11 @@ public class Generator {
if (j == 0 && captionNode.getTop() != null) {
caption = captionNode.getTop();
content = captionNode.getTopContent();
height = String.valueOf(captionNode.getTopHeight());
height = item.getMaxTopCaptionHeight();
} else if (j == 1 && captionNode.getBottom() != null) {
caption = captionNode.getBottom();
content = captionNode.getBottomContent();
height = String.valueOf(captionNode.getBottomHeight());
height = item.getMaxBottomCaptionHeight();
} else if (j == 2 && captionNode.getSecond() != null) {
caption = captionNode.getSecond();
content = captionNode.getSecondContent();
......@@ -406,6 +406,40 @@ public class Generator {
return String.valueOf(maxPaddingTop);
}
private String getMaxTopCaptionHeight() {
PicNode node = this;
int maxTop = Integer.MIN_VALUE;
while (node != null) {
int topHeight = node.getCaptionNode().getTopHeight() == null ? 0 : node.getCaptionNode().getTopHeight();
maxTop = Math.max(maxTop, topHeight);
node = node.getLeft();
}
node = this;
while (node != null) {
int topHeight = node.getCaptionNode().getTopHeight() == null ? 0 : node.getCaptionNode().getTopHeight();
maxTop = Math.max(maxTop, topHeight);
node = node.getRight();
}
return String.valueOf(maxTop);
}
private String getMaxBottomCaptionHeight() {
PicNode node = this;
int maxBottom = Integer.MIN_VALUE;
while (node != null) {
int bottomHeight = node.getCaptionNode().getBottomHeight() == null ? 0 : node.getCaptionNode().getBottomHeight();
maxBottom = Math.max(maxBottom, bottomHeight);
node = node.getLeft();
}
node = this;
while (node != null) {
int bottomHeight = node.getCaptionNode().getBottomHeight() == null ? 0 : node.getCaptionNode().getBottomHeight();
maxBottom = Math.max(maxBottom, bottomHeight);
node = node.getRight();
}
return String.valueOf(maxBottom);
}
/**
* 获取一个图片节点的左侧图片节点
*/
......@@ -600,7 +634,7 @@ public class Generator {
String dateFormat = (vo.getMillisecond() != null && vo.getMillisecond()) ? vo.getDateFormat() + ".xxx" : vo.getDateFormat();
Pair<String, Integer> pair = combineCaptionContent(vo.getPicType(), vo.getContexts(), dateFormat);
Integer wrapCount = pair.getValue();
int height = wrapCount == 0 ? fontSize + 10 : (wrapCount + 1) * (fontSize + 10);
int height = (wrapCount + 1) * fontSize + 10;
switch (positionType) {
case 0:
this.top = vo;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!