use of org.geotoolkit.report.graphic.map.MapDef in project geotoolkit by Geomatys.
the class JasperReportServiceTest method testHTML.
@Test
public void testHTML() throws JRException, IOException, DataStoreException {
final MapLayers context = createContext();
final URL template = JasperReportServiceTest.class.getResource("/report/MapReport.jrxml");
final Entry<JasperReport, FeatureType> entry = JasperReportService.prepareTemplate(template);
final JasperReport report = entry.getKey();
final FeatureType type = entry.getValue();
List<Feature> collection = new ArrayList<>();
Feature feature = type.newInstance();
CanvasDef cdef = new CanvasDef(new Dimension(1, 1), context.getEnvelope().get());
cdef.setBackground(Color.RED);
feature.setPropertyValue("map", new MapDef(cdef, new SceneDef(context), null));
collection.add(feature);
final File tempfile = File.createTempFile("report", ".html");
tempfile.deleteOnExit();
OutputDef output = new OutputDef(JasperReportService.MIME_HTML, tempfile);
JasperReportService.generateReport(report, collection, null, output);
// just test it's not empty
assertTrue(tempfile.length() > 1000);
}
Aggregations