我是靠谱客的博主 热心裙子,最近开发中收集的这篇文章主要介绍java中setcolor_Java XWPFRun.setColor方法代码示例,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类

/**

* Inserts the given {@link TemplateValidationMessage} in a run next to the one of the given construct subject to the message.

*

* @param message

* the {@link TemplateValidationMessage} to insert

* the error message to insert in a run

* @param offset

* the offset in number of {@link XWPFRun} to insert after {@link TemplateValidationMessage#getLocation() message location}

* @return the number of inserted {@link XWPFRun}

*/

private int addRunError(TemplateValidationMessage message, int offset) {

int res = 0;

if (message.getLocation().getParent() instanceof XWPFParagraph) {

XWPFParagraph paragraph = (XWPFParagraph) message.getLocation().getParent();

final int basePosition = paragraph.getRuns().indexOf(message.getLocation()) + offset;

// separation run.

res++;

final String color = M2DocUtils.getColor(message.getLevel());

XWPFRun newBlankRun = paragraph.insertNewRun(basePosition + res);

newBlankRun.setText(BLANK_SEPARATOR);

res++;

final XWPFRun separationRun = paragraph.insertNewRun(basePosition + res);

separationRun.setText(LOCATION_SEPARATOR);

separationRun.setColor(color);

separationRun.setFontSize(ERROR_MESSAGE_FONT_SIZE);

final CTHighlight separationHighlight = separationRun.getCTR().getRPr().addNewHighlight();

separationHighlight.setVal(STHighlightColor.LIGHT_GRAY);

res++;

final XWPFRun messageRun = paragraph.insertNewRun(basePosition + res);

messageRun.setText(message.getMessage());

messageRun.setColor(color);

messageRun.setFontSize(ERROR_MESSAGE_FONT_SIZE);

final CTHighlight messageHighlight = messageRun.getCTR().getRPr().addNewHighlight();

messageHighlight.setVal(STHighlightColor.LIGHT_GRAY);

}

return res;

}

最后

以上就是热心裙子为你收集整理的java中setcolor_Java XWPFRun.setColor方法代码示例的全部内容,希望文章能够帮你解决java中setcolor_Java XWPFRun.setColor方法代码示例所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部