public void testRichText() throws ReportProcessingException, ContentProcessingException { final Element e = new Element(); e.setElementType(LabelType.INSTANCE); e.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.RICH_TEXT_TYPE, "text/html"); e.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "Hi I am trying to use the <b>rich text type = text/html</b> in PRD version - 3.7."); e.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, 12); e.getStyle().setStyleProperty(TextStyleKeys.FONT, "Arial"); e.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 285f); e.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 20f); final MasterReport report = new MasterReport(); report.getReportHeader().addElement(e); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand(report, report.getReportHeader(), false, false); logicalPageBox.getRepeatFooterArea().setY(logicalPageBox.getContentArea().getHeight()); logicalPageBox.getFooterArea().setY(logicalPageBox.getContentArea().getHeight()); // ModelPrinter.INSTANCE.print(logicalPageBox); final RenderNode[] elementsByNodeType = MatchFactory.findElementsByNodeType(logicalPageBox, LayoutNodeTypes.TYPE_NODE_TEXT); assertEquals( 17, elementsByNodeType.length); // quick and easy way to see that all elements are there. // debugPrintText(elementsByNodeType); final LocalFontRegistry registry = new LocalFontRegistry(); registry.initialize(); final GraphicsOutputProcessorMetaData metaData = new GraphicsOutputProcessorMetaData(new DefaultFontStorage(registry)); metaData.initialize(report.getConfiguration()); final LogicalPageDrawable drawable = new LogicalPageDrawable(); drawable.init(logicalPageBox, metaData, report.getResourceManager()); final TracingGraphics g2 = new TracingGraphics(); drawable.draw(g2, new Rectangle2D.Double(0, 0, 500, 500)); /* for (int i = 0; i < g2.records.size(); i++) { final TextTraceRecord record = g2.records.get(i); System.out.println ("goldenSamples.add(new TextTraceRecord(" + record.x + ", " + record.y + ", \"" + record.text +"\"));"); } */ assertEquals(getSamples(), g2.records); }
/** * Draws the object. * * @param graphics the graphics device. * @param area the area inside which the object should be drawn. */ public void draw(final Graphics2D graphics, final Rectangle2D area) { super.draw(graphics, area); }