net.sf.nervalreports.generators.PDFSentence Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdf-generator Show documentation
Show all versions of pdf-generator Show documentation
This is the PDF generator package of NervalReports (a lightweight report creation library),
used to generate a report directly to a .pdf file.
The newest version!
/** This file is part of nervalreports.
*
* nervalreports is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nervalreports is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nervalreports. If not, see . */
package net.sf.nervalreports.generators;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
/** Basic class for sentences in {@link PDFReportGenerator}. A sentence usually is combined
* with another sentences to form a line.
* @author farrer */
/* default */ abstract class PDFSentence {
/* default */ enum Type {
PDF_TEXT_SENTENCE,
PDF_IMAGE_SENTENCE
};
/** Needed width for containing the current sentence. */
private float width;
/** Needed height for containing the current sentence */
private float height;
/** Sentence type */
private final Type type;
/** Constructor.
* @param type Sentence type. */
/* default */ PDFSentence(Type type) {
this.type = type;
}
/** Flush the sentence to the page.
* @param pageContentStream content stream to flush the sentence to.
* @param x page X position to flush the sentence to.
* @param y page Y position to flush the sentence to. */
/* default */ abstract void flush(PDPageContentStream pageContentStream, float x, float y) throws Exception;
/** @return {@link #width}. */
/* default */ float getWidth() {
return width;
}
/** Set {@link #width}.
* @param width new width value */
protected void setWidth(float width) {
this.width = width;
}
/** @return {@link #height}. */
/* default */ float getHeight() {
return height;
}
/** Set {@link #height}.
* @param height new height value */
protected void setHeight(float height) {
this.height = height;
}
/** @return {@link #type}. */
/* default */ Type getType() {
return type;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy