Java 类net.sf.jasperreports.engine.convert.ConvertVisitor 实例源码

项目:jasperreports    文件:DrawVisitor.java   
/**
 *
 */
public DrawVisitor(ReportConverter reportConverter, Graphics2D grx)
{
    this.convertVisitor = new ConvertVisitor(reportConverter);

    JasperReportsContext jasperReportsContext = reportConverter.getJasperReportsContext();
    JRReport report = reportConverter.getReport();
    JRPropertiesUtil propUtil = JRPropertiesUtil.getInstance(jasperReportsContext);

    this.drawVisitor = 
        new PrintDrawVisitor(
            jasperReportsContext,
            new RenderersCache(jasperReportsContext),
            propUtil.getBooleanProperty(report, Graphics2DReportConfiguration.MINIMIZE_PRINTER_JOB_SIZE, true),
            propUtil.getBooleanProperty(report, JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false)
            );

    setGraphics2D(grx);
    this.drawVisitor.setClip(true);
}
项目:jasperreports    文件:ListDesignConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter,
        JRComponentElement element)
{
    ListComponent list = (ListComponent) element.getComponent();
    if (list == null || list.getContents() == null)
    {
        return null;
    }

    JRBasePrintFrame frame = new JRBasePrintFrame(
            reportConverter.getDefaultStyleProvider());
    reportConverter.copyBaseAttributes(element, frame);

    ListContents contents = list.getContents();
    if (contents.getHeight() > 0)
    {
        JRBasePrintFrame contentsFrame = new JRBasePrintFrame(
                reportConverter.getDefaultStyleProvider());
        contentsFrame.setUUID(element.getUUID());
        contentsFrame.setX(0);
        contentsFrame.setY(0);
        contentsFrame.setWidth(element.getWidth());         
        contentsFrame.setHeight(contents.getHeight());
        contentsFrame.setMode(ModeEnum.TRANSPARENT);

        List<JRChild> children = contents.getChildren();
        if (children != null)
        {
            ConvertVisitor contentsVisitor = new ConvertVisitor(reportConverter, 
                    contentsFrame);
            for (Iterator<JRChild> it = children.iterator(); it
                    .hasNext();)
            {
                JRChild child = it.next();
                child.visit(contentsVisitor);
            }
        }

        frame.addElement(contentsFrame);

        /*
        Integer width = contents.getWidth();
        int contentsWidth = width == null ? element.getWidth() 
                : width.intValue();

        if (contents.getHeight() < element.getHeight() 
                || contentsWidth < element.getWidth())
        {
            // add a grey rectangle to highlight the contents height
            JRBasePrintImage image = new JRBasePrintImage(
                    reportConverter.getDefaultStyleProvider());
            image.setX(0);
            image.setWidth(element.getWidth());
            image.setY(0);
            image.setHeight(element.getHeight());
            image.setMode(ModeEnum.TRANSPARENT);

            // clip out the list contents area
            Area clip = new Area(new Rectangle(
                    0, 0, element.getWidth(), element.getHeight()));
            clip.subtract(new Area(new Rectangle(
                    0, 0, contentsWidth, contents.getHeight())));

            image.setRenderer(new UnusedSpaceImageRenderer(clip));
            frame.addElement(image);
        }
        */
    }

    return frame;
}
项目:jasperreports    文件:TableDesignConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter,
        JRComponentElement element)
{
    TableComponent table = (TableComponent) element.getComponent();
    if (table == null)// || list.getContents() == null)
    {
        return null;
    }

    JRBasePrintFrame frame = new JRBasePrintFrame(
            reportConverter.getDefaultStyleProvider());
    reportConverter.copyBaseAttributes(element, frame);

    TableUtil tableManager = 
        new TableUtil(
            table, 
            reportConverter.getReport()
            );

    Map<Cell, Rectangle> cellBounds = tableManager.getCellBounds();

    for (Map.Entry<Cell, Rectangle> pair : cellBounds.entrySet()) 
    {
        Cell cell = pair.getKey();
        Rectangle rectangle = pair.getValue(); 

        JRBasePrintFrame cellFrame = 
            new JRBasePrintFrame(
                reportConverter.getDefaultStyleProvider()
                );
        cellFrame.setX((int)rectangle.getX());
        cellFrame.setY((int)rectangle.getY());
        cellFrame.setWidth((int)rectangle.getWidth());          
        cellFrame.setHeight((int)rectangle.getHeight());
        cellFrame.setStyle(reportConverter.resolveStyle(cell));

        if (cell.getLineBox() != null)
        {
            cellFrame.copyBox(cell.getLineBox());
        }

        List<JRChild> children = cell.getChildren();
        if (children != null && children.size() > 0)
        {
            ConvertVisitor convertVisitor = new ConvertVisitor(reportConverter, cellFrame);
            for(int i = 0; i < children.size(); i++)
            {
                (children.get(i)).visit(convertVisitor);
            }
        }

        frame.addElement(cellFrame);
    }

    return frame;
}