Revert "IDEMPIERE-5908 Report parameters are not displayed in full in PDF. (#2099)"
This reverts commit 7e53d829e2
.
This commit is contained in:
parent
2547edf522
commit
104070993d
|
@ -70,25 +70,25 @@ public class GridElement extends PrintElement
|
|||
} // GridElement
|
||||
|
||||
/** Gap between Rows */
|
||||
protected int m_rowGap = 3;
|
||||
private int m_rowGap = 3;
|
||||
/** Gap between Columns */
|
||||
protected int m_colGap = 5;
|
||||
private int m_colGap = 5;
|
||||
|
||||
/** Rows */
|
||||
protected int m_rows;
|
||||
private int m_rows;
|
||||
/** Columns */
|
||||
protected int m_cols;
|
||||
private int m_cols;
|
||||
/** The Layout Data */
|
||||
protected TextLayout[][] m_textLayout = null;
|
||||
private TextLayout[][] m_textLayout = null;
|
||||
/** Character Iterator */
|
||||
protected AttributedCharacterIterator[][] m_iterator = null;
|
||||
private AttributedCharacterIterator[][] m_iterator = null;
|
||||
|
||||
/** Row Height */
|
||||
protected int[] m_rowHeight = null;
|
||||
private int[] m_rowHeight = null;
|
||||
/** Column Width */
|
||||
protected int[] m_colWidth = null;
|
||||
private int[] m_colWidth = null;
|
||||
/** Context */
|
||||
protected FontRenderContext m_frc = new FontRenderContext(null, true, true);
|
||||
private FontRenderContext m_frc = new FontRenderContext(null, true, true);
|
||||
|
||||
/**
|
||||
* Create TextLayout from Data and calculate size.
|
||||
|
|
|
@ -1912,7 +1912,6 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
|||
//
|
||||
ParameterElement pe = new ParameterElement(m_query, m_printCtx, m_format.getTableFormat());
|
||||
pe.layout(0, 0, false, null);
|
||||
pe.fitToPage((int) getPaper().getImageableWidth(true));
|
||||
return pe;
|
||||
} // layoutParameter
|
||||
|
||||
|
|
|
@ -16,15 +16,6 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.print.layout;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.font.LineBreakMeasurer;
|
||||
import java.awt.font.TextLayout;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.MQuery;
|
||||
|
@ -67,91 +58,5 @@ public class ParameterElement extends GridElement
|
|||
}
|
||||
} // ParameterElement
|
||||
|
||||
/** Row:List<TextLayout> for parameter value text column */
|
||||
private Map<Integer, List<TextLayout>> valueTextLayoutMap = new HashMap<Integer, List<TextLayout>>();
|
||||
|
||||
/**
|
||||
* Fit parameter text to page width
|
||||
* @param pageWidth
|
||||
*/
|
||||
public void fitToPage(int pageWidth) {
|
||||
//label + parameter name + operator
|
||||
int offsetWidth = m_colWidth[0] + m_colGap + m_colWidth[1] + m_colGap + m_colWidth[2];
|
||||
int maxWidth = pageWidth - offsetWidth;
|
||||
for (int row = 0; row < m_rows; row++) {
|
||||
int height = 0;
|
||||
AttributedCharacterIterator iter = m_iterator[row][3];
|
||||
LineBreakMeasurer measurer = new LineBreakMeasurer(iter, m_frc);
|
||||
while (measurer.getPosition() < iter.getEndIndex()) {
|
||||
TextLayout layout = measurer.nextLayout(maxWidth);
|
||||
List<TextLayout> layouts = valueTextLayoutMap.get(row);
|
||||
if (layouts == null) {
|
||||
layouts = new ArrayList<TextLayout>();
|
||||
valueTextLayoutMap.put(row, layouts);
|
||||
}
|
||||
height = height + ((int)(layout.getAscent() + layout.getDescent() + layout.getLeading())+1);
|
||||
layouts.add(layout);
|
||||
}
|
||||
if (m_rowHeight[row] < height)
|
||||
m_rowHeight[row] = height;
|
||||
}
|
||||
calculateSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint it
|
||||
* @param g2D Graphics
|
||||
* @param pageStart top left Location of page
|
||||
* @param pageNo page number for multi page support (0 = header/footer) - ignored
|
||||
* @param ctx print context
|
||||
* @param isView true if online view (IDs are links)
|
||||
*/
|
||||
@Override
|
||||
public void paint(Graphics2D g2D, int pageNo, Point2D pageStart, Properties ctx, boolean isView)
|
||||
{
|
||||
//fall back to GridElement paint if fitToPage(int pageWidth) is not call
|
||||
if (valueTextLayoutMap.isEmpty())
|
||||
{
|
||||
super.paint(g2D, pageNo, pageStart, ctx, isView);
|
||||
return;
|
||||
}
|
||||
|
||||
Point2D.Double location = getAbsoluteLocation(pageStart);
|
||||
float y = (float)location.y;
|
||||
//
|
||||
for (int row = 0; row < m_rows; row++)
|
||||
{
|
||||
float x = (float)location.x;
|
||||
for (int col = 0; col < m_cols; col++)
|
||||
{
|
||||
//use valueTextLayoutMap for parameter value text column
|
||||
if (col == 3 && valueTextLayoutMap.get(row) != null)
|
||||
{
|
||||
List<TextLayout> layouts = valueTextLayoutMap.get(row);
|
||||
float curY = y;
|
||||
for(TextLayout layout : layouts)
|
||||
{
|
||||
curY = curY + layout.getAscent();
|
||||
layout.draw(g2D, x, curY);
|
||||
curY += m_rowGap;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_textLayout[row][col] != null)
|
||||
{
|
||||
float yy = y + m_textLayout[row][col].getAscent();
|
||||
m_textLayout[row][col].draw(g2D, x, yy);
|
||||
}
|
||||
x += m_colWidth[col];
|
||||
if (m_colWidth[col] > 0)
|
||||
x += m_colGap;
|
||||
}
|
||||
}
|
||||
y += m_rowHeight[row];
|
||||
if (m_rowHeight[row] > 0)
|
||||
y += m_rowGap;
|
||||
}
|
||||
} // paint
|
||||
} // ParameterElement
|
||||
|
||||
|
|
Loading…
Reference in New Issue