add layout engine
This commit is contained in:
parent
854235cba9
commit
813cba2acb
36 changed files with 408 additions and 339 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
||||||
/.idea
|
/.idea
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/.settings
|
/.parameters
|
||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
/.gradle
|
/.gradle
|
||||||
|
|
|
@ -15,3 +15,4 @@ junit4.version = 4.13.2
|
||||||
cglib.version = 3.3.0
|
cglib.version = 3.3.0
|
||||||
objenesis.version = 2.6
|
objenesis.version = 2.6
|
||||||
log4j.version = 2.14.0
|
log4j.version = 2.14.0
|
||||||
|
xbib-content.version = 4.0.0
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(':graphics-pdfbox')
|
api project(':graphics-pdfbox')
|
||||||
api project(':graphics-barcode')
|
api project(':graphics-barcode')
|
||||||
|
api "org.xbib:settings-datastructures:${project.property('xbib-content.version')}"
|
||||||
|
runtimeOnly "org.xbib:settings-datastructures-json:${project.property('xbib-content.version')}"
|
||||||
|
runtimeOnly "org.xbib:settings-datastructures-yaml:${project.property('xbib-content.version')}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ module org.xbib.graphics.layout.pdfbox {
|
||||||
exports org.xbib.graphics.pdfbox.layout.util;
|
exports org.xbib.graphics.pdfbox.layout.util;
|
||||||
requires transitive org.xbib.graphics.barcode;
|
requires transitive org.xbib.graphics.barcode;
|
||||||
requires transitive org.xbib.graphics.pdfbox;
|
requires transitive org.xbib.graphics.pdfbox;
|
||||||
|
requires org.xbib.settings.datastructures;
|
||||||
requires transitive java.desktop;
|
requires transitive java.desktop;
|
||||||
requires java.logging;
|
requires java.logging;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,10 @@ public class Document implements Closeable, RenderListener {
|
||||||
|
|
||||||
private final List<RenderListener> renderListener = new ArrayList<>();
|
private final List<RenderListener> renderListener = new ArrayList<>();
|
||||||
|
|
||||||
private PDDocument pdDocument;
|
|
||||||
|
|
||||||
private final PageFormat pageFormat;
|
private final PageFormat pageFormat;
|
||||||
|
|
||||||
|
private final PDDocument pdDocument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Document using the {@link #DEFAULT_PAGE_FORMAT}.
|
* Creates a Document using the {@link #DEFAULT_PAGE_FORMAT}.
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +65,7 @@ public class Document implements Closeable, RenderListener {
|
||||||
float marginRight,
|
float marginRight,
|
||||||
float marginTop,
|
float marginTop,
|
||||||
float marginBottom, boolean memory) {
|
float marginBottom, boolean memory) {
|
||||||
this(PageFormat.with().margins(marginLeft, marginRight, marginTop, marginBottom).build(), memory);
|
this(PageFormat.builder().margins(marginLeft, marginRight, marginTop, marginBottom).build(), memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +201,6 @@ public class Document implements Closeable, RenderListener {
|
||||||
public synchronized void save(OutputStream outputStream) throws IOException {
|
public synchronized void save(OutputStream outputStream) throws IOException {
|
||||||
if (pdDocument != null) {
|
if (pdDocument != null) {
|
||||||
pdDocument.save(outputStream);
|
pdDocument.save(outputStream);
|
||||||
pdDocument = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,16 @@ package org.xbib.graphics.pdfbox.layout.elements;
|
||||||
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
||||||
import org.xbib.graphics.pdfbox.layout.elements.render.VerticalLayout;
|
import org.xbib.graphics.pdfbox.layout.elements.render.VerticalLayout;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the size and orientation of a page. The default is A4 portrait
|
* Defines the size and orientation of a page. The default is A4 portrait without margins.
|
||||||
* without margins.
|
|
||||||
*/
|
*/
|
||||||
public class PageFormat implements Element {
|
public class PageFormat implements Element {
|
||||||
|
|
||||||
private static final int DEFAULT_USER_SPACE_UNIT_DPI = 72;
|
public static final int DEFAULT_USER_SPACE_UNIT_DPI = 72;
|
||||||
|
|
||||||
private static final float MM_TO_UNITS = 1 / (10 * 2.54f)
|
public static final float MM_TO_UNITS = 1 / (10 * 2.54f) * DEFAULT_USER_SPACE_UNIT_DPI;
|
||||||
* DEFAULT_USER_SPACE_UNIT_DPI;
|
|
||||||
|
|
||||||
public static final PDRectangle A0 = new PDRectangle(841 * MM_TO_UNITS,
|
public static final PDRectangle A0 = new PDRectangle(841 * MM_TO_UNITS,
|
||||||
1189 * MM_TO_UNITS);
|
1189 * MM_TO_UNITS);
|
||||||
|
@ -113,6 +113,8 @@ public class PageFormat implements Element {
|
||||||
this.marginBottom = marginBottom;
|
this.marginBottom = marginBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the orientation to use.
|
* @return the orientation to use.
|
||||||
*/
|
*/
|
||||||
|
@ -172,7 +174,7 @@ public class PageFormat implements Element {
|
||||||
* @return a page format builder. The default of the builder is A4 portrait
|
* @return a page format builder. The default of the builder is A4 portrait
|
||||||
* without margins.
|
* without margins.
|
||||||
*/
|
*/
|
||||||
public static PageFormatBuilder with() {
|
public static PageFormatBuilder builder() {
|
||||||
return new PageFormatBuilder();
|
return new PageFormatBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,16 +190,6 @@ public class PageFormat implements Element {
|
||||||
protected PageFormatBuilder() {
|
protected PageFormatBuilder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Actually builds the PageFormat.
|
|
||||||
*
|
|
||||||
* @return the resulting PageFormat.
|
|
||||||
*/
|
|
||||||
public PageFormat build() {
|
|
||||||
return new PageFormat(mediaBox, orientation, rotation, marginLeft,
|
|
||||||
marginRight, marginTop, marginBottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the left margin.
|
* Sets the left margin.
|
||||||
*
|
*
|
||||||
|
@ -362,6 +354,11 @@ public class PageFormat implements Element {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageFormatBuilder orientation(String orientation) {
|
||||||
|
this.orientation = Orientation.valueOf(orientation);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the orientation to {@link Orientation#PORTRAIT}.
|
* Sets the orientation to {@link Orientation#PORTRAIT}.
|
||||||
*
|
*
|
||||||
|
@ -392,6 +389,45 @@ public class PageFormat implements Element {
|
||||||
this.rotation = angle;
|
this.rotation = angle;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageFormatBuilder pageFormat(String format) {
|
||||||
|
switch (format.toLowerCase(Locale.ROOT)) {
|
||||||
|
case "A0" :
|
||||||
|
A0();
|
||||||
|
break;
|
||||||
|
case "A1" :
|
||||||
|
A1();
|
||||||
|
break;
|
||||||
|
case "A2" :
|
||||||
|
A2();
|
||||||
|
break;
|
||||||
|
case "A3" :
|
||||||
|
A3();
|
||||||
|
break;
|
||||||
|
case "A4" :
|
||||||
|
A4();
|
||||||
|
break;
|
||||||
|
case "A5" :
|
||||||
|
A5();
|
||||||
|
break;
|
||||||
|
case "A6" :
|
||||||
|
A6();
|
||||||
|
break;
|
||||||
|
case "LETTER" :
|
||||||
|
letter();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually builds the PageFormat.
|
||||||
|
*
|
||||||
|
* @return the resulting PageFormat.
|
||||||
|
*/
|
||||||
|
public PageFormat build() {
|
||||||
|
return new PageFormat(mediaBox, orientation, rotation, marginLeft,
|
||||||
|
marginRight, marginTop, marginBottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
package org.xbib.graphics.pdfbox.layout.script;
|
|
||||||
|
|
||||||
public abstract class Command<T> {
|
|
||||||
|
|
||||||
private final T value;
|
|
||||||
|
|
||||||
public Command(T value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getKey();
|
|
||||||
|
|
||||||
public T getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s[value=%s]", getKey(), getValue());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package org.xbib.graphics.pdfbox.layout.script;
|
|
||||||
|
|
||||||
import org.xbib.graphics.pdfbox.layout.elements.Document;
|
|
||||||
import org.xbib.graphics.pdfbox.layout.elements.PageFormat;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class DocumentProcessor implements Processor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProcessorResult process(Iterable<Command<?>> commands, PageFormat pageFormat) throws IOException {
|
|
||||||
ProcessorResult processorResult = new DocumentProcessorResult(new Document(pageFormat));
|
|
||||||
for (Command<?> command : commands) {
|
|
||||||
processorResult.handle(command);
|
|
||||||
}
|
|
||||||
processorResult.close();
|
|
||||||
return processorResult;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package org.xbib.graphics.pdfbox.layout.script;
|
|
||||||
|
|
||||||
import org.xbib.graphics.pdfbox.layout.elements.Document;
|
|
||||||
import org.xbib.graphics.pdfbox.layout.script.commands.ParagraphCommand;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
public class DocumentProcessorResult implements ProcessorResult {
|
|
||||||
|
|
||||||
private final Document document;
|
|
||||||
|
|
||||||
public DocumentProcessorResult(Document document) {
|
|
||||||
this.document = document;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(Command<?> command) throws IOException {
|
|
||||||
if (command instanceof ParagraphCommand) {
|
|
||||||
ParagraphCommand paragraphCommand = (ParagraphCommand) command;
|
|
||||||
document.add(paragraphCommand.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(OutputStream out) throws IOException {
|
|
||||||
document.render().save(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException {
|
|
||||||
document.close();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.xbib.graphics.pdfbox.layout.script;
|
||||||
|
|
||||||
|
import org.xbib.graphics.pdfbox.layout.script.command.Command;
|
||||||
|
import org.xbib.settings.Settings;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Engine {
|
||||||
|
|
||||||
|
private final State state;
|
||||||
|
|
||||||
|
public Engine() {
|
||||||
|
this.state = new State();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(String key, Settings settings) throws IOException {
|
||||||
|
State state = new State();
|
||||||
|
String packageName = getClass().getPackageName();
|
||||||
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
for (Map.Entry<String, Settings> entry : settings.getGroups(key).entrySet()) {
|
||||||
|
try {
|
||||||
|
String string = entry.getKey();
|
||||||
|
Class<?> cl = classLoader.loadClass(packageName + ".command." + string.substring(0, 1).toUpperCase() + string.substring(1) + "Command");
|
||||||
|
Command command = (Command) cl.getConstructor().newInstance();
|
||||||
|
command.execute(this, state, entry.getValue());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IOException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
package org.xbib.graphics.pdfbox.layout.script;
|
|
||||||
|
|
||||||
import org.xbib.graphics.pdfbox.layout.elements.PageFormat;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public interface Processor {
|
|
||||||
|
|
||||||
ProcessorResult process(Iterable<Command<?>> commands, PageFormat pageFormat) throws IOException;
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package org.xbib.graphics.pdfbox.layout.script;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
public interface ProcessorResult {
|
|
||||||
|
|
||||||
void handle(Command<?> command) throws IOException;
|
|
||||||
|
|
||||||
void write(OutputStream out) throws IOException;
|
|
||||||
|
|
||||||
void close() throws IOException;
|
|
||||||
}
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.xbib.graphics.pdfbox.layout.script;
|
||||||
|
|
||||||
|
import org.xbib.graphics.pdfbox.layout.elements.Document;
|
||||||
|
|
||||||
|
public class State {
|
||||||
|
|
||||||
|
public Document document;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.xbib.graphics.pdfbox.layout.script.command;
|
||||||
|
|
||||||
|
import org.xbib.graphics.pdfbox.layout.script.Engine;
|
||||||
|
import org.xbib.graphics.pdfbox.layout.script.State;
|
||||||
|
import org.xbib.settings.Settings;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface Command {
|
||||||
|
void execute(Engine engine, State state, Settings settings) throws IOException;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.xbib.graphics.pdfbox.layout.script.command;
|
||||||
|
|
||||||
|
import org.xbib.graphics.pdfbox.layout.elements.Document;
|
||||||
|
import org.xbib.graphics.pdfbox.layout.elements.PageFormat;
|
||||||
|
import org.xbib.graphics.pdfbox.layout.script.Engine;
|
||||||
|
import org.xbib.graphics.pdfbox.layout.script.State;
|
||||||
|
import org.xbib.settings.Settings;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class DocumentCommand implements Command {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(Engine engine, State state, Settings settings) throws IOException {
|
||||||
|
PageFormat pageFormat = PageFormat.builder()
|
||||||
|
.pageFormat(settings.get("format", "A4"))
|
||||||
|
.orientation(settings.get("orientiation", "PORTRAIT"))
|
||||||
|
.build();
|
||||||
|
state.document = new Document(pageFormat);
|
||||||
|
engine.execute("paragraoh", settings);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.xbib.graphics.pdfbox.layout.script.command;
|
||||||
|
|
||||||
|
import org.xbib.graphics.pdfbox.layout.script.Engine;
|
||||||
|
import org.xbib.graphics.pdfbox.layout.script.State;
|
||||||
|
import org.xbib.settings.Settings;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ParagraphCommand implements Command {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(Engine engine, State state, Settings settings) throws IOException {
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
package org.xbib.graphics.pdfbox.layout.script.commands;
|
|
||||||
|
|
||||||
import org.xbib.graphics.pdfbox.layout.elements.Paragraph;
|
|
||||||
import org.xbib.graphics.pdfbox.layout.script.Command;
|
|
||||||
|
|
||||||
public class ParagraphCommand extends Command<Paragraph> {
|
|
||||||
|
|
||||||
public ParagraphCommand(Paragraph paragraph) {
|
|
||||||
super(paragraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.xbib.graphics.pdfbox.layout.shape;
|
||||||
|
|
||||||
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
|
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||||
|
import org.xbib.graphics.pdfbox.layout.text.DrawListener;
|
||||||
|
import org.xbib.graphics.pdfbox.layout.text.Position;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Path implements Shape {
|
||||||
|
|
||||||
|
private final List<Position> list;
|
||||||
|
|
||||||
|
public Path() {
|
||||||
|
this.list = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(PDDocument pdDocument, PDPageContentStream contentStream, Position upperLeft,
|
||||||
|
float width, float height, Color color, Stroke stroke, DrawListener drawListener) throws IOException {
|
||||||
|
contentStream.saveGraphicsState();
|
||||||
|
contentStream.moveTo(upperLeft.getX(), upperLeft.getY());
|
||||||
|
contentStream.setStrokingColor(color);
|
||||||
|
contentStream.setLineCapStyle(stroke.getCapStyle().value());
|
||||||
|
contentStream.setLineDashPattern(stroke.getDashPattern().getPattern(), stroke.getDashPattern().getPhase());
|
||||||
|
contentStream.setLineJoinStyle(stroke.getJoinStyle().value());
|
||||||
|
contentStream.setLineWidth(stroke.getLineWidth());
|
||||||
|
for (Position p : list) {
|
||||||
|
contentStream.lineTo(p.getX(), p.getY());
|
||||||
|
}
|
||||||
|
contentStream.restoreGraphicsState();
|
||||||
|
drawListener.drawn(this, upperLeft, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fill(PDDocument pdDocument, PDPageContentStream contentStream, Position upperLeft,
|
||||||
|
float width, float height, Color color, DrawListener drawListener) throws IOException {
|
||||||
|
// do not fill
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(PDDocument pdDocument, PDPageContentStream contentStream, Position upperLeft,
|
||||||
|
float width, float height) throws IOException {
|
||||||
|
list.add(new Position(width, height));
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,7 @@ public abstract class AbstractCell {
|
||||||
|
|
||||||
private float minHeight = DEFAULT_MIN_HEIGHT;
|
private float minHeight = DEFAULT_MIN_HEIGHT;
|
||||||
|
|
||||||
protected Settings settings;
|
protected Parameters parameters;
|
||||||
|
|
||||||
public void setColSpan(int colSpan) {
|
public void setColSpan(int colSpan) {
|
||||||
this.colSpan = colSpan;
|
this.colSpan = colSpan;
|
||||||
|
@ -33,91 +33,91 @@ public abstract class AbstractCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPaddingBottom() {
|
public float getPaddingBottom() {
|
||||||
return settings.getPaddingBottom();
|
return parameters.getPaddingBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPaddingTop() {
|
public float getPaddingTop() {
|
||||||
return settings.getPaddingTop();
|
return parameters.getPaddingTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPaddingLeft() {
|
public float getPaddingLeft() {
|
||||||
return settings.getPaddingLeft();
|
return parameters.getPaddingLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPaddingRight() {
|
public float getPaddingRight() {
|
||||||
return settings.getPaddingRight();
|
return parameters.getPaddingRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getHorizontalPadding() {
|
public float getHorizontalPadding() {
|
||||||
return settings.getPaddingLeft() + settings.getPaddingRight();
|
return parameters.getPaddingLeft() + parameters.getPaddingRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getVerticalPadding() {
|
public float getVerticalPadding() {
|
||||||
return settings.getPaddingTop() + settings.getPaddingBottom();
|
return parameters.getPaddingTop() + parameters.getPaddingBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBorderWidthTop() {
|
public float getBorderWidthTop() {
|
||||||
return hasBorderTop() ? settings.getBorderWidthTop() : 0;
|
return hasBorderTop() ? parameters.getBorderWidthTop() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBorderTop() {
|
public boolean hasBorderTop() {
|
||||||
return settings.getBorderWidthTop() != null && settings.getBorderWidthTop() > 0;
|
return parameters.getBorderWidthTop() != null && parameters.getBorderWidthTop() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBorderWidthBottom() {
|
public float getBorderWidthBottom() {
|
||||||
return hasBorderBottom() ? settings.getBorderWidthBottom() : 0;
|
return hasBorderBottom() ? parameters.getBorderWidthBottom() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBorderBottom() {
|
public boolean hasBorderBottom() {
|
||||||
return settings.getBorderWidthBottom() != null && settings.getBorderWidthBottom() > 0;
|
return parameters.getBorderWidthBottom() != null && parameters.getBorderWidthBottom() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBorderWidthLeft() {
|
public float getBorderWidthLeft() {
|
||||||
return hasBorderLeft() ? settings.getBorderWidthLeft() : 0;
|
return hasBorderLeft() ? parameters.getBorderWidthLeft() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBorderLeft() {
|
public boolean hasBorderLeft() {
|
||||||
return settings.getBorderWidthLeft() != null && settings.getBorderWidthLeft() > 0;
|
return parameters.getBorderWidthLeft() != null && parameters.getBorderWidthLeft() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBorderWidthRight() {
|
public float getBorderWidthRight() {
|
||||||
return hasBorderRight() ? settings.getBorderWidthRight() : 0;
|
return hasBorderRight() ? parameters.getBorderWidthRight() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBorderRight() {
|
public boolean hasBorderRight() {
|
||||||
return settings.getBorderWidthRight() != null && settings.getBorderWidthRight() > 0;
|
return parameters.getBorderWidthRight() != null && parameters.getBorderWidthRight() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BorderStyleInterface getBorderStyleTop() {
|
public BorderStyleInterface getBorderStyleTop() {
|
||||||
return settings.getBorderStyleTop();
|
return parameters.getBorderStyleTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BorderStyleInterface getBorderStyleBottom() {
|
public BorderStyleInterface getBorderStyleBottom() {
|
||||||
return settings.getBorderStyleBottom();
|
return parameters.getBorderStyleBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BorderStyleInterface getBorderStyleLeft() {
|
public BorderStyleInterface getBorderStyleLeft() {
|
||||||
return settings.getBorderStyleLeft();
|
return parameters.getBorderStyleLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BorderStyleInterface getBorderStyleRight() {
|
public BorderStyleInterface getBorderStyleRight() {
|
||||||
return settings.getBorderStyleRight();
|
return parameters.getBorderStyleRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBackgroundColor() {
|
public boolean hasBackgroundColor() {
|
||||||
return settings.getBackgroundColor() != null;
|
return parameters.getBackgroundColor() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getBackgroundColor() {
|
public Color getBackgroundColor() {
|
||||||
return settings.getBackgroundColor();
|
return parameters.getBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getBorderColor() {
|
public Color getBorderColor() {
|
||||||
return settings.getBorderColor();
|
return parameters.getBorderColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWordBreak() {
|
public boolean isWordBreak() {
|
||||||
return settings.isWordBreak();
|
return parameters.isWordBreak();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Column getColumn() {
|
public Column getColumn() {
|
||||||
|
@ -148,8 +148,8 @@ public abstract class AbstractCell {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings getSettings() {
|
public Parameters getParameters() {
|
||||||
return settings;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColumn(Column column) {
|
public void setColumn(Column column) {
|
||||||
|
@ -168,8 +168,8 @@ public abstract class AbstractCell {
|
||||||
this.row = row;
|
this.row = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSettings(Settings settings) {
|
public void setParameters(Parameters parameters) {
|
||||||
this.settings = settings;
|
this.parameters = parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWidth(float width) {
|
public void setWidth(float width) {
|
||||||
|
@ -194,7 +194,6 @@ public abstract class AbstractCell {
|
||||||
result += currentRow.getNext().getHeight();
|
result += currentRow.getNext().getHeight();
|
||||||
currentRow = currentRow.getNext();
|
currentRow = currentRow.getNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +204,10 @@ public abstract class AbstractCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHorizontallyAligned(HorizontalAlignment alignment) {
|
public boolean isHorizontallyAligned(HorizontalAlignment alignment) {
|
||||||
return getSettings().getHorizontalAlignment() == alignment;
|
return getParameters().getHorizontalAlignment() == alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVerticallyAligned(VerticalAlignment alignment) {
|
public boolean isVerticallyAligned(VerticalAlignment alignment) {
|
||||||
return getSettings().getVerticalAlignment() == alignment;
|
return getParameters().getVerticalAlignment() == alignment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,15 @@ public abstract class AbstractTextCell extends AbstractCell {
|
||||||
protected float lineSpacing = 1f;
|
protected float lineSpacing = 1f;
|
||||||
|
|
||||||
public Font getFont() {
|
public Font getFont() {
|
||||||
return settings.getFont();
|
return parameters.getFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFontSize() {
|
public Integer getFontSize() {
|
||||||
return settings.getFontSize();
|
return parameters.getFontSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getTextColor() {
|
public Color getTextColor() {
|
||||||
return settings.getTextColor();
|
return parameters.getTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Float textHeight;
|
private Float textHeight;
|
||||||
|
@ -40,7 +40,7 @@ public abstract class AbstractTextCell extends AbstractCell {
|
||||||
return this.textHeight;
|
return this.textHeight;
|
||||||
}
|
}
|
||||||
this.textHeight = PdfUtil.getFontHeight(getFont(), getFontSize());
|
this.textHeight = PdfUtil.getFontHeight(getFont(), getFontSize());
|
||||||
if (settings.isWordBreak()) {
|
if (parameters.isWordBreak()) {
|
||||||
final int size = PdfUtil.getOptimalTextBreakLines(getText(), getFont(), getFontSize(), getMaxWidth()).size();
|
final int size = PdfUtil.getOptimalTextBreakLines(getText(), getFont(), getFontSize(), getMaxWidth()).size();
|
||||||
final float heightOfTextLines = size * this.textHeight;
|
final float heightOfTextLines = size * this.textHeight;
|
||||||
final float heightOfLineSpacing = (size - 1) * this.textHeight * getLineSpacing();
|
final float heightOfLineSpacing = (size - 1) * this.textHeight * getLineSpacing();
|
||||||
|
@ -52,7 +52,7 @@ public abstract class AbstractTextCell extends AbstractCell {
|
||||||
public float getWidthOfText() {
|
public float getWidthOfText() {
|
||||||
assertIsRendered();
|
assertIsRendered();
|
||||||
final float notBrokenTextWidth = PdfUtil.getStringWidth(getText(), getFont(), getFontSize());
|
final float notBrokenTextWidth = PdfUtil.getStringWidth(getText(), getFont(), getFontSize());
|
||||||
if (settings.isWordBreak()) {
|
if (parameters.isWordBreak()) {
|
||||||
final float maxWidth = getMaxWidthOfText() - getHorizontalPadding();
|
final float maxWidth = getMaxWidthOfText() - getHorizontalPadding();
|
||||||
List<String> textLines = PdfUtil.getOptimalTextBreakLines(getText(), getFont(), getFontSize(), maxWidth);
|
List<String> textLines = PdfUtil.getOptimalTextBreakLines(getText(), getFont(), getFontSize(), maxWidth);
|
||||||
return textLines.stream()
|
return textLines.stream()
|
||||||
|
|
|
@ -72,11 +72,11 @@ public class Hyperlink implements ParagraphProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Paragraph paragraph, Settings settings) {
|
public void process(Paragraph paragraph, Parameters parameters) {
|
||||||
Annotations.HyperlinkAnnotation hyperlink =
|
Annotations.HyperlinkAnnotation hyperlink =
|
||||||
new Annotations.HyperlinkAnnotation(getUrl(), Annotations.HyperlinkAnnotation.LinkStyle.ul);
|
new Annotations.HyperlinkAnnotation(getUrl(), Annotations.HyperlinkAnnotation.LinkStyle.ul);
|
||||||
FontDescriptor fontDescriptor = new FontDescriptor(getFont() != null ? getFont() : settings.getFont(),
|
FontDescriptor fontDescriptor = new FontDescriptor(getFont() != null ? getFont() : parameters.getFont(),
|
||||||
getFontSize() != null ? getFontSize() : settings.getFontSize());
|
getFontSize() != null ? getFontSize() : parameters.getFontSize());
|
||||||
paragraph.add(new AnnotatedStyledText(getText(), fontDescriptor,
|
paragraph.add(new AnnotatedStyledText(getText(), fontDescriptor,
|
||||||
getColor(), getBaselineOffset(), 0, 0, Collections.singleton(hyperlink)));
|
getColor(), getBaselineOffset(), 0, 0, Collections.singleton(hyperlink)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ public class Markup implements ParagraphProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Paragraph paragraph, Settings settings) throws IOException {
|
public void process(Paragraph paragraph, Parameters parameters) throws IOException {
|
||||||
float fontSize = getFontSize() != null ? getFontSize() : settings.getFontSize();
|
float fontSize = getFontSize() != null ? getFontSize() : parameters.getFontSize();
|
||||||
paragraph.addMarkup(getMarkup(), fontSize, FONT_MAP.get(getFont()));
|
paragraph.addMarkup(getMarkup(), fontSize, FONT_MAP.get(getFont()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class NewLine implements ParagraphProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Paragraph paragraph, Settings settings) {
|
public void process(Paragraph paragraph, Parameters parameters) {
|
||||||
paragraph.add(new org.xbib.graphics.pdfbox.layout.text.NewLine(new FontDescriptor(font, fontSize)));
|
paragraph.add(new org.xbib.graphics.pdfbox.layout.text.NewLine(new FontDescriptor(font, fontSize)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class ParagraphCell extends AbstractCell {
|
||||||
}
|
}
|
||||||
for (ParagraphProcessor p : getParagraph().getProcessables()) {
|
for (ParagraphProcessor p : getParagraph().getProcessables()) {
|
||||||
try {
|
try {
|
||||||
p.process(getParagraph().getWrappedParagraph(), getSettings());
|
p.process(getParagraph().getWrappedParagraph(), getParameters());
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
throw new UncheckedIOException(exception);
|
throw new UncheckedIOException(exception);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@ import java.io.IOException;
|
||||||
|
|
||||||
public interface ParagraphProcessor {
|
public interface ParagraphProcessor {
|
||||||
|
|
||||||
void process(Paragraph paragraph, Settings settings) throws IOException;
|
void process(Paragraph paragraph, Parameters parameters) throws IOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.xbib.graphics.pdfbox.layout.table;
|
||||||
import org.xbib.graphics.pdfbox.layout.font.Font;
|
import org.xbib.graphics.pdfbox.layout.font.Font;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
public class Settings {
|
public class Parameters {
|
||||||
|
|
||||||
private Font font;
|
private Font font;
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ public class Settings {
|
||||||
this.wordBreak = wordBreak;
|
this.wordBreak = wordBreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillingMergeBy(Settings settings) {
|
public void fillingMergeBy(Parameters parameters) {
|
||||||
fillingMergeFontSettings(settings);
|
fillingMergeFontSettings(parameters);
|
||||||
fillingMergePaddingSettings(settings);
|
fillingMergePaddingSettings(parameters);
|
||||||
fillingMergeBorderWidthSettings(settings);
|
fillingMergeBorderWidthSettings(parameters);
|
||||||
fillingMergeBorderStyleSettings(settings);
|
fillingMergeBorderStyleSettings(parameters);
|
||||||
fillingMergeColorSettings(settings);
|
fillingMergeColorSettings(parameters);
|
||||||
fillingMergeAlignmentSettings(settings);
|
fillingMergeAlignmentSettings(parameters);
|
||||||
fillingMergeWordBreakSetting(settings);
|
fillingMergeWordBreakSetting(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getWordBreak() {
|
public Boolean getWordBreak() {
|
||||||
|
@ -225,97 +225,97 @@ public class Settings {
|
||||||
this.wordBreak = wordBreak;
|
this.wordBreak = wordBreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillingMergeWordBreakSetting(Settings settings) {
|
private void fillingMergeWordBreakSetting(Parameters parameters) {
|
||||||
// Note that we use the boxed Boolean only here internally!
|
// Note that we use the boxed Boolean only here internally!
|
||||||
if (wordBreak == null && settings.wordBreak != null) {
|
if (wordBreak == null && parameters.wordBreak != null) {
|
||||||
wordBreak = settings.getWordBreak();
|
wordBreak = parameters.getWordBreak();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillingMergePaddingSettings(Settings settings) {
|
private void fillingMergePaddingSettings(Parameters parameters) {
|
||||||
if (getPaddingBottom() == null && settings.getPaddingBottom() != null) {
|
if (getPaddingBottom() == null && parameters.getPaddingBottom() != null) {
|
||||||
paddingBottom = settings.getPaddingBottom();
|
paddingBottom = parameters.getPaddingBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPaddingTop() == null && settings.getPaddingTop() != null) {
|
if (getPaddingTop() == null && parameters.getPaddingTop() != null) {
|
||||||
paddingTop = settings.getPaddingTop();
|
paddingTop = parameters.getPaddingTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPaddingLeft() == null && settings.getPaddingLeft() != null) {
|
if (getPaddingLeft() == null && parameters.getPaddingLeft() != null) {
|
||||||
paddingLeft = settings.getPaddingLeft();
|
paddingLeft = parameters.getPaddingLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPaddingRight() == null && settings.getPaddingRight() != null) {
|
if (getPaddingRight() == null && parameters.getPaddingRight() != null) {
|
||||||
paddingRight = settings.getPaddingRight();
|
paddingRight = parameters.getPaddingRight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillingMergeBorderWidthSettings(Settings settings) {
|
private void fillingMergeBorderWidthSettings(Parameters parameters) {
|
||||||
if (getBorderWidthBottom() == null && settings.getBorderWidthBottom() != null) {
|
if (getBorderWidthBottom() == null && parameters.getBorderWidthBottom() != null) {
|
||||||
borderWidthBottom = settings.getBorderWidthBottom();
|
borderWidthBottom = parameters.getBorderWidthBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBorderWidthTop() == null && settings.getBorderWidthTop() != null) {
|
if (getBorderWidthTop() == null && parameters.getBorderWidthTop() != null) {
|
||||||
borderWidthTop = settings.getBorderWidthTop();
|
borderWidthTop = parameters.getBorderWidthTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBorderWidthLeft() == null && settings.getBorderWidthLeft() != null) {
|
if (getBorderWidthLeft() == null && parameters.getBorderWidthLeft() != null) {
|
||||||
borderWidthLeft = settings.getBorderWidthLeft();
|
borderWidthLeft = parameters.getBorderWidthLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBorderWidthRight() == null && settings.getBorderWidthRight() != null) {
|
if (getBorderWidthRight() == null && parameters.getBorderWidthRight() != null) {
|
||||||
borderWidthRight = settings.getBorderWidthRight();
|
borderWidthRight = parameters.getBorderWidthRight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillingMergeBorderStyleSettings(Settings settings) {
|
private void fillingMergeBorderStyleSettings(Parameters parameters) {
|
||||||
if (getBorderStyleBottom() == null && settings.getBorderStyleBottom() != null) {
|
if (getBorderStyleBottom() == null && parameters.getBorderStyleBottom() != null) {
|
||||||
borderStyleBottom = settings.getBorderStyleBottom();
|
borderStyleBottom = parameters.getBorderStyleBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBorderStyleTop() == null && settings.getBorderStyleTop() != null) {
|
if (getBorderStyleTop() == null && parameters.getBorderStyleTop() != null) {
|
||||||
borderStyleTop = settings.getBorderStyleTop();
|
borderStyleTop = parameters.getBorderStyleTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBorderStyleLeft() == null && settings.getBorderStyleLeft() != null) {
|
if (getBorderStyleLeft() == null && parameters.getBorderStyleLeft() != null) {
|
||||||
borderStyleLeft = settings.getBorderStyleLeft();
|
borderStyleLeft = parameters.getBorderStyleLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBorderStyleRight() == null && settings.getBorderStyleRight() != null) {
|
if (getBorderStyleRight() == null && parameters.getBorderStyleRight() != null) {
|
||||||
borderStyleRight = settings.getBorderStyleRight();
|
borderStyleRight = parameters.getBorderStyleRight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillingMergeColorSettings(Settings settings) {
|
private void fillingMergeColorSettings(Parameters parameters) {
|
||||||
if (getTextColor() == null && settings.getTextColor() != null) {
|
if (getTextColor() == null && parameters.getTextColor() != null) {
|
||||||
textColor = settings.getTextColor();
|
textColor = parameters.getTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBackgroundColor() == null && settings.getBackgroundColor() != null) {
|
if (getBackgroundColor() == null && parameters.getBackgroundColor() != null) {
|
||||||
backgroundColor = settings.getBackgroundColor();
|
backgroundColor = parameters.getBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBorderColor() == null && settings.getBorderColor() != null) {
|
if (getBorderColor() == null && parameters.getBorderColor() != null) {
|
||||||
borderColor = settings.getBorderColor();
|
borderColor = parameters.getBorderColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillingMergeAlignmentSettings(Settings settings) {
|
private void fillingMergeAlignmentSettings(Parameters parameters) {
|
||||||
if (getHorizontalAlignment() == null && settings.getHorizontalAlignment() != null) {
|
if (getHorizontalAlignment() == null && parameters.getHorizontalAlignment() != null) {
|
||||||
horizontalAlignment = settings.getHorizontalAlignment();
|
horizontalAlignment = parameters.getHorizontalAlignment();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getVerticalAlignment() == null && settings.getVerticalAlignment() != null) {
|
if (getVerticalAlignment() == null && parameters.getVerticalAlignment() != null) {
|
||||||
verticalAlignment = settings.getVerticalAlignment();
|
verticalAlignment = parameters.getVerticalAlignment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillingMergeFontSettings(Settings settings) {
|
private void fillingMergeFontSettings(Parameters parameters) {
|
||||||
if (getFont() == null && settings.getFont() != null) {
|
if (getFont() == null && parameters.getFont() != null) {
|
||||||
font = settings.getFont();
|
font = parameters.getFont();
|
||||||
}
|
}
|
||||||
if (getFontSize() == null && settings.getFontSize() != null) {
|
if (getFontSize() == null && parameters.getFontSize() != null) {
|
||||||
fontSize = settings.getFontSize();
|
fontSize = parameters.getFontSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@ public class Row {
|
||||||
|
|
||||||
private List<AbstractCell> cells;
|
private List<AbstractCell> cells;
|
||||||
|
|
||||||
private Settings settings;
|
private Parameters parameters;
|
||||||
|
|
||||||
private Float height;
|
private Float height;
|
||||||
|
|
||||||
|
@ -27,12 +27,12 @@ public class Row {
|
||||||
this.cells = cells;
|
this.cells = cells;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSettings(Settings settings) {
|
public void setSettings(Parameters parameters) {
|
||||||
this.settings = settings;
|
this.parameters = parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings getSettings() {
|
public Parameters getSettings() {
|
||||||
return settings;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Row getNext() {
|
public Row getNext() {
|
||||||
|
@ -96,7 +96,7 @@ public class Row {
|
||||||
|
|
||||||
private final List<AbstractCell> cells = new ArrayList<>();
|
private final List<AbstractCell> cells = new ArrayList<>();
|
||||||
|
|
||||||
private final Settings settings = new Settings();
|
private final Parameters parameters = new Parameters();
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
}
|
}
|
||||||
|
@ -107,72 +107,72 @@ public class Row {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder font(Font font) {
|
public Builder font(Font font) {
|
||||||
settings.setFont(font);
|
parameters.setFont(font);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fontSize(final Integer fontSize) {
|
public Builder fontSize(final Integer fontSize) {
|
||||||
settings.setFontSize(fontSize);
|
parameters.setFontSize(fontSize);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder textColor(final Color textColor) {
|
public Builder textColor(final Color textColor) {
|
||||||
settings.setTextColor(textColor);
|
parameters.setTextColor(textColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder backgroundColor(final Color backgroundColor) {
|
public Builder backgroundColor(final Color backgroundColor) {
|
||||||
settings.setBackgroundColor(backgroundColor);
|
parameters.setBackgroundColor(backgroundColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder padding(final float padding) {
|
public Builder padding(final float padding) {
|
||||||
settings.setPaddingTop(padding);
|
parameters.setPaddingTop(padding);
|
||||||
settings.setPaddingBottom(padding);
|
parameters.setPaddingBottom(padding);
|
||||||
settings.setPaddingLeft(padding);
|
parameters.setPaddingLeft(padding);
|
||||||
settings.setPaddingRight(padding);
|
parameters.setPaddingRight(padding);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderWidth(final float borderWidth) {
|
public Builder borderWidth(final float borderWidth) {
|
||||||
settings.setBorderWidthTop(borderWidth);
|
parameters.setBorderWidthTop(borderWidth);
|
||||||
settings.setBorderWidthBottom(borderWidth);
|
parameters.setBorderWidthBottom(borderWidth);
|
||||||
settings.setBorderWidthLeft(borderWidth);
|
parameters.setBorderWidthLeft(borderWidth);
|
||||||
settings.setBorderWidthRight(borderWidth);
|
parameters.setBorderWidthRight(borderWidth);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderStyle(final BorderStyleInterface borderStyle) {
|
public Builder borderStyle(final BorderStyleInterface borderStyle) {
|
||||||
settings.setBorderStyleTop(borderStyle);
|
parameters.setBorderStyleTop(borderStyle);
|
||||||
settings.setBorderStyleBottom(borderStyle);
|
parameters.setBorderStyleBottom(borderStyle);
|
||||||
settings.setBorderStyleLeft(borderStyle);
|
parameters.setBorderStyleLeft(borderStyle);
|
||||||
settings.setBorderStyleRight(borderStyle);
|
parameters.setBorderStyleRight(borderStyle);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderColor(final Color borderColor) {
|
public Builder borderColor(final Color borderColor) {
|
||||||
settings.setBorderColor(borderColor);
|
parameters.setBorderColor(borderColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder horizontalAlignment(HorizontalAlignment alignment) {
|
public Builder horizontalAlignment(HorizontalAlignment alignment) {
|
||||||
settings.setHorizontalAlignment(alignment);
|
parameters.setHorizontalAlignment(alignment);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder verticalAlignment(VerticalAlignment alignment) {
|
public Builder verticalAlignment(VerticalAlignment alignment) {
|
||||||
settings.setVerticalAlignment(alignment);
|
parameters.setVerticalAlignment(alignment);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder wordBreak(Boolean wordBreak) {
|
public Builder wordBreak(Boolean wordBreak) {
|
||||||
settings.setWordBreak(wordBreak);
|
parameters.setWordBreak(wordBreak);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Row build() {
|
public Row build() {
|
||||||
final Row row = new Row(cells);
|
final Row row = new Row(cells);
|
||||||
row.setSettings(settings);
|
row.setSettings(parameters);
|
||||||
//row.setHeight(height);
|
//row.setHeight(height);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,10 +49,10 @@ public class StyledText implements ParagraphProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Paragraph paragraph, Settings settings) {
|
public void process(Paragraph paragraph, Parameters parameters) {
|
||||||
final float actualFontSize = getFontSize() != null ? getFontSize() : settings.getFontSize();
|
final float actualFontSize = getFontSize() != null ? getFontSize() : parameters.getFontSize();
|
||||||
final Font actualFont = getFont() != null ? getFont() : settings.getFont();
|
final Font actualFont = getFont() != null ? getFont() : parameters.getFont();
|
||||||
final Color actualColor = getColor() != null ? getColor() : settings.getTextColor();
|
final Color actualColor = getColor() != null ? getColor() : parameters.getTextColor();
|
||||||
// TODO this is a complete mess to handle new lines!!!
|
// TODO this is a complete mess to handle new lines!!!
|
||||||
String[] lines = getText().split(PdfUtil.NEW_LINE_REGEX);
|
String[] lines = getText().split(PdfUtil.NEW_LINE_REGEX);
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class Table {
|
||||||
|
|
||||||
private final Set<Point> rowSpanCells;
|
private final Set<Point> rowSpanCells;
|
||||||
|
|
||||||
private Settings settings;
|
private Parameters parameters;
|
||||||
|
|
||||||
private int numberOfColumns;
|
private int numberOfColumns;
|
||||||
|
|
||||||
|
@ -48,12 +48,12 @@ public class Table {
|
||||||
this.rowSpanCells = rowSpanCells;
|
this.rowSpanCells = rowSpanCells;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSettings(Settings settings) {
|
public void setSettings(Parameters parameters) {
|
||||||
this.settings = settings;
|
this.parameters = parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings getSettings() {
|
public Parameters getSettings() {
|
||||||
return settings;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWidth(float width) {
|
public void setWidth(float width) {
|
||||||
|
@ -130,7 +130,7 @@ public class Table {
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private final Settings settings = new Settings();
|
private final Parameters parameters = new Parameters();
|
||||||
|
|
||||||
private final List<Row> rows = new ArrayList<>();
|
private final List<Row> rows = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -143,19 +143,19 @@ public class Table {
|
||||||
private float width;
|
private float width;
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
settings.setFont(DEFAULT_FONT);
|
parameters.setFont(DEFAULT_FONT);
|
||||||
settings.setFontSize(DEFAULT_FONT_SIZE);
|
parameters.setFontSize(DEFAULT_FONT_SIZE);
|
||||||
settings.setTextColor(DEFAULT_TEXT_COLOR);
|
parameters.setTextColor(DEFAULT_TEXT_COLOR);
|
||||||
settings.setBorderColor(DEFAULT_BORDER_COLOR);
|
parameters.setBorderColor(DEFAULT_BORDER_COLOR);
|
||||||
settings.setBorderStyleTop(DEFAULT_BORDER_STYLE);
|
parameters.setBorderStyleTop(DEFAULT_BORDER_STYLE);
|
||||||
settings.setBorderStyleBottom(DEFAULT_BORDER_STYLE);
|
parameters.setBorderStyleBottom(DEFAULT_BORDER_STYLE);
|
||||||
settings.setBorderStyleLeft(DEFAULT_BORDER_STYLE);
|
parameters.setBorderStyleLeft(DEFAULT_BORDER_STYLE);
|
||||||
settings.setBorderStyleRight(DEFAULT_BORDER_STYLE);
|
parameters.setBorderStyleRight(DEFAULT_BORDER_STYLE);
|
||||||
settings.setPaddingTop(DEFAULT_PADDING);
|
parameters.setPaddingTop(DEFAULT_PADDING);
|
||||||
settings.setPaddingBottom(DEFAULT_PADDING);
|
parameters.setPaddingBottom(DEFAULT_PADDING);
|
||||||
settings.setPaddingLeft(DEFAULT_PADDING);
|
parameters.setPaddingLeft(DEFAULT_PADDING);
|
||||||
settings.setPaddingRight(DEFAULT_PADDING);
|
parameters.setPaddingRight(DEFAULT_PADDING);
|
||||||
settings.setWordBreak(true);
|
parameters.setWordBreak(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addRow(final Row row) {
|
public Builder addRow(final Row row) {
|
||||||
|
@ -225,66 +225,66 @@ public class Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder font(Font font) {
|
public Builder font(Font font) {
|
||||||
settings.setFont(font);
|
parameters.setFont(font);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fontSize(final Integer fontSize) {
|
public Builder fontSize(final Integer fontSize) {
|
||||||
settings.setFontSize(fontSize);
|
parameters.setFontSize(fontSize);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder textColor(final Color textColor) {
|
public Builder textColor(final Color textColor) {
|
||||||
settings.setTextColor(textColor);
|
parameters.setTextColor(textColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder backgroundColor(final Color backgroundColor) {
|
public Builder backgroundColor(final Color backgroundColor) {
|
||||||
settings.setBackgroundColor(backgroundColor);
|
parameters.setBackgroundColor(backgroundColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderWidth(final float borderWidth) {
|
public Builder borderWidth(final float borderWidth) {
|
||||||
settings.setBorderWidthTop(borderWidth);
|
parameters.setBorderWidthTop(borderWidth);
|
||||||
settings.setBorderWidthBottom(borderWidth);
|
parameters.setBorderWidthBottom(borderWidth);
|
||||||
settings.setBorderWidthLeft(borderWidth);
|
parameters.setBorderWidthLeft(borderWidth);
|
||||||
settings.setBorderWidthRight(borderWidth);
|
parameters.setBorderWidthRight(borderWidth);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderStyle(final BorderStyleInterface borderStyle) {
|
public Builder borderStyle(final BorderStyleInterface borderStyle) {
|
||||||
settings.setBorderStyleTop(borderStyle);
|
parameters.setBorderStyleTop(borderStyle);
|
||||||
settings.setBorderStyleBottom(borderStyle);
|
parameters.setBorderStyleBottom(borderStyle);
|
||||||
settings.setBorderStyleLeft(borderStyle);
|
parameters.setBorderStyleLeft(borderStyle);
|
||||||
settings.setBorderStyleRight(borderStyle);
|
parameters.setBorderStyleRight(borderStyle);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder padding(final float padding) {
|
public Builder padding(final float padding) {
|
||||||
settings.setPaddingTop(padding);
|
parameters.setPaddingTop(padding);
|
||||||
settings.setPaddingBottom(padding);
|
parameters.setPaddingBottom(padding);
|
||||||
settings.setPaddingLeft(padding);
|
parameters.setPaddingLeft(padding);
|
||||||
settings.setPaddingRight(padding);
|
parameters.setPaddingRight(padding);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderColor(final Color borderColor) {
|
public Builder borderColor(final Color borderColor) {
|
||||||
settings.setBorderColor(borderColor);
|
parameters.setBorderColor(borderColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder horizontalAlignment(HorizontalAlignment alignment) {
|
public Builder horizontalAlignment(HorizontalAlignment alignment) {
|
||||||
settings.setHorizontalAlignment(alignment);
|
parameters.setHorizontalAlignment(alignment);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder verticalAlignment(VerticalAlignment alignment) {
|
public Builder verticalAlignment(VerticalAlignment alignment) {
|
||||||
settings.setVerticalAlignment(alignment);
|
parameters.setVerticalAlignment(alignment);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder wordBreak(Boolean wordBreak) {
|
public Builder wordBreak(Boolean wordBreak) {
|
||||||
settings.setWordBreak(wordBreak);
|
parameters.setWordBreak(wordBreak);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ public class Table {
|
||||||
"This could be due to row or col spanning not being correct");
|
"This could be due to row or col spanning not being correct");
|
||||||
}
|
}
|
||||||
Table table = new Table(rows, columns, rowSpanCells);
|
Table table = new Table(rows, columns, rowSpanCells);
|
||||||
table.setSettings(settings);
|
table.setSettings(parameters);
|
||||||
table.setWidth(width);
|
table.setWidth(width);
|
||||||
table.setNumberOfColumns(numberOfColumns);
|
table.setNumberOfColumns(numberOfColumns);
|
||||||
setupConnectionsBetweenElementsFor(table);
|
setupConnectionsBetweenElementsFor(table);
|
||||||
|
@ -311,7 +311,7 @@ public class Table {
|
||||||
}
|
}
|
||||||
int columnIndex = 0;
|
int columnIndex = 0;
|
||||||
for (AbstractCell cell : row.getCells()) {
|
for (AbstractCell cell : row.getCells()) {
|
||||||
cell.getSettings().fillingMergeBy(row.getSettings());
|
cell.getParameters().fillingMergeBy(row.getSettings());
|
||||||
cell.setRow(row);
|
cell.setRow(row);
|
||||||
while (table.isRowSpanAt(rowIndex, columnIndex)) {
|
while (table.isRowSpanAt(rowIndex, columnIndex)) {
|
||||||
columnIndex++;
|
columnIndex++;
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class TextCell extends AbstractTextCell {
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private final Settings settings;
|
private final Parameters parameters;
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class TextCell extends AbstractTextCell {
|
||||||
private int rowSpan;
|
private int rowSpan;
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
settings = new Settings();
|
parameters = new Parameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder text(String text) {
|
public Builder text(String text) {
|
||||||
|
@ -46,65 +46,65 @@ public class TextCell extends AbstractTextCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder font(Font font) {
|
public Builder font(Font font) {
|
||||||
settings.setFont(font);
|
parameters.setFont(font);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fontSize(Integer fontSize) {
|
public Builder fontSize(Integer fontSize) {
|
||||||
settings.setFontSize(fontSize);
|
parameters.setFontSize(fontSize);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder textColor(Color textColor) {
|
public Builder textColor(Color textColor) {
|
||||||
settings.setTextColor(textColor);
|
parameters.setTextColor(textColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderWidth(float borderWidth) {
|
public Builder borderWidth(float borderWidth) {
|
||||||
settings.setBorderWidthTop(borderWidth);
|
parameters.setBorderWidthTop(borderWidth);
|
||||||
settings.setBorderWidthBottom(borderWidth);
|
parameters.setBorderWidthBottom(borderWidth);
|
||||||
settings.setBorderWidthLeft(borderWidth);
|
parameters.setBorderWidthLeft(borderWidth);
|
||||||
settings.setBorderWidthRight(borderWidth);
|
parameters.setBorderWidthRight(borderWidth);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderWidthTop(final float borderWidth) {
|
public Builder borderWidthTop(final float borderWidth) {
|
||||||
settings.setBorderWidthTop(borderWidth);
|
parameters.setBorderWidthTop(borderWidth);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderWidthBottom(final float borderWidth) {
|
public Builder borderWidthBottom(final float borderWidth) {
|
||||||
settings.setBorderWidthBottom(borderWidth);
|
parameters.setBorderWidthBottom(borderWidth);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderWidthLeft(final float borderWidth) {
|
public Builder borderWidthLeft(final float borderWidth) {
|
||||||
settings.setBorderWidthLeft(borderWidth);
|
parameters.setBorderWidthLeft(borderWidth);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderWidthRight(final float borderWidth) {
|
public Builder borderWidthRight(final float borderWidth) {
|
||||||
settings.setBorderWidthRight(borderWidth);
|
parameters.setBorderWidthRight(borderWidth);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderStyleTop(final BorderStyleInterface style) {
|
public Builder borderStyleTop(final BorderStyleInterface style) {
|
||||||
settings.setBorderStyleTop(style);
|
parameters.setBorderStyleTop(style);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderStyleBottom(final BorderStyleInterface style) {
|
public Builder borderStyleBottom(final BorderStyleInterface style) {
|
||||||
settings.setBorderStyleBottom(style);
|
parameters.setBorderStyleBottom(style);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderStyleLeft(final BorderStyleInterface style) {
|
public Builder borderStyleLeft(final BorderStyleInterface style) {
|
||||||
settings.setBorderStyleLeft(style);
|
parameters.setBorderStyleLeft(style);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderStyleRight(final BorderStyleInterface style) {
|
public Builder borderStyleRight(final BorderStyleInterface style) {
|
||||||
settings.setBorderStyleRight(style);
|
parameters.setBorderStyleRight(style);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,47 +123,47 @@ public class TextCell extends AbstractTextCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder paddingTop(final float padding) {
|
public Builder paddingTop(final float padding) {
|
||||||
settings.setPaddingTop(padding);
|
parameters.setPaddingTop(padding);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder paddingBottom(final float padding) {
|
public Builder paddingBottom(final float padding) {
|
||||||
settings.setPaddingBottom(padding);
|
parameters.setPaddingBottom(padding);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder paddingLeft(final float padding) {
|
public Builder paddingLeft(final float padding) {
|
||||||
settings.setPaddingLeft(padding);
|
parameters.setPaddingLeft(padding);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder paddingRight(final float padding) {
|
public Builder paddingRight(final float padding) {
|
||||||
settings.setPaddingRight(padding);
|
parameters.setPaddingRight(padding);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder horizontalAlignment(final HorizontalAlignment alignment) {
|
public Builder horizontalAlignment(final HorizontalAlignment alignment) {
|
||||||
settings.setHorizontalAlignment(alignment);
|
parameters.setHorizontalAlignment(alignment);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder verticalAlignment(final VerticalAlignment alignment) {
|
public Builder verticalAlignment(final VerticalAlignment alignment) {
|
||||||
settings.setVerticalAlignment(alignment);
|
parameters.setVerticalAlignment(alignment);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder backgroundColor(final Color backgroundColor) {
|
public Builder backgroundColor(final Color backgroundColor) {
|
||||||
settings.setBackgroundColor(backgroundColor);
|
parameters.setBackgroundColor(backgroundColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder borderColor(final Color borderColor) {
|
public Builder borderColor(final Color borderColor) {
|
||||||
settings.setBorderColor(borderColor);
|
parameters.setBorderColor(borderColor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder wordBreak(final Boolean wordBreak) {
|
public Builder wordBreak(final Boolean wordBreak) {
|
||||||
settings.setWordBreak(wordBreak);
|
parameters.setWordBreak(wordBreak);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public class TextCell extends AbstractTextCell {
|
||||||
|
|
||||||
public TextCell build() {
|
public TextCell build() {
|
||||||
TextCell cell = new TextCell();
|
TextCell cell = new TextCell();
|
||||||
cell.setSettings(settings);
|
cell.setParameters(parameters);
|
||||||
cell.setText(text);
|
cell.setText(text);
|
||||||
if (colSpan > 0) {
|
if (colSpan > 0) {
|
||||||
cell.setColSpan(colSpan);
|
cell.setColSpan(colSpan);
|
||||||
|
|
|
@ -21,9 +21,9 @@ public class ImageCellRenderer extends AbstractCellRenderer<ImageCell> {
|
||||||
final Point2D.Float size = cell.getFitSize();
|
final Point2D.Float size = cell.getFitSize();
|
||||||
final Point2D.Float drawAt = new Point2D.Float();
|
final Point2D.Float drawAt = new Point2D.Float();
|
||||||
float xOffset = moveX + cell.getPaddingLeft();
|
float xOffset = moveX + cell.getPaddingLeft();
|
||||||
if (cell.getSettings().getHorizontalAlignment() == HorizontalAlignment.RIGHT) {
|
if (cell.getParameters().getHorizontalAlignment() == HorizontalAlignment.RIGHT) {
|
||||||
xOffset = moveX + (cell.getWidth() - (size.x + cell.getPaddingRight()));
|
xOffset = moveX + (cell.getWidth() - (size.x + cell.getPaddingRight()));
|
||||||
} else if (cell.getSettings().getHorizontalAlignment() == HorizontalAlignment.CENTER) {
|
} else if (cell.getParameters().getHorizontalAlignment() == HorizontalAlignment.CENTER) {
|
||||||
final float diff = (cell.getWidth() - size.x) / 2;
|
final float diff = (cell.getWidth() - size.x) / 2;
|
||||||
xOffset = moveX + diff;
|
xOffset = moveX + diff;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class ParagraphCellRenderer extends AbstractCellRenderer<ParagraphCell> {
|
||||||
float y = renderContext.getStartingPoint().y + getAdaptionForVerticalAlignment();
|
float y = renderContext.getStartingPoint().y + getAdaptionForVerticalAlignment();
|
||||||
paragraph.drawText(renderContext.getContentStream(),
|
paragraph.drawText(renderContext.getContentStream(),
|
||||||
new Position(x, y),
|
new Position(x, y),
|
||||||
ALIGNMENT_MAP.getOrDefault(cell.getSettings().getHorizontalAlignment(), Alignment.LEFT),
|
ALIGNMENT_MAP.getOrDefault(cell.getParameters().getHorizontalAlignment(), Alignment.LEFT),
|
||||||
annotationDrawListener
|
annotationDrawListener
|
||||||
);
|
);
|
||||||
annotationDrawListener.afterPage(null);
|
annotationDrawListener.afterPage(null);
|
||||||
|
|
|
@ -188,7 +188,7 @@ public class CustomAnnotationTest {
|
||||||
// register our custom highlight annotation processor
|
// register our custom highlight annotation processor
|
||||||
AnnotationProcessorFactory.register(HighlightAnnotationProcessor.class);
|
AnnotationProcessorFactory.register(HighlightAnnotationProcessor.class);
|
||||||
|
|
||||||
Document document = new Document(PageFormat.with().A4()
|
Document document = new Document(PageFormat.builder().A4()
|
||||||
.margins(40, 60, 40, 60).portrait().build());
|
.margins(40, 60, 40, 60).portrait().build());
|
||||||
|
|
||||||
Paragraph paragraph = new Paragraph();
|
Paragraph paragraph = new Paragraph();
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class Landscape {
|
||||||
Paragraph titleA5 = new Paragraph();
|
Paragraph titleA5 = new Paragraph();
|
||||||
titleA5.addMarkup("*Format A5 in Landscape*", 20, BaseFont.TIMES);
|
titleA5.addMarkup("*Format A5 in Landscape*", 20, BaseFont.TIMES);
|
||||||
|
|
||||||
PageFormat a5_landscape = PageFormat.with().A5().landscape().margins(10, 50, 0, 30).build();
|
PageFormat a5_landscape = PageFormat.builder().A5().landscape().margins(10, 50, 0, 30).build();
|
||||||
PageFormat a4_portrait = PageFormat.with().margins(40, 50, 40, 60).build();
|
PageFormat a4_portrait = PageFormat.builder().margins(40, 50, 40, 60).build();
|
||||||
Document document = new Document(a4_portrait);
|
Document document = new Document(a4_portrait);
|
||||||
|
|
||||||
document.add(titleA4, VerticalLayoutHint.CENTER);
|
document.add(titleA4, VerticalLayoutHint.CENTER);
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class RotationTest {
|
||||||
Paragraph titleA5 = new Paragraph();
|
Paragraph titleA5 = new Paragraph();
|
||||||
titleA5.addMarkup("*Format A4 Landscape rotated by -90 degrees*", 20, BaseFont.TIMES);
|
titleA5.addMarkup("*Format A4 Landscape rotated by -90 degrees*", 20, BaseFont.TIMES);
|
||||||
|
|
||||||
PageFormat a4_landscape = PageFormat.with().margins(40, 50, 40, 60).landscape().build();
|
PageFormat a4_landscape = PageFormat.builder().margins(40, 50, 40, 60).landscape().build();
|
||||||
PageFormat a4_landscape_rotated = PageFormat.with().margins(40, 50, 40, 60).landscape().rotation(-90).build();
|
PageFormat a4_landscape_rotated = PageFormat.builder().margins(40, 50, 40, 60).landscape().rotation(-90).build();
|
||||||
|
|
||||||
Document document = new Document(a4_landscape);
|
Document document = new Document(a4_landscape);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ without fee is hereby granted.
|
||||||
These 15 images are part of the much larger PngSuite test-set of
|
These 15 images are part of the much larger PngSuite test-set of
|
||||||
images, available for developers of PNG supporting software. The
|
images, available for developers of PNG supporting software. The
|
||||||
complete set, available at http:/www.schaik.com/pngsuite/, contains
|
complete set, available at http:/www.schaik.com/pngsuite/, contains
|
||||||
a variety of images to test interlacing, gamma settings, ancillary
|
a variety of images to test interlacing, gamma parameters, ancillary
|
||||||
chunks, etc.
|
chunks, etc.
|
||||||
|
|
||||||
The images in this directory represent the basic PNG color-types:
|
The images in this directory represent the basic PNG color-types:
|
||||||
|
|
Loading…
Reference in a new issue