
net.sf.nervalreports.generators.TeXSpanInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tex-generator Show documentation
Show all versions of tex-generator Show documentation
This is the TeX generator package of NervalReports (a lightweight report creation library),
used to generate a report in a LaTeX file (.tex).
/** 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;
/** Span information container class for {@link TeXReportGenerator}.
* @author farrer */
/* default */ class TeXSpanInfo {
/** Number of rows to occupy with current cell. */
private int rowSpan;
/** Number of columns to occupy with current cell. */
private int colSpan;
/** How many rows needed to occupy before done with cell's {@link #rowSpan} */
private int remainingRows;
/** StringBuilder to use when {@link #rowSpan} > 1. It's needed due to the way
* lines are colored with multirow: to avoid the row fill its textual contents,
* the content must be defined at the last row (with negative fill index). Thus,
* we must keep the textual contents until reach the last affected row. */
private final StringBuilder stringBuilder;
/** If {@link #stringBuilder} should be used for current elements. */
private boolean useStringBuilder;
/** Aligned string for multicolumn definition (used when {@link #colSpan} > 1). */
private final String alignmentStringForColSpanedCell;
/** Default constructor. */
TeXSpanInfo(int rowSpan, int colSpan, String alignmentStringForColSpanedCell) {
this.rowSpan = rowSpan;
this.colSpan = colSpan;
this.remainingRows = rowSpan;
this.alignmentStringForColSpanedCell = alignmentStringForColSpanedCell;
if (rowSpan > 1) {
this.stringBuilder = new StringBuilder();
useStringBuilder = true;
} else {
this.stringBuilder = null;
useStringBuilder = false;
}
}
/** Called when the use of internal {@link #stringBuilder} is done. */
public void doneWithStringBuilder() {
useStringBuilder = false;
}
/** @return if should use internal {@link #stringBuilder} instead of default document one. */
public boolean getUseStringBuilder() {
return useStringBuilder;
}
/** @return {@link #stringBuilder}. */
public StringBuilder getStringBuilder() {
return stringBuilder;
}
/** @return {@link #rowSpan}. */
int getRowSpan() {
return this.rowSpan;
}
/** @return {@link #colSpan} */
int getColSpan() {
return this.colSpan;
}
/** @return {@link #remainingRows}. */
int getRemainingRows() {
return this.remainingRows;
}
/** Decrements a row from the remaining needed rows ({@link #remainingRows}).
* @return true
if there are remaining rows, false
if no more. */
boolean decRemainingRows() {
if (this.remainingRows > 0) {
this.remainingRows--;
}
return this.remainingRows > 0;
}
/** @return {@link #alignmentStringForColSpanedCell}. */
public String getAlignmentStringForColSpanedCell() {
return alignmentStringForColSpanedCell;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy