Commit 1b130e8f by xmh

修改字幕高度计算方式

1 parent 9a899c4e
...@@ -191,11 +191,11 @@ public class Generator { ...@@ -191,11 +191,11 @@ public class Generator {
if (j == 0 && captionNode.getTop() != null) { if (j == 0 && captionNode.getTop() != null) {
caption = captionNode.getTop(); caption = captionNode.getTop();
content = captionNode.getTopContent(); content = captionNode.getTopContent();
height = String.valueOf(captionNode.getTopHeight()); height = item.getMaxTopCaptionHeight();
} else if (j == 1 && captionNode.getBottom() != null) { } else if (j == 1 && captionNode.getBottom() != null) {
caption = captionNode.getBottom(); caption = captionNode.getBottom();
content = captionNode.getBottomContent(); content = captionNode.getBottomContent();
height = String.valueOf(captionNode.getBottomHeight()); height = item.getMaxBottomCaptionHeight();
} else if (j == 2 && captionNode.getSecond() != null) { } else if (j == 2 && captionNode.getSecond() != null) {
caption = captionNode.getSecond(); caption = captionNode.getSecond();
content = captionNode.getSecondContent(); content = captionNode.getSecondContent();
...@@ -406,6 +406,40 @@ public class Generator { ...@@ -406,6 +406,40 @@ public class Generator {
return String.valueOf(maxPaddingTop); 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 { ...@@ -600,7 +634,7 @@ public class Generator {
String dateFormat = (vo.getMillisecond() != null && vo.getMillisecond()) ? vo.getDateFormat() + ".xxx" : vo.getDateFormat(); String dateFormat = (vo.getMillisecond() != null && vo.getMillisecond()) ? vo.getDateFormat() + ".xxx" : vo.getDateFormat();
Pair<String, Integer> pair = combineCaptionContent(vo.getPicType(), vo.getContexts(), dateFormat); Pair<String, Integer> pair = combineCaptionContent(vo.getPicType(), vo.getContexts(), dateFormat);
Integer wrapCount = pair.getValue(); Integer wrapCount = pair.getValue();
int height = wrapCount == 0 ? fontSize + 10 : (wrapCount + 1) * (fontSize + 10); int height = (wrapCount + 1) * fontSize + 10;
switch (positionType) { switch (positionType) {
case 0: case 0:
this.top = vo; this.top = vo;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!