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

项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public boolean isUnderline(JRFont font)
{
    Boolean ownUnderline = font.isOwnUnderline();
    if (ownUnderline != null)
    {
        return ownUnderline.booleanValue();
    }
    JRStyle baseStyle = getBaseStyle(font);
    if (baseStyle != null)
    {
        Boolean underline = baseStyle.isUnderline();
        if (underline != null)
        {
            return underline.booleanValue();
        }
    }
    return false;
}
项目:jasperreports    文件:JasperDesign.java   
/**
 * Removes a report style from the list.
 */
public JRStyle removeStyle(JRStyle style)
{
    if (style != null)
    {
        if (style.isDefault())
        {
            resetDefaultStyle();
        }

        int idx = stylesList.indexOf(style);
        if (idx >= 0)
        {
            stylesList.remove(idx);
            stylesMap.remove(style.getName());
            getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_STYLES, style, idx);
        }
    }

    return style;
}
项目:jasperreports    文件:JRPptxExporter.java   
/**
 *
 */
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale)
{
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
        runHelper.export(
            style, 
            iterator.getAttributes(), 
            text.substring(iterator.getIndex(), runLimit),
            locale,
            invalidCharReplacement
            );

        iterator.setIndex(runLimit);
    }
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public boolean isBlankWhenNull(JRTextField element)
{
    Boolean ownBlankWhenNull = element.isOwnBlankWhenNull();
    if (ownBlankWhenNull != null)
    {
        return ownBlankWhenNull.booleanValue();
    }
    JRStyle baseStyle = getBaseStyle(element);
    if (baseStyle != null)
    {
        Boolean blankWhenNull = baseStyle.isBlankWhenNull();
        if (blankWhenNull != null)
        {
            return blankWhenNull.booleanValue();
        }
    }
    return false;
}
项目:jasperreports    文件:JRBaseObjectFactory.java   
@Override
public JRStyle getStyle(JRStyle style)
{
    JRBaseStyle baseStyle = null;

    if (style != null)
    {
        baseStyle = (JRBaseStyle)get(style);
        if (baseStyle == null)
        {
            baseStyle = new JRBaseStyle(style, this);
            put(style, baseStyle);
        }
    }

    return baseStyle;
}
项目:jasperreports    文件:DocxParagraphHelper.java   
/**
     *
     */
    public void exportProps(JRPrintText text)
    {
        JRStyle baseStyle = text.getDefaultStyleProvider().getStyleResolver().getBaseStyle(text); 
        exportPropsHeader(baseStyle == null ? null : baseStyle.getName(), text.getParagraph()); //javadoc says getStyleNameReference is not supposed to work for print elements

        exportAlignment(
            getHorizontalTextAlign(
                text.getOwnHorizontalTextAlign()
                )
            );

        exportTabStops(
            text.getParagraph() 
            );

        exportLineSpacing(
            text.getParagraph() 
            );

//      exportRunDirection(text.getRunDirection() == JRPrintText.RUN_DIRECTION_RTL ? "rl" : null);

        exportPropsFooter();
    }
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public String getPdfFontName(JRStyle style)
{
    String ownPdfFontName = style.getOwnPdfFontName();
    if (ownPdfFontName != null)
    {
        return ownPdfFontName;
    }
    JRStyle baseStyle = getBaseStyle(style);
    if (baseStyle != null)
    {
        String pdfFontName = baseStyle.getPdfFontName();
        if (pdfFontName != null)
        {
            return pdfFontName;
        }
    }
    return propertiesUtil.getProperty(JRFont.DEFAULT_PDF_FONT_NAME);
}
项目:jasperreports    文件:JRBaseFiller.java   
protected void loadStyles() throws JRException
{
    List<JRStyle> styleList = collectStyles();
    JRStyle reportDefaultStyle = jasperReport.getDefaultStyle();
    if (reportDefaultStyle == null)
    {
        lookupExternalDefaultStyle(styleList);
    }

    List<JRStyle> includedStyles = factory.setStyles(styleList);
    if (bandReportParent != null)
    {
        bandReportParent.registerReportStyles(includedStyles);
    }

    styles = includedStyles.toArray(new JRStyle[includedStyles.size()]);

    if (reportDefaultStyle != null)
    {
        setDefaultStyle(factory.getStyle(reportDefaultStyle));
    }
}
项目:jasperreports    文件:JRFillTextElement.java   
/**
 *
 */
protected Map<Attribute,Object> getStyledTextAttributes()
{
    JRStyle style = getStyle();
    Map<Attribute,Object> styledTextAttributes = styledTextAttributesMap.get(style);
    if (styledTextAttributes == null)
    {
        styledTextAttributes = new HashMap<Attribute,Object>(); 
        //JRFontUtil.getAttributes(styledTextAttributes, this, filler.getLocale());
        FontUtil.getInstance(filler.getJasperReportsContext()).getAttributesWithoutAwtFont(styledTextAttributes, this);
        styledTextAttributes.put(TextAttribute.FOREGROUND, getForecolor());
        if (getModeValue() == ModeEnum.OPAQUE)
        {
            styledTextAttributes.put(TextAttribute.BACKGROUND, getBackcolor());
        }
        styledTextAttributesMap.put(style, styledTextAttributes);
    }

    return styledTextAttributes;
}
项目:jasperreports    文件:FillPartPrintOutput.java   
@Override
public void addStyles(Collection<JRStyle> stylesList)
{
    for (JRStyle style : stylesList)
    {
        if (styles.containsKey(style.getName()))
        {
            log.debug("style " + style.getName() + " alread present");
        }
        else
        {
            if (log.isDebugEnabled())
            {
                log.debug("added style " + style.getName());
            }

            styles.put(style.getName(), style);
        }
    }
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public String getMarkup(JRCommonText element)
{
    String ownMarkup = element.getOwnMarkup();
    if (ownMarkup != null)
    {
        return ownMarkup;
    }
    JRStyle baseStyle = getBaseStyle(element);
    if (baseStyle != null)
    {
        String markup = baseStyle.getMarkup();
        if (markup != null)
        {
            return markup;
        }
    }
    return JRCommonText.MARKUP_NONE;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public String getPdfEncoding(JRFont font)
{
    String ownPdfEncoding = font.getOwnPdfEncoding();
    if (ownPdfEncoding != null)
    {
        return ownPdfEncoding;
    }
    JRStyle baseStyle = getBaseStyle(font);
    if (baseStyle != null)
    {
        String pdfEncoding = baseStyle.getPdfEncoding();
        if (pdfEncoding != null)
        {
            return pdfEncoding;
        }
    }
    return propertiesUtil.getProperty(JRFont.DEFAULT_PDF_ENCODING);
}
项目:jasperreports    文件:JRFillFrame.java   
public JRFillFrame(JRBaseFiller filler, JRFrame frame, JRFillObjectFactory factory)
{
    super(filler, frame, factory);

    parentFrame = frame;

    lineBox = frame.getLineBox().clone(this);
    borderSplitType = initBorderSplitType(filler, frame);

    frameContainer = new JRFillFrameElements(factory);

    bottomTemplateFrames = new HashMap<JRStyle,JRTemplateElement>();
    topTemplateFrames = new HashMap<JRStyle,JRTemplateElement>();
    topBottomTemplateFrames = new HashMap<JRStyle,JRTemplateElement>();

    setShrinkable(true);
}
项目:jasperreports    文件:JRStyleFactory.java   
@Override
protected void setParentStyle(JRDesignStyle currentStyle, String parentStyleName)
{
    JasperDesign jasperDesign = (JasperDesign) digester.peek(digester.getCount() - 2);
    Map<String,JRStyle> stylesMap = jasperDesign.getStylesMap();

    if (stylesMap.containsKey(parentStyleName))
    {
        JRStyle parent = stylesMap.get(parentStyleName);
        currentStyle.setParentStyle(parent);
    }
    else
    {
        currentStyle.setParentStyleNameReference(parentStyleName);
    }
}
项目:jasperreports    文件:HeaderToolbarElementJsonHandler.java   
private boolean hasExternalStyle(JRStyleContainer styleContainer)
{
    if (styleContainer.getStyle() == null && styleContainer.getStyleNameReference() != null)
    {
        return true;
    }

    JRStyle style = styleContainer.getStyle();
    while (style != null)
    {
        if (style.getStyle() == null && style.getStyleNameReference() != null)
        {
            return true;
        }

        style = style.getStyle();
    }
    return false;
}
项目:jasperreports    文件:JRPrintStyleFactory.java   
@Override
protected void setParentStyle(JRDesignStyle currentStyle, String parentStyleName)
{
    JRPrintXmlLoader printXmlLoader = (JRPrintXmlLoader) digester.peek(digester.getCount() - 1);
    JasperPrint jasperPrint = (JasperPrint) digester.peek(digester.getCount() - 2);
    Map<String,JRStyle> stylesMap = jasperPrint.getStylesMap();

    if (!stylesMap.containsKey(parentStyleName))
    {
        printXmlLoader.addError(
            new JRRuntimeException(
                EXCEPTION_MESSAGE_KEY_UNKNOWN_REPORT_STYLE,
                new Object[]{parentStyleName}
            )
        );
    }

    JRStyle parent = stylesMap.get(parentStyleName);
    currentStyle.setParentStyle(parent);
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Integer getFirstLineIndent(JRParagraph paragraph)
{
    Integer ownFirstLineIndent = paragraph.getOwnFirstLineIndent();
    if (ownFirstLineIndent != null)
    {
        return ownFirstLineIndent;
    }
    JRStyle style = getBaseStyle(paragraph);
    if (style != null)
    {
        Integer firstLineIndent = style.getParagraph().getFirstLineIndent();
        if (firstLineIndent != null)
        {
            return firstLineIndent;
        }
    }
    return propertiesUtil.getIntegerProperty(JRParagraph.DEFAULT_FIRST_LINE_INDENT);
}
项目:jasperreports    文件:JRXlsxExporter.java   
/**
 *
 */
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean isStyledText)
{
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
        runHelper.export(
                style, iterator.getAttributes(), 
                text.substring(iterator.getIndex(), runLimit),
                locale,
                invalidCharReplacement,
                isStyledText
                );

        iterator.setIndex(runLimit);
    }
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Integer getBottomPadding(JRLineBox box)
{
    Integer ownBottomPadding = box.getOwnBottomPadding();
    if (ownBottomPadding != null)
    {
        return ownBottomPadding;
    }
    Integer ownPadding = box.getOwnPadding();
    if (ownPadding != null)
    {
        return ownPadding;
    }
    JRStyle style = getBaseStyle(box);
    if (style != null)
    {
        Integer bottomPadding = style.getLineBox().getBottomPadding();
        if (bottomPadding != null)
        {
            return bottomPadding;
        }
    }
    return INTEGER_ZERO;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Integer getSpacingAfter(JRParagraph paragraph)
{
    Integer ownSpacingAfter = paragraph.getOwnSpacingAfter();
    if (ownSpacingAfter != null)
    {
        return ownSpacingAfter;
    }
    JRStyle style = getBaseStyle(paragraph);
    if (style != null)
    {
        Integer spacingAfter = style.getParagraph().getSpacingAfter();
        if (spacingAfter != null)
        {
            return spacingAfter;
        }
    }
    return propertiesUtil.getIntegerProperty(JRParagraph.DEFAULT_SPACING_AFTER);
}
项目:jasperreports    文件:JRFillObjectFactory.java   
protected void renameExistingStyle(String name)
{
    JRStyle originalStyle = stylesMap.getStyle(name);
    if (originalStyle != null)
    {
        //found a previous external style with the same name
        //renaming the previous style
        JRBaseStyle style = (JRBaseStyle) get(originalStyle);

        String newName;
        int suf = 1;
        do
        {
            newName = name + suf;
            ++suf;
        }
        while(stylesMap.containsStyle(newName));

        style.rename(newName);
        stylesMap.renamed(name, newName);
    }
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Integer getTopPadding(JRLineBox box)
{
    Integer ownTopPadding = box.getOwnTopPadding();
    if (ownTopPadding != null)
    {
        return ownTopPadding;
    }
    Integer ownPadding = box.getOwnPadding();
    if (ownPadding != null)
    {
        return ownPadding;
    }
    JRStyle style = getBaseStyle(box);
    if (style != null)
    {
        Integer topPadding = style.getLineBox().getTopPadding();
        if (topPadding != null)
        {
            return topPadding;
        }
    }
    return INTEGER_ZERO;
}
项目:jasperreports    文件:BaseFillList.java   
protected JRTemplateFrame getFrameTemplate()
{
    JRStyle style = fillContext.getElementStyle();
    JRTemplateFrame frameTemplate = printFrameTemplates.get(style);
    if (frameTemplate == null)
    {
        frameTemplate = new JRTemplateFrame(
                    fillContext.getElementOrigin(),
                    fillContext.getDefaultStyleProvider());
        frameTemplate.setElement(fillContext.getComponentElement());
        frameTemplate = deduplicate(frameTemplate);

        printFrameTemplates.put(style, frameTemplate);
    }

    return frameTemplate;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public JRStyle getBaseStyle(JRStyle styleContainer)
{
    if (styleContainer != null)
    {
        JRStyle style = styleContainer.getStyle();
        if (style != null)
        {
            return style;
        }
        if (stylesInheritFromDefault && !styleContainer.isDefault())
        {
            JRDefaultStyleProvider defaultStyleProvider = styleContainer.getDefaultStyleProvider();
            if (defaultStyleProvider != null)
            {
                return defaultStyleProvider.getDefaultStyle();
            }
        }
    }
    return null;
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 *
 */
private void writeStyle( JRStyle style, String styleName)
{
    if (style != null && stylesMap.get(style.getName()) == null)
    {
        write( "JRDesignStyle " + styleName + " = new JRDesignStyle();\n");

        write( styleName + ".setName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(style.getName()));

        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()));
        }

        write( styleName + ".setDefault({0});\n", style.isDefault(), false);

        writeCommonStyle(style, styleName);

        stylesMap.put(style.getName(), styleName);
        flush();
    }
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public JRStyle getBaseStyle(JRPen pen)
{
    if (pen != null)
    {
        JRPenContainer penContainer = pen.getPenContainer();

        if (penContainer instanceof JRStyle)
        {
            return getBaseStyle((JRStyle)penContainer);
        }

        if (penContainer instanceof JRLineBox)
        {
            return getBaseStyle((JRLineBox)penContainer);
        }

        return getBaseStyle(penContainer);
    }
    return null;
}
项目:jasperreports    文件:JRBaseFiller.java   
protected List<JRStyle> collectStyles() throws JRException
{
    List<JRStyle> styleList = collectTemplateStyles();

    JRStyle[] reportStyles = jasperReport.getStyles();
    if (reportStyles != null)
    {
        styles = new JRStyle[reportStyles.length];//FIXME remove this

        for (int i = 0; i < reportStyles.length; i++)
        {
            JRStyle style = reportStyles[i];
            styleList.add(style);

            //add dummy style requester so that report styles are always included
            //in the final list
            factory.registerDelayedStyleSetter(DUMMY_STYLE_SETTER, style.getName());
        }
    }

    return styleList;
}
项目:jasperreports    文件:BarcodeFillComponent.java   
protected JRTemplateImage getTemplateImage()
{
    JRStyle elementStyle = fillContext.getElementStyle();
    JRTemplateImage templateImage = printTemplates.get(elementStyle);
    if (templateImage == null)
    {
        templateImage = new JRTemplateImage(
                fillContext.getElementOrigin(), 
                fillContext.getDefaultStyleProvider());
        templateImage.setElement(fillContext.getComponentElement());
        templateImage.setStyle(elementStyle);//already set by setElement, but keeping for safety
        templateImage.setScaleImage(ScaleImageEnum.RETAIN_SHAPE);
        templateImage.setUsingCache(false);

        templateImage = deduplicate(templateImage);
        printTemplates.put(elementStyle, templateImage);
    }
    return templateImage;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Color getForecolor(JRCommonElement element)
{
    Color ownForecolor = element.getOwnForecolor();
    if (ownForecolor != null) 
    {
        return ownForecolor;
    }
    JRStyle style = getBaseStyle(element);
    if (style != null)
    {
        Color forecolor = style.getForecolor();
        if (forecolor != null)
        {
            return forecolor;
        }
    }
    return Color.black;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public String getPdfFontName(JRFont font)
{
    String ownPdfFontName = font.getOwnPdfFontName();
    if (ownPdfFontName != null)
    {
        return ownPdfFontName;
    }
    JRStyle baseStyle = getBaseStyle(font);
    if (baseStyle != null)
    {
        String pdfFontName = baseStyle.getPdfFontName();
        if (pdfFontName != null)
        {
            return pdfFontName;
        }
    }
    return propertiesUtil.getProperty(JRFont.DEFAULT_PDF_FONT_NAME);
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Float getLineWidth(JRPen pen, Float defaultLineWidth)
{
    Float ownLineWidth = pen.getOwnLineWidth();
    if (ownLineWidth != null)
    {
        return ownLineWidth;
    }
    JRStyle baseStyle = getBaseStyle(pen);
    if (baseStyle != null)
    {
        Float lineWidth = baseStyle.getLinePen().getLineWidth();
        if (lineWidth != null)
        {
            return lineWidth;
        }
    }
    return defaultLineWidth;
}
项目:jasperreports    文件:PartReportFiller.java   
@Override
public void addStyles(Collection<JRStyle> stylesList)
{
    for (JRStyle style : stylesList)
    {
        try
        {
            jasperPrint.addStyle(style, true);
        }
        catch (JRException e)
        {
            // should not happen
            throw new JRRuntimeException(e);
        }
    }
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public boolean isBold(JRFont font)
{
    Boolean ownBold = font.isOwnBold();
    if (ownBold != null)
    {
        return ownBold.booleanValue();
    }
    JRStyle baseStyle = getBaseStyle(font);
    if (baseStyle != null)
    {
        Boolean bold = baseStyle.isBold();
        if (bold != null)
        {
            return bold.booleanValue();
        }
    }
    return false;
}
项目:jasperreports    文件:JRFillElement.java   
protected void collectStyleDelayedEvaluations()
{
    JRStyle elementStyle = initStyle;
    if (elementStyle == null)
    {
        elementStyle = filler.getDefaultStyle();
    }

    if (elementStyle != null)
    {
        JRStyle style = elementStyle;
        while (style != null)
        {
            collectDelayedEvaluations(style);

            // proceed to the parent style
            style = style.getStyle();
        }
    }
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Color getLineColor(JRBoxPen boxPen, Color defaultColor)
{
    //FIXMENOW line color is resolved to base style forecolor before current pen container forecolor; 
    // for example, rectangle with blue forecolor would have border drawn in red, if it uses style with red forecolor
    Color ownLineColor = boxPen.getOwnLineColor();
    if (ownLineColor != null)
    {
        return ownLineColor;
    }
    Color penLineColor = boxPen.getBox().getPen().getOwnLineColor();
    if (penLineColor != null)
    {
        return penLineColor;
    }
    JRStyle baseStyle = getBaseStyle(boxPen);
    if (baseStyle != null)
    {
        Color lineColor = boxPen.getPen(baseStyle.getLineBox()).getLineColor();
        if (lineColor != null)
        {
            return lineColor;
        }
    }
    return defaultColor;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public int getRadius(JRCommonRectangle rectangle)
{
    Integer ownRadius = rectangle.getOwnRadius();
    if (ownRadius != null)
    {
        return ownRadius.intValue();
    }
    JRStyle baseStyle = getBaseStyle(rectangle);
    if (baseStyle != null)
    {
        Integer radius = baseStyle.getRadius();
        if (radius != null)
        {
            return radius.intValue();
        }
    }
    return 0;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public String getFontName(JRFont font)
{
    String ownFontName = font.getOwnFontName();
    if (ownFontName != null)
    {
        return ownFontName;
    }
    JRStyle baseStyle = getBaseStyle(font);
    if (baseStyle != null)
    {
        String fontName = baseStyle.getFontName();
        if (fontName != null)
        {
            return fontName;
        }
    }
    return propertiesUtil.getProperty(JRFont.DEFAULT_FONT_NAME);
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public ScaleImageEnum getScaleImageValue(JRCommonImage image)
{
    ScaleImageEnum ownScaleImage = image.getOwnScaleImageValue();
    if (ownScaleImage != null)
    {
        return ownScaleImage;
    }
    JRStyle baseStyle = getBaseStyle(image);
    if (baseStyle != null)
    {
        ScaleImageEnum scaleImage = baseStyle.getScaleImageValue();
        if (scaleImage != null)
        {
            return scaleImage;
        }
    }
    return ScaleImageEnum.RETAIN_SHAPE;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public HorizontalTextAlignEnum getHorizontalTextAlign(JRTextAlignment alignment)
{
    HorizontalTextAlignEnum ownHorizontalAlignment = alignment.getOwnHorizontalTextAlign();
    if (ownHorizontalAlignment != null)
    {
        return ownHorizontalAlignment;
    }
    JRStyle baseStyle = getBaseStyle(alignment);
    if (baseStyle != null)
    {
        HorizontalTextAlignEnum horizontalAlignment = baseStyle.getHorizontalTextAlign();
        if (horizontalAlignment != null)
        {
            return horizontalAlignment;
        }
    }
    return HorizontalTextAlignEnum.LEFT;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public HorizontalImageAlignEnum getHorizontalImageAlign(JRImageAlignment alignment)
{
    HorizontalImageAlignEnum ownHorizontalAlignment = alignment.getOwnHorizontalImageAlign();
    if (ownHorizontalAlignment != null)
    {
        return ownHorizontalAlignment;
    }
    JRStyle baseStyle = getBaseStyle(alignment);
    if (baseStyle != null)
    {
        HorizontalImageAlignEnum horizontalAlignment = baseStyle.getHorizontalImageAlign();
        if (horizontalAlignment != null)
        {
            return horizontalAlignment;
        }
    }
    return HorizontalImageAlignEnum.LEFT;
}