Java 类net.sf.jasperreports.engine.JRComponentElement 实例源码

项目:jasperreports    文件:FillXYChart.java   
@Override
public JRPrintElement fill()
{
    JRComponentElement element = fillContext.getComponentElement();
    JRTemplateImage templateImage = new JRTemplateImage(fillContext.getElementOrigin(), 
            fillContext.getDefaultStyleProvider());
    templateImage.setStyle(fillContext.getElementStyle());

    JRTemplatePrintImage image = new JRTemplatePrintImage(templateImage, printElementOriginator);
    image.setX(element.getX());
    image.setY(fillContext.getElementPrintY());
    image.setWidth(element.getWidth());
    image.setHeight(element.getHeight());

    if (isEvaluateNow())
    {
        copy(image);
    }
    else
    {
        fillContext.registerDelayedEvaluation(image, 
                chart.getEvaluationTime(), chart.getEvaluationGroup());
    }

    return image;
}
项目:jasperreports    文件:HtmlComponentDesignConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRComponentElement element)
{
    if (element.getComponent() == null)
    {
        return null;
    }

    try
    {
        HtmlPrintElement htmlPrintElement = HtmlPrintElementUtils.getHtmlPrintElement();
        return htmlPrintElement.createImageFromComponentElement(element);
    }
    catch (Exception e)
    { 
        return null;
    }

}
项目:jasperreports    文件:JRBaseObjectFactory.java   
@Override
public void visitComponentElement(JRComponentElement componentElement)
{
    JRBaseComponentElement base = null;

    if (componentElement != null)
    {
        base = (JRBaseComponentElement) get(componentElement);
        if (base == null)
        {
            base = new JRBaseComponentElement(componentElement, this);
        }
    }

    setVisitResult(base);
}
项目:jasperreports    文件:JRXmlWriter.java   
public void writeComponentElement(JRComponentElement componentElement) throws IOException
{
    ComponentKey componentKey = componentElement.getComponentKey();
    ComponentXmlWriter componentXmlWriter = 
        ComponentsEnvironment.getInstance(jasperReportsContext).getManager(componentKey).getComponentXmlWriter(jasperReportsContext);

    if (componentXmlWriter.isToWrite(componentElement, this))
    {
        writer.startElement(JRXmlConstants.ELEMENT_componentElement, getNamespace());
        writeReportElement(componentElement);

        componentXmlWriter.writeToXml(componentElement, this);

        writer.closeElement();
    }
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 * Writes the contents (child elements) of an element container.
 * 
 * @param elementContainer the element container
 */
public void writeChildElements( JRElementGroup elementContainer, String parentName)
{
    List<JRChild> children = elementContainer.getChildren();
    if (children != null && children.size() > 0)
    {
        for(int i = 0; i < children.size(); i++)
        {
            String childName = parentName + "_" + i;
            apiWriterVisitor.setName(childName);
            children.get(i).visit(apiWriterVisitor);
            if(children.get(i) instanceof JRElementGroup && !(children.get(i) instanceof JRElement))
            {
                write( parentName +".addElementGroup(" + childName + ");\n\n");

            }
            else if (!(children.get(i) instanceof JRComponentElement))//FIXME component
            {
                write( parentName +".addElement(" + childName + ");\n\n");
            }
        }
    }
}
项目:jasperreports    文件:JRFillObjectFactory.java   
@Override
public void visitComponentElement(JRComponentElement componentElement)
{
    JRFillComponentElement fill = null;

    if (componentElement != null)
    {
        fill = (JRFillComponentElement) get(componentElement);
        if (fill == null)
        {
            fill = new JRFillComponentElement(filler, componentElement, this);
        }
    }

    setVisitResult(fill);
}
项目:jasperreports    文件:BarcodeDesignConverter.java   
protected Renderable evaluateBarcode(ReportConverter reportConverter,
        JRComponentElement element)
{
    try
    {
        BarcodeDesignEvaluator evaluator = 
            new BarcodeDesignEvaluator(
                reportConverter.getJasperReportsContext(),
                element, 
                reportConverter.getDefaultStyleProvider()
                );
        return evaluator.evaluateImage();
    }
    catch (Exception e)
    {
        if (log.isWarnEnabled())
        {
            log.warn("Failed to create barcode preview", e);
        }

        return null;
    }
}
项目:jasperreports    文件:ComponentsXmlWriter.java   
private void writeItemDataContent(String name, ItemData itemData, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement) throws IOException
{
    writer.startElement(name, namespace);

    JRElementDataset dataset = itemData.getDataset();
    if (dataset != null)
    {
        reportWriter.writeElementDataset(dataset, false);
    }

    /*   */
    List<Item> itemList = itemData.getItems();
    if (itemList != null && !itemList.isEmpty())
    {
        for(Item item : itemList)
        {
            if(item.getProperties() != null && !item.getProperties().isEmpty())
            {
                writeItem(item, writer, reportWriter, namespace, componentElement);
            }
        }
    }
}
项目:jasperreports    文件:ComponentsXmlWriter.java   
/**
 * @deprecated To be removed.
 */
private void writeMarker(
    net.sf.jasperreports.components.map.Marker marker, 
    JRXmlWriteHelper writer, 
    JRXmlWriter reportWriter, 
    XmlNamespace namespace, 
    JRComponentElement componentElement
    ) throws IOException
{
    writer.startElement(MapXmlFactory.ELEMENT_marker, namespace);
    List<net.sf.jasperreports.components.map.MarkerProperty> markerProperties = marker.getProperties();
    for(net.sf.jasperreports.components.map.MarkerProperty property : markerProperties)
    {
        writeMarkerProperty(property, writer, reportWriter, namespace, componentElement);
    }
    writer.closeElement();
}
项目:jasperreports    文件:ComponentsXmlWriter.java   
/**
 * @deprecated To be removed.
 */
private void writeMarkerProperty(
    net.sf.jasperreports.components.map.MarkerProperty markerProperty, 
    JRXmlWriteHelper writer, 
    JRXmlWriter reportWriter, 
    XmlNamespace namespace, 
    JRComponentElement componentElement
    ) throws IOException
{
    writer.startElement(MapXmlFactory.ELEMENT_markerProperty, namespace);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_name, markerProperty.getName());
    if(markerProperty.getValue() != null)
    {
        writer.addAttribute(JRXmlConstants.ATTRIBUTE_value, markerProperty.getValue());
    }
    writeExpression(JRXmlConstants.ELEMENT_valueExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, markerProperty.getValueExpression(), false, componentElement, reportWriter);
    writer.closeElement();
}
项目:jasperreports    文件:ComponentsXmlWriter.java   
protected void writeTableCell(JRComponentElement componentElement, Cell cell, String name, 
        JRXmlWriter reportWriter) throws IOException
{
    if (cell != null)
    {
        JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper();
        writer.startElement(name);
        reportWriter.writeStyleReferenceAttr(cell);
        writer.addAttribute("height", cell.getHeight());
        writer.addAttribute("rowSpan", cell.getRowSpan());

        if (isNewerVersionOrEqual(componentElement, reportWriter, JRConstants.VERSION_4_8_0))
        {
            reportWriter.writeProperties(cell);
        }
        reportWriter.writeBox(cell.getLineBox(), JRXmlWriter.JASPERREPORTS_NAMESPACE);
        reportWriter.writeChildElements(cell);

        writer.closeElement();//cell
    }
}
项目:jasperreports    文件:AbstractComponentXmlWriter.java   
/**
 * 
 */
public static String getVersion(JasperReportsContext jasperReportsContext, JRComponentElement componentElement, JRXmlWriter reportWriter) 
{
    String version = null;

    ComponentKey componentKey = componentElement.getComponentKey();
    String versionProperty = PROPERTY_COMPONENTS_PREFIX + componentKey.getName() + PROPERTY_COMPONENTS_VERSION_SUFFIX;

    if (componentElement.getPropertiesMap().containsProperty(versionProperty))
    {
        version = componentElement.getPropertiesMap().getProperty(versionProperty);
    }
    else
    {
        JRReport report = reportWriter.getReport();
        version = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(report, versionProperty);

        if (version == null)
        {
            version = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(report, JRXmlBaseWriter.PROPERTY_REPORT_VERSION);
        }
    }

    return version;
}
项目:jasperreports    文件:BarbecueStyleResolver.java   
/**
 * 
 */
public static RotationEnum getRotationValue(JRComponentElement element)
{
    RotationEnum ownRotation = ((BarbecueComponent)element.getComponent()).getOwnRotation();
    if (ownRotation != null) {
        return ownRotation;
    }
    JRStyle style = getStyleResolver(element).getBaseStyle(element);
    if (style != null) {
        RotationEnum rotation = style.getRotationValue();
        if (rotation != null) {
            return rotation;
        }
    }
    return RotationEnum.NONE;
}
项目:jasperreports    文件:BarbecueFillComponent.java   
@Override
public JRPrintElement fill()
{
    JRTemplateImage templateImage = getTemplateImage();

    JRTemplatePrintImage image = new JRTemplatePrintImage(templateImage, printElementOriginator);
    JRComponentElement element = fillContext.getComponentElement();
    image.setUUID(element.getUUID());
    image.setX(element.getX());
    image.setY(fillContext.getElementPrintY());
    image.setWidth(element.getWidth());
    image.setHeight(element.getHeight());

    if (isEvaluateNow())
    {
        setBarcodeImage(image);
    }
    else
    {
        fillContext.registerDelayedEvaluation(image, 
                barcodeComponent.getEvaluationTimeValue(), 
                barcodeComponent.getEvaluationGroup());
    }

    return image;
}
项目:jasperreports    文件:TextInputComponentXmlWriter.java   
@Override
public void writeToXml(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException 
{
    Component component = componentElement.getComponent();
    if (component instanceof TextInputComponent) {
        TextInputComponent textInputComponent = (TextInputComponent) component;
        ComponentKey componentKey = componentElement.getComponentKey();
        writeTextInputComponent(textInputComponent, componentKey, reportWriter);
    }
}
项目:jasperreports    文件:PieChartXmlWriter.java   
public void writeToXml(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException
{
    Component component = componentElement.getComponent();
    PieChartComponent chart = (PieChartComponent) component;
    JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper();
    ComponentKey componentKey = componentElement.getComponentKey();

    String namespaceURI = componentKey.getNamespace();
    String schemaLocation = 
        ComponentsEnvironment.getInstance(jasperReportsContext)
            .getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation();
    XmlNamespace namespace = new XmlNamespace(namespaceURI, componentKey.getNamespacePrefix(),
            schemaLocation);

    writer.startElement("pieChart", namespace);

    writer.addAttribute("evaluationTime", chart.getEvaluationTime(), EvaluationTimeEnum.NOW);
    if (chart.getEvaluationTime() == EvaluationTimeEnum.GROUP)
    {
        writer.addEncodedAttribute("evaluationGroup", chart.getEvaluationGroup());
    }

    PieDataset dataset = chart.getDataset();
    writer.startElement("pieDataset");

    reportWriter.writeElementDataset(dataset);

    writer.writeExpression("keyExpression", dataset.getKeyExpression());
    writer.writeExpression("valueExpression", dataset.getValueExpression());

    writer.closeElement();//pieDataset

    writer.writeExpression("titleExpression", chart.getTitleExpression());

    writer.closeElement();//pieChart
}
项目:jasperreports    文件:FillPieChart.java   
public JRPrintElement fill()
{
    JRComponentElement element = fillContext.getComponentElement();
    JRTemplateGenericElement template = new JRTemplateGenericElement(
            fillContext.getElementOrigin(), 
            fillContext.getDefaultStyleProvider(),
            CHART_PRINT_TYPE);

    JRTemplateGenericPrintElement printElement = new JRTemplateGenericPrintElement(
            template, printElementOriginator);
    printElement.setX(element.getX());
    printElement.setY(fillContext.getElementPrintY());
    printElement.setWidth(element.getWidth());
    printElement.setHeight(element.getHeight());

    if (isEvaluateNow())
    {
        copy(printElement);
    }
    else
    {
        fillContext.registerDelayedEvaluation(printElement, 
                chart.getEvaluationTime(), chart.getEvaluationGroup());
    }

    return printElement;
}
项目:jasperreports    文件:FillBarChart.java   
public JRPrintElement fill()
{
    JRComponentElement element = fillContext.getComponentElement();
    JRTemplateGenericElement template = new JRTemplateGenericElement(
            fillContext.getElementOrigin(), 
            fillContext.getDefaultStyleProvider(),
            CHART_PRINT_TYPE);

    JRTemplateGenericPrintElement printElement = new JRTemplateGenericPrintElement(
            template, printElementOriginator);
    printElement.setX(element.getX());
    printElement.setY(fillContext.getElementPrintY());
    printElement.setWidth(element.getWidth());
    printElement.setHeight(element.getHeight());

    if (isEvaluateNow())
    {
        copy(printElement);
    }
    else
    {
        fillContext.registerDelayedEvaluation(printElement, 
                chart.getEvaluationTime(), chart.getEvaluationGroup());
    }

    return printElement;
}
项目:jasperreports    文件:FlyingSaucerHtmlPrintElement.java   
@Override
public JRPrintImage createImageFromComponentElement(JRComponentElement componentElement) throws JRException {
    HtmlComponent html = (HtmlComponent) componentElement.getComponent();

    String htmlContent = "";

    if (html.getHtmlContentExpression() != null) {
        htmlContent = JRExpressionUtil.getExpressionText(html.getHtmlContentExpression());
    }

    JRBasePrintImage printImage = new JRBasePrintImage(componentElement.getDefaultStyleProvider());

    printImage.setStyle(componentElement.getStyle());
    printImage.setMode(componentElement.getModeValue());
    printImage.setBackcolor(componentElement.getBackcolor());
    printImage.setForecolor(componentElement.getForecolor());
    printImage.setX(componentElement.getX());
    printImage.setY(componentElement.getY());
    printImage.setWidth(componentElement.getWidth());
    printImage.setHeight(componentElement.getHeight());
    printImage.setScaleImage(html.getScaleType());
    printImage.setHorizontalImageAlign(html.getHorizontalImageAlign());
    printImage.setVerticalImageAlign(html.getVerticalImageAlign());

    FlyingSaucerXhtmlToImageRenderer renderer = new FlyingSaucerXhtmlToImageRenderer(getHtmlDocument(htmlContent), componentElement.getWidth(), componentElement.getHeight());
    printImage.setRenderer(renderer);
    return printImage;
}
项目:jasperreports    文件:DefaultHtmlPrintElement.java   
@Override
public JRPrintImage createImageFromComponentElement(JRComponentElement componentElement) throws JRException {
    HtmlComponent html = (HtmlComponent) componentElement.getComponent();

    JEditorPane editorPane = new JEditorPane();
    editorPane.setEditorKitForContentType("text/html", new SynchronousImageLoaderKit());
    editorPane.setContentType("text/html");

    String htmlContent = "";

    if (html.getHtmlContentExpression() != null) {
        htmlContent = JRExpressionUtil.getExpressionText(html.getHtmlContentExpression());
    }

    editorPane.setText(htmlContent);
    editorPane.setBorder(null);
    editorPane.setSize(editorPane.getPreferredSize());

    JRBasePrintImage printImage = new JRBasePrintImage(componentElement.getDefaultStyleProvider());
    printImage.setX(componentElement.getX());
    printImage.setY(componentElement.getY());
    printImage.setWidth(componentElement.getWidth());
    printImage.setHeight(componentElement.getHeight());
    printImage.setScaleImage(html.getScaleType());
    printImage.setHorizontalImageAlign(html.getHorizontalImageAlign());
    printImage.setVerticalImageAlign(html.getVerticalImageAlign());
    printImage.setStyle(componentElement.getStyle());
    printImage.setMode(componentElement.getModeValue());
    printImage.setBackcolor(componentElement.getBackcolor());
    printImage.setForecolor(componentElement.getForecolor());

    printImage.setRenderer(new AwtComponentRendererImpl(editorPane));

    return printImage;
}
项目:jasperreports    文件:HtmlComponentXmlWriter.java   
@Override
public void writeToXml(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException 
{
    Component component = componentElement.getComponent();
    if (component instanceof HtmlComponent) 
    {
        writeHtmlComponent(componentElement, reportWriter);
    }
}
项目:jasperreports    文件:HtmlComponentXmlWriter.java   
protected void writeHtmlComponent(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException 
{
    Component component = componentElement.getComponent();
    HtmlComponent htmlComponent = (HtmlComponent) component;
    ComponentKey componentKey = componentElement.getComponentKey();

    XmlNamespace namespace = new XmlNamespace(
            HtmlComponentExtensionsRegistryFactory.NAMESPACE, 
            componentKey.getNamespacePrefix(),
            HtmlComponentExtensionsRegistryFactory.XSD_LOCATION);

    JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper();

    writer.startElement("html", namespace);

    writer.addAttribute(HtmlComponent.PROPERTY_SCALE_TYPE, htmlComponent.getScaleType());
    writer.addAttribute(HtmlComponent.PROPERTY_HORIZONTAL_ALIGN, htmlComponent.getHorizontalImageAlign());
    writer.addAttribute(HtmlComponent.PROPERTY_VERTICAL_ALIGN, htmlComponent.getVerticalImageAlign());
    writeExpression(HtmlComponent.PROPERTY_HTMLCONTENT_EXPRESSION, htmlComponent.getHtmlContentExpression(), false, componentElement, reportWriter);

    if (htmlComponent.getEvaluationTime() != EvaluationTimeEnum.NOW) {
        writer.addAttribute(HtmlComponent.PROPERTY_EVALUATION_TIME, htmlComponent.getEvaluationTime());
    }
    writer.addAttribute(HtmlComponent.PROPERTY_EVALUATION_GROUP, htmlComponent.getEvaluationGroup());
    writer.addAttribute(HtmlComponent.PROPERTY_CLIP_ON_OVERFLOW, htmlComponent.getClipOnOverflow());

    writer.closeElement();
}
项目:jasperreports    文件:JRBaseComponentElement.java   
public JRBaseComponentElement(JRComponentElement element, JRBaseObjectFactory factory)
{
    super(element, factory);

    componentKey = element.getComponentKey();

    ComponentManager manager = ComponentsEnvironment.getInstance(DefaultJasperReportsContext.getInstance()).getManager(componentKey);
    component = manager.getComponentCompiler(DefaultJasperReportsContext.getInstance()).toCompiledComponent(
            element.getComponent(), factory);
}
项目:jasperreports    文件:ConvertVisitor.java   
@Override
public void visitComponentElement(JRComponentElement componentElement)
{
    JRPrintElement image = ComponentElementConverter.getInstance()
        .convert(reportConverter, componentElement);
    addElement(parentFrame, image);
    addContour(reportConverter, parentFrame, image);
}
项目:jasperreports    文件:ComponentElementConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter,
        JRElement element)
{
    JRComponentElement componentElement = (JRComponentElement) element;
    JRPrintElement converted = null;
    ComponentKey componentKey = componentElement.getComponentKey();
    if (componentKey != null)
    {
        ComponentManager manager = reportConverter.getComponentsEnvironment().getManager(componentKey);
        if (manager != null)
        {
            ComponentDesignConverter converter = manager.getDesignConverter(reportConverter.getJasperReportsContext());
            if (converter != null)
            {
                // convert using the component converter
                converted = converter.convert(reportConverter, componentElement);
            }
        }
    }

    if (converted == null)
    {
        // fallback to the icon converter
        converted = ICON_CONVERTER.convert(reportConverter, element);
    }

    return converted;
}
项目:jasperreports    文件:XmlWriterVisitor.java   
@Override
public void visitComponentElement(JRComponentElement componentElement)
{
    try
    {
        xmlWriter.writeComponentElement(componentElement);
    }
    catch (IOException e)
    {
        throw new JRRuntimeException(e);
    }
}
项目:jasperreports    文件:JRApiWriter.java   
/**
     * 
     */
    public void writeComponentElement( JRComponentElement componentElement, String componentName)
    {
        write( "JRDesignComponentElement " + componentName + " = new JRDesignComponentElement(jasperDesign);\n");
        writeReportElement( componentElement, componentName);

//      ComponentKey componentKey = componentElement.getComponentKey();
//      Component component = componentElement.getComponent();
        //TODO: component specific API writer
//      ComponentXmlWriter componentXmlWriter = ComponentsEnvironment.
//          getComponentManager(componentKey).getComponentXmlWriter();
//      componentXmlWriter.writeToXml(componentKey, component, this);

        flush();
    }
项目:jasperreports    文件:JRVerifier.java   
public void verifyElement(JRElement element)
{
    if (element instanceof JRStaticText)
    {
        verifyStaticText((JRStaticText)element);
    }
    else if (element instanceof JRTextField)
    {
        verifyTextField((JRTextField)element);
    }
    else if (element instanceof JRImage)
    {
        verifyImage((JRImage)element);
    }
    else if (element instanceof JRSubreport)
    {
        verifySubreport((JRSubreport)element);
    }
    else if (element instanceof JRCrosstab)
    {
        verifyCrosstab((JRDesignCrosstab) element);
    }
    else if (element instanceof JRChart)
    {
        verifyChart((JRChart) element);
    }
    else if (element instanceof JRFrame)
    {
        verifyFrame((JRFrame) element);
    }
    else if (element instanceof JRComponentElement)
    {
        verifyComponentElement((JRComponentElement) element);
    }
    else if (element instanceof JRGenericElement)
    {
        verifyGenericElement((JRGenericElement) element);
    }
}
项目:jasperreports    文件:JRVerifier.java   
protected void verifyComponentElement(JRComponentElement element)
{
    verifyReportElement(element);

    ComponentKey componentKey = element.getComponentKey();
    if (componentKey == null)
    {
        addBrokenRule("No component key set for component element", element);
    }

    Component component = element.getComponent();
    if (component == null)
    {
        addBrokenRule("No component set for component element", element);
    }

    if (componentKey != null && component != null)
    {
        ComponentCompiler compiler = 
            ComponentsEnvironment.getInstance(jasperReportsContext).getManager(componentKey).getComponentCompiler(jasperReportsContext);
        pushCurrentComponentElement(element);
        try
        {
            compiler.verify(component, this);
        }
        finally
        {
            popCurrentComponentElement();
        }
    }
}
项目:jasperreports    文件:JRFillComponentElement.java   
public JRFillComponentElement(JRBaseFiller filler, JRComponentElement element,
        JRFillObjectFactory factory)
{
    super(filler, element, factory);

    ComponentKey componentKey = element.getComponentKey();
    ComponentManager manager = ComponentsEnvironment.getInstance(filler.getJasperReportsContext()).getManager(componentKey);

    factory.trackDatasetRuns();
    fillComponent = manager.getComponentFillFactory(filler.getJasperReportsContext()).toFillComponent(element.getComponent(), factory);
    fillComponent.initialize(this);
    this.componentDatasetRuns = factory.getTrackedDatasetRuns();
}
项目:jasperreports    文件:BarcodeDesignEvaluator.java   
public BarcodeDesignEvaluator(
    JasperReportsContext jasperReportsContext,
    JRComponentElement componentElement,
    JRDefaultStyleProvider defaultStyleProvider
    )
{
    super(jasperReportsContext, componentElement, defaultStyleProvider);
}
项目:jasperreports    文件:BarcodeDesignConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter,
        JRComponentElement element)
{
    JRBasePrintImage printImage = new JRBasePrintImage(
            reportConverter.getDefaultStyleProvider());
    reportConverter.copyBaseAttributes(element, printImage);
    printImage.setScaleImage(ScaleImageEnum.RETAIN_SHAPE);

    Renderable barcodeImage = evaluateBarcode(reportConverter, element);
    printImage.setRenderer(barcodeImage);

    return printImage;
}
项目:jasperreports    文件:BarcodeRasterizedImageProducer.java   
@Override
public Renderable createImage(
    JasperReportsContext jasperReportsContext,
    JRComponentElement componentElement, 
    BarcodeGenerator barcode, 
    String message
    )
{
    try
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        int resolution = JRPropertiesUtil.getInstance(jasperReportsContext).getIntegerProperty(
                componentElement, PROPERTY_RESOLUTION, 300);
        boolean gray = JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(
                componentElement, PROPERTY_GRAY, true);
        boolean antiAlias = JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(
                componentElement, PROPERTY_ANTIALIAS, true);
        int imageType = gray ? BufferedImage.TYPE_BYTE_GRAY 
                : BufferedImage.TYPE_BYTE_BINARY;

        BitmapCanvasProvider provider = 
            new BitmapCanvasProvider(
                out, "image/x-png", resolution, imageType, antiAlias, 
                ((Barcode4jComponent)componentElement.getComponent()).getOrientationValue().getValue()
                );
        barcode.generateBarcode(provider, message);
        provider.finish();

        byte[] imageData = out.toByteArray();
        return SimpleDataRenderer.getInstance(imageData);
    }
    catch (Exception e)
    {
        throw new JRRuntimeException(e);
    }
}
项目:jasperreports    文件:BarcodeFillComponent.java   
@Override
public JRPrintElement fill()
{
    JRTemplateImage templateImage = getTemplateImage();

    JRTemplatePrintImage image = new JRTemplatePrintImage(templateImage, printElementOriginator);
    JRComponentElement element = fillContext.getComponentElement();
    image.setUUID(element.getUUID());
    image.setX(element.getX());
    image.setY(fillContext.getElementPrintY());
    image.setWidth(element.getWidth());
    image.setHeight(element.getHeight());
    image.getPropertiesMap().setProperty(HtmlReportConfiguration.PROPERTY_EMBED_IMAGE, Boolean.TRUE.toString());
    image.getPropertiesMap().setProperty(HtmlReportConfiguration.PROPERTY_EMBEDDED_SVG_USE_FONTS, Boolean.TRUE.toString());

    if (isEvaluateNow())
    {
        setBarcodeImage(image);
    }
    else
    {
        fillContext.registerDelayedEvaluation(image, 
                barcodeComponent.getEvaluationTimeValue(), 
                barcodeComponent.getEvaluationGroup());
    }

    return image;
}
项目:jasperreports    文件:BarcodeSVGImageProducer.java   
@Override
public Renderable createImage(
    JasperReportsContext jasperReportsContext,
    JRComponentElement componentElement,
    BarcodeGenerator barcode, 
    String message
    )
{
    try
    {
        SVGCanvasProvider provider = 
            new SVGCanvasProvider(
                false, 
                ((Barcode4jComponent)componentElement.getComponent()).getOrientationValue().getValue()
                );
        barcode.generateBarcode(provider, message);
        Document svgDoc = provider.getDOM();

        Source source = new DOMSource(svgDoc);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Result output = new StreamResult(baos);
        Transformer transformer = TransformerFactory.newInstance()
                .newTransformer();
        transformer.transform(source, output);

        return SimpleRenderToImageAwareDataRenderer.getInstance(baos.toByteArray());
    }
    catch (Exception e)
    {
        throw new JRRuntimeException(e);
    }
}
项目:jasperreports    文件:AbstractBarcodeEvaluator.java   
protected AbstractBarcodeEvaluator(
    JasperReportsContext jasperReportsContext,
    JRComponentElement componentElement, 
    JRDefaultStyleProvider defaultStyleProvider
    )
{
    this.jasperReportsContext = jasperReportsContext;
    this.componentElement = componentElement;
    this.barcodeComponent = (BarcodeComponent) componentElement.getComponent();
    this.defaultStyleProvider = defaultStyleProvider;
}
项目:jasperreports    文件:BarcodeXmlWriter.java   
public BarcodeXmlWriter(JRXmlWriter reportWriter, JRComponentElement componentElement, String version, VersionComparator versionComparator)
{
    this.xmlWriteHelper = reportWriter.getXmlWriteHelper();
    this.barcodeComponent = (BarcodeComponent) componentElement.getComponent();
    this.componentKey = componentElement.getComponentKey();
    this.version = version;
    this.versionComparator = versionComparator;
}
项目:jasperreports    文件:ComponentsXmlWriter.java   
protected void writeList(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException
{
    ListComponent list = (ListComponent) componentElement.getComponent();
    ComponentKey componentKey = componentElement.getComponentKey();
    JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper();

    XmlNamespace namespace = new XmlNamespace(
            ComponentsExtensionsRegistryFactory.NAMESPACE, 
            componentKey.getNamespacePrefix(),
            ComponentsExtensionsRegistryFactory.XSD_LOCATION);

    writer.startElement("list", namespace);
    if(isNewerVersionOrEqual(componentElement, reportWriter, JRConstants.VERSION_3_6_1))
    {
        writer.addAttribute("printOrder", list.getPrintOrderValue());
    }
    writer.addAttribute("ignoreWidth", list.getIgnoreWidth()); 
    reportWriter.writeDatasetRun(list.getDatasetRun());

    ListContents contents = list.getContents();
    writer.startElement("listContents");
    writer.addAttribute("height", contents.getHeight());
    writer.addAttribute("width", contents.getWidth());
    reportWriter.writeChildElements(contents);
    writer.closeElement();

    writer.closeElement();
}
项目:jasperreports    文件:ComponentsXmlWriter.java   
protected void writeBarbecue(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException
{
    Component component = componentElement.getComponent();
    BarbecueComponent barcode = (BarbecueComponent) component;
    JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper();
    ComponentKey componentKey = componentElement.getComponentKey();

    XmlNamespace namespace = new XmlNamespace(
            ComponentsExtensionsRegistryFactory.NAMESPACE, 
            componentKey.getNamespacePrefix(),
            ComponentsExtensionsRegistryFactory.XSD_LOCATION);

    writer.startElement("barbecue", namespace);

    writer.addAttribute("type", barcode.getType());
    writer.addAttribute("drawText", barcode.isDrawText());
    writer.addAttribute("checksumRequired", barcode.isChecksumRequired());
    writer.addAttribute("barWidth", barcode.getBarWidth());
    writer.addAttribute("barHeight", barcode.getBarHeight());
    if (isNewerVersionOrEqual(componentElement, reportWriter, JRConstants.VERSION_4_0_0))
    {
        writer.addAttribute("rotation", barcode.getOwnRotation());
    }
    if (barcode.getEvaluationTimeValue() != EvaluationTimeEnum.NOW)
    {
        writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, 
                barcode.getEvaluationTimeValue());
    }
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, 
            barcode.getEvaluationGroup());

    writeExpression("codeExpression", barcode.getCodeExpression(), false, componentElement, reportWriter);
    writeExpression("applicationIdentifierExpression", barcode.getApplicationIdentifierExpression(), false, componentElement, reportWriter);

    writer.closeElement();
}
项目:jasperreports    文件:ComponentsXmlWriter.java   
private void writeItemData(String name, ItemData itemData, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement) throws IOException
{
    if (itemData != null)
    {
        writeItemDataContent(name, itemData, writer, reportWriter, namespace, componentElement);
        writer.closeElement();
    }
}