2004 IR Help Posted August 24, 2006 Share Posted August 24, 2006 By: Juha - juharossi Updating from 0.6.6 to 1.1.0 2005-11-11 01:18 Hi all, Using version 0.6.6. I had no problems with method shown below. Now when updated to 1.1.0, the class JRFont no more provides getAttributes()-method and my getStyledText() doesnt work. When I comment the line,I got following error at runtime: java.lang.NullPointerException at java.io.PrintWriter.write(PrintWriter.java:247) at net.sf.jasperreports.engine.export.JRHtmlExporter.exportStyledTextRun(JRHtmlExporter.java:864) at net.sf.jasperreports.engine.export.JRHtmlExporter.exportStyledText(JRHtmlExporter.java:841) at net.sf.jasperreports.engine.export.JRHtmlExporter.exportText(JRHtmlExporter.java:1131) at net.sf.jasperreports.engine.export.JRHtmlExporter.exportGrid(JRHtmlExporter.java:725) at net.sf.jasperreports.engine.export.JRHtmlExporter.exportPage(JRHtmlExporter.java:642) at net.sf.jasperreports.engine.export.JRHtmlExporter.exportReportToWriter(JRHtmlExporter.java:601) at net.sf.jasperreports.engine.export.JRHtmlExporter.exportReport(JRHtmlExporter.java:336) protected JRStyledText getStyledText( JRPrintText textElement) { Map colorMap = this.getColorMap(); JRStyledText styledText = null; String name = textElement.getAnchorName(); String text = textElement.getText() ; if (text != null) { //JRFont font = textElement.getFont(); JRFont font = textElement.getReportFont(); if (font == null) { //font = getDefaultFont(); } Map attributes = new HashMap(); attributes.putAll(font.getAttributes()); Color c = this.getColor(name, text, colorMap, textElement.getForecolor()); attributes.put(TextAttribute.FOREGROUND, c); //attributes.put(TextAttribute.FOREGROUND, c); if (textElement.getMode() == JRElement.MODE_OPAQUE) { attributes.put(TextAttribute.BACKGROUND, textElement.getBackcolor()); } if (textElement.isStyledText()) { try { styledText = styledTextParser.parse(attributes, text); } catch (SAXException e) { //ignore if invalid styled text and treat like normal text } } if (styledText == null) { styledText = new JRStyledText(); styledText.append(text); styledText.addRun(new JRStyledText.Run(attributes, 0, text.length())); } } return styledText; } By: Juha - juharossi RE: Updating from 0.6.6 to 1.1.0 2005-11-14 00:39 Nevermind, I constructed the attributes manually instead of using depracated/removed font.getAttributes()-method. Thanks anyways -J Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now