本文整理汇总了Java中rst.pdfbox.layout.text.Alignment类的典型用法代码示例。如果您正苦于以下问题:Java Alignment类的具体用法?Java Alignment怎么用?Java Alignment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Alignment类属于rst.pdfbox.layout.text包,在下文中一共展示了Alignment类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
@Override
public void render(Document target, int indent, CertificateStyle style) throws IOException {
int offset = indent * style.getListIndent();
for (Element item : items) {
if (item instanceof ElementList) {
((ElementList)item).render(target, indent+1, style);
} else if (item instanceof ElementText) {
Paragraph paragraph = new Paragraph();
paragraph.add(new Indent(getListItemIndicator(indent), offset, SpaceUnit.pt, style.getTextSize(),
getListItemIndicatorFont(style).getPlainFont(), Alignment.Right));
paragraph.addMarkup(((ElementText)item).getText(), style.getTextSize(), style.getTextFont());
target.add(paragraph);
} else {
throw new IllegalStateException("Unsupported element");
}
}
}
示例2: writeAttributes
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
private void writeAttributes() throws IOException {
List<InstanceAttribute> instanceAttributes = data.getInstanceAttributes();
if (!instanceAttributes.isEmpty()) {
resetLayout();
drawHorizontalSeparator();
Paragraph mapTitle = new Paragraph();
mapTitle.addText(data.getBundleString("attributes"), TITLE_MAP_SIZE, TEXT_BOLD_FONT);
breakLine(mapTitle);
document.add(mapTitle, new VerticalLayoutHint(Alignment.Left, 0, 0, 0, MAP_TITLE_MARGIN_BOTTOM));
InstanceAttribute headerAttribute = new InstanceTextAttribute(
data.getBundleString("attributes.name"),
data.getBundleString("attributes.value"),
false
);
writeAttribute(headerAttribute, true);
for (InstanceAttribute attr : instanceAttributes) {
writeAttribute(attr, false);
}
}
}
示例3: drawWorkflow
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
private void drawWorkflow(Workflow workflow) throws IOException {
if (workflow != null) {
resetLayout();
drawHorizontalSeparator();
Paragraph paragraph = new Paragraph();
paragraph.addText(data.getBundleString("lifecycle"), TITLE_MAP_SIZE, TEXT_BOLD_FONT);
document.add(paragraph, new VerticalLayoutHint(Alignment.Left, 0, 0, 0, 10));
for (Activity activity : workflow.getActivities()) {
drawActivity(activity);
}
}
}
示例4: afterPage
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
@Override
public void afterPage(RenderContext renderContext) throws IOException {
String content = String.format("Section %s, Page %s",
sectionNumber, renderContext.getPageIndex() + 1);
TextFlow text = TextFlowUtil.createTextFlow(content, 11,
PDType1Font.TIMES_ROMAN);
float offset = renderContext.getPageFormat().getMarginLeft()
+ TextSequenceUtil.getOffset(text,
renderContext.getWidth(), Alignment.Right);
text.drawText(renderContext.getContentStream(), new Position(
offset, 30), Alignment.Right, null);
}
示例5: writeEntityInfo
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
private void writeEntityInfo() throws IOException {
Paragraph titleParagraph = new Paragraph();
titleParagraph.addText(data.getTitle(), DOCUMENT_TITLE_SIZE, TEXT_BOLD_FONT);
document.add(titleParagraph, new VerticalLayoutHint(Alignment.Left, 0, 0, 0, TITLE_MARGIN_BOTTOM));
Paragraph paragraph = new Paragraph();
paragraph.addText(data.getBundleString("original.author"), TEXT_SIZE, TEXT_BOLD_FONT);
space(paragraph);
paragraph.addText(data.getAuthorName(), TEXT_SIZE, TEXT_REGULAR_FONT);
breakLine(paragraph);
paragraph.addText(data.getBundleString("iteration.date"), TEXT_SIZE, TEXT_BOLD_FONT);
space(paragraph);
paragraph.addText(data.getCreationDate(), TEXT_SIZE, TEXT_REGULAR_FONT);
breakLine(paragraph);
paragraph.addText(data.getBundleString("iteration"), TEXT_SIZE, TEXT_BOLD_FONT);
space(paragraph);
paragraph.addText(data.getCurrentIteration(), TEXT_SIZE, TEXT_REGULAR_FONT);
breakLine(paragraph);
paragraph.addText(data.getBundleString("iteration.date"), TEXT_SIZE, TEXT_BOLD_FONT);
space(paragraph);
paragraph.addText(data.getIterationDate(), TEXT_SIZE, TEXT_REGULAR_FONT);
breakLine(paragraph);
String revisionNote = data.getRevisionNote();
if (revisionNote != null) {
paragraph.addText(data.getBundleString("iteration.note"), TEXT_SIZE, TEXT_BOLD_FONT);
space(paragraph);
paragraph.addText(revisionNote, TEXT_SIZE, TEXT_REGULAR_FONT);
}
document.add(paragraph, new VerticalLayoutHint(Alignment.Left, 0, 0, 0, 5));
String description = data.getDescription();
if (description != null && !description.isEmpty()) {
drawLightHorizontalSeparator();
Paragraph descriptionParagraph = new Paragraph();
descriptionParagraph.addText(description, TEXT_SIZE, TEXT_ITALIC_FONT);
document.add(descriptionParagraph);
}
}
示例6: drawTask
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
private void drawTask(Task task) throws IOException {
String iconMessage;
String taskMessage;
switch (task.getStatus()) {
case APPROVED:
iconMessage = "\uf00c";
taskMessage = data.getBundleString("lifecycle.approved");
break;
case REJECTED:
iconMessage = "\uf00d";
taskMessage = data.getBundleString("lifecycle.rejected");
break;
default:
// Dont draw other tasks status
return;
}
Paragraph left = new Paragraph();
document.add(new ColumnLayout(2, CELLS_SPACING));
left.addText(iconMessage, TEXT_SIZE, iconFont);
space(left);
left.addText(task.getTitle(), TEXT_SIZE, TEXT_BOLD_FONT);
document.add(left, new VerticalLayoutHint(Alignment.Left, 0, 0, 0, 0));
document.add(ColumnLayout.NEWCOLUMN);
Date closureDate = task.getClosureDate();
Paragraph right = new Paragraph();
if (closureDate != null) {
right.addText(data.format(closureDate), TEXT_SIZE, TEXT_ITALIC_FONT);
}
document.add(right, new VerticalLayoutHint(Alignment.Right, 0, 0, 0, 0));
resetLayout();
document.add(new ColumnLayout(4, CELLS_SPACING));
Paragraph taskDetailsLeft = new Paragraph();
taskDetailsLeft.addText(taskMessage, TEXT_SIZE, TEXT_ITALIC_FONT);
space(taskDetailsLeft);
taskDetailsLeft.addText(task.getWorker().getName(), TEXT_SIZE, TEXT_BOLD_FONT);
document.add(taskDetailsLeft, new VerticalLayoutHint(Alignment.Left, 0, 0, 10, 10));
document.add(ColumnLayout.NEWCOLUMN);
Paragraph taskDetailsRight = new Paragraph();
taskDetailsRight.addText(task.getClosureComment(), SMALL_TEXT_SIZE, TEXT_ITALIC_FONT);
document.add(taskDetailsRight, new VerticalLayoutHint(Alignment.Left, 0, 0, 10, 10));
taskDetailsRight.setMaxWidth(360.0f);
resetLayout();
}
示例7: drawReletivePartAndMovePosition
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
/**
* Actually draws the (drawble) part at the
* {@link RenderContext#getCurrentPosition()} and - depending on flag
* <code>movePosition</code> - moves to the new Y position. Any left or
* right margin is taken into account to calculate the position and
* alignment.
*
* @param renderContext
* the context providing all rendering state.
* @param drawable
* the drawable to draw.
* @param layoutHint
* the layout hint used to layout.
* @param movePosition
* indicates if the position should be moved (vertically) after
* drawing.
* @throws IOException
* by pdfbox
*/
protected void drawReletivePartAndMovePosition(
final RenderContext renderContext, Drawable drawable,
final LayoutHint layoutHint, final boolean movePosition)
throws IOException {
PDPageContentStream contentStream = renderContext.getContentStream();
PageFormat pageFormat = renderContext.getPageFormat();
float offsetX = 0;
if (layoutHint instanceof VerticalLayoutHint) {
VerticalLayoutHint verticalLayoutHint = (VerticalLayoutHint) layoutHint;
Alignment alignment = verticalLayoutHint.getAlignment();
float horizontalExtraSpace = getTargetWidth(renderContext)
- drawable.getWidth();
switch (alignment) {
case Right:
offsetX = horizontalExtraSpace
- verticalLayoutHint.getMarginRight();
break;
case Center:
offsetX = horizontalExtraSpace / 2f;
break;
default:
offsetX = verticalLayoutHint.getMarginLeft();
break;
}
}
contentStream.saveGraphicsState();
contentStream.addRect(0, pageFormat.getMarginBottom(), renderContext.getPageWidth(),
renderContext.getHeight());
CompatibilityHelper.clip(contentStream);
drawable.draw(renderContext.getPdDocument(), contentStream,
renderContext.getCurrentPosition().add(offsetX, 0),renderContext);
contentStream.restoreGraphicsState();
if (movePosition) {
renderContext.movePositionBy(0, -drawable.getHeight());
}
}
示例8: VerticalLayoutHint
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
/**
* Creates a layout hint with {@link Alignment#Left left alignment}.
*/
public VerticalLayoutHint() {
this(Alignment.Left);
}
示例9: getAlignment
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
public Alignment getAlignment() {
return alignment;
}
示例10: getAlignment
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
/**
* @return the text alignment to apply. Default is left.
*/
public Alignment getAlignment() {
return alignment;
}
示例11: getTitleAlignment
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
/**
* @return the titleAlignment
*/
public Alignment getTitleAlignment() {
return titleAlignment;
}
示例12: setTitleAlignment
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
/**
* @param titleAlignment the titleAlignment to set
*/
public CertificateStyle setTitleAlignment(Alignment titleAlignment) {
this.titleAlignment = titleAlignment;
return this;
}
示例13: ColumnLayoutHint
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
/**
* Creates a layout hint with the given alignment and margins.
*
* @param alignment
* the element alignment.
* @param marginLeft
* the left alignment.
* @param marginRight
* the right alignment.
* @param marginTop
* the top alignment.
* @param marginBottom
* the bottom alignment.
* @param resetY
* if <code>true</code>, the y coordinate will be reset to the
* point before layouting the element.
*/
public ColumnLayoutHint(Alignment alignment, float marginLeft,
float marginRight, float marginTop, float marginBottom,
boolean resetY) {
super(alignment, marginLeft, marginRight, marginTop, marginBottom,
resetY);
}
示例14: setAlignment
import rst.pdfbox.layout.text.Alignment; //导入依赖的package包/类
/**
* Sets the alignment to apply.
*
* @param alignment
* the text alignment.
*/
public void setAlignment(Alignment alignment) {
this.alignment = alignment;
}