📅  最后修改于: 2022-03-11 14:58:31.302000             🧑  作者: Mango
private List textWithRectangleList = new ArrayList<>();
private void renderText(TextRenderInfo renderInfo) {
if (renderInfo.getText().trim().length() == 0)
return;
LineSegment ascent = renderInfo.getAscentLine();
LineSegment descent = renderInfo.getDescentLine();
float initX = descent.getStartPoint().get(0);
float initY = descent.getStartPoint().get(1);
float endX = ascent.getEndPoint().get(0);
float endY = ascent.getEndPoint().get(1);
Rectangle rectangle = new Rectangle(initX, initY, endX - initX, endY - initY);
SimpleTextWithRectangle textWithRectangle = new SimpleTextWithRectangle(rectangle, renderInfo.getText());
textWithRectangleList.add(textWithRectangle);
}
public List getResultantTextWithPosition() {
return textWithRectangleList;
}
@Override
public void eventOccurred(IEventData data, EventType type) {
renderText((TextRenderInfo) data);
}
@Override
public Set getSupportedEvents() {
return Collections.unmodifiableSet(new LinkedHashSet<>(Collections.singletonList(EventType.RENDER_TEXT)));
}