net.sf.nervalreports.generators.PDFGroupInfo 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 net.sf.nervalreports.core.ReportGroupType;
import net.sf.nervalreports.core.ReportTextAlignment;
/** Group construction information for {@link PDFReportGenerator}.
* @author farrer */
/* default */ class PDFGroupInfo extends PDFBlockInfo {
/** Current line */
private PDFLine line;
/** Type of current group. */
private ReportGroupType groupType;
/** X coordinate to be at a new line. */
private final float initialX;
/** Create a {@link PDFGroupInfo}.
* @param type type of the group.
* @param textAligment alignment to use for entire group.
* @param initialX X coordinate to set for new lines.
* @param maxWidth width of the entire group (ie: page width). */
PDFGroupInfo(ReportGroupType type, ReportTextAlignment textAligment, float initialX, float maxWidth) {
super(Type.PDF_GROUP_INFO);
this.line = new PDFLine(textAligment, maxWidth);
this.initialX = initialX;
this.groupType = type;
}
/** @return if current line has some sentences to flush to page */
boolean hasSentencesToFlush() {
return (line.getSentences().size() > 0);
}
/** Discard the current one and create a new line (usually, just after flush the current one to pdf).
* @return new line created. */
PDFLine discardCurrentAndCreateNewLine() {
PDFLine newLine = new PDFLine(line.getTextAlignment(), line.getMaxWidth());
line = newLine;
return line;
}
/** @return {@link #line}. */
PDFLine getLine() {
return line;
}
/** @return {@link #groupType}. */
ReportGroupType getGroupType() {
return groupType;
}
/** {@inheritDoc} */
@Override
/* default */ float getChildMaxWidth() {
return line.getMaxWidth();
}
/** {@inheritDoc} */
@Override
/* default */ float getCurrentInitialX() {
return initialX;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy