public JRPrintText getTextElementReplacement( JRExporterContext exporterContext, JRGenericPrintElement element ) { JRBasePrintText text = new JRBasePrintText(exporterContext.getExportedReport().getDefaultStyleProvider()); text.setX(element.getX()); text.setY(element.getY()); text.setWidth(element.getWidth()); text.setHeight(element.getHeight()); text.setText("[Open Flash Chart Component]"); text.setMode(ModeEnum.OPAQUE); text.setBackcolor(Color.lightGray); text.setHorizontalTextAlign(HorizontalTextAlignEnum.CENTER); text.setVerticalTextAlign(VerticalTextAlignEnum.MIDDLE); text.getLineBox().getPen().setLineWidth(1f); text.getLineBox().getPen().setLineColor(Color.black); text.getLineBox().getPen().setLineStyle(LineStyleEnum.DASHED); JRTextMeasurerUtil.getInstance(exporterContext.getJasperReportsContext()).measureTextElement(text); return text; }
/** * */ public HorizontalTextAlignEnum getHorizontalTextAlign(JRTextAlignment alignment) { HorizontalTextAlignEnum ownHorizontalAlignment = alignment.getOwnHorizontalTextAlign(); if (ownHorizontalAlignment != null) { return ownHorizontalAlignment; } JRStyle baseStyle = getBaseStyle(alignment); if (baseStyle != null) { HorizontalTextAlignEnum horizontalAlignment = baseStyle.getHorizontalTextAlign(); if (horizontalAlignment != null) { return horizontalAlignment; } } return HorizontalTextAlignEnum.LEFT; }
/** * */ public static String getHorizontalAlignment(HorizontalTextAlignEnum horizontalAlignment) { if (horizontalAlignment != null) { switch (horizontalAlignment) { case RIGHT : return HORIZONTAL_ALIGN_RIGHT; case CENTER : return HORIZONTAL_ALIGN_CENTER; case JUSTIFIED : return HORIZONTAL_ALIGN_JUSTIFY; case LEFT : default : return HORIZONTAL_ALIGN_LEFT; } } return null; }
/** * */ public static String getHorizontalTextAlign(HorizontalTextAlignEnum horizontalAlignment) { if (horizontalAlignment != null) { switch (horizontalAlignment) { case RIGHT : return HORIZONTAL_ALIGN_RIGHT; case CENTER : return HORIZONTAL_ALIGN_CENTER; case JUSTIFIED : return HORIZONTAL_ALIGN_BOTH; case LEFT : default : return HORIZONTAL_ALIGN_LEFT; } } return null; }
@Override public void setHorizontalTextAlign(HorizontalTextAlignEnum horizontalTextAlign) { Object old = this.horizontalTextAlign; this.horizontalTextAlign = horizontalTextAlign; getEventSupport().firePropertyChange(JRBaseStyle.PROPERTY_HORIZONTAL_TEXT_ALIGNMENT, old, this.horizontalTextAlign); }
@Override public void setHorizontalTextAlign(HorizontalTextAlignEnum horizontalTextAlign) { HorizontalTextAlignEnum old = this.horizontalTextAlign; this.horizontalTextAlign = horizontalTextAlign; getEventSupport().firePropertyChange(PROPERTY_HORIZONTAL_TEXT_ALIGNMENT, old, this.horizontalTextAlign); }
/** * */ public HorizontalTextAlignEnum getHorizontalTextAlign(JRStyle style) { HorizontalTextAlignEnum ownHorizontalAlignment = style.getOwnHorizontalTextAlign(); if (ownHorizontalAlignment != null) { return ownHorizontalAlignment; } JRStyle baseStyle = getBaseStyle(style); if (baseStyle != null) { return baseStyle.getHorizontalTextAlign(); } return null; }
/** * */ public CellStyle(WriterHelper styleWriter, JRExporterGridCell gridCell, boolean shrinkToFit, boolean wrapText) { super(styleWriter); JRPrintElement element = gridCell.getElement(); if (element != null && element.getModeValue() == ModeEnum.OPAQUE) { //fill = "solid"; backcolor = JRColorUtil.getColorHexa(element.getBackcolor()); } else { //fill = "none"; if (gridCell.getBackcolor() != null) { backcolor = JRColorUtil.getColorHexa(gridCell.getBackcolor()); } } RotationEnum rotation = element instanceof JRPrintText ? ((JRPrintText)element).getRotationValue() : RotationEnum.NONE; VerticalTextAlignEnum vAlign = VerticalTextAlignEnum.TOP; HorizontalTextAlignEnum hAlign = HorizontalTextAlignEnum.LEFT; JRTextAlignment alignment = element instanceof JRTextAlignment ? (JRTextAlignment)element : null; if (alignment != null) { vAlign = alignment.getVerticalTextAlign(); hAlign = alignment.getHorizontalTextAlign(); } horizontalAlignment = ParagraphStyle.getHorizontalAlignment(hAlign, vAlign, rotation); verticalAlignment = ParagraphStyle.getVerticalAlignment(hAlign, vAlign, rotation); this.shrinkToFit = shrinkToFit; this.wrapText = wrapText; setBox(gridCell.getBox()); }
private void applyColumnHeaderData(EditTextElementData textElementData, JRDesignTextElement textElement, boolean execute) { if (EditTextElementData.APPLY_TO_HEADING.equals(textElementData.getApplyTo())) { if (textElement instanceof JRDesignTextField) { JRDesignTextField designTextField = (JRDesignTextField)textElement; if (execute) { if (oldText == null) { oldText = (designTextField.getExpression()).getText(); } ((JRDesignExpression)designTextField.getExpression()).setText("\"" + JRStringUtil.escapeJavaStringLiteral(textElementData.getHeadingName()) + "\""); } else { ((JRDesignExpression)designTextField.getExpression()).setText(oldText); } } else if (textElement instanceof JRDesignStaticText){ JRDesignStaticText staticText = (JRDesignStaticText)textElement; if (execute) { if (oldText == null) { oldText = staticText.getText(); } staticText.setText(textElementData.getHeadingName()); } else { staticText.setText(oldText); } } } textElement.setFontName(textElementData.getFontName()); textElement.setFontSize(textElementData.getFloatFontSize()); textElement.setBold(textElementData.getFontBold()); textElement.setItalic(textElementData.getFontItalic()); textElement.setUnderline(textElementData.getFontUnderline()); textElement.setForecolor(textElementData.getFontColor() != null ? JRColorUtil.getColor("#" + textElementData.getFontColor(), textElement.getForecolor()) : null); textElement.setHorizontalTextAlign(HorizontalTextAlignEnum.getByName(textElementData.getFontHAlign())); textElement.setBackcolor(textElementData.getFontBackColor() != null ? JRColorUtil.getColor("#" + textElementData.getFontBackColor(), Color.white) : null); textElement.setMode(ModeEnum.getByName(textElementData.getMode())); if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) { ((JRDesignTextField) textElement).setPattern(textElementData.getFormatPattern()); } }
/** * Build the page footer band * * @return */ private static JRDesignBand buildPageFooterBand() { JRDesignBand band = new JRDesignBand(); band.setHeight(20); JRDesignTextField rightText = new JRDesignTextField(); rightText.setY(0); rightText.setWidth(300); rightText.setHeight(15); rightText.setHorizontalTextAlign(HorizontalTextAlignEnum.LEFT); JRDesignExpression rightExpression = new JRDesignExpression(); Calendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); rightExpression.setText("\" (C) " + calendar.get(Calendar.YEAR) + " \" + $R{" + ApplicationBean.getInstance().getLicenseHolder() + " - " + RESOURCE_KEYS.RIGHTS + "}"); rightText.setExpression(rightExpression); band.addElement(rightText); JRDesignTextField pageText = new JRDesignTextField(); pageText.setX(720); pageText.setY(0); pageText.setWidth(60); pageText.setHeight(15); pageText.setHorizontalTextAlign(HorizontalTextAlignEnum.RIGHT); JRDesignExpression pageExpression = new JRDesignExpression(); pageExpression.setText("$R{" + RESOURCE_KEYS.PAGE + "} + \" \" + $V{PAGE_NUMBER}"); pageText.setExpression(pageExpression); band.addElement(pageText); return band; }
@Override public HorizontalTextAlignEnum getHorizontalTextAlign() { return getStyleResolver().getHorizontalTextAlign(this); }
@Override public HorizontalTextAlignEnum getOwnHorizontalTextAlign() { return horizontalTextAlign; }
@Override public void setHorizontalTextAlign(HorizontalTextAlignEnum horizontalTextAlign) { this.horizontalTextAlign = horizontalTextAlign; }
@Override public Object createObject(Attributes atts) { JRDesignTextElement textElement = (JRDesignTextElement)digester.peek(); HorizontalTextAlignEnum horizontalTextAlign = HorizontalTextAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_textAlignment)); if (horizontalTextAlign != null) { textElement.setHorizontalTextAlign(horizontalTextAlign); } VerticalTextAlignEnum verticalTextAlign = VerticalTextAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_verticalAlignment)); if (verticalTextAlign != null) { textElement.setVerticalTextAlign(verticalTextAlign); } RotationEnum rotation = RotationEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_rotation)); if (rotation != null) { textElement.setRotation(rotation); } LineSpacingEnum lineSpacing = LineSpacingEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_lineSpacing)); if (lineSpacing != null) { if (log.isWarnEnabled()) { log.warn("The 'lineSpacing' attribute is deprecated. Use the <paragraph> tag instead."); } textElement.getParagraph().setLineSpacing(lineSpacing); } textElement.setMarkup(atts.getValue(JRXmlConstants.ATTRIBUTE_markup)); String isStyledText = atts.getValue(JRXmlConstants.ATTRIBUTE_isStyledText); if (isStyledText != null && isStyledText.length() > 0) { if (log.isWarnEnabled()) { log.warn("The 'isStyledText' attribute is deprecated. Use the 'markup' attribute instead."); } textElement.setMarkup(Boolean.valueOf(isStyledText) ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE); } return textElement; }
/** * */ public static HorizontalTextAlignEnum getHorizontalTextAlign(JRTextAlignment alignment) { return styleResolver.getHorizontalTextAlign(alignment); }
/** * */ public static HorizontalTextAlignEnum getHorizontalTextAlign(JRStyle style) { return styleResolver.getHorizontalTextAlign(style); }
/** * */ public static String getVerticalAlignment( HorizontalTextAlignEnum horizontalAlignment, VerticalTextAlignEnum verticalAlignment, RotationEnum rotation ) { switch(rotation) { case LEFT: { switch (horizontalAlignment) { case RIGHT : return VERTICAL_ALIGN_TOP; case CENTER : return VERTICAL_ALIGN_MIDDLE; case JUSTIFIED : return HORIZONTAL_ALIGN_JUSTIFY;//FIXMEODT ????????????????? case LEFT : default : return VERTICAL_ALIGN_BOTTOM; } } case RIGHT: { switch (horizontalAlignment) { case RIGHT : return VERTICAL_ALIGN_BOTTOM; case CENTER : return VERTICAL_ALIGN_MIDDLE; case JUSTIFIED : return HORIZONTAL_ALIGN_JUSTIFY;//????????????????? case LEFT : default : return VERTICAL_ALIGN_TOP; } } case UPSIDE_DOWN://FIXMEODT possible? case NONE: default: { switch (verticalAlignment) { case BOTTOM : return VERTICAL_ALIGN_BOTTOM; case MIDDLE : return VERTICAL_ALIGN_MIDDLE; case TOP : case JUSTIFIED : default : return VERTICAL_ALIGN_TOP; } } } }
/** * */ public static String getHorizontalAlignment( HorizontalTextAlignEnum horizontalAlignment, VerticalTextAlignEnum verticalAlignment, RotationEnum rotation ) { switch(rotation) { case LEFT: { switch (verticalAlignment) { case BOTTOM : return HORIZONTAL_ALIGN_RIGHT; case MIDDLE : return HORIZONTAL_ALIGN_CENTER; case TOP : case JUSTIFIED : default : return HORIZONTAL_ALIGN_LEFT; } } case RIGHT: { switch (verticalAlignment) { case BOTTOM : return HORIZONTAL_ALIGN_LEFT; case MIDDLE : return HORIZONTAL_ALIGN_CENTER; case TOP : case JUSTIFIED : default : return HORIZONTAL_ALIGN_RIGHT; } } case UPSIDE_DOWN://FIXMEODT possible? case NONE: default: { switch (horizontalAlignment) { case RIGHT : return HORIZONTAL_ALIGN_RIGHT; case CENTER : return HORIZONTAL_ALIGN_CENTER; case JUSTIFIED : return HORIZONTAL_ALIGN_JUSTIFY; case LEFT : default : return HORIZONTAL_ALIGN_LEFT; } } } }
/** * */ public void exportText(DocxTableHelper tableHelper, JRPrintText text, JRExporterGridCell gridCell) { tableHelper.getCellHelper().exportHeader(text, gridCell); JRStyledText styledText = getStyledText(text); int textLength = 0; if (styledText != null) { textLength = styledText.length(); } // if (styleBuffer.length() > 0) // { // writer.write(" style=\""); // writer.write(styleBuffer.toString()); // writer.write("\""); // } // // writer.write(">"); docHelper.write(" <w:p>\n"); tableHelper.getParagraphHelper().exportProps(text); if (startPage) { insertBookmark(pageAnchor, docHelper); } if (text.getAnchorName() != null) { insertBookmark(text.getAnchorName(), docHelper); } boolean startedHyperlink = startHyperlink(text, true); boolean isNewLineAsParagraph = false; if (HorizontalTextAlignEnum.JUSTIFIED.equals(text.getHorizontalTextAlign())) { if (text.hasProperties() && text.getPropertiesMap().containsProperty(DocxReportConfiguration.PROPERTY_NEW_LINE_AS_PARAGRAPH)) { isNewLineAsParagraph = getPropertiesUtil().getBooleanProperty(text, DocxReportConfiguration.PROPERTY_NEW_LINE_AS_PARAGRAPH, false); } else { isNewLineAsParagraph = getCurrentItemConfiguration().isNewLineAsParagraph(); } } if (textLength > 0) { exportStyledText( getCurrentJasperPrint().getDefaultStyleProvider().getStyleResolver().getBaseStyle(text), styledText, getTextLocale(text), getPropertiesUtil().getBooleanProperty(text, PROPERTY_HIDDEN_TEXT, false), startedHyperlink, isNewLineAsParagraph ); } if (startedHyperlink) { endHyperlink(true); } docHelper.write(" </w:p>\n"); tableHelper.getCellHelper().exportFooter(); }
protected String getHorizontalAlignment(HorizontalTextAlignEnum hAlign, VerticalTextAlignEnum vAlign, int rotation) { switch (rotation) { case 90: { switch (vAlign) { case JUSTIFIED : { hAlign = HorizontalTextAlignEnum.JUSTIFIED; break; } case BOTTOM : { hAlign = HorizontalTextAlignEnum.RIGHT; break; } case MIDDLE : { hAlign = HorizontalTextAlignEnum.CENTER; break; } case TOP : default: { hAlign = HorizontalTextAlignEnum.LEFT; } } break; } case 180: { switch (vAlign) { case JUSTIFIED : { hAlign = HorizontalTextAlignEnum.JUSTIFIED; break; } case BOTTOM : { hAlign = HorizontalTextAlignEnum.LEFT; break; } case MIDDLE : { hAlign = HorizontalTextAlignEnum.CENTER; break; } case TOP : default: { hAlign = HorizontalTextAlignEnum.RIGHT; } } break; } default: { } } return XlsxParagraphHelper.getHorizontalAlignment(hAlign); }
protected String getVerticalAlignment(HorizontalTextAlignEnum hAlign, VerticalTextAlignEnum vAlign, int rotation) { switch (rotation) { case 90: { switch (hAlign) { case JUSTIFIED : { vAlign = VerticalTextAlignEnum.JUSTIFIED; break; } case RIGHT : { vAlign = VerticalTextAlignEnum.TOP; break; } case CENTER : { vAlign = VerticalTextAlignEnum.MIDDLE; break; } case LEFT : default: { vAlign = VerticalTextAlignEnum.BOTTOM; } } break; } case 180: { switch (hAlign) { case JUSTIFIED : { vAlign = VerticalTextAlignEnum.JUSTIFIED; break; } case RIGHT : { vAlign = VerticalTextAlignEnum.BOTTOM; break; } case CENTER : { vAlign = VerticalTextAlignEnum.MIDDLE; break; } case LEFT : default: { vAlign = VerticalTextAlignEnum.TOP; } } break; } default: { } } return XlsxParagraphHelper.getVerticalAlignment(vAlign); }
public TextAlignHolder(HorizontalTextAlignEnum horizontalAlignment, VerticalTextAlignEnum verticalAlignment, RotationEnum rotation) { this.horizontalAlignment = horizontalAlignment; this.verticalAlignment = verticalAlignment; this.rotation = rotation; }
@Override public HorizontalTextAlignEnum getOwnHorizontalTextAlign() { return providerStyle == null || providerStyle.getOwnHorizontalTextAlign() == null ? ((JRTextElement)this.parent).getOwnHorizontalTextAlign() : providerStyle.getOwnHorizontalTextAlign(); }
@Override public void setHorizontalTextAlign(HorizontalTextAlignEnum horizontalAlignment) { throw new UnsupportedOperationException(); }
@Override public HorizontalTextAlignEnum getHorizontalTextAlign() { return ((JRTemplateText)this.template).getHorizontalTextAlign(); }
@Override public HorizontalTextAlignEnum getOwnHorizontalTextAlign() { return ((JRTemplateText)this.template).getOwnHorizontalTextAlign(); }
/** * Gets the text horizontal alignment. * @return a value representing one of the horizontal text alignment constants in {@link HorizontalTextAlignEnum} */ public HorizontalTextAlignEnum getHorizontalTextAlign();
/** * Sets the text horizontal alignment. * @param horizontalAlignment a value representing one of the horizontal text alignment constants in {@link HorizontalTextAlignEnum} */ public void setHorizontalTextAlign(HorizontalTextAlignEnum horizontalAlignment);