net.sf.jasperreports.engine.export.draw.DrawVisitor Maven / Gradle / Ivy
/*
* JasperReports - Free Java Reporting Library.
* Copyright (C) 2001 - 2014 TIBCO Software Inc. All rights reserved.
* http://www.jaspersoft.com
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is part of JasperReports.
*
* JasperReports is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* JasperReports is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JasperReports. If not, see .
*/
/*
* Contributors:
* Eugene D - [email protected]
* Adrian Jackson - [email protected]
* David Taylor - [email protected]
* Lars Kristensen - [email protected]
*/
package net.sf.jasperreports.engine.export.draw;
import java.awt.Graphics2D;
import net.sf.jasperreports.engine.JRBreak;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRReport;
import net.sf.jasperreports.engine.convert.ConvertVisitor;
import net.sf.jasperreports.engine.convert.ReportConverter;
import net.sf.jasperreports.engine.util.UniformElementVisitor;
/**
* @author Teodor Danciu ([email protected])
*/
public class DrawVisitor extends UniformElementVisitor
{
protected ConvertVisitor convertVisitor;
protected PrintDrawVisitor drawVisitor;
/**
* @deprecated Replaced by {@link #DrawVisitor(ReportConverter, Graphics2D)}.
*/
public DrawVisitor(JRReport report, Graphics2D grx)
{
this(new ReportConverter(report, true), grx);
setTextRenderer(report);
}
/**
*
*/
public DrawVisitor(ReportConverter reportConverter, Graphics2D grx)
{
this.convertVisitor = new ConvertVisitor(reportConverter);
this.drawVisitor = new PrintDrawVisitor(reportConverter.getJasperReportsContext());
setTextRenderer(reportConverter.getReport());
setGraphics2D(grx);
this.drawVisitor.setClip(true);
}
public void setClip(boolean clip)
{
this.drawVisitor.setClip(clip);
}
/**
*
*/
public void setGraphics2D(Graphics2D grx)
{
drawVisitor.setGraphics2D(grx);
}
/**
*
*/
public void setTextRenderer(JRReport report)
{
drawVisitor.setTextRenderer(report);
}
/**
*
*/
@Override
public void visitBreak(JRBreak breakElement)
{
//FIXMEDRAW
}
@Override
protected void visitElement(JRElement element)
{
JRPrintElement printElement = convertVisitor.getVisitPrintElement(element);
printElement.accept(drawVisitor, elementOffset(element));
}
protected Offset elementOffset(JRElement element)
{
return new Offset(-element.getX(), -element.getY());
}
/**
*
*/
public void visitElementGroup(JRElementGroup elementGroup)
{
//nothing to draw. elements are drawn individually.
}
}