@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); } }
/** * Returns the built-in hyperlink type, or {@link HyperlinkTypeEnum#CUSTOM HyperlinkTypeEnum.CUSTOM} * if the type is not a built-in type. * * @param linkType the link type * @return the hyperlink type */ public static HyperlinkTypeEnum getHyperlinkTypeValue(String linkType) { HyperlinkTypeEnum type; if (linkType == null) { type = HyperlinkTypeEnum.NONE; } else { HyperlinkTypeEnum builtinType = HyperlinkTypeEnum.getByName(linkType); if (builtinType == null) { type = HyperlinkTypeEnum.CUSTOM; } else { type = builtinType; } } return type; }
private void initHypelinks() { links.clear(); if (page == null) return; List<JRPrintElement> elements = page.getElements(); if (elements == null) return; for (JRPrintElement element : elements) { if (element instanceof JRPrintImage) { Renderable r = ((JRPrintImage) element).getRenderable(); if (r instanceof ImageMapRenderable) { try { List<JRPrintImageAreaHyperlink> hyperlinks = ((ImageMapRenderable) r).getImageAreaHyperlinks(new java.awt.Rectangle(0, 0, element.getWidth(), element.getHeight())); if (hyperlinks != null) links.add(new ImageAreaHyperlink(element.getX(), element.getY(), hyperlinks)); } catch (JRException e) { throw new RuntimeException(e); } } } else if (element instanceof JRPrintHyperlink && !((JRPrintHyperlink) element).getHyperlinkTypeValue().equals(HyperlinkTypeEnum.NONE)) links.add(new PrintHyperlink(0, 0, element)); } }
private String getLinkToolTip(JRPrintHyperlink link) { String tTip = link.getHyperlinkTooltip(); if (tTip == null) { HyperlinkTypeEnum hType = link.getHyperlinkTypeValue(); if (hType.equals(HyperlinkTypeEnum.REFERENCE)) tTip = link.getHyperlinkReference(); else if (hType.equals(HyperlinkTypeEnum.LOCAL_ANCHOR)) { if (link.getHyperlinkAnchor() != null) tTip = "#" + link.getHyperlinkAnchor(); //$NON-NLS-1$ } else if (hType.equals(HyperlinkTypeEnum.LOCAL_PAGE)) { if (link.getHyperlinkPage() != null) tTip = "#page " + link.getHyperlinkPage(); //$NON-NLS-1$ } else if (hType.equals(HyperlinkTypeEnum.REMOTE_ANCHOR)) { if (link.getHyperlinkReference() != null) tTip = link.getHyperlinkReference(); if (currentLink.getHyperlinkAnchor() != null) tTip = "#" + currentLink.getHyperlinkAnchor(); //$NON-NLS-1$ } else if (hType.equals(HyperlinkTypeEnum.REMOTE_PAGE)) { if (link.getHyperlinkReference() != null) tTip = link.getHyperlinkReference(); if (link.getHyperlinkPage() != null) tTip = "#page " + link.getHyperlinkPage(); //$NON-NLS-1$ } } return tTip; }
/** * @param pieDataset the pieDataset to set */ public void setPieSeries(JRDesignPieSeries originalPieSeries) { this.pieSeries = originalPieSeries; jRTextExpressionKey.setText( Misc.getExpressionText(pieSeries.getKeyExpression()) ); jRTextExpressionValue.setText( Misc.getExpressionText(pieSeries.getValueExpression()) ); jRTextExpressionLabel.setText( Misc.getExpressionText(pieSeries.getLabelExpression()) ); if (pieSeries.getSectionHyperlink() == null) { JRDesignHyperlink hl = new JRDesignHyperlink(); hl.setHyperlinkType( HyperlinkTypeEnum.NONE); pieSeries.setSectionHyperlink(hl); } sectionItemHyperlinkPanel1.setHyperlink( pieSeries.getSectionHyperlink() ); }
@Override public void test() { super.test(); numberOfPagesTest(1); JRPrintText textField = (JRPrintText) getElementAt("title.textField1", 0); Assert.assertEquals("hyperlink reference", "reference", textField.getHyperlinkReference()); Assert.assertEquals("hyperlink tooltip", "tooltip", textField.getHyperlinkTooltip()); Assert.assertEquals("hyperlink anchor", "anchor", textField.getHyperlinkAnchor()); Assert.assertEquals("hyperlink anchorName", "anchorName", textField.getAnchorName()); Assert.assertEquals("hyperlink bookmark level", 1, textField.getBookmarkLevel()); Assert.assertEquals("hyperlink page", new Integer(1), textField.getHyperlinkPage()); Assert.assertEquals("hyperlink type reference", HyperlinkTypeEnum.LOCAL_ANCHOR, textField.getHyperlinkTypeValue()); Assert.assertEquals("hyperlink type reference", HyperlinkTypeEnum.LOCAL_ANCHOR.getName(), textField.getLinkType()); Assert.assertEquals("hyperlink target", HyperlinkTargetEnum.TOP, textField.getHyperlinkTargetValue()); Assert.assertEquals("hyperlink target", HyperlinkTargetEnum.TOP.getName(), textField.getLinkTarget()); textField = (JRPrintText) getElementAt("title.textField2", 0); Assert.assertEquals("hyperlink type reference", HyperlinkTypeEnum.CUSTOM, textField.getHyperlinkTypeValue()); Assert.assertEquals("hyperlink type reference", "customType", textField.getLinkType()); Assert.assertEquals("hyperlink target", HyperlinkTargetEnum.CUSTOM, textField.getHyperlinkTargetValue()); Assert.assertEquals("hyperlink target", "customTarget", textField.getLinkTarget()); }
@Override public void test() { super.test(); numberOfPagesTest(2); elementCountTest("title.textField1", 2); elementValueTest("title.textField1", "title 1", "test title"); JRPrintText textField = (JRPrintText) getElementAt("title.textField1", 0); Assert.assertEquals("hyperlink reference", "link", textField.getHyperlinkReference()); Assert.assertEquals("hyperlink tooltip", "tooltip", textField.getHyperlinkTooltip()); Assert.assertEquals("hyperlink type reference", HyperlinkTypeEnum.REFERENCE, textField.getHyperlinkTypeValue()); elementCountTest("title.textField2", 1); elementValueTest("title.textField2", "title 2"); elementCountTest("title.textField3", 1); elementValueTest("title.textField3", "title 3"); elementCountTest("title.textField4", 1); elementValueTest("title.textField4", "test title"); }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_1_3) { legendPositionValue = EdgeEnum.getByValue(legendPosition); titlePositionValue = EdgeEnum.getByValue(titlePosition); showLegend = Boolean.valueOf(isShowLegend); } else { legendPositionValue = EdgeEnum.getByValue(legendPositionByte); titlePositionValue = EdgeEnum.getByValue(titlePositionByte); legendPositionByte = null; titlePositionByte = 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) { horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment); verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment); scaleImageValue = ScaleImageEnum.getByValue(scaleImage); onErrorTypeValue = OnErrorTypeEnum.getByValue(onErrorType); evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); horizontalAlignment = null; verticalAlignment = null; scaleImage = null; } if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2) { horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue); verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue); horizontalAlignmentValue = null; verticalAlignmentValue = null; } }
/** * */ public void writeImage(JRImage image) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_image, getNamespace()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_scaleImage, image.getOwnScaleImageValue()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_hAlign, image.getOwnHorizontalImageAlign()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_vAlign, image.getOwnVerticalImageAlign()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isUsingCache, image.getUsingCache()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isLazy, image.isLazy(), false); writer.addAttribute(JRXmlConstants.ATTRIBUTE_onErrorType, image.getOnErrorTypeValue(), OnErrorTypeEnum.ERROR); writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, image.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); if (image.getEvaluationGroup() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, image.getEvaluationGroup().getName()); } writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, image.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, image.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel, image.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); writeReportElement(image); writeBox(image.getLineBox()); writeGraphicElement(image); //FIXME class is mandatory in verifier writeExpression(JRXmlConstants.ELEMENT_imageExpression, image.getExpression(), true); writeExpression(JRXmlConstants.ELEMENT_anchorNameExpression, image.getAnchorNameExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, image.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, image.getHyperlinkWhenExpression(), false);//FIXMENOW can we reuse method for writing hyperlink? writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, image.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, image.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, image.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(image.getHyperlinkParameters()); writer.closeElement(); }
/** * */ public void writeTextField(JRTextField textField) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_textField, getNamespace()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isStretchWithOverflow, textField.isStretchWithOverflow(), false); writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, textField.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); if (textField.getEvaluationGroup() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, textField.getEvaluationGroup().getName()); } writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_pattern, textField.getOwnPattern()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isBlankWhenNull, textField.isOwnBlankWhenNull()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, textField.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, textField.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel, textField.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); writeReportElement(textField); writeBox(textField.getLineBox()); writeTextElement(textField); writeExpression(JRXmlConstants.ELEMENT_textFieldExpression, textField.getExpression(), true); if(isNewerVersionOrEqual(JRConstants.VERSION_4_1_1)) { writer.writeExpression(JRXmlConstants.ELEMENT_patternExpression, textField.getPatternExpression()); } writeExpression(JRXmlConstants.ELEMENT_anchorNameExpression, textField.getAnchorNameExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, textField.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, textField.getHyperlinkWhenExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, textField.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, textField.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, textField.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(textField.getHyperlinkParameters()); writer.closeElement(); }
public void writeHyperlink(String tagName, XmlNamespace namespace, JRHyperlink hyperlink) throws IOException { if (hyperlink != null) { writer.startElement(tagName, namespace); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, hyperlink.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, hyperlink.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkWhenExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(hyperlink.getHyperlinkParameters()); if(isNewerVersionOrEqual(JRConstants.VERSION_3_5_1)) { writer.closeElement(true); } else { writer.closeElement(); } } }
/** * Returns the link type associated with a built-in type. * * @param hyperlinkType the built-in type * @return the String link type */ public static String getLinkType(HyperlinkTypeEnum hyperlinkType) { String type; switch (hyperlinkType) { case NULL: case NONE: type = null; break; case REFERENCE: case LOCAL_ANCHOR: case LOCAL_PAGE: case REMOTE_ANCHOR: case REMOTE_PAGE: type = hyperlinkType.getName(); break; case CUSTOM: throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_TYPE_BYTE_CONSTANT_USED, (Object[])null); default: throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_UNKNOWN_HYPERLINK_TYPE, new Object[]{hyperlinkType}); } return type; }
protected void writeImageMap(String imageMapName, JRPrintImage image, List<JRPrintImageAreaHyperlink> imageMapAreas) throws IOException { writer.write("<map name=\"" + imageMapName + "\">\n"); for (ListIterator<JRPrintImageAreaHyperlink> it = imageMapAreas.listIterator(imageMapAreas.size()); it.hasPrevious();) { JRPrintImageAreaHyperlink areaHyperlink = it.previous(); JRPrintHyperlink link = areaHyperlink.getHyperlink(); JRPrintImageArea area = areaHyperlink.getArea(); writer.write(" <area shape=\"" + JRPrintImageArea.getHtmlShape(area.getShape()) + "\""); writeImageAreaCoordinates(area.getCoordinates()); writeImageAreaHyperlink(link); writer.write("/>\n"); } if (image.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE) { writer.write(" <area shape=\"default\""); writeImageAreaCoordinates(new int[]{0, 0, image.getWidth(), image.getHeight()});//for IE writeImageAreaHyperlink(image); writer.write("/>\n"); } writer.write("</map>\n"); }
@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) { horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment); verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment); scaleImageValue = ScaleImageEnum.getByValue(scaleImage); onErrorTypeValue = OnErrorTypeEnum.getByValue(onErrorType); horizontalAlignment = null; verticalAlignment = null; scaleImage = null; } if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2) { horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue); verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue); horizontalAlignmentValue = null; verticalAlignmentValue = null; } }
@Override public void mouseMoved(MouseEvent e) { JRPrintImageAreaHyperlink imageArea = getImageMapArea(e); if (imageArea != null && imageArea.getHyperlink().getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE) { e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { e.getComponent().setCursor(Cursor.getDefaultCursor()); } }
public void mouseMoved(MouseEvent e) { JRPrintImageAreaHyperlink imageArea = getImageMapArea(e); if (imageArea != null && imageArea.getHyperlink().getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE) { e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { e.getComponent().setCursor(Cursor.getDefaultCursor()); } }
@Override public HyperlinkTypeEnum getHyperlinkTypeValue() { return JRHyperlinkHelper.getHyperlinkTypeValue(this); }
@Override public HyperlinkTypeEnum getHyperlinkTypeValue() { return JRHyperlinkHelper.getHyperlinkTypeValue(getLinkType()); }
@Override public void setHyperlinkType(HyperlinkTypeEnum hyperlinkType) { setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType)); }
@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) { horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment); verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment); rotationValue = RotationEnum.getByValue(rotation); runDirectionValue = RunDirectionEnum.getByValue(runDirection); lineSpacingValue = LineSpacingEnum.getByValue(lineSpacing); horizontalAlignment = null; verticalAlignment = null; rotation = null; lineSpacing = null; } if (isStyledText != null) { markup = isStyledText.booleanValue() ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE; isStyledText = null; } if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (paragraph == null) { paragraph = new JRBaseParagraph(this); paragraph.setLineSpacing(lineSpacingValue); lineSpacingValue = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_5_5_2) { fontsize = fontSize == null ? null : fontSize.floatValue(); fontSize = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2) { horizontalTextAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalTextAlignEnum(horizontalAlignmentValue); verticalTextAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalTextAlignEnum(verticalAlignmentValue); horizontalAlignmentValue = null; verticalAlignmentValue = 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) { horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment); verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment); scaleImageValue = ScaleImageEnum.getByValue(scaleImage); onErrorTypeValue = OnErrorTypeEnum.getByValue(onErrorType); horizontalAlignment = null; verticalAlignment = null; scaleImage = null; } if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (renderer != null && renderable == null) { if (renderer instanceof Renderable) { renderable = (Renderable)renderer; } else { renderable = net.sf.jasperreports.engine.RenderableUtil.getWrappingRenderable(renderer); } } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2) { horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue); verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue); horizontalAlignmentValue = null; verticalAlignmentValue = null; } }
/** * */ private void writeChart(JRChart chart) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_chart); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLegend, chart.getShowLegend()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, chart.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); if (chart.getEvaluationTimeValue() == EvaluationTimeEnum.GROUP) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, chart.getEvaluationGroup().getName()); } writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, chart.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, chart.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel, chart.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); writer.addAttribute(JRXmlConstants.ATTRIBUTE_customizerClass, chart.getCustomizerClass()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_renderType, chart.getRenderType()); if(isNewerVersionOrEqual(JRConstants.VERSION_3_1_0)) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_theme, chart.getTheme()); } writeReportElement(chart); writeBox(chart.getLineBox()); // write title writer.startElement(JRXmlConstants.ELEMENT_chartTitle); writer.addAttribute(JRXmlConstants.ATTRIBUTE_position, chart.getTitlePositionValue()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_color, chart.getOwnTitleColor()); writeFont(chart.getTitleFont()); if (chart.getTitleExpression() != null) { writeExpression(JRXmlConstants.ELEMENT_titleExpression, chart.getTitleExpression(), false); } writer.closeElement(); // write subtitle writer.startElement(JRXmlConstants.ELEMENT_chartSubtitle); writer.addAttribute(JRXmlConstants.ATTRIBUTE_color, chart.getOwnSubtitleColor()); writeFont(chart.getSubtitleFont()); if (chart.getSubtitleExpression() != null) { writeExpression(JRXmlConstants.ELEMENT_subtitleExpression, chart.getSubtitleExpression(), false); } writer.closeElement(); // write chartLegend writer.startElement(JRXmlConstants.ELEMENT_chartLegend); if (chart.getOwnLegendColor() != null) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_textColor, chart.getOwnLegendColor()); } if (chart.getOwnLegendBackgroundColor() != null) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_backgroundColor, chart.getOwnLegendBackgroundColor()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_position, chart.getLegendPositionValue()); writeFont(chart.getLegendFont()); writer.closeElement(); writeExpression(JRXmlConstants.ELEMENT_anchorNameExpression, chart.getAnchorNameExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, chart.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, chart.getHyperlinkWhenExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, chart.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, chart.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, chart.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(chart.getHyperlinkParameters()); writer.closeElement(); }
/** * */ public void writeImage( JRImage image, String imageName) { if(image != null) { write( "JRDesignImage " + imageName + " = new JRDesignImage(jasperDesign);\n"); write( imageName + ".setScaleImage({0});\n", image.getOwnScaleImageValue()); write( imageName + ".setHorizontalImageAlign({0});\n", image.getOwnHorizontalImageAlign()); write( imageName + ".setVerticalImageAlign({0});\n", image.getOwnVerticalImageAlign()); write( imageName + ".setUsingCache({0});\n", image.getUsingCache()); write( imageName + ".setLazy({0});\n", image.isLazy(), false); write( imageName + ".setOnErrorType({0});\n",image.getOnErrorTypeValue(), OnErrorTypeEnum.ERROR); write( imageName + ".setEvaluationTime({0});\n", image.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); write( imageName + ".setEvaluationGroup({0});\n", getGroupName(image.getEvaluationGroup())); if(image.getLinkType() != null) { write( imageName + ".setLinkType(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(image.getLinkType()), HyperlinkTypeEnum.NONE.getName()); } if(image.getLinkTarget() != null) { write( imageName + ".setLinkTarget(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(image.getLinkTarget()), HyperlinkTargetEnum.SELF.getName()); } write( imageName + ".setBookmarkLevel({0, number, #});\n", image.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); writeReportElement( image, imageName); writeBox( image.getLineBox(), imageName + ".getLineBox()"); writeGraphicElement( image, imageName); writeExpression( image.getExpression(), imageName, "Expression"); writeExpression( image.getAnchorNameExpression(), imageName, "AnchorNameExpression"); writeExpression( image.getHyperlinkReferenceExpression(), imageName, "HyperlinkReferenceExpression"); writeExpression( image.getHyperlinkWhenExpression(), imageName, "HyperlinkWhenExpression"); writeExpression( image.getHyperlinkAnchorExpression(), imageName, "HyperlinkAnchorExpression"); writeExpression( image.getHyperlinkPageExpression(), imageName, "HyperlinkPageExpression"); writeExpression( image.getHyperlinkTooltipExpression(), imageName, "HyperlinkTooltipExpression"); writeHyperlinkParameters( image.getHyperlinkParameters(), imageName); flush(); } }
/** * */ public void writeTextField( JRTextField textField, String textFieldName) { if(textField != null) { write( "JRDesignTextField " + textFieldName + " = new JRDesignTextField(jasperDesign);\n"); write( textFieldName + ".setBold({0});\n", textField.isOwnBold()); write( textFieldName + ".setStretchWithOverflow({0});\n", textField.isStretchWithOverflow(), false); write( textFieldName + ".setEvaluationTime({0});\n", textField.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); write( textFieldName + ".setEvaluationGroup({0});\n", getGroupName(textField.getEvaluationGroup())); write( textFieldName + ".setPattern(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(textField.getOwnPattern())); write( textFieldName + ".setBlankWhenNull({0});\n", textField.isOwnBlankWhenNull()); if(textField.getLinkType() != null) { write( textFieldName + ".setLinkType(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(textField.getLinkType()), HyperlinkTypeEnum.NONE.getName()); } if(textField.getLinkTarget() != null) { write( textFieldName + ".setLinkTarget(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(textField.getLinkTarget()), HyperlinkTargetEnum.SELF.getName()); } write( textFieldName + ".setBookmarkLevel({0, number, #});\n", textField.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); writeReportElement( textField, textFieldName); writeBox( textField.getLineBox(), textFieldName + ".getLineBox()"); writeTextElement( textField, textFieldName); writeExpression( textField.getExpression(), textFieldName, "Expression"); writeExpression( textField.getPatternExpression(), textFieldName, "PatternExpression"); writeExpression( textField.getAnchorNameExpression(), textFieldName, "AnchorNameExpression"); writeExpression( textField.getHyperlinkReferenceExpression(), textFieldName, "HyperlinkReferenceExpression"); writeExpression( textField.getHyperlinkWhenExpression(), textFieldName, "HyperlinkWhenExpression"); writeExpression( textField.getHyperlinkAnchorExpression(), textFieldName, "HyperlinkAnchorExpression"); writeExpression( textField.getHyperlinkPageExpression(), textFieldName, "HyperlinkPageExpression"); writeExpression( textField.getHyperlinkTooltipExpression(), textFieldName, "HyperlinkTooltipExpression"); writeHyperlinkParameters( textField.getHyperlinkParameters(), textFieldName); flush(); } }
/** * */ private void writeChart( JRChart chart, String chartName) { if(chart != null) { write( chartName + ".setShowLegend({0});\n", getBooleanText(chart.getShowLegend())); write( chartName + ".setEvaluationTime({0});\n", chart.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); write( chartName + ".setEvaluationGroup({0});\n", getGroupName(chart.getEvaluationGroup())); if(chart.getLinkType() != null) { write( chartName + ".setLinkType(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(chart.getLinkType()), HyperlinkTypeEnum.NONE.getName()); } if(chart.getLinkTarget() != null) { write( chartName + ".setLinkTarget(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(chart.getLinkTarget()), HyperlinkTargetEnum.SELF.getName()); } write( chartName + ".setBookmarkLevel({0, number, #});\n", chart.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); if(chart.getCustomizerClass() != null) { write( chartName + ".setCustomizerClass(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(chart.getCustomizerClass())); } write( chartName + ".setRenderType(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(chart.getRenderType())); write( chartName + ".setTheme(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(chart.getTheme())); writeReportElement( chart, chartName); writeBox( chart.getLineBox(), chartName + ".getLineBox()"); write( chartName + ".setTitlePosition({0});\n", chart.getTitlePositionValue()); write( chartName + ".setTitleColor({0});\n", chart.getOwnTitleColor()); if(chart.getTitleFont() != null) { write( chartName + ".setTitleFont(new JRBaseFont());\n"); writeFont( chart.getTitleFont(), chartName + ".getTitleFont()"); } writeExpression( chart.getTitleExpression(), chartName, "TitleExpression"); write( chartName + ".setSubtitleColor({0});\n", chart.getOwnSubtitleColor()); if(chart.getSubtitleFont() != null) { write( chartName + ".setSubtitleFont(new JRBaseFont());\n"); writeFont( chart.getSubtitleFont(), chartName + ".getSubtitleFont()"); } writeExpression( chart.getSubtitleExpression(), chartName, "SubtitleExpression"); write( chartName + ".setLegendColor({0});\n", chart.getOwnLegendColor()); write( chartName + ".setLegendBackgroundColor({0});\n", chart.getOwnLegendBackgroundColor()); write( chartName + ".setLegendPosition({0});\n", chart.getLegendPositionValue()); if(chart.getLegendFont() != null) { write( chartName + ".setLegendFont(new JRBaseFont());\n"); writeFont( chart.getLegendFont(), chartName + ".getLegendFont()"); } writeExpression( chart.getAnchorNameExpression(), chartName, "AnchorNameExpression"); writeExpression( chart.getHyperlinkReferenceExpression(), chartName, "HyperlinkReferenceExpression"); writeExpression( chart.getHyperlinkWhenExpression(), chartName, "HyperlinkWhenExpression");//FIXMENOW can we reuse hyperlink write method? writeExpression( chart.getHyperlinkAnchorExpression(), chartName, "HyperlinkAnchorExpression"); writeExpression( chart.getHyperlinkPageExpression(), chartName, "HyperlinkPageExpression"); writeExpression( chart.getHyperlinkTooltipExpression(), chartName, "HyperlinkTooltipExpression"); writeHyperlinkParameters( chart.getHyperlinkParameters(), chartName); flush(); } }
/**@deprecated Repalced by {@link #setHyperlinkType(HyperlinkTypeEnum)}. */ public void setHyperlinkType(byte hyperlinkType) { setHyperlinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); }
/** * @deprecated Replaced by {@link #setHyperlinkType(HyperlinkTypeEnum)}. */ public void setHyperlinkType(byte hyperlinkType) { setHyperlinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); }