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; }
@Override public String getHtmlFragment(JRHtmlExporterContext exporterContext, JRGenericPrintElement element) { StringBuilder script = new StringBuilder(128); String htmlContent = (String) element.getParameterValue(HtmlPrintElement.PARAMETER_HTML_CONTENT); script.append("<div style='width:" + (element.getWidth() - 0) + "px;height:" + (element.getHeight() - 0) + "px;"); if (element.getModeValue() == ModeEnum.OPAQUE) { script.append("background-color: #"); script.append(JRColorUtil.getColorHexa(element.getBackcolor())); script.append("; "); } script.append("overflow:hidden;'>"); script.append(htmlContent); script.append("</div>"); return script.toString(); }
/** * */ public ModeEnum getMode(JRCommonElement element, ModeEnum defaultMode) { ModeEnum ownMode = element.getOwnModeValue(); if (ownMode != null) { return ownMode; } JRStyle style = getBaseStyle(element); if (style != null) { ModeEnum mode = style.getModeValue(); if (mode != null) { return mode; } } return defaultMode; }
/** * */ private Map<Attribute,Object> getAttributes(JRStyle style)//FIXMEDOCX put this in util? { JRPrintText text = new JRBasePrintText(null); text.setStyle(style); Map<Attribute,Object> styledTextAttributes = new HashMap<Attribute,Object>(); //JRFontUtil.getAttributes(styledTextAttributes, text, (Locale)null);//FIXMEDOCX getLocale()); fontUtil.getAttributesWithoutAwtFont(styledTextAttributes, text); styledTextAttributes.put(TextAttribute.FOREGROUND, text.getForecolor()); if (text.getModeValue() == ModeEnum.OPAQUE) { styledTextAttributes.put(TextAttribute.BACKGROUND, text.getBackcolor()); } return styledTextAttributes; }
/** * */ private Map<Attribute,Object> getAttributes(JRStyle style)//FIXMEDOCX put this in util? { Map<Attribute,Object> styledTextAttributes = new HashMap<Attribute,Object>(); if (style != null) { JRPrintText text = new JRBasePrintText(null); text.setStyle(style); //JRFontUtil.getAttributes(styledTextAttributes, text, (Locale)null);//FIXMEDOCX getLocale()); fontUtil.getAttributesWithoutAwtFont(styledTextAttributes, text); styledTextAttributes.put(TextAttribute.FOREGROUND, text.getForecolor()); if (text.getModeValue() == ModeEnum.OPAQUE) { styledTextAttributes.put(TextAttribute.BACKGROUND, text.getBackcolor()); } } return styledTextAttributes; }
/** * */ protected Map<Attribute,Object> getStyledTextAttributes() { JRStyle style = getStyle(); Map<Attribute,Object> styledTextAttributes = styledTextAttributesMap.get(style); if (styledTextAttributes == null) { styledTextAttributes = new HashMap<Attribute,Object>(); //JRFontUtil.getAttributes(styledTextAttributes, this, filler.getLocale()); FontUtil.getInstance(filler.getJasperReportsContext()).getAttributesWithoutAwtFont(styledTextAttributes, this); styledTextAttributes.put(TextAttribute.FOREGROUND, getForecolor()); if (getModeValue() == ModeEnum.OPAQUE) { styledTextAttributes.put(TextAttribute.BACKGROUND, getBackcolor()); } styledTextAttributesMap.put(style, styledTextAttributes); } return styledTextAttributes; }
protected void setChartBackground(JFreeChart jfreeChart) { Paint defaultBackgroundPaint = (Paint)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_PAINT); Image defaultBackgroundImage = (Image)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_IMAGE); Integer defaultBackgroundImageAlignment = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_IMAGE_ALIGNMENT); Float defaultBackgroundImageAlpha = (Float)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_IMAGE_ALPHA); if (getChart().getOwnModeValue() != null) { if (getChart().getOwnModeValue() == ModeEnum.OPAQUE) { if (getChart().getOwnBackcolor() == null && defaultBackgroundPaint != null) { jfreeChart.setBackgroundPaint(defaultBackgroundPaint); } else { jfreeChart.setBackgroundPaint(getChart().getBackcolor()); } setChartBackgroundImage(jfreeChart, defaultBackgroundImage, defaultBackgroundImageAlignment, defaultBackgroundImageAlpha); } else { jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); setChartBackgroundImage(jfreeChart, defaultBackgroundImage, defaultBackgroundImageAlignment, new Float(0f)); } } else if (defaultBackgroundPaint != null) { jfreeChart.setBackgroundPaint(defaultBackgroundPaint); } }
protected void setChartBackground(JFreeChart jfreeChart) { Paint backgroundPaint = getChartSettings().getBackgroundPaint() == null ? null : getChartSettings().getBackgroundPaint().getPaint(); if (getChart().getOwnModeValue() != null) { if (getChart().getOwnModeValue() == ModeEnum.OPAQUE) { if (getChart().getOwnBackcolor() != null || backgroundPaint == null) { backgroundPaint = getChart().getBackcolor(); } } else { backgroundPaint = ChartThemesConstants.TRANSPARENT_PAINT; } } if (backgroundPaint != null) { GradientPaint gp = backgroundPaint instanceof GradientPaint ? (GradientPaint)backgroundPaint : null; if (gp != null) { backgroundPaint = new GradientPaint(0f, 0f, gp.getColor1(), 0f, getChart().getHeight() * 0.7f, gp.getColor2(), false); } jfreeChart.setBackgroundPaint(backgroundPaint); } setChartBackgroundImage(jfreeChart); }
@Override public void setMode(ModeEnum modeValue) { Object old = this.modeValue; this.modeValue = modeValue; getEventSupport().firePropertyChange(JRBaseStyle.PROPERTY_MODE, old, this.modeValue); }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { modeValue = ModeEnum.getByValue(mode); positionTypeValue = PositionTypeEnum.getByValue(positionType); stretchTypeValue = StretchTypeEnum.getByValue(stretchType); mode = null; } }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { modeValue = ModeEnum.getByValue(mode); mode = null; } }
/** * Sets the cell transparency mode. * * @param modeValue the transparency mode * @see JRCellContents#getModeValue() */ public void setMode(ModeEnum modeValue) { Object old = this.modeValue; this.modeValue = modeValue; getEventSupport().firePropertyChange(JRBaseStyle.PROPERTY_MODE, old, this.modeValue); }
@Override public Map<Attribute,Object> getStyledTextAttributes(JRPrintText printText) { Map<Attribute,Object> attributes = new HashMap<Attribute,Object>(); //JRFontUtil.getAttributes(attributes, printText, getTextLocale(printText)); FontUtil.getInstance(jasperReportsContext).getAttributesWithoutAwtFont(attributes, printText); attributes.put(TextAttribute.FOREGROUND, printText.getForecolor()); if (printText.getModeValue() == ModeEnum.OPAQUE) { attributes.put(TextAttribute.BACKGROUND, printText.getBackcolor()); } return attributes; }
/** * */ public ModeEnum getModeValue(JRStyle style) { ModeEnum ownMode = style.getOwnModeValue(); if (ownMode != null) { return ownMode; } JRStyle baseStyle = getBaseStyle(style); if (baseStyle != null) { return baseStyle.getModeValue(); } return null; }
public ModeEnum resolveMode(JRStyleContainer styleContainer) { JRStyle style = styleContainer.getStyle(); if (style != null) { ModeEnum styleMode = style.getOwnModeValue(); if (styleMode != null) { JRConditionalStyle[] conditionalStyles = style.getConditionalStyles(); if (conditionalStyles != null) { for (JRConditionalStyle conditionalStyle : conditionalStyles) { ModeEnum conditionalMode = conditionalStyle.getOwnModeValue(); if (conditionalMode != null && conditionalMode != styleMode) { // a conditional style overrides the style mode return null; } } } // we have a style return styleMode; } // going to the parent return resolveMode(style); } if (styleContainer.getStyleNameReference() != null) { // we can't resolve external style references here return null; } // if no style set, default return ModeEnum.TRANSPARENT; }
public ModeEnum resolveElementMode(JRElement element) { ModeEnum elementMode = element.getOwnModeValue(); if (elementMode != null) { return elementMode; } return resolveMode(element); }
@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); }
/** * */ public FrameStyle(WriterHelper styleWriter, JRPrintElement element) { super(styleWriter); if (element.getModeValue() == ModeEnum.OPAQUE) { fill = "solid"; backcolor = JRColorUtil.getColorHexa(element.getBackcolor()); } else { fill = "none"; } }
/** * */ 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()); }
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); }
public Color getCellBackcolor() { Color color; JRPrintElement element = getElement(); if (element != null && element.getModeValue() == ModeEnum.OPAQUE) { color = element.getBackcolor(); } else { color = getBackcolor(); } return color; }
/** * */ private void startElement(JRPrintElement element) throws IOException { contentWriter.write("{\\shp\\shpbxpage\\shpbypage\\shpwr5\\shpfhdr0\\shpfblwtxt0\\shpz"); contentWriter.write(String.valueOf(zorder++)); contentWriter.write("\\shpleft"); contentWriter.write(String.valueOf(LengthUtil.twip(element.getX() + getOffsetX()))); contentWriter.write("\\shpright"); contentWriter.write(String.valueOf(LengthUtil.twip(element.getX() + getOffsetX() + element.getWidth()))); contentWriter.write("\\shptop"); contentWriter.write(String.valueOf(LengthUtil.twip(element.getY() + getOffsetY()))); contentWriter.write("\\shpbottom"); contentWriter.write(String.valueOf(LengthUtil.twip(element.getY() + getOffsetY() + element.getHeight()))); Color bgcolor = element.getBackcolor(); if (element.getModeValue() == ModeEnum.OPAQUE) { contentWriter.write("{\\sp{\\sn fFilled}{\\sv 1}}"); contentWriter.write("{\\sp{\\sn fillColor}{\\sv "); contentWriter.write(String.valueOf(getColorRGB(bgcolor))); contentWriter.write("}}"); } else { contentWriter.write("{\\sp{\\sn fFilled}{\\sv 0}}"); } contentWriter.write("{\\shpinst"); }
private InternalImageProcessorResult process(Renderable renderer) throws JRException { if (renderer instanceof ResourceRenderer) { renderer = imageRenderersCache.getLoadedRenderer((ResourceRenderer)renderer); } Dimension2D dimension = null; if (needDimension) { DimensionRenderable dimensionRenderer = imageRenderersCache.getDimensionRenderable(renderer); dimension = dimensionRenderer == null ? null : dimensionRenderer.getDimension(jasperReportsContext); } DataRenderable imageRenderer = getRendererUtil().getImageDataRenderable( imageRenderersCache, renderer, new Dimension(availableImageWidth, availableImageHeight), ModeEnum.OPAQUE == imageElement.getModeValue() ? imageElement.getBackcolor() : null ); byte[] imageData = imageRenderer.getData(jasperReportsContext); return new InternalImageProcessorResult( imageData, dimension, JRTypeSniffer.getImageTypeValue(imageData) ); }
/** * 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 void exportProps(JRExporterGridCell gridCell) { exportBackcolor(ModeEnum.OPAQUE, gridCell.getCellBackcolor()); borderHelper.export(gridCell.getBox()); }
/** * */ private void exportBackcolor(ModeEnum mode, Color backcolor) { if (mode == ModeEnum.OPAQUE && backcolor != null) { write(" <w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" + JRColorUtil.getColorHexa(backcolor) + "\" />\n"); } }
/** * */ public void exportProps(JRPrintText text, Locale locale) { Map<Attribute,Object> textAttributes = new HashMap<Attribute,Object>(); fontUtil.getAttributesWithoutAwtFont(textAttributes, text); textAttributes.put(TextAttribute.FOREGROUND, text.getForecolor()); if (text.getModeValue() == null || text.getModeValue() == ModeEnum.OPAQUE) { textAttributes.put(TextAttribute.BACKGROUND, text.getBackcolor()); } exportProps("a:defRPr", new HashMap<Attribute,Object>(), textAttributes, locale); }
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()); } }
protected Color getElementBackcolor(BaseElementCell cell) { if (cell == null) { return null; } JRPrintElement element = getCellElement(cell); if (element.getModeValue() == ModeEnum.OPAQUE) { return element.getBackcolor(); } return getElementBackcolor(cell.getParent()); }
@Override public ModeEnum getModeValue() { return getStyleResolver().getMode(this, ModeEnum.TRANSPARENT); }
@Override public ModeEnum getModeValue() { return getStyleResolver().getMode(this, ModeEnum.OPAQUE); }
@Override public ModeEnum getModeValue() { return getStyleResolver().getModeValue(this); }