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

项目:jasperreports    文件:JRBasePrintText.java   
@Override
public JRStyledText getFullStyledText(JRStyledTextAttributeSelector attributeSelector)
{
    if (getFullText() == null)
    {
        return null;
    }

    return 
        JRStyledTextParser.getInstance().getStyledText(
            attributeSelector.getStyledTextAttributes(this), 
            getFullText(), 
            !JRCommonText.MARKUP_NONE.equals(getMarkup()),
            JRStyledTextAttributeSelector.getTextLocale(this)
            );
}
项目: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    文件:StyleResolver.java   
/**
 *
 */
public RotationEnum getRotationValue(JRCommonText element)
{
    RotationEnum ownRotation = element.getOwnRotationValue();
    if (ownRotation != null)
    {
        return ownRotation;
    }
    JRStyle style = getBaseStyle(element);
    if (style != null)
    {
        RotationEnum rotation = style.getRotationValue();
        if (rotation != null)
        {
            return rotation;
        }
    }
    return RotationEnum.NONE;
}
项目: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    文件:JdkGlyphFixTextMeasurer.java   
/**
 * Create a text measurer for a text element.
 * 
 * @param textElement the text element
 */
public JdkGlyphFixTextMeasurer(JasperReportsContext jasperReportsContext, JRCommonText textElement)
{
    super(jasperReportsContext, textElement);

    JRPropertiesUtil properties = JRPropertiesUtil.getInstance(jasperReportsContext);
    attempts = properties.getIntegerProperty(PROPERTY_ATTEMPTS, DEFAULT_ATTEMPTS);
    sleep = properties.getIntegerProperty(PROPERTY_ATTEMPT_SLEEP, DEFAULT_ATTEMPT_SLEEP);

    String emptyStackProp = properties.getProperty(PROPERTY_CATCH_EMPTY_STACKTRACE_EXCEPTION);
    if (emptyStackProp != null)
    {
        catchEmptyStacktrace = JRPropertiesUtil.asBoolean(emptyStackProp);
    }
    else
    {
        //use the old property
        catchEmptyStacktrace = properties.getBooleanProperty(PROPERTY_CATCH_EMPTY_STACKTRACE);
    }
}
项目:jasperreports    文件:JRFillTextElement.java   
/**
 *
 */
protected JRStyledText getStyledText()
{
    if (styledText == null)
    {
        String text = getRawText();
        if (text != null)
        {
            styledText = 
                filler.getStyledTextParser().getStyledText(
                    getStyledTextAttributes(), 
                    text, 
                    !JRCommonText.MARKUP_NONE.equals(getMarkup()),
                    filler.getLocale()
                    );
        }
        processedStyledText = null;
    }

    return styledText;
}
项目:jasperreports    文件:JRFillTextElement.java   
protected String processMarkupText(String text)
{
    text = JRStringUtil.replaceCRwithLF(text);

    if (text != null)
    {
        String markup = getMarkup();
        if (
            !JRCommonText.MARKUP_NONE.equals(markup)
            && !JRCommonText.MARKUP_STYLED_TEXT.equals(markup)
            )
        {
            text = getMarkupProcessor(markup).convert(text);
        }
    }

    return text;
}
项目:jasperreports    文件:JRTemplatePrintText.java   
@Override
public JRStyledText getFullStyledText(JRStyledTextAttributeSelector attributeSelector)
{
    if (getFullText() == null)
    {
        return null;
    }

    return 
        JRStyledTextParser.getInstance().getStyledText(
            attributeSelector.getStyledTextAttributes(this), 
            getFullText(), 
            !JRCommonText.MARKUP_NONE.equals(getMarkup()),
            JRStyledTextAttributeSelector.getTextLocale(this)
            );
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public String getMarkup(JRStyle style)
{
    String ownMarkup = style.getOwnMarkup();
    if (ownMarkup != null)
    {
        return ownMarkup;
    }
    JRStyle baseStyle = getBaseStyle(style);
    if (baseStyle != null)
    {
        return baseStyle.getMarkup();
    }
    return JRCommonText.MARKUP_NONE;
}
项目:jasperreports    文件:JRStyledTextUtil.java   
/**
 *
 */
public String getTruncatedText(JRPrintText printText)
{
    String truncatedText = null;
    String originalText = printText.getOriginalText();
    if (originalText != null)
    {
        if (printText.getTextTruncateIndex() == null)
        {
            truncatedText = originalText;
        }
        else
        {
            if (!JRCommonText.MARKUP_NONE.equals(printText.getMarkup()))
            {
                truncatedText = JRStyledTextParser.getInstance().write(
                        printText.getFullStyledText(allSelector), 
                        0, printText.getTextTruncateIndex().intValue());
            }
            else
            {
                truncatedText = originalText.substring(0, printText.getTextTruncateIndex().intValue());
            }
        }

        String textTruncateSuffix = printText.getTextTruncateSuffix();
        if (textTruncateSuffix != null)
        {
            truncatedText += textTruncateSuffix;
        }
    }
    return truncatedText;
}
项目:jasperreports    文件:JRStyledTextUtil.java   
protected JRStyledText getStyledText(JRPrintText printText, String text,
        JRStyledTextAttributeSelector attributeSelector, Locale locale)
{
    return JRStyledTextParser.getInstance().getStyledText(
        attributeSelector.getStyledTextAttributes(printText), 
        text, 
        !JRCommonText.MARKUP_NONE.equals(printText.getMarkup()),
        locale
        );
}
项目:jasperreports    文件:ComplexTextLineWrapper.java   
@Override
public void init(TextMeasureContext context)
{
    this.context = context;

    boolean isStyledText = !JRCommonText.MARKUP_NONE.equals(context.getElement().getMarkup());
    maxFontSizeFinder = MaxFontSizeFinder.getInstance(isStyledText);
}
项目:jasperreports    文件:TextMeasurer.java   
/**
 * 
 */
public TextMeasurer(JasperReportsContext jasperReportsContext, JRCommonText textElement)
{
    this.jasperReportsContext = jasperReportsContext;
    this.textElement = textElement;
    this.propertiesHolder = textElement instanceof JRPropertiesHolder ? (JRPropertiesHolder) textElement : null;//FIXMENOW all elements are now properties holders, so interfaces might be rearranged
    if (textElement.getDefaultStyleProvider() instanceof JRPropertiesHolder)
    {
        this.propertiesHolder = 
            new DelegatePropertiesHolder(
                propertiesHolder, 
                (JRPropertiesHolder)textElement.getDefaultStyleProvider()
                );
    }

    if (textElement instanceof DynamicPropertiesHolder)
    {
        this.dynamicPropertiesHolder = (DynamicPropertiesHolder) textElement;

        // we can check this from the beginning
        this.hasDynamicIgnoreMissingFontProp = this.dynamicPropertiesHolder.hasDynamicProperty(
                JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT);
        this.hasDynamicSaveLineBreakOffsetsProp = this.dynamicPropertiesHolder.hasDynamicProperty(
                JRTextElement.PROPERTY_SAVE_LINE_BREAKS);
    }

    // read static property values
    JRPropertiesUtil propertiesUtil = JRPropertiesUtil.getInstance(jasperReportsContext);
    defaultIgnoreMissingFont = propertiesUtil.getBooleanProperty(propertiesHolder, 
            JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false);
    defaultSaveLineBreakOffsets = propertiesUtil.getBooleanProperty(propertiesHolder, 
            JRTextElement.PROPERTY_SAVE_LINE_BREAKS, false);

    Context measureContext = new Context();
    simpleLineWrapper = new SimpleTextLineWrapper();
    simpleLineWrapper.init(measureContext);

    complextLineWrapper = new ComplexTextLineWrapper();
    complextLineWrapper.init(measureContext);
}
项目:ireport-fork    文件:MarkupProperty.java   
@Override
public List getTagList() 
{
    List tags = new java.util.ArrayList();
    tags.add(new Tag(JRCommonText.MARKUP_NONE, JRCommonText.MARKUP_NONE));
    tags.add(new Tag(JRCommonText.MARKUP_STYLED_TEXT, JRCommonText.MARKUP_STYLED_TEXT));
    tags.add(new Tag(JRCommonText.MARKUP_RTF, JRCommonText.MARKUP_RTF));
    tags.add(new Tag(JRCommonText.MARKUP_HTML, JRCommonText.MARKUP_HTML));
    return tags;
}
项目:ireport-fork    文件:MarkupProperty.java   
@Override
public List getTagList() 
{
    List tags = new java.util.ArrayList();
    tags.add(new Tag(JRCommonText.MARKUP_NONE, JRCommonText.MARKUP_NONE));
    tags.add(new Tag(JRCommonText.MARKUP_STYLED_TEXT, JRCommonText.MARKUP_STYLED_TEXT));
    tags.add(new Tag(JRCommonText.MARKUP_RTF, JRCommonText.MARKUP_RTF));
    tags.add(new Tag(JRCommonText.MARKUP_HTML, JRCommonText.MARKUP_HTML));
    return tags;
}
项目:TechnologyReadinessTool    文件:ReportExportPdf.java   
public void adjustTextMarkup(JasperReport jr) {
    JRSection detailSection = jr.getDetailSection();
    for (JRBand band : detailSection.getBands()) {
        if (band.getElements().length > 0) {
            JRBaseTextField text = (JRBaseTextField) band.getElements()[0];
            text.setBold(true);
            for (JRElement element : band.getElements()) {
                JRBaseTextField column = (JRBaseTextField) element;
                column.setMarkup(JRCommonText.MARKUP_HTML);
            }
        }
    }
}
项目:jasperreports    文件:JRBaseTextElement.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment);
        verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment);
        rotationValue = RotationEnum.getByValue(rotation);
        lineSpacingValue = LineSpacingEnum.getByValue(lineSpacing);

        horizontalAlignment = null;
        verticalAlignment = null;
        rotation = null;
        lineSpacing = null;
    }

    if (isStyledText != null)
    {
        markup = isStyledText.booleanValue() ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE;
        isStyledText = null;
    }

    if (paragraph == null)
    {
        paragraph = new JRBaseParagraph(this);
        paragraph.setLineSpacing(lineSpacingValue);
        lineSpacingValue = null;
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_5_5_2)
    {
        fontsize = fontSize == null ? null : fontSize.floatValue();

        fontSize = null;
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2)
    {
        horizontalTextAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalTextAlignEnum(horizontalAlignmentValue);
        verticalTextAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalTextAlignEnum(verticalAlignmentValue);

        horizontalAlignmentValue = null;
        verticalAlignmentValue = null;
    }
}
项目:jasperreports    文件:JRBasePrintText.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment);
        verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment);
        rotationValue = RotationEnum.getByValue(rotation);
        runDirectionValue = RunDirectionEnum.getByValue(runDirection);
        lineSpacingValue = LineSpacingEnum.getByValue(lineSpacing);

        horizontalAlignment = null;
        verticalAlignment = null;
        rotation = null;
        lineSpacing = null;
    }

    if (isStyledText != null)
    {
        markup = isStyledText.booleanValue() ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE;
        isStyledText = null;
    }

    if (linkType == null)
    {
         linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType));
    }

    if (linkTarget == null)
    {
         linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget));
    }

    if (paragraph == null)
    {
        paragraph = new JRBaseParagraph(this);
        paragraph.setLineSpacing(lineSpacingValue);
        lineSpacingValue = null;
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_5_5_2)
    {
        fontsize = fontSize == null ? null : fontSize.floatValue();

        fontSize = null;
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2)
    {
        horizontalTextAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalTextAlignEnum(horizontalAlignmentValue);
        verticalTextAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalTextAlignEnum(verticalAlignmentValue);

        horizontalAlignmentValue = null;
        verticalAlignmentValue = null;
    }
}
项目:jasperreports    文件:JRBaseStyle.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        modeValue = ModeEnum.getByValue(mode);
        horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment);
        verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment);
        rotationValue = RotationEnum.getByValue(rotation);
        lineSpacingValue = LineSpacingEnum.getByValue(lineSpacing);
        scaleImageValue = ScaleImageEnum.getByValue(scaleImage);
        fillValue = FillEnum.getByValue(fill);

        mode = null;
        horizontalAlignment = null;
        verticalAlignment = null;
        rotation = null;
        lineSpacing = null;
        scaleImage = null;
        fill = null;
    }

    if (isStyledText != null)
    {
        markup = isStyledText.booleanValue() ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE;
        isStyledText = null;
    }

    if (paragraph == null)
    {
        paragraph = new JRBaseParagraph(this);
        paragraph.setLineSpacing(lineSpacingValue);
        lineSpacingValue = null;
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_5_5_2)
    {
        fontsize = fontSize == null ? null : fontSize.floatValue();

        fontSize = null;
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2)
    {
        horizontalTextAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalTextAlignEnum(horizontalAlignmentValue);
        verticalTextAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalTextAlignEnum(verticalAlignmentValue);

        horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue);
        verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue);

        horizontalAlignmentValue = null;
        verticalAlignmentValue = null;
    }
}
项目:jasperreports    文件:JRTextElementFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignTextElement textElement = (JRDesignTextElement)digester.peek();

    HorizontalTextAlignEnum horizontalTextAlign = HorizontalTextAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_textAlignment));
    if (horizontalTextAlign != null)
    {
        textElement.setHorizontalTextAlign(horizontalTextAlign);
    }

    VerticalTextAlignEnum verticalTextAlign = VerticalTextAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_verticalAlignment));
    if (verticalTextAlign != null)
    {
        textElement.setVerticalTextAlign(verticalTextAlign);
    }

    RotationEnum rotation = RotationEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_rotation));
    if (rotation != null)
    {
        textElement.setRotation(rotation);
    }

    LineSpacingEnum lineSpacing = LineSpacingEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_lineSpacing));
    if (lineSpacing != null)
    {
        if (log.isWarnEnabled())
        {
            log.warn("The 'lineSpacing' attribute is deprecated. Use the <paragraph> tag instead.");
        }
        textElement.getParagraph().setLineSpacing(lineSpacing);
    }

    textElement.setMarkup(atts.getValue(JRXmlConstants.ATTRIBUTE_markup));

    String isStyledText = atts.getValue(JRXmlConstants.ATTRIBUTE_isStyledText);
    if (isStyledText != null && isStyledText.length() > 0)
    {
        if (log.isWarnEnabled())
        {
            log.warn("The 'isStyledText' attribute is deprecated. Use the 'markup' attribute instead.");
        }

        textElement.setMarkup(Boolean.valueOf(isStyledText) ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE);
    }

    return textElement;
}
项目:jasperreports    文件:JRStyleResolver.java   
/**
 *
 */
public static RotationEnum getRotationValue(JRCommonText element)
{
    return styleResolver.getRotationValue(element);
}
项目:jasperreports    文件:JRStyleResolver.java   
/**
 * @deprecated Replaced by {@link #getLineSpacing(JRParagraph)}.
 */
public static LineSpacingEnum getLineSpacingValue(JRCommonText element)
{
    return getLineSpacing(element.getParagraph());
}
项目:jasperreports    文件:JRStyleResolver.java   
/**
 *
 */
public static String getMarkup(JRCommonText element)
{
    return styleResolver.getMarkup(element);
}
项目:jasperreports    文件:AbstractTextMeasurerFactory.java   
/**
 * @deprecated Replaced by {@link #createMeasurer(JasperReportsContext, JRCommonText)}.
 */
@Override
public final JRTextMeasurer createMeasurer(JRCommonText text)
{
    return createMeasurer(DefaultJasperReportsContext.getInstance(), text);
}
项目:jasperreports    文件:JdkGlyphFixTextMeasurerFactory.java   
/**
 * Creates a {@link JdkGlyphFixTextMeasurer} instance.
 */
@Override
public JRTextMeasurer createMeasurer(JasperReportsContext jasperReportsContext, JRCommonText text)
{
    return new JdkGlyphFixTextMeasurer(jasperReportsContext, text);
}
项目:jasperreports    文件:JRTextMeasurerUtil.java   
/**
 * 
 */
public void measureTextElement(JRPrintText printText)
{
    String text = styledTextUtil.getTruncatedText(printText);

    JRTextMeasurer textMeasurer = createTextMeasurer(printText);//FIXME use element properties?

    if (text == null)
    {
        text = "";
    }
    Locale textLocale = JRStyledTextAttributeSelector.getTextLocale(printText);
    JRStyledText styledText = 
        JRStyledTextParser.getInstance().getStyledText(
            noBackcolorSelector.getStyledTextAttributes(printText), 
            text, 
            JRCommonText.MARKUP_STYLED_TEXT.equals(printText.getMarkup()),//FIXMEMARKUP only static styled text appears on preview. no other markup
            textLocale
            );

    JRStyledText processedStyledText = styledTextUtil.resolveFonts(styledText, textLocale);
    JRMeasuredText measuredText = textMeasurer.measure(
            processedStyledText, 
            0,
            0,
            false
            );
    printText.setTextHeight(measuredText.getTextHeight() < printText.getHeight() ? measuredText.getTextHeight() : printText.getHeight());
    printText.setLeadingOffset(measuredText.getLeadingOffset());
    printText.setLineSpacingFactor(measuredText.getLineSpacingFactor());

    int textEnd = measuredText.getTextOffset();
    String printedText;
    if (JRCommonText.MARKUP_STYLED_TEXT.equals(printText.getMarkup()))
    {
        printedText = JRStyledTextParser.getInstance().write(styledText, 0, textEnd);
    }
    else
    {
        printedText = text.substring(0, textEnd);
    }
    printText.setText(printedText);
}
项目:jasperreports    文件:JRTextMeasurerUtil.java   
@Override
public JRTextMeasurer createMeasurer(JRCommonText text) {
    return factory.createMeasurer(text);
}
项目:jasperreports    文件:JRTextMeasurerUtil.java   
@Override
public JRTextMeasurer createMeasurer(
        JasperReportsContext jasperReportsContext, JRCommonText text) {
    return factory.createMeasurer(text);
}
项目:jasperreports    文件:JRFillTextElement.java   
protected void setPrintText(JRPrintText printText)
{
    int startIndex = getTextStart();
    int endIndex = getTextEnd();
    JRStyledText fullStyledText = getStyledText();
    String fullText = fullStyledText.getText();

    boolean keepAllText = !canOverflow() && keepFullText();
    if (keepAllText)
    {
        //assert getTextStart() == 0
        if (startIndex != 0)
        {
            throw 
            new JRRuntimeException(
                EXCEPTION_MESSAGE_KEY_INVALID_START_INDEX,  
                (Object[])null 
                );
        }

        if (!JRCommonText.MARKUP_NONE.equals(getMarkup()))
        {
            //rewrite as styled text
            String styledText = filler.getStyledTextParser().write(
                    fullStyledText);
            setPrintText(printText, styledText);
        }
        else
        {
            setPrintText(printText, fullText);
        }

        if (endIndex < fullText.length())
        {
            printText.setTextTruncateIndex(Integer.valueOf(endIndex));
        }
    }
    else
    {
        String printedText;
        if (!JRCommonText.MARKUP_NONE.equals(getMarkup()))
        {
            printedText = filler.getStyledTextParser().write(
                    fullStyledText, 
                    startIndex, endIndex);
        }
        else
        {
            // relying on substring to return the same String object when whole substring
            printedText = fullText.substring(startIndex, endIndex);
        }

        setPrintText(printText, printedText);
    }

    printText.setTextTruncateSuffix(getTextTruncateSuffix());
    printText.setLineBreakOffsets(getLineBreakOffsets());
}
项目:jasperreports    文件:TextMeasurerFactory.java   
/**
 * Returns a {@link TextMeasurer} instance for the text object.
 */
@Override
public JRTextMeasurer createMeasurer(JasperReportsContext jasperReportsContext, JRCommonText text)
{
    return new TextMeasurer(jasperReportsContext, text);
}
项目:jasperreports    文件:TextMeasurer.java   
@Override
public JRCommonText getElement()
{
    return textElement;
}
项目:PDFReporter-Studio    文件:DefaultValuesMap.java   
/**
 * Create the default property map for a wide range of object
 * @param type the type of the element for which the properties are requested
 * @return the default properties of the requested element
 */
@SuppressWarnings("deprecation")
private static HashMap<String, Object> initializeType(Object type){
    HashMap<String, Object> result = new HashMap<String, Object>();
    result.put(JRDesignStyle.PROPERTY_FONT_NAME, JRProperties.getProperty(JRFont.DEFAULT_FONT_NAME));
    result.put(JRBaseLineBox.PROPERTY_PADDING, INTEGER_ZERO);
    result.put(JRBaseLineBox.PROPERTY_TOP_PADDING, INTEGER_ZERO);
    result.put(JRBaseLineBox.PROPERTY_RIGHT_PADDING, INTEGER_ZERO);
    result.put(JRDesignStyle.PROPERTY_PDF_FONT_NAME, JRProperties.getProperty(JRFont.DEFAULT_PDF_FONT_NAME));
    result.put(JRDesignStyle.PROPERTY_PDF_ENCODING,JRProperties.getProperty(JRFont.DEFAULT_PDF_ENCODING));
    result.put(JRDesignStyle.PROPERTY_PATTERN, null);
    result.put(JRDesignStyle.PROPERTY_MARKUP,JRCommonText.MARKUP_NONE);
    result.put(JRBasePen.PROPERTY_LINE_STYLE, LineStyleEnum.SOLID);

    if (type instanceof JRStyle){

        result.put(JRDesignStyle.PROPERTY_FONT_SIZE, null);
        result.put(JRDesignStyle.PROPERTY_BOLD, null);
        result.put(JRDesignStyle.PROPERTY_ITALIC, null);
        result.put(JRDesignStyle.PROPERTY_UNDERLINE, null);
        result.put(JRDesignStyle.PROPERTY_STRIKE_THROUGH, null);
        result.put(JRDesignStyle.PROPERTY_PDF_EMBEDDED,null);
        result.put(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL,null);
        result.put(JRDesignStyle.PROPERTY_VERTICAL_ALIGNMENT,null);
        result.put(JRDesignStyle.PROPERTY_HORIZONTAL_ALIGNMENT,null);
        result.put(JRDesignStyle.PROPERTY_SCALE_IMAGE,null);
        result.put(JRDesignStyle.PROPERTY_ROTATION,null);
        result.put(JRDesignStyle.PROPERTY_RADIUS,null);
        result.put(JRBasePen.PROPERTY_LINE_WIDTH, null);
        result.put(JRBasePen.PROPERTY_LINE_COLOR, null);
        result.put(JRDesignStyle.PROPERTY_BACKCOLOR, null);
        result.put(JRDesignStyle.PROPERTY_FORECOLOR, null);
        result.put(JRDesignStyle.PROPERTY_FILL, null);
        result.put(JRDesignStyle.PROPERTY_MODE, null);
    } else {
        result.put(JRDesignStyle.PROPERTY_FONT_SIZE, JRProperties.getIntegerProperty(JRFont.DEFAULT_FONT_SIZE));
        result.put(JRDesignStyle.PROPERTY_BOLD, false);
        result.put(JRDesignStyle.PROPERTY_ITALIC, false);
        result.put(JRDesignStyle.PROPERTY_UNDERLINE, false);
        result.put(JRDesignStyle.PROPERTY_STRIKE_THROUGH, false);
        result.put(JRDesignStyle.PROPERTY_PDF_EMBEDDED,JRProperties.getBooleanProperty(JRFont.DEFAULT_PDF_EMBEDDED));
        result.put(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL,false);
        result.put(JRDesignStyle.PROPERTY_VERTICAL_ALIGNMENT,VerticalAlignEnum.TOP);
        result.put(JRDesignStyle.PROPERTY_HORIZONTAL_ALIGNMENT,HorizontalAlignEnum.LEFT);
        result.put(JRDesignStyle.PROPERTY_SCALE_IMAGE,ScaleImageEnum.RETAIN_SHAPE);
        result.put(JRDesignStyle.PROPERTY_ROTATION,RotationEnum.NONE);
        result.put(JRDesignStyle.PROPERTY_RADIUS,INTEGER_ZERO);
        result.put(JRBasePen.PROPERTY_LINE_WIDTH,JRPen.LINE_WIDTH_0);
        result.put(JRBasePen.PROPERTY_LINE_COLOR, Color.black);
        result.put(MGraphicElementLinePen.LINE_PEN, createBaseLinePen(type));
        result.put(MGraphicElementLineBox.LINE_BOX, createBaseLineBox(type));
        result.put(JRDesignStyle.PROPERTY_BACKCOLOR, Color.white);
        result.put(JRDesignStyle.PROPERTY_FORECOLOR, Color.black);
        result.put(JRDesignStyle.PROPERTY_FILL, FillEnum.SOLID);
        ModeEnum opaqueValue = ModeEnum.getByValue(ModeEnum.OPAQUE.getValue());
        ModeEnum transparentValue = ModeEnum.getByValue(ModeEnum.TRANSPARENT.getValue());
        if (type instanceof JRDesignTextElement){
            result.put(JRDesignStyle.PROPERTY_MODE, transparentValue);
        } else if (type instanceof JRTemplateElement){
            result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue);
        } else if (type instanceof JRBaseElement) {
            result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue);
        } else if (type instanceof JRBasePrintElement) {
            result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue);
        } else if (type instanceof JRFillElement){
            result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue);
        } else {
            result.put(JRDesignStyle.PROPERTY_MODE, transparentValue);
        }
    }
    return result;
}
项目:ireport-fork    文件:DefaultTableCellElementsLayout.java   
public void animatorFinished(AnimatorEvent arg0) {
    animations--;
    if (animations == 0)
    {
        for (Iterator iter = getNewSizes().keySet().iterator(); iter.hasNext(); )
        {
            JRDesignElement element = (JRDesignElement)iter.next();
            Rectangle rectangle = getNewSizes().get(element);
            element.setX( rectangle.x);
            element.setY( rectangle.y);
            element.setWidth( rectangle.width);
            element.setHeight( rectangle.height);

            // Calculate the best font height...
            if (element instanceof JRDesignTextElement)
            {
                JRStyledTextParser styledTextParser = JRStyledTextParser.getInstance();
                JRDesignTextElement dte = (JRDesignTextElement)element;
                dte.setFontSize(null);
                for (int i=dte.getFontSize()-1; i>1 ; --i)
                {
                        String text = "test";

                        // Convert the element in a print element...
                        Map attributes = JRFontUtil.getAttributes(new HashMap(), dte, Locale.getDefault());

                        JRStyledText styledText =
                            styledTextParser.getStyledText(
                            attributes,
                            text,
                            JRCommonText.MARKUP_STYLED_TEXT.equals(dte.getMarkup()),//FIXMEMARKUP only static styled text appears on preview. no other markup
                            Locale.getDefault()
                            );


                        JRTextMeasurer measurer = JRTextMeasurerUtil.getInstance(DefaultJasperReportsContext.getInstance()).createTextMeasurer(dte);
                        JRMeasuredText measuredText = measurer.measure(  styledText, 0, dte.getHeight(), true);

                        if  (measuredText.getTextHeight() > dte.getHeight())
                        {
                            if (i>1)
                            {
                                dte.setFontSize(i);
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                }
            }
        }
    }
}
项目:ireport-fork    文件:DefaultCellElementsLayout.java   
public void animatorFinished(AnimatorEvent arg0) {
        animations--;
        if (animations == 0)
        {
            for (Iterator iter = getNewSizes().keySet().iterator(); iter.hasNext(); )
            {
                JRDesignElement element = (JRDesignElement)iter.next();
                Rectangle rectangle = getNewSizes().get(element);
                element.setX( rectangle.x);
                element.setY( rectangle.y);
                element.setWidth( rectangle.width);
                element.setHeight( rectangle.height);

                // Calculate the best font height...
                if (element instanceof JRDesignTextElement)
                {
                    JRStyledTextParser styledTextParser = JRStyledTextParser.getInstance();
                    JRDesignTextElement dte = (JRDesignTextElement)element;
                    dte.setFontSize(null);
                    for (int i=dte.getFontSize()-1; i>1 ; --i)
                    {
                            String text = "test";

                            // Convert the element in a print element...
                            Map<Attribute, Object> attributes = JRFontUtil.getAttributes(new HashMap(), dte, Locale.getDefault());

                            JRStyledText styledText = 
                                styledTextParser.getStyledText(
                                attributes, 
                                text, 
                                JRCommonText.MARKUP_STYLED_TEXT.equals(dte.getMarkup()),//FIXMEMARKUP only static styled text appears on preview. no other markup
                                Locale.getDefault()
);

                            JasperReportsContext context = IRLocalJasperReportsContext.getInstance();

                            JRTextMeasurerUtil measurerUtil = JRTextMeasurerUtil.getInstance(context);
                            JRTextMeasurer measurer = measurerUtil.createTextMeasurer(dte);
                            JRMeasuredText measuredText = measurer.measure(  styledText, 0, dte.getHeight(), true);

                            if  (measuredText.getTextHeight() > dte.getHeight())
                            {
                                if (i>1)
                                {
                                    dte.setFontSize(i);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                    }
                }
            }
        }
    }
项目:jasperreports    文件:JRTextMeasurerUtil.java   
/**
 * Creates a text measurer for a text object.
 * 
 * <p>
 * If the text object is an instance of {@link JRPropertiesHolder}, its properties
 * are used when determining the text measurer factory.
 * </p>
 * 
 * @param text the text object
 * @return a text measurer for the text object
 */
public JRTextMeasurer createTextMeasurer(JRCommonText text)
{
    JRPropertiesHolder propertiesHolder =
        text instanceof JRPropertiesHolder ? (JRPropertiesHolder) text : null;
    return createTextMeasurer(text, propertiesHolder);
}
项目:jasperreports    文件:JRTextMeasurerFactory.java   
/**
 * Creates a text measurer for a text object.
 * 
 * @param text the text object
 * @return a text measurer
 */
JRTextMeasurer createMeasurer(JasperReportsContext jasperReportsContext, JRCommonText text);
项目:jasperreports    文件:JRTextMeasurerUtil.java   
/**
 * Creates a text measurer for a text object.
 * 
 * @param text the text object
 * @param propertiesHolder the properties to use for determining the text measurer factory;
 * can be <code>null</code>
 * @return a text measurer for the text object
 */
public JRTextMeasurer createTextMeasurer(JRCommonText text, JRPropertiesHolder propertiesHolder)
{
    JRTextMeasurerFactory factory = getFactory(propertiesHolder);
    return factory.createMeasurer(jasperReportsContext, text);
}
项目:jasperreports    文件:JRTextMeasurerFactory.java   
/**
 * @deprecated Replaced by {@link net.sf.jasperreports.engine.util.JRTextMeasurerFactory#createMeasurer(JasperReportsContext, JRCommonText)}.
 */
JRTextMeasurer createMeasurer(JRCommonText text);
项目:jasperreports    文件:TextMeasureContext.java   
JRCommonText getElement();