@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); } } }
@Override public void visit(JRPrintLine line, T arg) { for (PrintElementVisitor<T> visitor : visitors) { visitor.visit(line, arg); } }
/** * */ public void exportLine(JRPrintLine line, JRExporterGridCell gridCell) { buildCellHeader(null, gridCell.getColSpan(), gridCell.getRowSpan()); double x1, y1, x2, y2; if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { x1 = 0; y1 = 0; x2 = line.getWidth() - 1; y2 = line.getHeight() - 1; } else { x1 = 0; y1 = line.getHeight() - 1; x2 = line.getWidth() - 1; y2 = 0; } bodyWriter.write("<text:p>"); documentBuilder.insertPageAnchor(this); bodyWriter.write( "<draw:line text:anchor-type=\"paragraph\" " + "draw:style-name=\"" + styleCache.getGraphicStyle(line) + "\" " + "svg:x1=\"" + LengthUtil.inchFloor4Dec(x1) + "in\" " + "svg:y1=\"" + LengthUtil.inchFloor4Dec(y1) + "in\" " + "svg:x2=\"" + LengthUtil.inchFloor4Dec(x2) + "in\" " + "svg:y2=\"" + LengthUtil.inchFloor4Dec(y2) + "in\">" //+ "</draw:line>" + "<text:p/></draw:line>" + "</text:p>" ); buildCellFooter(); }
@Override public void visit(JRPrintLine line, TableCell cell) { try { writeLine(line, cell); } catch (IOException e) { throw new JRRuntimeException(e); } }
@Override public void visit(JRPrintLine line, Offset offset) { lineDrawer.draw( grx, line, offset.getX(), offset.getY() ); }
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); } } } } }
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); } } }
/** * @throws IOException * */ protected void exportLine(JRPrintLine line) throws IOException { xmlWriter.startElement(JRXmlConstants.ELEMENT_line); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_direction, line.getDirectionValue(), LineDirectionEnum.TOP_DOWN); exportReportElement(line); exportGraphicElement(line); xmlWriter.closeElement(); }
@Override public void paintValue(Graphics grx, Rectangle box) { JRPen pen = getValue() instanceof JRPen ? (JRPen)getValue() : null; if (pen == null) { super.paintValue(grx, box); } else { // //grx.clearRect(box.x, box.y, box.width, box.height); // grx.setColor(pen.getLineColor() == null ? Color.BLACK : pen.getLineColor()); // //Stroke s = BoxBorderSelectionPanel.createStroke(pen); // Stroke stroke = JRPenUtil.getStroke(pen, BasicStroke.CAP_SQUARE); // if (stroke != null) // { // ((Graphics2D)grx).setStroke(stroke); // grx.drawLine(box.x + 4, box.y + box.height / 2, box.x + box.width - 4, box.y + box.height / 2); // } JRPrintLine line = new JRBasePrintLine(null); line.setX(box.x + 4); line.setY(box.y + box.height / 2); line.setWidth(box.width - 8); line.setHeight(1); line.getLinePen().setLineColor(pen.getLineColor()); line.getLinePen().setLineStyle(pen.getLineStyleValue()); line.getLinePen().setLineWidth(pen.getLineWidth()); new LineDrawer().draw((Graphics2D)grx, line, 0, 0); } }
@Override public void visit(JRPrintLine line, T arg) { //NOP }
@Override public void visit(JRPrintLine line, T arg) { visitor.visit(line, arg); }
@Override public void visit(JRPrintLine line, T arg) { visitElement(line, arg); }
@Override protected void exportLine(JRPrintLine line, JRExporterGridCell gridCell, int colIndex, int rowIndex) { short forecolor = getWorkbookColor(line.getLinePen().getLineColor()).getIndex(); int side = BoxStyle.TOP; float ratio = line.getWidth() / line.getHeight(); if (ratio > 1) { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { side = BoxStyle.TOP; } else { side = BoxStyle.BOTTOM; } } else { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { side = BoxStyle.LEFT; } else { side = BoxStyle.RIGHT; } } BoxStyle boxStyle = new BoxStyle(side, line.getLinePen()); FillPatternType mode = backgroundMode; short backcolor = whiteIndex; if (!Boolean.TRUE.equals(sheetInfo.ignoreCellBackground) && gridCell.getCellBackcolor() != null) { mode = FillPatternType.SOLID_FOREGROUND; backcolor = getWorkbookColor(gridCell.getCellBackcolor()).getIndex(); } HSSFCellStyle cellStyle = getLoadedCellStyle( mode, backcolor, HorizontalAlignment.LEFT, VerticalAlignment.TOP, (short)0, getLoadedFont(getDefaultFont(), forecolor, null, getLocale()), boxStyle, false, isCellLocked(line), isCellHidden(line), isShrinkToFit(line) ); createMergeRegion(gridCell, colIndex, rowIndex, cellStyle); cell = row.createCell(colIndex); cell.setCellStyle(cellStyle); }
/** * */ protected void exportLine(TableBuilder tableBuilder, JRPrintLine line, JRExporterGridCell gridCell) { tableBuilder.exportLine(line, gridCell); }
@Override protected void exportLine( JRPrintLine line, JRExporterGridCell gridCell, int colIndex, int rowIndex ) throws JRException { JRLineBox box = new JRBaseLineBox(null); JRPen pen = null; float ratio = line.getWidth() / line.getHeight(); if (ratio > 1) { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { pen = box.getTopPen(); } else { pen = box.getBottomPen(); } } else { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { pen = box.getLeftPen(); } else { pen = box.getRightPen(); } } pen.setLineColor(line.getLinePen().getLineColor()); pen.setLineStyle(line.getLinePen().getLineStyleValue()); pen.setLineWidth(line.getLinePen().getLineWidth()); gridCell.setBox(box);//CAUTION: only some exporters set the cell box tableBuilder.buildCellHeader(styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan()); // double x1, y1, x2, y2; // // if (line.getDirection() == JRLine.DIRECTION_TOP_DOWN) // { // x1 = Utility.translatePixelsToInches(0); // y1 = Utility.translatePixelsToInches(0); // x2 = Utility.translatePixelsToInches(line.getWidth() - 1); // y2 = Utility.translatePixelsToInches(line.getHeight() - 1); // } // else // { // x1 = Utility.translatePixelsToInches(0); // y1 = Utility.translatePixelsToInches(line.getHeight() - 1); // x2 = Utility.translatePixelsToInches(line.getWidth() - 1); // y2 = Utility.translatePixelsToInches(0); // } tempBodyWriter.write("<text:p>"); //FIXMEODS insertPageAnchor(); // tempBodyWriter.write( // "<draw:line text:anchor-type=\"paragraph\" " // + "draw:style-name=\"" + styleCache.getGraphicStyle(line) + "\" " // + "svg:x1=\"" + x1 + "in\" " // + "svg:y1=\"" + y1 + "in\" " // + "svg:x2=\"" + x2 + "in\" " // + "svg:y2=\"" + y2 + "in\">" // //+ "</draw:line>" // + "<text:p/></draw:line>" // ); tempBodyWriter.write("</text:p>"); tableBuilder.buildCellFooter(); }
protected void exportElements(Collection<JRPrintElement> elements) throws DocumentException, IOException, JRException { if (elements != null && elements.size() > 0) { for(Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) { JRPrintElement element = it.next(); if (filter == null || filter.isToExport(element)) { tagHelper.startElement(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); } tagHelper.endElement(element); } } } }
protected void writeLine(JRPrintLine line, TableCell cell) throws IOException { startCell(line, cell); if(isOblique(line)) { finishStartCell(); int width = line.getWidth(); int height = line.getHeight(); LineDirectionEnum lineDirection = line.getDirectionValue(); int y1 = lineDirection == LineDirectionEnum.BOTTOM_UP ? height : 0; int y2 = lineDirection == LineDirectionEnum.BOTTOM_UP ? 0 : height; writer.write("<svg height=\"" + height + "\" width=\"" + width + "\">"); writer.write("<line x1=\"0\" y1=\"" + y1 +"\" x2=\"" + width + "\" y2=\"" + y2 + "\" "); writeSvgStyle(line); writer.write("\"/></svg>"); } else { StringBuilder styleBuffer = new StringBuilder(); appendElementCellGenericStyle(cell, styleBuffer); appendBackcolorStyle(cell, styleBuffer); String side = null; float ratio = line.getWidth() / line.getHeight(); if (ratio > 1) { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { side = "top"; } else { side = "bottom"; } } else { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { side = "left"; } else { side = "right"; } } appendPen( styleBuffer, line.getLinePen(), side ); writeStyle(styleBuffer); finishStartCell(); } endCell(); }
protected boolean isOblique(JRPrintLine line){ return line.getWidth() > 1 && line.getHeight() > 1; }
@Override protected void exportLine(JRPrintLine line) throws JRException { String currentColumnName = line.getPropertiesMap().getProperty(JRXlsAbstractMetadataExporter.PROPERTY_COLUMN_NAME); if (currentColumnName != null && currentColumnName.length() > 0) { boolean repeatValue = getPropertiesUtil().getBooleanProperty(line, JRXlsAbstractMetadataExporter.PROPERTY_REPEAT_VALUE, false); setColumnName(currentColumnName); adjustColumnWidth(currentColumnName, line.getWidth(), ((JRXlsExporterNature)nature).getColumnAutoFit(line)); adjustRowHeight(line.getHeight(), ((JRXlsExporterNature)nature).getRowAutoFit(line)); short forecolor = getWorkbookColor(line.getLinePen().getLineColor()).getIndex(); int side = BoxStyle.TOP; float ratio = line.getWidth() / line.getHeight(); if (ratio > 1) { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { side = BoxStyle.TOP; } else { side = BoxStyle.BOTTOM; } } else { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { side = BoxStyle.LEFT; } else { side = BoxStyle.RIGHT; } } BoxStyle boxStyle = new BoxStyle(side, line.getLinePen()); FillPatternType mode = backgroundMode; short backcolor = whiteIndex; if (!Boolean.TRUE.equals(sheetInfo.ignoreCellBackground) && line.getBackcolor() != null) { mode = FillPatternType.SOLID_FOREGROUND; backcolor = getWorkbookColor(line.getBackcolor()).getIndex(); } HSSFCellStyle cellStyle = getLoadedCellStyle( mode, backcolor, HorizontalAlignment.LEFT, VerticalAlignment.TOP, (short)0, getLoadedFont(getDefaultFont(), forecolor, null, getLocale()), boxStyle, isCellLocked(line), isCellHidden(line), isShrinkToFit(line) ); addBlankElement(cellStyle, repeatValue, currentColumnName); } }
/** * Draw a line object * @param line JasperReports line object - JRPrintLine * @throws IOException */ protected void exportLine(JRPrintLine line) throws IOException { int x = line.getX() + getOffsetX(); int y = line.getY() + getOffsetY(); int height = line.getHeight(); int width = line.getWidth(); if (width <= 1 || height <= 1) { if (width > 1) { height = 0; } else { width = 0; } } contentWriter.write("{\\shp\\shpbxpage\\shpbypage\\shpwr5\\shpfhdr0\\shpz"); contentWriter.write(String.valueOf(zorder++)); contentWriter.write("\\shpleft"); contentWriter.write(String.valueOf(LengthUtil.twip(x))); contentWriter.write("\\shpright"); contentWriter.write(String.valueOf(LengthUtil.twip(x + width))); contentWriter.write("\\shptop"); contentWriter.write(String.valueOf(LengthUtil.twip(y))); contentWriter.write("\\shpbottom"); contentWriter.write(String.valueOf(LengthUtil.twip(y + height))); contentWriter.write("{\\shpinst"); contentWriter.write("{\\sp{\\sn shapeType}{\\sv 20}}"); exportPen(line.getLinePen()); if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { contentWriter.write("{\\sp{\\sn fFlipV}{\\sv 0}}"); } else { contentWriter.write("{\\sp{\\sn fFlipV}{\\sv 1}}"); } contentWriter.write("}}\n"); }
@Override protected void exportLine(JRPrintLine line, JRExporterGridCell cell, int colIndex, int rowIndex) throws JRException { }
/** * */ protected void exportElements(List<JRPrintElement> elements) throws JRException { if (elements != null && elements.size() > 0) { JRPrintElement element; for(int i = 0; i < elements.size(); i++) { elementIndex = i; element = elements.get(i); 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); } } } } }
/** * */ protected void exportLine(DocxTableHelper tableHelper, JRPrintLine line, JRExporterGridCell gridCell) { JRLineBox box = new JRBaseLineBox(null); JRPen pen = null; float ratio = line.getWidth() / line.getHeight(); if (ratio > 1) { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { pen = box.getTopPen(); } else { pen = box.getBottomPen(); } } else { if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { pen = box.getLeftPen(); } else { pen = box.getRightPen(); } } pen.setLineColor(line.getLinePen().getLineColor()); pen.setLineStyle(line.getLinePen().getLineStyleValue()); pen.setLineWidth(line.getLinePen().getLineWidth()); gridCell.setBox(box);//CAUTION: only some exporters set the cell box tableHelper.getCellHelper().exportHeader(line, gridCell); tableHelper.getParagraphHelper().exportEmptyParagraph(startPage, bookmarkIndex, pageAnchor); if (startPage) { // increment the bookmarkIndex for the first cell in the sheet, due to page anchor creation bookmarkIndex++; } tableHelper.getCellHelper().exportFooter(); }
@Override protected void exportLine( JRPrintLine line, JRExporterGridCell gridCell, int colIndex, int rowIndex ) throws JRException { JRLineBox box = new JRBaseLineBox(null); JRPen pen = null; LineDirectionEnum direction = null; float ratio = line.getWidth() / line.getHeight(); if (ratio > 1) { if(line.getHeight() > 1) { direction = line.getDirectionValue(); pen = box.getPen(); } else if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { pen = box.getTopPen(); } else { pen = box.getBottomPen(); } } else { if(line.getWidth() > 1) { direction = line.getDirectionValue(); pen = box.getPen(); } else if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) { pen = box.getLeftPen(); } else { pen = box.getRightPen(); } } pen.setLineColor(line.getLinePen().getLineColor()); pen.setLineStyle(line.getLinePen().getLineStyleValue()); pen.setLineWidth(line.getLinePen().getLineWidth()); gridCell.setBox(box);//CAUTION: only some exporters set the cell box cellHelper.exportHeader(gridCell, rowIndex, colIndex, maxColumnIndex, sheetInfo, direction); sheetHelper.exportMergedCells(rowIndex, colIndex, maxColumnIndex, gridCell.getRowSpan(), gridCell.getColSpan()); cellHelper.exportFooter(); }
protected abstract void exportLine(JRPrintLine line) throws JRException;
protected abstract void exportLine(JRPrintLine line, JRExporterGridCell cell, int colIndex, int rowIndex) throws JRException;