isStretchWithOverflow的iReport问题 [英] iReport issue with isStretchWithOverflow

查看:956
本文介绍了isStretchWithOverflow的iReport问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,当文本字段中的内容太长时,我使用属性 isStretchWithOverflow 来打破行。有用。但我想知道如何确定它打破线条的方式。



以下是我的 jrxml 文件的片段:

 < textField isStretchWithOverflow =true> 
< reportElement positionType =Floatwidth =150height =20/>
< box leftPadding =15>

< / box>
< textFieldExpression><![CDATA [$ F {content}]]>< / textFieldExpression>
< / textField>

对于像



$ b

哦,我的上帝测试=longstringabcdefg hijk

我想要长串 被视为一个词。所以我的想象输出是

 哦我的上帝测试= 
longstringabcdefg
hijk

但实际输出是

 哦,我的上帝测试=
longstringabcdefg
hijk

另一个问题是类似的



原始内容是

  abc .def / hij / k.lmnopqrstu 

我想要

  abc.def / 
hij / k。
lmnopqrstu

但实际产量是

  abc。 
def / hij / k。
lmnopqrstu

遇到/时它不会破坏线路



有什么方法可以做我想做的事吗?

解决方案

网。 sf.jasperreports.engine.fill.TextMeasurer实现(net.sf.jasperreports.engine.fill.JRMeasuredText接口)类使用由私有RuleBasedBreakIterator类实现的java.text.BreakIterator接口。 RuleBasedBreakIterator读取随JDK提供的文件,该文件定义要在其上执行换行符的字符。由于RuleBasedBreakIterator类是私有的,我没有找到一种简单的方法来更改默认行为。通过修改以下属性,可以使用替代实现替换net.sf.jasperreports.engine.fill.TextMeasurer:

  #Default text testr 
net.sf.jasperreports.text.measurer.factory = default
net.sf.jasperreports.text.measurer.factory.default = net.sf.jasperreports.engine.fill.TextMeasurerFactory

除非您可以使用自定义项在JDK中实现强大的分解逻辑,否则这在实践中可能是不可取的。 / p>

对某些人来说,另一种选择可能是使用不是ICU4J的IBM JDK,它提供了一个可自定义的RuleBasedBreakIterator实现,如下所述:



http://sujitpal.blogspot.com/2008 /05/tokenizing-text-with-icu4js.html


Currently I use the attribute isStretchWithOverflow to break the lines when the content in text field is too long. It works. But I want to know how can I determine the way it breaks lines.

Below is the snippet of my jrxml file:

<textField isStretchWithOverflow="true">
    <reportElement positionType="Float" width="150" height="20"/>
    <box leftPadding="15">

    </box>
    <textFieldExpression><![CDATA[$F{content}]]></textFieldExpression>
</textField>

For the content like

oh my god test="longstring" abcdefg hijk

I want "longstring" is regarded as a word. So my imagine output is

oh my god test=
"longstring" abcdefg
hijk

But the actual output is

oh my god test="
longstring" abcdefg
hijk

Another problem is similar

The original content is

abc.def/hij/k.lmnopqrstu

I want

abc.def/
hij/k.
lmnopqrstu

But the actual output is

abc.
def/hij/k.
lmnopqrstu

It does not break the line when it meet "/"

Is there any way I can do what I want?

解决方案

The net.sf.jasperreports.engine.fill.TextMeasurer implementation (of net.sf.jasperreports.engine.fill.JRMeasuredText interface) class uses the java.text.BreakIterator interface as implemented by the private RuleBasedBreakIterator class. The RuleBasedBreakIterator reads a file supplied with the JDK that defines the characters on which to perform line breaks on. Since the RuleBasedBreakIterator class is private I have not found an easy way to change the default behavior. Replacing net.sf.jasperreports.engine.fill.TextMeasurer with an alternate implementation is possible by modifying the following properties:

#Default text measurer
net.sf.jasperreports.text.measurer.factory=default
net.sf.jasperreports.text.measurer.factory.default=net.sf.jasperreports.engine.fill.TextMeasurerFactory 

This in practice may not be advisable unless you can implement the robust breaking logic in the JDK with your customizations.

An alternative for some may be to use IBM JDK that does not ICU4J that provides a customizable implementation of RuleBasedBreakIterator as decsribed here:

http://sujitpal.blogspot.com/2008/05/tokenizing-text-with-icu4js.html

这篇关于isStretchWithOverflow的iReport问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆