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

项目:jasperreports    文件:ChartConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider());
    JRChart chart = (JRChart)element;

    copyElement(reportConverter, chart, printImage);

    printImage.copyBox(chart.getLineBox());

    printImage.setAnchorName(JRExpressionUtil.getExpressionText(chart.getAnchorNameExpression()));
    printImage.setBookmarkLevel(chart.getBookmarkLevel());
    printImage.setLinkType(chart.getLinkType());
    printImage.setOnErrorType(OnErrorTypeEnum.ICON);
    printImage.setRenderer(getRenderer(reportConverter, chart));
    printImage.setScaleImage(ScaleImageEnum.CLIP);

    return printImage;
}
项目:jasperreports    文件:CrosstabConverter.java   
@Override
    public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
    {
        JRBasePrintFrame printFrame = new JRBasePrintFrame(reportConverter.getDefaultStyleProvider());
        JRCrosstab crosstab = (JRCrosstab)element; 

        printFrame.copyBox(crosstab.getLineBox());
        copyElement(reportConverter, crosstab, printFrame);

        List<JRPrintElement> children = getCrosstabChildren(reportConverter, crosstab);
        if (children != null && children.size() > 0)
        {
//          ConvertVisitor convertVisitor = new ConvertVisitor(reportConverter, printFrame);
            for(int i = 0; i < children.size(); i++)
            {
//              ((JRChild)children.get(i)).visit(convertVisitor);
                printFrame.addElement(children.get(i));
            }
        }

        return printFrame;
    }
项目:jasperreports    文件:TextFieldConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintText printText = new JRBasePrintText(reportConverter.getDefaultStyleProvider());
    JRTextField textField = (JRTextField)element;

    copyTextElement(reportConverter, textField, printText);

    printText.setMarkup(JRCommonText.MARKUP_NONE);//text fields are never converted to styled print text elements
    printText.setAnchorName(JRExpressionUtil.getExpressionText(textField.getAnchorNameExpression()));
    printText.setBookmarkLevel(textField.getBookmarkLevel());
    printText.setLinkType(textField.getLinkType());
    printText.setPattern(textField.getOwnPattern());

    printText.setText(JRExpressionUtil.getExpressionText(textField.getExpression()));

    JRTextMeasurerUtil.getInstance(reportConverter.getJasperReportsContext()).measureTextElement(printText);

    return printText;
}
项目:jasperreports    文件:FrameConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintFrame printFrame = new JRBasePrintFrame(reportConverter.getDefaultStyleProvider());
    JRFrame frame = (JRFrame)element; 

    copyElement(reportConverter, frame, printFrame);

    printFrame.copyBox(frame.getLineBox());

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

    return printFrame;
}
项目: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    文件:JRVerifier.java   
protected void verifyElementsOverlap(JRElement[] elements)
{
    if (!toVerifyElementOverlap())
    {
        return;
    }

    for(int index = 1; index < elements.length; index++)
    {
        JRElement element = elements[index];
        if (!isAllowedToOverlap(element))
        {
            for (int overlapIndex = 0; overlapIndex < index; ++overlapIndex)
            {
                if (!isAllowedToOverlap(elements[overlapIndex]))
                {
                    verifyElementOverlap(elements[overlapIndex], element);
                }
            }
        }
    }
}
项目:jasperreports    文件:JRVerifier.java   
protected boolean allowElementNegativeX(JRElement element)
{
    // default to report/global property
    boolean allow = allowElementNegativeX;
    if (element.hasProperties())
    {
        JRPropertiesMap properties = element.getPropertiesMap();
        if (properties.containsProperty(PROPERTY_ALLOW_ELEMENT_NEGATIVE_X))
        {
            // use element level property
            allow = JRPropertiesUtil.asBoolean(properties.getProperty(
                    PROPERTY_ALLOW_ELEMENT_NEGATIVE_X));
        }
    }
    return allow;
}
项目:jasperreports    文件:JRVerifier.java   
protected boolean allowElementNegativeY(JRElement element)
{
    // default to report/global property
    boolean allow = allowElementNegativeY;
    if (element.hasProperties())
    {
        JRPropertiesMap properties = element.getPropertiesMap();
        if (properties.containsProperty(PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y))
        {
            // use element level property
            allow = JRPropertiesUtil.asBoolean(properties.getProperty(
                    PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y));
        }
    }
    return allow;
}
项目:jasperreports    文件:JRVerifier.java   
private static int getBreakHeight(JRBand band)
{
    int breakHeight = 0;

    if (band != null)
    {
        breakHeight = band.getHeight();
        JRElement[] elements = band.getElements();
        if (
            SplitTypeEnum.IMMEDIATE == band.getSplitTypeValue()
            && elements != null && elements.length > 0
            )
        {
            for(int i = 0; i < elements.length; i++)
            {
                JRElement element = elements[i];
                int bottom = element.getY() + element.getHeight();
                breakHeight = bottom < breakHeight ? bottom : breakHeight;
            }
        }
    }

    return breakHeight;
}
项目:jasperreports    文件:JRDesignFrame.java   
/**
 * Removes a sub element from the frame.
 * 
 * @param element the element to remove
 * @return <tt>true</tt> if this frame contained the specified element
 */
public boolean removeElement(JRElement element)
{
    if (element instanceof JRDesignElement)
    {
        ((JRDesignElement) element).setElementGroup(null);
    }

    int idx = children.indexOf(element);
    if (idx >= 0)
    {
        children.remove(idx);
        getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_CHILDREN, element, idx);
        return true;
    }
    return false;
}
项目:jasperreports    文件:JRFillCrosstab.java   
private int findRowGroupColumHeaderElementIndex(int rowGroupIndex, List<JRChild> cellElements)
{
    String rowGropIndexStr = Integer.toString(rowGroupIndex);
    int colHeaderTextIndex = -1;
    for (ListIterator<JRChild> elemIt = cellElements.listIterator(cellElements.size()); elemIt.hasPrevious();)
    {
        JRChild child = elemIt.previous();
        if (child instanceof JRTextElement)
        {
            JRFillTextElement textElement = (JRFillTextElement) child;
            JRElement parentElement = textElement.getParent();
            String prop = parentElement.hasProperties() 
                    ? parentElement.getPropertiesMap().getProperty(PROPERTY_ROW_GROUP_COLUMN_HEADER) : null;
            if (prop != null && prop.equals(rowGropIndexStr))
            {
                // found it
                colHeaderTextIndex = elemIt.nextIndex();
                break;
            }
        }
    }
    return colHeaderTextIndex;
}
项目:jasperreports    文件:JRFillCrosstab.java   
private int determineColumnSortMeasure(JRFillCellContents contents)
{
    int sortMeasureIdx = -1;
    JRElement[] cellElements = contents.getElements();
    for (JRElement element : cellElements)
    {
        String sortMeasureIdxProp = element.hasProperties() 
                ? element.getPropertiesMap().getProperty(PROPERTY_COLUMN_HEADER_SORT_MEASURE_INDEX) : null;
        if (sortMeasureIdxProp != null)
        {
            sortMeasureIdx = JRPropertiesUtil.asInteger(sortMeasureIdxProp);
            break;
        }
    }
    return sortMeasureIdx;
}
项目:jasperreports    文件:JRFillElementContainer.java   
/**
 *
 */
protected void evaluate(byte evaluation) throws JRException
{
    //evaluatePrintWhenExpression(evaluation);

    //if (
    //  (isPrintWhenExpressionNull() ||
    //  (!isPrintWhenExpressionNull() && 
    //  isPrintWhenTrue()))
    //  )
    //{
        JRElement[] allElements = getElements();
        if (allElements != null && allElements.length > 0)
        {
            for(int i = 0; i < allElements.length; i++)
            {
                JRFillElement element = (JRFillElement)allElements[i];
                element.setCurrentEvaluation(evaluation);
                element.evaluate(evaluation);
            }
        }
    //}
}
项目:jasperreports    文件:PropertiesMetadataUtil.java   
protected boolean inScope(PropertyMetadata propertyMetadata, JRElementGroup container)
{
    if (container instanceof JRFrame)
    {
        return inScope(propertyMetadata, (JRElement) container);
    }

    List<PropertyScope> scopes = propertyMetadata.getScopes();

    if (container instanceof JRBand)
    {
        return scopes.contains(PropertyScope.BAND);
    }

    if (container instanceof Cell)
    {
        return scopes.contains(PropertyScope.TABLE_CELL);
    }

    if (container instanceof JRCellContents)
    {
        return scopes.contains(PropertyScope.CROSSTAB_CELL);
    }

    return false;
}
项目:jasperreports    文件:ListComponentCompiler.java   
@Override
public void collectExpressions(Component component,
        JRExpressionCollector collector)
{
    ListComponent listComponent = (ListComponent) component;
    JRDatasetRun datasetRun = listComponent.getDatasetRun();
    collector.collect(datasetRun);

    JRExpressionCollector datasetCollector = collector.getDatasetCollector(
            datasetRun.getDatasetName());
    JRElement[] elements = listComponent.getContents().getElements();
    if (elements != null)
    {
        for (int i = 0; i < elements.length; i++)
        {
            elements[i].collectExpressions(datasetCollector);
        }
    }
}
项目:jasperreports    文件:HeaderLabelUtil.java   
/**
 * 
 */
public static HeaderLabelBuiltinExpression alterHeaderLabel(JRDesignFrame frame, String suffix)
{
    HeaderLabelBuiltinExpression evaluator = null;

    JRElement[] elements = frame.getElements();
    JRElement element = (elements == null || elements.length == 0) ? null : elements[0];

    if (element instanceof JRStaticText)
    {
        JRElement elementProxy = getProxy((JRStaticText)element, suffix); 
        frame.getChildren().set(0, elementProxy);
    }
    else if (element instanceof JRTextField)
    {
        evaluator = new HeaderLabelBuiltinExpression(((JRTextField)element).getExpression(), suffix); 
    }


    return evaluator;
}
项目:jasperreports    文件:ColumnExpressionCollector.java   
protected void collectCell(Cell cell)
{
    if (cell == null)
    {
        return;
    }

    datasetCollector.collect(cell.getStyle());

    JRElement[] elements = cell.getElements();
    if (elements != null)
    {
        for (int i = 0; i < elements.length; i++)
        {
            elements[i].collectExpressions(datasetCollector);
        }
    }
}
项目:jasperreports    文件:TableUtil.java   
/**
 * 
 */
public static <T extends JRElement> T getCellElement(Class<T> type, Cell cell, boolean oneElementPerCell) 
{
    List<JRChild> detailElements = cell == null ? null : cell.getChildren();

    if (detailElements == null || (detailElements != null && oneElementPerCell && detailElements.size() != 1)) 
    {
        return null;
    }

    for (JRChild detailElement: detailElements) 
    {
        if (type.isInstance(detailElement) ) 
        {
            @SuppressWarnings("unchecked")
            T de = (T) detailElement;
            return de;
        }
    }

    return null;
}
项目:jasperreports    文件:TableUtil.java   
/**
 * 
 */
public static <T extends JRElement> T getCellElement(Class<T> type, BaseColumn column, int sectionType, String groupName, TableComponent table) 
{
    T element = TableUtil.getCellElement(type, getCell(column, sectionType, groupName), false);

    if (element == null) 
    {
        List<ColumnGroup> colGroups = TableUtil.getHierarchicalColumnGroupsForColumn(column, table.getColumns(), table);

        for (ColumnGroup colGroup: colGroups) 
        {
            if (colGroup.getGroupHeader(groupName) == null) 
            {
                continue;
            }
            element = TableUtil.getCellElement(type, getCell(colGroup, sectionType, groupName), false);
            if (element != null)
            {
                break;
            }
        }

    }

    return element;
}
项目:jasperreports    文件:TableReport.java   
@Override
public Void visitColumn(Column column)
{
    Cell cell = columnCell(column);

    if (!isEmpty(cell))
    {
        int rowSpan = cell.getRowSpan() == null ? 1 : cell.getRowSpan();
        int rowLevel = level + rowSpan - 1;
        JRDesignElementGroup elementGroup = bandInfo.getRowElementGroup(rowLevel);

        JRElement cellElement = createColumnCell(column, elementGroup, cell);
        elementGroup.addElement(cellElement);
        bandInfo.cellAdded(level, new CellInfo(cellElement, rowSpan, fillColumn.getColSpan()));

        yOffset += cell.getHeight();
    }

    xOffset += column.getWidth();

    return null;
}
项目:jasperreports    文件:JRBaseElement.java   
/**
 * Initializes basic properties of the element.
 * @param element an element whose properties are copied to this element. Usually it is a
 * {@link net.sf.jasperreports.engine.design.JRDesignElement} that must be transformed into an
 * <tt>JRBaseElement</tt> at compile time.
 * @param factory a factory used in the compile process
 */
protected JRBaseElement(JRElement element, JRBaseObjectFactory factory)
{
    factory.put(element, this);

    defaultStyleProvider = factory.getDefaultStyleProvider();

    parentStyle = factory.getStyle(element.getStyle());
    parentStyleNameReference = element.getStyleNameReference();

    uuid = element.getUUID();
    key = element.getKey();
    positionTypeValue = element.getPositionTypeValue();
    stretchTypeValue = element.getStretchTypeValue();
    isPrintRepeatedValues = element.isPrintRepeatedValues();
    modeValue = element.getOwnModeValue();
    x = element.getX();
    y = element.getY();
    width = element.getWidth();
    height = element.getHeight();
    isRemoveLineWhenBlank = element.isRemoveLineWhenBlank();
    isPrintInFirstWholeBand = element.isPrintInFirstWholeBand();
    isPrintWhenDetailOverflows = element.isPrintWhenDetailOverflows();
    forecolor = element.getOwnForecolor();
    backcolor = element.getOwnBackcolor();

    printWhenExpression = factory.getExpression(element.getPrintWhenExpression());
    printWhenGroupChanges = factory.getGroup(element.getPrintWhenGroupChanges());
    elementGroup = (JRElementGroup)factory.getVisitResult(element.getElementGroup());

    propertiesMap = JRPropertiesMap.getPropertiesClone(element);
    propertyExpressions = factory.getPropertyExpressions(element.getPropertyExpressions());
}
项目:jasperreports    文件:JRBaseElementGroup.java   
/**
 *
 */
public static JRElement[] getElements(List<JRChild> children)
{
    JRElement[] elements = null;

    if (children != null)
    {
        List<JRElement> allElements = new ArrayList<JRElement>();
        Object child = null;
        JRElement[] childElementArray = null;
        for(int i = 0; i < children.size(); i++)
        {
            child = children.get(i);
            if (child instanceof JRElement)
            {
                allElements.add((JRElement)child);
            }
            else if (child instanceof JRElementGroup)
            {
                childElementArray = ((JRElementGroup)child).getElements();
                if (childElementArray != null)
                {
                    allElements.addAll( Arrays.asList(childElementArray) );
                }
            }
        }

        elements = new JRElement[allElements.size()];
        allElements.toArray(elements);
    }

    return elements;
}
项目:jasperreports    文件:JRBaseElementGroup.java   
/**
 *
 */
public static JRElement getElementByKey(JRElement[] elements, String key)
{
    JRElement element = null;

    if (key != null)
    {
        if (elements != null)
        {
            int i = 0;
            while (element == null && i < elements.length)
            {
                JRElement elem = elements[i];
                if (key.equals(elem.getKey()))
                {
                    element = elem;
                }
                else if (elem instanceof JRFrame)
                {
                    element = ((JRFrame) elem).getElementByKey(key);
                }
                else if (elem instanceof JRCrosstab)
                {
                    element = ((JRCrosstab) elem).getElementByKey(key);
                }
                i++;
            }
        }
    }

    return element;
}
项目:jasperreports    文件:ElementConverter.java   
/**
 * 
 */
protected void copyElement(ReportConverter reportConverter, JRElement element, JRPrintElement printElement)
{
    reportConverter.copyBaseAttributes(element, printElement);

    JRPropertiesUtil.getInstance(reportConverter.getJasperReportsContext()).transferProperties(element, printElement, JasperPrint.PROPERTIES_PRINT_TRANSFER_PREFIX);
}
项目:jasperreports    文件:ReportConverter.java   
public void copyBaseAttributes(JRElement source, JRPrintElement converted)
{
    converted.setUUID(source.getUUID());
    converted.setX(source.getX());
    converted.setY(source.getY());
    converted.setWidth(source.getWidth());          
    converted.setHeight(source.getHeight());
    converted.setBackcolor(source.getOwnBackcolor());
    converted.setForecolor(source.getOwnForecolor());
    //printElement.setKey(element.getKey());
    converted.setMode(source.getOwnModeValue());
    converted.setStyle(resolveStyle(source));
}
项目:jasperreports    文件:StaticTextConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintText printText = new JRBasePrintText(reportConverter.getDefaultStyleProvider());
    JRStaticText staticText = (JRStaticText)element;

    copyTextElement(reportConverter, staticText, printText);

    printText.setText(staticText.getText());

    JRTextMeasurerUtil.getInstance(reportConverter.getJasperReportsContext()).measureTextElement(printText);

    return printText;
}
项目:jasperreports    文件:ImageConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider());
    JRImage image = (JRImage)element;

    copyGraphicElement(reportConverter, image, printImage);

    printImage.copyBox(image.getLineBox());

    printImage.setAnchorName(JRExpressionUtil.getExpressionText(image.getAnchorNameExpression()));
    printImage.setBookmarkLevel(image.getBookmarkLevel());
    printImage.setHorizontalImageAlign(image.getOwnHorizontalImageAlign());
    printImage.setLinkType(image.getLinkType());
    printImage.setOnErrorType(OnErrorTypeEnum.ICON);
    printImage.setVerticalImageAlign(image.getOwnVerticalImageAlign());

    printImage.setRenderer(
        ResourceRenderer.getInstance(
            JRExpressionUtil.getSimpleExpressionText(image.getExpression()),
            image.isLazy()
            )
        );

    printImage.setScaleImage(image.getOwnScaleImageValue());

    return printImage;
}
项目:jasperreports    文件:ElementIconConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintImage printImage = new JRBasePrintImage(
            reportConverter.getDefaultStyleProvider());
    copyElement(reportConverter, element, printImage);

    printImage.getLineBox().setPadding(3);
    printImage.setScaleImage(ScaleImageEnum.CLIP);

    printImage.setRenderer(ResourceRenderer.getInstance(iconLocation, false));

    return printImage;
}
项目:jasperreports    文件:RectangleConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintRectangle printRectangle = new JRBasePrintRectangle(reportConverter.getDefaultStyleProvider());
    JRRectangle rectangle = (JRRectangle)element;

    copyGraphicElement(reportConverter, rectangle, printRectangle);

    printRectangle.setRadius(rectangle.getOwnRadius());

    return printRectangle;
}
项目: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    文件:LineConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintLine printLine = new JRBasePrintLine(reportConverter.getDefaultStyleProvider());
    JRLine line = (JRLine)element;

    copyGraphicElement(reportConverter, line, printLine);

    printLine.setDirection(line.getDirectionValue());

    return printLine;
}
项目:jasperreports    文件:EllipseConverter.java   
@Override
public JRPrintElement convert(ReportConverter reportConverter, JRElement element)
{
    JRBasePrintEllipse printEllipse = new JRBasePrintEllipse(reportConverter.getDefaultStyleProvider());

    copyGraphicElement(reportConverter, (JREllipse)element, printEllipse);

    return printEllipse;
}
项目:jasperreports    文件:JRXmlWriter.java   
/**
 *
 */
private void writeReportElement(JRElement element) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_reportElement);
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_key, element.getKey());
    writeStyleReferenceAttr(element);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_positionType, element.getPositionTypeValue(), PositionTypeEnum.FIX_RELATIVE_TO_TOP);
    writeStretchType(element.getStretchTypeValue());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_isPrintRepeatedValues, element.isPrintRepeatedValues(), true);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_mode, element.getOwnModeValue());

    writer.addAttribute(JRXmlConstants.ATTRIBUTE_x, element.getX());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_y, element.getY());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_width, element.getWidth());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_height, element.getHeight());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_isRemoveLineWhenBlank, element.isRemoveLineWhenBlank(), false);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_isPrintInFirstWholeBand, element.isPrintInFirstWholeBand(), false);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_isPrintWhenDetailOverflows, element.isPrintWhenDetailOverflows(), false);

    if (element.getPrintWhenGroupChanges() != null)
    {
        writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_printWhenGroupChanges, element.getPrintWhenGroupChanges().getName());
    }

    writer.addAttribute(JRXmlConstants.ATTRIBUTE_forecolor, element.getOwnForecolor());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_backcolor, element.getOwnBackcolor());

    if (
        isNewerVersionOrEqual(JRConstants.VERSION_4_6_0)
        && !isExcludeUuids()
        )
    {
        writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_uuid, element.getUUID().toString());
    }

    writeProperties(element);
    writePropertyExpressions(element.getPropertyExpressions());
    writeExpression(JRXmlConstants.ELEMENT_printWhenExpression, element.getPrintWhenExpression(), false);
    writer.closeElement();
}
项目:jasperreports    文件:StyleUtil.java   
public ModeEnum resolveElementMode(JRElement element)
{
    ModeEnum elementMode = element.getOwnModeValue();
    if (elementMode != null)
    {
        return elementMode;
    }

    return resolveMode(element);
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 *
 */
private void writeReportElement( JRElement element, String elementName)
{
    if(element != null)
    {
        write( elementName + ".setKey(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(element.getKey()));
        writeStyleReferenceAttr( element, elementName);
        write( elementName + ".setPositionType({0});\n", element.getPositionTypeValue());
        write( elementName + ".setStretchType({0});\n", element.getStretchTypeValue(), StretchTypeEnum.NO_STRETCH);
        write( elementName + ".setPrintRepeatedValues({0});\n", element.isPrintRepeatedValues(),true);
        write( elementName + ".setMode({0});\n", element.getOwnModeValue());
        write( elementName + ".setX({0, number, #});\n", element.getX());
        write( elementName + ".setY({0, number, #});\n", element.getY());
        write( elementName + ".setWidth({0, number, #});\n", element.getWidth());
        write( elementName + ".setHeight({0, number, #});\n", element.getHeight());
        write( elementName + ".setRemoveLineWhenBlank({0});\n", element.isRemoveLineWhenBlank(), false);
        write( elementName + ".setPrintInFirstWholeBand({0});\n", element.isPrintInFirstWholeBand(), false);
        write( elementName + ".setPrintWhenDetailOverflows({0});\n", element.isPrintWhenDetailOverflows(), false);

        if (element.getPrintWhenGroupChanges() != null)
        {
            String groupName = getGroupName( element.getPrintWhenGroupChanges());
            write( elementName + ".setPrintWhenGroupChanges(" + groupName + ");\n");
        }

        write( elementName + ".setForecolor({0});\n", element.getOwnForecolor());
        write( elementName + ".setBackcolor({0});\n", element.getOwnBackcolor());

        writeProperties( element, elementName + ".getPropertiesMap()");
        writePropertyExpressions( element.getPropertyExpressions(), elementName);
        writeExpression( element.getPrintWhenExpression(), elementName, "PrintWhenExpression");
        flush();
    }
}
项目:jasperreports    文件:JRVerifier.java   
protected void verifyEmptyBackground()
{
    // if element overlapping checks are on, do not allow any content
    // in the background band
    JRBand background = jasperDesign.getBackground();
    if (background != null 
            && background.getHeight() > 0)
    {
        JRElement[] elements = background.getElements();
        if (elements != null && elements.length > 0)
        {
            boolean foundContent = false;
            for (int i = 0; i < elements.length; i++)
            {
                if (elements[i].getWidth() > 0 && elements[i].getHeight() > 0)
                {
                    foundContent = true;
                    break;
                }
            }

            if (foundContent)
            {
                addBrokenRule("Use of the background section is not recommended " +
                        "for reports that are supposed to be exported using grid exporters such as HTML and XLS " +
                        "because the background content would likely be overlapped by other sections " +
                        "resulting in it not showing up.", 
                        background);
            }
        }
    }
}
项目:jasperreports    文件:JRVerifier.java   
protected boolean isAllowedToOverlap(JRElement element)
{
    // check whether the element has been marked to allow to overwrite
    return element.hasProperties()
        && JRPropertiesUtil.asBoolean(element.getPropertiesMap().getProperty(
                        PROPERTY_ALLOW_ELEMENT_OVERLAP));
}
项目:jasperreports    文件:JRVerifier.java   
protected void verifyElementOverlap(JRElement element1, JRElement element2)
{
    if (element1.getWidth() <= 0 || element1.getHeight() <= 0
            || element2.getWidth() <= 0 || element2.getHeight() <= 0)
    {
        // no-space element -> no overlap
        return;
    }

    if ((element1.getX() < element2.getX() + element2.getWidth()
            && element2.getX() < element1.getX() + element1.getWidth())
            && (element1.getY() < element2.getY() + element2.getHeight()
                    && element2.getY() < element1.getY() + element1.getHeight()))
    {
        // we have an overlap
        StringBuilder message = new StringBuilder();
        message.append("Element ");
        if (element2.getKey() != null)
        {
            message.append("\"");
            message.append(element2.getKey());
            message.append("\" ");
        }
        message.append("at ");
        message.append(getElementPositionText(element2));
        message.append(" overlaps element ");
        if (element1.getKey() != null)
        {
            message.append("\"");
            message.append(element1.getKey());
            message.append("\" ");
        }
        message.append("at ");
        message.append(getElementPositionText(element1));

        // using the element on top (in z-order) as source 
        addBrokenRule(message.toString(), element2);
    }
}
项目:jasperreports    文件:JRVerifier.java   
protected String getElementPositionText(JRElement element)
{
    return "[x = " + element.getX()
        + ", y = " + element.getY()
        + ", width = " + element.getWidth()
        + ", height = " + element.getHeight()
        + "]";
}
项目: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);
    }
}