@Override public void visit(JRPrintFrame frame, T arg) { visitElement(frame, arg); if (deep) { List<JRPrintElement> elements = frame.getElements(); if (elements != null) { for (JRPrintElement element : elements) { element.accept(this, arg); } } } }
protected void exportElements(Collection<JRPrintElement> elements) throws IOException { if (elements != null && elements.size() > 0) { for(Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) { JRPrintElement element = it.next(); if (filter == null || filter.isToExport(element)) { exportElement(element); if (element instanceof JRGenericPrintElement) { //exportElement(element); } else if (element instanceof JRPrintFrame) { exportElements(((JRPrintFrame) element).getElements()); } } } } }
protected void exportElements(Collection<JRPrintElement> elements) throws IOException { if (elements != null && elements.size() > 0) { for(Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) { JRPrintElement element = it.next(); if (filter == null || filter.isToExport(element)) { if (element instanceof JRPrintFrame) { exportFrame((JRPrintFrame)element); } else if (element instanceof JRGenericPrintElement) { exportGenericElement((JRGenericPrintElement) element); } } } } }
@Override protected void exportFrame(JRPrintFrame frame) throws JRException { for (Object element : frame.getElements()) { if (element instanceof JRPrintLine) { exportLine((JRPrintLine)element); } else if (element instanceof JRPrintRectangle) { exportRectangle((JRPrintRectangle)element); } else if (element instanceof JRPrintEllipse) { exportRectangle((JRPrintEllipse)element); } else if (element instanceof JRPrintImage) { exportImage((JRPrintImage) element); } else if (element instanceof JRPrintText) { exportText((JRPrintText)element); } else if (element instanceof JRPrintFrame) { exportFrame((JRPrintFrame) element); } else if (element instanceof JRGenericPrintElement) { exportGenericElement((JRGenericPrintElement) element); } } }
/** * */ public static JRPrintImage getImage(List<JasperPrint> jasperPrintList, JRPrintElementIndex imageIndex) { JasperPrint report = jasperPrintList.get(imageIndex.getReportIndex()); JRPrintPage page = report.getPages().get(imageIndex.getPageIndex()); Integer[] elementIndexes = imageIndex.getAddressArray(); Object element = page.getElements().get(elementIndexes[0].intValue()); for (int i = 1; i < elementIndexes.length; ++i) { JRPrintFrame frame = (JRPrintFrame) element; element = frame.getElements().get(elementIndexes[i].intValue()); } return (JRPrintImage) element; }
@Override public void visit(JRPrintFrame frame, Offset offset) { try { frameDrawer.draw( grx, frame, offset.getX(), offset.getY() ); } catch (JRException e) { throw new JRRuntimeException(e); } }
/** * * @param frame * @throws JRException */ public void exportFrame(JRPrintFrame frame) throws JRException, IOException { int x = frame.getX() + getOffsetX(); int y = frame.getY() + getOffsetY(); int width = frame.getWidth(); int height = frame.getHeight(); startElement(frame); exportPen(frame.getForecolor()); finishElement(); setFrameElementsOffset(frame, false); exportElements(frame.getElements()); restoreElementOffsets(); exportBox(frame.getLineBox(), x, y, width, height); }
@Override public boolean isToExport(JRPrintElement element) { // JRPrintFrame frame = element instanceof JRPrintFrame ? (JRPrintFrame)element : null; // if (frame != null) // { // List<JRPrintElement> elements = frame.getElements(); // return elements != null && elements.size() > 0; // } // return (element instanceof JRPrintText || element instanceof JRGenericPrintElement) // && (filter == null || filter.isToExport(element)); if (element instanceof JRGenericPrintElement) { JRGenericPrintElement genericElement = (JRGenericPrintElement) element; GenericElementHandler handler = handlerEnvironment.getElementHandler( genericElement.getGenericType(), JRAbstractCsvExporter.CSV_EXPORTER_KEY); if (handler == null || !handler.toExport(genericElement)) { return false; } } return (element instanceof JRPrintText || element instanceof JRPrintFrame || element instanceof JRGenericPrintElement) && (filter == null || filter.isToExport(element)); }
protected void exportElements( List<JRPrintElement> elements, CsvMetadataReportConfiguration configuration, Map<String, String> currentRow, Map<String, String> repeatedValues, boolean hasDefinedColumns) throws IOException { for (int i = 0; i < elements.size(); ++i) { Object element = elements.get(i); if (element instanceof JRPrintText) { exportText((JRPrintText) element, configuration, currentRow, repeatedValues, hasDefinedColumns); } else if (element instanceof JRPrintFrame) { exportElements(((JRPrintFrame) element).getElements(), configuration, currentRow, repeatedValues, hasDefinedColumns); } } }
protected void exportFrame(JRPrintFrame frame) throws IOException, JRException { xmlWriter.startElement(JRXmlConstants.ELEMENT_frame); setFrameElementsOffset(frame, true); try { exportReportElement(frame); exportBox(frame.getLineBox()); exportElements(frame.getElements()); xmlWriter.closeElement(); } finally { restoreElementOffsets(); } }
protected void exportElements(List<JRPrintElement> elements) { for (int i = 0; i < elements.size();i++) { Object element = elements.get(i); if (element instanceof JRPrintText) { exportText((JRPrintText) element); } else if (element instanceof JRPrintFrame) { JRPrintFrame frame = (JRPrintFrame) element; setFrameElementsOffset(frame, false); try { exportElements(frame.getElements()); } finally { restoreElementOffsets(); } } } }
@Override public TableCell visit(LayeredCell layeredCell, TablePosition position) { SpanInfo<Column> colSpan = getColumnCellSpan(position, layeredCell); SpanInfo<Row> rowSpan = getRowCellSpan(position, layeredCell); Color backcolor = getElementBackcolor(layeredCell.getParent()); JRLineBox box = null; FrameCell parentCell = layeredCell.getParent(); if (parentCell != null) { boolean[] borders = getFrameCellBorders(position.getTable(), parentCell, position.getColumn(), colSpan.lastEntry, position.getRow(), rowSpan.lastEntry); if (borders[0] || borders[1] || borders[2] || borders[3]) { JRPrintFrame parentFrame = (JRPrintFrame) getCellElement(parentCell); box = copyFrameBox(parentCell, parentFrame, null, borders[0], borders[1], borders[2], borders[3]); } } return new TableCell(Tabulator.this, position, layeredCell, null, colSpan.span, rowSpan.span, backcolor, box); }
protected JRLineBox copyParentBox(Cell cell, JRPrintElement element, JRLineBox baseBox, boolean keepLeft, boolean keepRight, boolean keepTop, boolean keepBottom) { FrameCell parentCell = cell.getParent(); if (parentCell == null) { return baseBox; } // TODO lucianc check this in the table instead? JRPrintFrame parentFrame = (JRPrintFrame) getCellElement(parentCell); keepLeft &= element.getX() == 0 && parentFrame.getLineBox().getLeftPadding() == 0; keepRight &= (element.getX() + element.getWidth() + parentFrame.getLineBox().getLeftPadding()) == parentFrame.getWidth(); keepTop &= element.getY() == 0 && parentFrame.getLineBox().getTopPadding() == 0; keepBottom &= (element.getY() + element.getHeight() + parentFrame.getLineBox().getTopPadding()) == parentFrame.getHeight(); JRLineBox resultBox = baseBox; if (keepLeft || keepRight || keepTop || keepBottom) { resultBox = copyFrameBox(parentCell, parentFrame, baseBox, keepLeft, keepRight, keepTop, keepBottom); } return resultBox; }
public JRGridLayout getLayout() { JRPrintElement element = getElement(); if (!(element instanceof JRPrintFrame)) { // should not happen throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_NOT_FRAME_ELEMENT, new Object[]{getElementAddress()}); } JRPrintFrame frame = (JRPrintFrame) element; PrintElementIndex frameIndex = new PrintElementIndex(getParentIndex(), getElementIndex()); return new JRGridLayout( container, frame.getElements(), frame.getWidth(), frame.getHeight(), 0, //offsetX 0, //offsetY frameIndex ); }
protected void copy(JRPrintFrame printFrame) { //printElement.iconLabelComponent.getLineBox().clone(printElement); // if (contentVisible) // { labelTextField.setAlreadyPrinted(labelTextField.isToPrint() || labelTextField.isAlreadyPrinted()); iconTextField.setAlreadyPrinted(iconTextField.isToPrint() || iconTextField.isAlreadyPrinted()); if (labelTextField.isToPrint()) { printElement.addElement(labelPrintText); } if (iconTextField.isToPrint() && iconsVisible) { printElement.addElement(iconPrintText); } // } }
/** * */ private void addHorizontalGridLine(int x, int y, int width) { JRPrintFrame printFrame = new JRBasePrintFrame(getDefaultStyleProvider()); printFrame.setX(x); printFrame.setY(y); printFrame.setWidth(width); printFrame.setHeight(1); printFrame.getLineBox().getPen().setLineWidth(0); printFrame.getLineBox().getPen().setLineStyle(LineStyleEnum.SOLID); printFrame.getLineBox().getTopPen().setLineWidth(0.1f); printFrame.getLineBox().getTopPen().setLineStyle(LineStyleEnum.DASHED); printFrame.getLineBox().getTopPen().setLineColor(GRID_LINE_COLOR); pageElements.add(0, printFrame); }
/** * */ private void addVerticalGridLine(int x, int y, int height) { JRPrintFrame printFrame = new JRBasePrintFrame(getDefaultStyleProvider()); printFrame.setX(x); printFrame.setY(y); printFrame.setWidth(1); printFrame.setHeight(height); printFrame.getLineBox().getPen().setLineWidth(0); printFrame.getLineBox().getPen().setLineStyle(LineStyleEnum.SOLID); printFrame.getLineBox().getLeftPen().setLineWidth(0.1f); printFrame.getLineBox().getLeftPen().setLineStyle(LineStyleEnum.DASHED); printFrame.getLineBox().getLeftPen().setLineColor(GRID_LINE_COLOR); pageElements.add(0, printFrame); }
@Override public void visit(JRPrintFrame frame, T arg) { visitor.visit(frame, arg); List<JRPrintElement> elements = frame.getElements(); if (elements != null) { for (JRPrintElement element : elements) { element.accept(this, arg); } } }
@Override public void visit(JRPrintFrame frame, T arg) { for (PrintElementVisitor<T> visitor : visitors) { visitor.visit(frame, arg); } }
protected static void transformElements( TransformerContext context, String transformerExportKey, List<JRPrintElement> elements) { for (ListIterator<JRPrintElement> it = elements.listIterator(); it.hasNext();) { JRPrintElement element = it.next(); if (element instanceof JRGenericPrintElement) { JRGenericPrintElement genericElement = (JRGenericPrintElement) element; GenericElementTransformer handler = (GenericElementTransformer) GenericElementHandlerEnviroment.getInstance(context.getJasperReportsContext()).getElementHandler( genericElement.getGenericType(), transformerExportKey); if (handler != null && handler.toExport(genericElement)) { JRPrintElement transformed = handler.transformElement( context, genericElement); if (log.isDebugEnabled()) { log.debug("Transformed element " + genericElement + " to " + transformed + " using the " + transformerExportKey + " transformer"); } // assuming that the list is modifiable it.set(transformed); } } else if (element instanceof JRPrintFrame) { JRPrintFrame frame = (JRPrintFrame) element; transformElements(context, transformerExportKey, frame.getElements()); } } }
@Override protected void exportFrame(JRPrintFrame frame, JRExporterGridCell gridCell, int x, int y) { FillPatternType mode = backgroundMode; short backcolor = whiteIndex; if (frame.getModeValue() == ModeEnum.OPAQUE) { mode = FillPatternType.SOLID_FOREGROUND; backcolor = getWorkbookColor(frame.getBackcolor()).getIndex(); } short forecolor = getWorkbookColor(frame.getForecolor()).getIndex(); HSSFCellStyle cellStyle = getLoadedCellStyle( mode, backcolor, HorizontalAlignment.LEFT, VerticalAlignment.TOP, (short)0, getLoadedFont(getDefaultFont(), forecolor, null, getLocale()), gridCell, isWrapText(frame), isCellLocked(frame), isCellHidden(frame), isShrinkToFit(frame) ); createMergeRegion(gridCell, x, y, cellStyle); cell = row.createCell(x); cell.setCellStyle(cellStyle); }
/** * */ protected void exportFrame(TableBuilder tableBuilder, JRPrintFrame frame, JRExporterGridCell gridCell) throws IOException, JRException { tableBuilder.buildCellHeader(styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan()); boolean appendBackcolor = frame.getModeValue() == ModeEnum.OPAQUE && (backcolor == null || frame.getBackcolor().getRGB() != backcolor.getRGB()); if (appendBackcolor) { setBackcolor(frame.getBackcolor()); } try { JRGridLayout layout = ((ElementGridCell) gridCell).getLayout(); JRPrintElementIndex frameIndex = new JRPrintElementIndex( reportIndex, pageIndex, gridCell.getElementAddress() ); exportGrid(layout, frameIndex); } finally { if (appendBackcolor) { restoreBackcolor(); } } tableBuilder.buildCellFooter(); }
@Override protected void exportFrame( JRPrintFrame frame, JRExporterGridCell cell, int colIndex, int rowIndex ) throws JRException { addBlankCell(cell, colIndex, rowIndex); }
public void exportFrame(JRPrintFrame frame) throws DocumentException, IOException, JRException { if (frame.getModeValue() == ModeEnum.OPAQUE) { int x = frame.getX() + getOffsetX(); int y = frame.getY() + getOffsetY(); Color backcolor = frame.getBackcolor(); pdfContentByte.setRGBColorFill( backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue() ); pdfContentByte.rectangle( x, pageFormat.getPageHeight() - y, frame.getWidth(), - frame.getHeight() ); pdfContentByte.fill(); } setFrameElementsOffset(frame, false); try { exportElements(frame.getElements()); } finally { restoreElementOffsets(); } exportBox(frame.getLineBox(), frame); }
@Override public void visit(JRPrintFrame frame, TableCell cell) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_INTERNAL_ERROR, (Object[])null ); }
/** * */ private void setFrameElementsOffset(JRPrintFrame frame, int offsetX, int offsetY) { setElementOffsets( offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue(), offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue() ); }
protected void exportElements(Collection<JRPrintElement> elements) throws JRException, IOException { if (elements != null && elements.size() > 0) { for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) { JRPrintElement element = it.next(); if (filter == null || filter.isToExport(element)) { if (element instanceof JRPrintLine) { exportLine((JRPrintLine)element); } else if (element instanceof JRPrintRectangle) { exportRectangle((JRPrintRectangle)element); } else if (element instanceof JRPrintEllipse) { exportEllipse((JRPrintEllipse)element); } else if (element instanceof JRPrintImage) { exportImage((JRPrintImage)element); } else if (element instanceof JRPrintText) { exportText((JRPrintText)element); } else if (element instanceof JRPrintFrame) { exportFrame((JRPrintFrame)element); } else if (element instanceof JRGenericPrintElement) { exportGenericElement((JRGenericPrintElement)element); } } } } }
@Override public boolean isToExport(JRPrintElement element) { return (!isIgnoreGraphics || (element instanceof JRPrintText) || (element instanceof JRPrintFrame) || (element instanceof JRGenericPrintElement)) && (filter == null || filter.isToExport(element)); }
protected void endElement(JRPrintElement element) { if (isTagged) { if (element instanceof JRPrintFrame) { if (crtCrosstabRowY >= 0) // crosstab started { crosstabFrameDepth--; } } createEndTags(element); } }
/** * In deep grids, this is called only for empty frames. */ protected void exportFrame(DocxTableHelper tableHelper, JRPrintFrame frame, JRExporterGridCell gridCell) throws JRException { tableHelper.getCellHelper().exportHeader(frame, gridCell); // tableHelper.getCellHelper().exportProps(gridCell); boolean appendBackcolor = frame.getModeValue() == ModeEnum.OPAQUE && (backcolor == null || frame.getBackcolor().getRGB() != backcolor.getRGB()); if (appendBackcolor) { setBackcolor(frame.getBackcolor()); } try { JRGridLayout layout = ((ElementGridCell) gridCell).getLayout(); JRPrintElementIndex frameIndex = new JRPrintElementIndex( reportIndex, pageIndex, gridCell.getElementAddress() ); exportGrid(layout, frameIndex); } finally { if (appendBackcolor) { restoreBackcolor(); } } tableHelper.getParagraphHelper().exportEmptyParagraph(); tableHelper.getCellHelper().exportFooter(); }
public JRPrintImage getImage(ExporterInput exporterInput, JRPrintElementIndex imageIndex) throws JRException//FIXMECONTEXT move these to an abstract up? { List<ExporterInputItem> items = exporterInput.getItems(); ExporterInputItem item = items.get(imageIndex.getReportIndex()); JasperPrint report = item.getJasperPrint(); JRPrintPage page = report.getPages().get(imageIndex.getPageIndex()); Integer[] elementIndexes = imageIndex.getAddressArray(); Object element = page.getElements().get(elementIndexes[0].intValue()); for (int i = 1; i < elementIndexes.length; ++i) { JRPrintFrame frame = (JRPrintFrame) element; element = frame.getElements().get(elementIndexes[i].intValue()); } if(element instanceof JRGenericPrintElement) { JRGenericPrintElement genericPrintElement = (JRGenericPrintElement)element; return ((GenericElementXlsxHandler)GenericElementHandlerEnviroment.getInstance(jasperReportsContext).getElementHandler( genericPrintElement.getGenericType(), XLSX_EXPORTER_KEY )).getImage(exporterContext, genericPrintElement); } return (JRPrintImage) element; }
@Override public boolean isDeep(JRPrintFrame frame) { if ( frame.hasProperties() && frame.getPropertiesMap().containsProperty(DocxReportConfiguration.PROPERTY_FRAMES_AS_NESTED_TABLES) ) { // we make this test to avoid reaching the global default value of the property directly // and thus skipping the report level one, if present return !getPropertiesUtil().getBooleanProperty(frame, DocxReportConfiguration.PROPERTY_FRAMES_AS_NESTED_TABLES, !deepGrid); } return deepGrid; }
public void exportElement(JRPrintElement element) throws IOException, JRException { if (filter == null || filter.isToExport(element)) { if (element instanceof JRPrintLine) { exportLine((JRPrintLine)element); } else if (element instanceof JRPrintRectangle) { exportRectangle((JRPrintRectangle)element); } else if (element instanceof JRPrintEllipse) { exportEllipse((JRPrintEllipse)element); } else if (element instanceof JRPrintImage) { exportImage((JRPrintImage)element); } else if (element instanceof JRPrintText) { exportText((JRPrintText)element); } else if (element instanceof JRPrintFrame) { exportFrame((JRPrintFrame) element); } else if (element instanceof JRGenericPrintElement) { exportGenericElement((JRGenericPrintElement) element); } } }
public JRPrintElement getElement(PrintElementIndex parentIndex, int index) { // TODO lucianc keep a cache of current element position? JRPrintElement element; if (parentIndex == null) { element = elementList.get(index); } else { JRPrintFrame parentFrame = (JRPrintFrame) getElement(parentIndex.getParentIndex(), parentIndex.getIndex()); element = parentFrame.getElements().get(index); } return element; }
protected void createCuts(List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, boolean createXCuts) { for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) { JRPrintElement element = it.next(); if (nature.isToExport(element)) { if (createXCuts) { xCuts.addCutOffset(element.getX() + elementOffsetX); xCuts.addCutOffset(element.getX() + element.getWidth() + elementOffsetX); } yCuts.addCutOffset(element.getY() + elementOffsetY); yCuts.addCutOffset(element.getY() + element.getHeight() + elementOffsetY); JRPrintFrame frame = element instanceof JRPrintFrame ? (JRPrintFrame)element : null; if (frame != null && nature.isDeep(frame)) { createCuts( frame.getElements(), element.getX() + elementOffsetX + frame.getLineBox().getLeftPadding().intValue(), element.getY() + elementOffsetY + frame.getLineBox().getTopPadding().intValue(), createXCuts ); } } } }
/** * This static method calculates the X cuts for a list of print elements and * stores them in the list indicated by the xCuts parameter. * * @param elementsList * The list of elements to be used to determine the X cuts. * @param elementOffsetX * horizontal element position offset * @param xCuts * The list to which the X cuts are to be added. */ protected static void addXCuts(ExporterNature nature, List<JRPrintElement> elementsList, int elementOffsetX, CutsInfo xCuts) { for (Iterator<JRPrintElement> it = elementsList.iterator(); it.hasNext();) { JRPrintElement element = it.next(); if (nature.isToExport(element)) { xCuts.addCutOffset(element.getX() + elementOffsetX); xCuts.addCutOffset(element.getX() + element.getWidth() + elementOffsetX); if (element instanceof JRPrintFrame) { JRPrintFrame frame = (JRPrintFrame) element; addXCuts( nature, frame.getElements(), element.getX() + elementOffsetX + frame.getLineBox().getLeftPadding().intValue(), xCuts ); } nature.setXProperties(xCuts.getPropertiesMap(), element); } } }
protected void setElementCells(Table table, FrameCell parentCell, int xOffset, int yOffset, JRPrintElement element, PrintElementIndex parentIndex, int elementIndex, DimensionRange<Column> colRange, DimensionRange<Row> rowRange) { DimensionRange<Column> elementColRange = table.columns.addEntries(colRange); DimensionRange<Row> elementRowRange = table.rows.addEntries(rowRange); if (element instanceof JRPrintFrame) { JRPrintFrame frame = (JRPrintFrame) element; FrameCell frameCell = new FrameCell(parentCell, parentIndex, elementIndex); setElementCells(elementColRange, elementRowRange, frameCell); // go deep in the frame PrintElementIndex frameIndex = new PrintElementIndex(parentIndex, elementIndex); JRLineBox box = frame.getLineBox(); layoutElements(frame.getElements(), table, frameCell, frameIndex, xOffset + frame.getX() + box.getLeftPadding(), yOffset + frame.getY() + box.getTopPadding(), new Bounds(0, frame.getWidth() - box.getLeftPadding() - box.getRightPadding(), 0, frame.getHeight() - box.getTopPadding() - box.getBottomPadding())); } else { ElementCell elementCell = new ElementCell(parentCell, parentIndex, elementIndex); setElementCells(elementColRange, elementRowRange, elementCell); } }
protected JRPrintElement getCellElement(PrintElementIndex parentIndex, int index) { // TODO lucianc keep a cache of current element position? JRPrintElement element; if (parentIndex == null) { element = elements.get(index); } else { JRPrintFrame parentFrame = (JRPrintFrame) getCellElement(parentIndex.getParentIndex(), parentIndex.getIndex()); element = parentFrame.getElements().get(index); } return element; }
@Override public TableCell visit(FrameCell frameCell, TablePosition position) { JRPrintElement element = getCellElement(frameCell); Color backcolor = getElementBackcolor(frameCell); boolean[] borders = getFrameCellBorders(position.getTable(), frameCell, position.getColumn(), position.getColumn(), position.getRow(), position.getRow()); JRLineBox box = copyFrameBox(frameCell, (JRPrintFrame) element, null, borders[0], borders[1], borders[2], borders[3]); return new TableCell(Tabulator.this, position, frameCell, element, 1, 1, backcolor, box); }
protected JRLineBox copyFrameBox(FrameCell frameCell, JRPrintFrame frame, JRLineBox baseBox, boolean keepLeft, boolean keepRight, boolean keepTop, boolean keepBottom) { // TODO lucianc cache JRLineBox resultBox = JRBoxUtil.copyBordersNoPadding(frame.getLineBox(), keepLeft, keepRight, keepTop, keepBottom, baseBox); // recurse resultBox = copyParentBox(frameCell, frame, resultBox, keepLeft, keepRight, keepTop, keepBottom); return resultBox; }