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

项目:jasperreports    文件:JRApiWriter.java   
/**
 * Writes a conditional style.
 * 
 * @param style the conditional style
 * 
 */
protected void writeConditionalStyle( JRConditionalStyle style, String styleName)
{
    if(style != null)
    {
        write( "JRDesignConditionalStyle " + styleName + " = new JRDesignConditionalStyle();\n");
        writeExpression( style.getConditionExpression(), styleName, "ConditionExpression");

        if (style.getStyle() != null)//FIXME double check which one to use; style or styleNameReference?
        {
            write( styleName + ".setParentStyle({0});\n", JRStringUtil.escapeJavaStringLiteral(style.getStyle().getName()));
        }
        else if (style.getStyleNameReference() != null)
        {
            write( styleName + ".setParentStyleNameReference(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(style.getStyleNameReference()));
        }

        writeCommonStyle(style, styleName);

        flush();
    }
}
项目:jasperreports    文件:JRVerifier.java   
/**
 *
 */
private void verifyConditionalStyles(JRStyle style)
{
    JRConditionalStyle[] condStyles = style.getConditionalStyles();
    if (condStyles != null && condStyles.length > 0)
    {
        for(int index = 0; index < condStyles.length; index++)
        {
            JRConditionalStyle condStyle = condStyles[index];

            if (log.isWarnEnabled())
            {
                if (condStyle.getName() != null)
                {
                    log.warn("Conditional style should not have a name.");
                }

                if (condStyle.isDefault())
                {
                    log.warn("Conditional style can't be the default style.");
                }
            }
        }
    }
}
项目:jasperreports    文件:JRBaseObjectFactory.java   
@Override
public JRConditionalStyle getConditionalStyle(JRConditionalStyle conditionalStyle, JRStyle style)
{
    JRBaseConditionalStyle baseConditionalStyle = null;
    if (conditionalStyle != null)
    {
        baseConditionalStyle = (JRBaseConditionalStyle) get(conditionalStyle);
        if (baseConditionalStyle == null) {
            baseConditionalStyle = new JRBaseConditionalStyle(conditionalStyle, style, this);
            put(conditionalStyle, baseConditionalStyle);
        }
    }
    return baseConditionalStyle;
}
项目:jasperreports    文件:JRBaseConditionalStyle.java   
public JRBaseConditionalStyle(JRConditionalStyle style, JRStyle parentStyle, JRAbstractObjectFactory factory)
{
    this.parentStyle = parentStyle;

    modeValue = style.getOwnModeValue();
    forecolor = style.getOwnForecolor();
    backcolor = style.getOwnBackcolor();

    linePen = style.getLinePen().clone(this);
    fillValue = style.getOwnFillValue();

    radius = style.getOwnRadius();

    scaleImageValue = style.getOwnScaleImageValue();
    horizontalTextAlign = style.getOwnHorizontalTextAlign();
    verticalTextAlign = style.getOwnVerticalTextAlign();
    horizontalImageAlign = style.getOwnHorizontalImageAlign();
    verticalImageAlign = style.getOwnVerticalImageAlign();

    lineBox = style.getLineBox().clone(this);
    paragraph = style.getParagraph().clone(this);

    rotationValue = style.getOwnRotationValue();
    markup = style.getOwnMarkup();

    pattern = style.getOwnPattern();

    fontName = style.getOwnFontName();
    isBold = style.isOwnBold();
    isItalic = style.isOwnItalic();
    isUnderline = style.isOwnUnderline();
    isStrikeThrough = style.isOwnStrikeThrough();
    fontsize = style.getOwnFontsize();
    pdfFontName = style.getOwnPdfFontName();
    pdfEncoding = style.getOwnPdfEncoding();
    isPdfEmbedded = style.isOwnPdfEmbedded();
    isBlankWhenNull = style.isOwnBlankWhenNull();
    conditionExpression = factory.getExpression(style.getConditionExpression(), true);
}
项目:jasperreports    文件:JRXmlBaseWriter.java   
public void writeStyleReferenceAttr(JRStyleContainer styleContainer)
{
    if (!(styleContainer instanceof JRConditionalStyle))
    {
        if (styleContainer.getStyle() != null)
        {
            writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_style, styleContainer.getStyle().getName());
        }
        else if (styleContainer.getStyleNameReference() != null)
        {
            writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_style, styleContainer.getStyleNameReference());
        }
    }
}
项目:jasperreports    文件:JRXmlBaseWriter.java   
/**
 * Writes a conditional style.
 * 
 * @param style the conditional style
 * @throws IOException
 */
protected void writeConditionalStyle(JRConditionalStyle style) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_conditionalStyle);
    writeExpression(JRXmlConstants.ELEMENT_conditionExpression, style.getConditionExpression(), false);
    writeStyle(style);
    writer.closeElement();
}
项目:jasperreports    文件:StyleUtil.java   
public ModeEnum resolveMode(JRStyleContainer styleContainer)
{
    JRStyle style = styleContainer.getStyle();
    if (style != null)
    {
        ModeEnum styleMode = style.getOwnModeValue();
        if (styleMode != null)
        {
            JRConditionalStyle[] conditionalStyles = style.getConditionalStyles();
            if (conditionalStyles != null)
            {
                for (JRConditionalStyle conditionalStyle : conditionalStyles)
                {
                    ModeEnum conditionalMode = conditionalStyle.getOwnModeValue();
                    if (conditionalMode != null && conditionalMode != styleMode)
                    {
                        // a conditional style overrides the style mode
                        return null;
                    }
                }
            }

            // we have a style
            return styleMode;
        }

        // going to the parent
        return resolveMode(style);
    }

    if (styleContainer.getStyleNameReference() != null)
    {
        // we can't resolve external style references here
        return null;
    }

    // if no style set, default
    return ModeEnum.TRANSPARENT;
}
项目:jasperreports    文件:JRDesignStyle.java   
/**
 *
 */
public void addConditionalStyle(int index, JRConditionalStyle conditionalStyle)
{
    conditionalStylesList.add(index, conditionalStyle);
    getEventSupport().fireCollectionElementAddedEvent(PROPERTY_CONDITIONAL_STYLES, 
            conditionalStyle, index);
}
项目:jasperreports    文件:JRDesignStyle.java   
/**
 *
 */
public boolean removeConditionalStyle(JRConditionalStyle conditionalStyle)
{
    int idx = conditionalStylesList.indexOf(conditionalStyle);
    if (idx >= 0)
    {
        conditionalStylesList.remove(idx);
        getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_CONDITIONAL_STYLES, 
                conditionalStyle, idx);
        return true;
    }
    return false;
}
项目:jasperreports    文件:JRFillObjectFactory.java   
@Override
public JRConditionalStyle getConditionalStyle(JRConditionalStyle conditionalStyle, JRStyle style)
{
    JRBaseConditionalStyle baseConditionalStyle = null;
    if (conditionalStyle != null)
    {
        baseConditionalStyle = (JRBaseConditionalStyle) get(conditionalStyle);
        if (baseConditionalStyle == null) {
            baseConditionalStyle = new JRBaseConditionalStyle(conditionalStyle, style, this);
            put(conditionalStyle, baseConditionalStyle);
        }
    }
    return baseConditionalStyle;
}
项目:jasperreports    文件:JRFillElement.java   
protected void collectDelayedEvaluations(JRStyle style)
{
    JRConditionalStyle[] conditionalStyles = style.getConditionalStyles();
    // collect delayed evaluations from conditional style expressions
    if (conditionalStyles != null && conditionalStyles.length > 0)
    {
        for (int i = 0; i < conditionalStyles.length; i++)
        {
            collectDelayedEvaluations(
                    conditionalStyles[i].getConditionExpression());
        }
    }
}
项目:PDFReporter-Studio    文件:StyleTemplateFactory.java   
public static void openEditor(Object obj, IEditorInput editorInput, ANode node) {
    if (obj instanceof JRStyle || obj instanceof JRConditionalStyle) {
        if (node.getParent() instanceof MStyles)
            return;
        if (node instanceof MConditionalStyle)
            node = (ANode) node.getParent();
        if (node instanceof MStyle)
            node = (ANode) node.getParent();
    }
    if (node instanceof MStyleTemplate)
        obj = node.getValue();
    else if (node instanceof MStyleTemplateReference) {
        IFile file = getFile(node, ((FileEditorInput) editorInput).getFile());
        JRTemplateReference st = (JRTemplateReference) node.getValue();
        SelectionHelper.openEditor(file, st.getLocation());
    }

    if (obj instanceof JRDesignReportTemplate) {
        if (editorInput instanceof FileEditorInput) {
            JRDesignReportTemplate s = (JRDesignReportTemplate) obj;
            if (s.getSourceExpression() != null)
                SelectionHelper.openEditor((FileEditorInput) editorInput,
                        ExpressionUtil.eval(s.getSourceExpression(), node.getJasperConfiguration()));
        }
        return;
    }
}
项目:dynamicreports-jasper    文件:JasperTemplateStyleLoader.java   
private static DRStyle convertStyle(JRStyle jrStyle) {
    DRStyle style = new DRStyle();
    abstractStyle(jrStyle, style);

    style.setName(jrStyle.getName());
    JRStyle jrParentStyle = jrStyle.getStyle();
    if (jrParentStyle != null) {
        style.setParentStyle(convertStyle(jrParentStyle));
    }
    for (JRConditionalStyle jrConditionalStyle : jrStyle.getConditionalStyles()) {
        style.addConditionalStyle(conditionalStyle(jrConditionalStyle));
    }
    return style;
}
项目:jasperreports    文件:JRBaseStyle.java   
@Override
public JRConditionalStyle[] getConditionalStyles()
{
    return conditionalStyles;
}
项目:jasperreports    文件:JRDesignStyle.java   
/**
 *
 */
public void addConditionalStyle(JRConditionalStyle conditionalStyle)
{
    addConditionalStyle(conditionalStylesList.size(), conditionalStyle);
}
项目:jasperreports    文件:JRDesignStyle.java   
@Override
public JRConditionalStyle[] getConditionalStyles()
{
    return conditionalStylesList.toArray(new JRDesignConditionalStyle[conditionalStylesList.size()]);
}
项目:jasperreports    文件:JRDesignStyle.java   
/**
 *
 */
public List<JRConditionalStyle> getConditionalStyleList()
{
    return conditionalStylesList;
}
项目:jasperreports    文件:JRFillElementContainer.java   
protected boolean buildConsolidatedStyle(JRStyle style, byte evaluation, StringBuilder code, List<JRStyle> condStylesToApply) throws JRException
{
    boolean anyTrue = false;

    JRConditionalStyle[] conditionalStyles = style.getConditionalStyles();
    if (conditionalStyles != null && conditionalStyles.length > 0)
    {
        for (int j = 0; j < conditionalStyles.length; j++) 
        {
            JRConditionalStyle conditionalStyle = conditionalStyles[j];
            Boolean expressionValue = 
                (Boolean) expressionEvaluator.evaluate(
                    conditionalStyle.getConditionExpression(),
                    evaluation
                    );

            boolean condition;
            if (expressionValue == null)
            {
                condition = false;
            }
            else
            {
                condition = expressionValue.booleanValue();
            }

            code.append(condition ? '1' : '0');
            anyTrue = anyTrue | condition;

            if (condition)
            {
                condStylesToApply.add(conditionalStyle);
            }
        }
    }

    condStylesToApply.add(style);

    if (style.getStyle() != null)
    {
        anyTrue = anyTrue | buildConsolidatedStyle(style.getStyle(), evaluation, code, condStylesToApply);
    }
    return anyTrue;
}