protected static void setPenAttributes(Attributes atts, JRPen pen) { String lineWidth = atts.getValue(JRXmlConstants.ATTRIBUTE_lineWidth); if (lineWidth != null && lineWidth.length() > 0) { pen.setLineWidth(Float.parseFloat(lineWidth)); } LineStyleEnum lineStyle = LineStyleEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_lineStyle)); if (lineStyle != null) { pen.setLineStyle(lineStyle); } String lineColor = atts.getValue(JRXmlConstants.ATTRIBUTE_lineColor); if (lineColor != null && lineColor.length() > 0) { pen.setLineColor(JRColorUtil.getColor(lineColor, null)); } }
/** * */ public JRStyle getBaseStyle(JRPen pen) { if (pen != null) { JRPenContainer penContainer = pen.getPenContainer(); if (penContainer instanceof JRStyle) { return getBaseStyle((JRStyle)penContainer); } if (penContainer instanceof JRLineBox) { return getBaseStyle((JRLineBox)penContainer); } return getBaseStyle(penContainer); } return null; }
/** * */ public Float getLineWidth(JRPen pen, Float defaultLineWidth) { Float ownLineWidth = pen.getOwnLineWidth(); if (ownLineWidth != null) { return ownLineWidth; } JRStyle baseStyle = getBaseStyle(pen); if (baseStyle != null) { Float lineWidth = baseStyle.getLinePen().getLineWidth(); if (lineWidth != null) { return lineWidth; } } return defaultLineWidth; }
/** * */ public LineStyleEnum getLineStyleValue(JRPen pen) { LineStyleEnum ownLineStyle = pen.getOwnLineStyleValue(); if (ownLineStyle != null) { return ownLineStyle; } JRStyle baseStyle = getBaseStyle(pen); if (baseStyle != null) { LineStyleEnum lineStyle = baseStyle.getLinePen().getLineStyleValue(); if (lineStyle != null) { return lineStyle; } } return LineStyleEnum.SOLID; }
/** * */ public Color getLineColor(JRPen pen, Color defaultColor) { Color ownLineColor = pen.getOwnLineColor(); if (ownLineColor != null) { return ownLineColor; } JRStyle baseStyle = getBaseStyle(pen); if (baseStyle != null) { Color lineColor = baseStyle.getLinePen().getLineColor(); if (lineColor != null) { return lineColor; } } return defaultColor; }
/** * Merges two pens, by appending the properties of the source pen to the ones of the destination pen. */ public static void appendPen(JRPen destPen, JRPen srcPen) { if (srcPen.getOwnLineWidth() != null) { destPen.setLineWidth(srcPen.getOwnLineWidth()); } if (srcPen.getOwnLineStyleValue() != null) { destPen.setLineStyle(srcPen.getOwnLineStyleValue()); } if (srcPen.getOwnLineColor() != null) { destPen.setLineColor(srcPen.getOwnLineColor()); } }
public void setPen(JRPen pen) { if ( borderStyle[TOP] == BorderStyle.NONE && borderStyle[LEFT] == BorderStyle.NONE && borderStyle[BOTTOM] == BorderStyle.NONE && borderStyle[RIGHT] == BorderStyle.NONE ) { BorderStyle style = JRXlsExporter.getBorderStyle(pen); short colour = JRXlsExporter.this.getWorkbookColor(pen.getLineColor()).getIndex(); borderStyle[TOP] = style; borderStyle[BOTTOM] = style; borderStyle[LEFT] = style; borderStyle[RIGHT] = style; borderColour[TOP] = colour; borderColour[BOTTOM] = colour; borderColour[LEFT] = colour; borderColour[RIGHT] = colour; } hash = computeHash(); }
/** * */ public void setPen(JRPen pen) { if ( borderWidth[TOP_BORDER] == null && borderWidth[LEFT_BORDER] == null && borderWidth[BOTTOM_BORDER] == null && borderWidth[RIGHT_BORDER] == null ) { appendBorder(pen, TOP_BORDER); appendBorder(pen, LEFT_BORDER); appendBorder(pen, BOTTOM_BORDER); appendBorder(pen, RIGHT_BORDER); } }
public void setPen(JRPen pen) { if ( borderStyle[TOP] == BorderStyle.NONE && borderStyle[LEFT] == BorderStyle.NONE && borderStyle[BOTTOM] == BorderStyle.NONE && borderStyle[RIGHT] == BorderStyle.NONE ) { BorderStyle style = JRXlsMetadataExporter.getBorderStyle(pen); short colour = JRXlsMetadataExporter.this.getWorkbookColor(pen.getLineColor()).getIndex(); borderStyle[TOP] = style; borderStyle[BOTTOM] = style; borderStyle[LEFT] = style; borderStyle[RIGHT] = style; borderColour[TOP] = colour; borderColour[BOTTOM] = colour; borderColour[LEFT] = colour; borderColour[RIGHT] = colour; } hash = computeHash(); }
/** * */ private void exportBorder(JRPen pen, float x, float y, float width, float height) throws IOException { contentWriter.write("{\\shp\\shpbxpage\\shpbypage\\shpwr5\\shpfhdr0\\shpz"); contentWriter.write(String.valueOf(zorder++)); contentWriter.write("\\shpleft"); contentWriter.write(String.valueOf(LengthUtil.twip(x)));//FIXMEBORDER starting point of borders seem to have CAP_SQUARE-like appearence at least for Thin 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(pen); contentWriter.write("}}\n"); }
/** * */ private void exportTopPen( JRPen topPen, JRPen leftPen, JRPen rightPen, int x, int y, int width, int height ) throws IOException { if (topPen.getLineWidth().floatValue() > 0f) { exportBorder( topPen, x - leftPen.getLineWidth().floatValue() / 2, y, width + (leftPen.getLineWidth().floatValue() + rightPen.getLineWidth().floatValue()) / 2, 0 ); //exportBorder(topPen, x, y + getAdjustment(topPen), width, 0); } }
/** * */ private void exportLeftPen( JRPen topPen, JRPen leftPen, JRPen bottomPen, int x, int y, int width, int height ) throws IOException { if (leftPen.getLineWidth().floatValue() > 0f) { exportBorder( leftPen, x, y - topPen.getLineWidth().floatValue() / 2, 0, height + (topPen.getLineWidth().floatValue() + bottomPen.getLineWidth().floatValue()) / 2 ); //exportBorder(leftPen, x + getAdjustment(leftPen), y, 0, height); } }
/** * */ private void exportBottomPen( JRPen leftPen, JRPen bottomPen, JRPen rightPen, int x, int y, int width, int height ) throws IOException { if (bottomPen.getLineWidth().floatValue() > 0f) { exportBorder( bottomPen, x - leftPen.getLineWidth().floatValue() / 2, y + height, width + (leftPen.getLineWidth().floatValue() + rightPen.getLineWidth().floatValue()) / 2, 0 ); //exportBorder(bottomPen, x, y + height - getAdjustment(bottomPen), width, 0); } }
/** * */ private void exportRightPen( JRPen topPen, JRPen bottomPen, JRPen rightPen, int x, int y, int width, int height ) throws IOException { if (rightPen.getLineWidth().floatValue() > 0f) { exportBorder( rightPen, x + width, y - topPen.getLineWidth().floatValue() / 2, 0, height + (topPen.getLineWidth().floatValue() + bottomPen.getLineWidth().floatValue()) / 2 ); //exportBorder(rightPen, x + width - getAdjustment(rightPen), y, 0, height); } }
@Override protected int getImageBorderCorrection(JRPen pen) { float lineWidth = pen.getLineWidth().floatValue(); if (lineWidth > 0f) { if (lineWidth >= 2f) { return 2; } return 1; } return getCurrentItemConfiguration().isImageBorderFixEnabled() ? 1 : 0; }
/** * */ protected void exportRectangle(DocxTableHelper tableHelper, JRPrintRectangle rectangle, JRExporterGridCell gridCell) { JRLineBox box = new JRBaseLineBox(null); JRPen pen = box.getPen(); pen.setLineColor(rectangle.getLinePen().getLineColor()); pen.setLineStyle(rectangle.getLinePen().getLineStyleValue()); pen.setLineWidth(rectangle.getLinePen().getLineWidth()); gridCell.setBox(box);//CAUTION: only some exporters set the cell box tableHelper.getCellHelper().exportHeader(rectangle, 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(); }
/** * */ protected void exportEllipse(DocxTableHelper tableHelper, JRPrintEllipse ellipse, JRExporterGridCell gridCell) { JRLineBox box = new JRBaseLineBox(null); JRPen pen = box.getPen(); pen.setLineColor(ellipse.getLinePen().getLineColor()); pen.setLineStyle(ellipse.getLinePen().getLineStyleValue()); pen.setLineWidth(ellipse.getLinePen().getLineWidth()); gridCell.setBox(box);//CAUTION: only some exporters set the cell box tableHelper.getCellHelper().exportHeader(ellipse, 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(); }
/** * */ public DocxBorderInfo(JRPen pen) { if ( borderWidth[TOP_BORDER] == null && borderWidth[LEFT_BORDER] == null && borderWidth[BOTTOM_BORDER] == null && borderWidth[RIGHT_BORDER] == null ) { setBorder(pen, TOP_BORDER); setBorder(pen, LEFT_BORDER); setBorder(pen, BOTTOM_BORDER); setBorder(pen, RIGHT_BORDER); } }
@Override protected void exportRectangle( JRPrintGraphicElement rectangle, JRExporterGridCell gridCell, int colIndex, int rowIndex ) throws JRException { JRLineBox box = new JRBaseLineBox(null); JRPen pen = box.getPen(); pen.setLineColor(rectangle.getLinePen().getLineColor()); pen.setLineStyle(rectangle.getLinePen().getLineStyleValue()); pen.setLineWidth(rectangle.getLinePen().getLineWidth()); gridCell.setBox(box);//CAUTION: only some exporters set the cell box cellHelper.exportHeader(gridCell, rowIndex, colIndex, maxColumnIndex, sheetInfo); sheetHelper.exportMergedCells(rowIndex, colIndex, maxColumnIndex, gridCell.getRowSpan(), gridCell.getColSpan()); cellHelper.exportFooter(); }
/** * */ protected int getImageBorderCorrection(JRPen pen) { float lineWidth = pen.getLineWidth().floatValue(); if (lineWidth > 0f) { if (lineWidth >= 2f) { return 2; } return 1; } return getCurrentItemConfiguration().isImageBorderFixEnabled() ? 1 : 0; }
@Override public String getText(Object element) { if (element != null && element instanceof MLinePen) { JRPen pen = (JRPen) ((MLinePen) element).getValue(); String lineStyle = pen.getOwnLineStyleValue() != null ? pen.getOwnLineStyleValue().getName() : NullEnum.INHERITED .getName(); String lineWidth = pen.getOwnLineWidth() != null ? pen.getOwnLineWidth().toString() : NullEnum.INHERITED .getName(); Color rgb = pen.getOwnLineColor(); String lineColor = NullEnum.INHERITED.getName(); if (rgb != null) lineColor = "RGB (" + rgb.getRed() + "," + rgb.getGreen() + "," + rgb.getBlue() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ return "[" + lineStyle + "," + lineWidth + "," + lineColor + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } return ""; //$NON-NLS-1$ }
/** Create a StringCustomEditor. * @param value the initial value for the string * @param editable whether to show the editor in read only or read-write mode (NOT USED) * @param oneline whether the text component should be a single-line or multi-line component (NOT USED) * @param instructions any instructions that should be displayed (NOT USED) */ JRPenPropertyCustomEditor (JRPen value, boolean oneline, String instructions, PropertyEditor editor, PropertyEnv env) { super(); this.oneline = oneline; this.instructions = instructions; this.env = env; this.editor = editor; this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION); this.env.addPropertyChangeListener(this); if (value != null) { this.setPen(value); } }
/** * */ private void writePen(String element, JRPen pen) throws IOException { writer.startElement(element); writer.addAttribute(JRXmlConstants.ATTRIBUTE_lineWidth, pen.getOwnLineWidth()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_lineStyle, pen.getOwnLineStyleValue()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_lineColor, pen.getOwnLineColor()); writer.closeElement(true); }
/** * * @param element * @param pen * @throws IOException */ private void writePen( JRPen pen, String penHolder) { if(pen != null) { write( penHolder + ".setLineWidth({0});\n", pen.getOwnLineWidth()); write( penHolder + ".setLineStyle({0});\n", pen.getOwnLineStyleValue()); write( penHolder + ".setLineColor({0});\n", pen.getOwnLineColor()); flush(); } }
public BoxStyle(int side, JRPen pen) { borderStyle[side] = JRXlsExporter.getBorderStyle(pen); borderColour[side] = JRXlsExporter.this.getWorkbookColor(pen.getLineColor()).getIndex(); hash = computeHash(); }
/** * */ public void exportRectangle(JRPrintGraphicElement rectangle, JRExporterGridCell gridCell) { JRLineBox box = new JRBaseLineBox(null); JRPen pen = box.getPen(); pen.setLineColor(rectangle.getLinePen().getLineColor()); pen.setLineStyle(rectangle.getLinePen().getLineStyleValue()); pen.setLineWidth(rectangle.getLinePen().getLineWidth()); gridCell.setBox(box);//CAUTION: only some exporters set the cell box buildCellHeader(styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan()); buildCellFooter(); }
/** * */ private void appendBorder(JRPen pen, int side) { double width = pen.getLineWidth().doubleValue(); String style = null; if (width > 0f) { switch (pen.getLineStyleValue())//FIXMEBORDER is this working? deal with double border too. { case DOTTED : { style = "dotted"; break; } case DASHED : { style = "dashed"; break; } case SOLID : default : { style = "solid"; break; } } borderWidth[side] = String.valueOf(LengthUtil.inchFloor4Dec(width)); } else { style = "none"; } borderStyle[side] = style; borderColor[side] = JRColorUtil.getColorHexa(pen.getLineColor()); }
/** * */ protected void exportPen(JRPen pen, JRPrintElement element) { exportTopPen(pen, pen, pen, element); exportLeftPen(pen, pen, pen, element); exportBottomPen(pen, pen, pen, element); exportRightPen(pen, pen, pen, element); pdfContentByte.setLineDash(0f); pdfContentByte.setLineCap(PdfContentByte.LINE_CAP_PROJECTING_SQUARE); }
/** * */ protected static BorderStyle getBorderStyle(JRPen pen) { float lineWidth = pen.getLineWidth().floatValue(); if (lineWidth > 0f) { switch (pen.getLineStyleValue()) { case DOUBLE : { return BorderStyle.DOUBLE; } case DOTTED : { return BorderStyle.DOTTED; } case DASHED : { if (lineWidth >= 1f) { return BorderStyle.MEDIUM_DASHED; } return BorderStyle.DASHED; } case SOLID : default : { if (lineWidth >= 2f) { return BorderStyle.THICK; } else if (lineWidth >= 1f) { return BorderStyle.MEDIUM; } else if (lineWidth >= 0.5f) { return BorderStyle.THIN; } return BorderStyle.HAIR; } } } return BorderStyle.NONE; }
/** * */ protected void drawPen(Graphics2D grx, JRPen pen, JRPrintElement element, int offsetX, int offsetY) { drawTopPen(grx, pen, pen, pen, element, offsetX, offsetY); drawLeftPen(grx, pen, pen, pen, element, offsetX, offsetY); drawBottomPen(grx, pen, pen, pen, element, offsetX, offsetY); drawRightPen(grx, pen, pen, pen, element, offsetX, offsetY); }
/** * */ private void exportPen(JRPen pen) throws IOException { contentWriter.write("{\\sp{\\sn lineColor}{\\sv "); contentWriter.write(String.valueOf(getColorRGB(pen.getLineColor()))); contentWriter.write("}}"); float lineWidth = pen.getLineWidth().floatValue(); if (lineWidth == 0f) { contentWriter.write("{\\sp{\\sn fLine}{\\sv 0}}"); } switch (pen.getLineStyleValue()) { case DOUBLE : { contentWriter.write("{\\sp{\\sn lineStyle}{\\sv 1}}"); break; } case DOTTED : { contentWriter.write("{\\sp{\\sn lineDashing}{\\sv 2}}"); break; } case DASHED : { contentWriter.write("{\\sp{\\sn lineDashing}{\\sv 1}}"); break; } } contentWriter.write("{\\sp{\\sn lineWidth}{\\sv "); contentWriter.write(String.valueOf(LengthUtil.emu(lineWidth))); contentWriter.write("}}"); }
/** * */ private void exportPen(JRPen pen, int x, int y, int width, int height) throws IOException { exportTopPen(pen, pen, pen, x, y, width, height); exportLeftPen(pen, pen, pen, x, y, width, height); exportBottomPen(pen, pen, pen, x, y, width, height); exportRightPen(pen, pen, pen, x, y, width, height); }
/** * */ public void export(JRPen pen) { if (pen != null) { export(new DocxBorderInfo(pen)); } }
/** * */ public XlsxBorderInfo(JRPen pen) { setBorder(pen, TOP_BORDER); setBorder(pen, LEFT_BORDER); setBorder(pen, BOTTOM_BORDER); setBorder(pen, RIGHT_BORDER); }
/** * */ public void export(JRPen pen) { if (pen != null) { export(new XlsxBorderInfo(pen)); } }
/** * @throws IOException * */ protected void exportPen(String element, JRPen pen) throws IOException { xmlWriter.startElement(element); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_lineWidth, pen.getOwnLineWidth()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_lineStyle, pen.getOwnLineStyleValue()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_lineColor, pen.getOwnLineColor()); xmlWriter.closeElement(true); }
@Override public void trasnferProperties(JRElement target){ super.trasnferProperties(target); JRDesignGraphicElement jrSourceElement = (JRDesignGraphicElement) getValue(); JRPen jrSourceBox = (JRPen)jrSourceElement.getLinePen(); JRDesignGraphicElement jrTargetElement = (JRDesignGraphicElement) target; JRPen jrTargetBox = (JRPen)jrTargetElement.getLinePen(); if (jrSourceBox != null && jrTargetBox != null){ jrTargetBox.setLineColor(getColorClone(jrSourceBox.getOwnLineColor())); jrTargetBox.setLineStyle(jrSourceBox.getOwnLineStyleValue()); jrTargetBox.setLineWidth(jrSourceBox.getOwnLineWidth()); } }
private void transferLinePenProeprties(JRPen jrTarget, JRPen source){ if (jrTarget != null && source != null){ jrTarget.setLineColor(getColorClone(source.getOwnLineColor())); jrTarget.setLineStyle(source.getOwnLineStyleValue()); Float lineWidth = source.getOwnLineWidth(); jrTarget.setLineWidth(lineWidth != null ? lineWidth.floatValue(): null); } }
public Object getPropertyValue(Object id) { // pen JRPen linePen = (JRPen) getValue(); if (linePen != null) { if (id.equals(JRBasePen.PROPERTY_LINE_COLOR)) return Colors.getSWTRGB4AWTGBColor(linePen.getOwnLineColor()); if (id.equals(JRBasePen.PROPERTY_LINE_WIDTH)) return linePen.getOwnLineWidth(); if (id.equals(JRBasePen.PROPERTY_LINE_STYLE)) return penLineStyleD.getEnumValue(linePen.getOwnLineStyleValue()); } return null; }
public Object getPropertyActualValue(Object id) { // pen JRPen linePen = (JRPen) getValue(); if (linePen != null) { if (id.equals(JRBasePen.PROPERTY_LINE_COLOR)) return Colors.getSWTRGB4AWTGBColor(linePen.getLineColor()); if (id.equals(JRBasePen.PROPERTY_LINE_WIDTH)) return linePen.getLineWidth(); if (id.equals(JRBasePen.PROPERTY_LINE_STYLE)) return penLineStyleD.getEnumValue(linePen.getLineStyleValue()); } return null; }