当前位置: 首页>>代码示例>>Java>>正文


Java JRTextMeasurerUtil类代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.util.JRTextMeasurerUtil的典型用法代码示例。如果您正苦于以下问题:Java JRTextMeasurerUtil类的具体用法?Java JRTextMeasurerUtil怎么用?Java JRTextMeasurerUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JRTextMeasurerUtil类属于net.sf.jasperreports.engine.util包,在下文中一共展示了JRTextMeasurerUtil类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTextElementReplacement

import net.sf.jasperreports.engine.util.JRTextMeasurerUtil; //导入依赖的package包/类
public JRPrintText getTextElementReplacement(
	JRExporterContext exporterContext, 
	JRGenericPrintElement element
	)
{
	JRBasePrintText text = new JRBasePrintText(exporterContext.getExportedReport().getDefaultStyleProvider());
	text.setX(element.getX());
	text.setY(element.getY());
	text.setWidth(element.getWidth());
	text.setHeight(element.getHeight());
	text.setText("[Open Flash Chart Component]");
	text.setMode(ModeEnum.OPAQUE);
	text.setBackcolor(Color.lightGray);
	text.setHorizontalTextAlign(HorizontalTextAlignEnum.CENTER);
	text.setVerticalTextAlign(VerticalTextAlignEnum.MIDDLE);
	text.getLineBox().getPen().setLineWidth(1f);
	text.getLineBox().getPen().setLineColor(Color.black);
	text.getLineBox().getPen().setLineStyle(LineStyleEnum.DASHED);
	
	JRTextMeasurerUtil.getInstance(exporterContext.getJasperReportsContext()).measureTextElement(text);
	
	return text;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:24,代码来源:BaseChartHandler.java

示例2: convert

import net.sf.jasperreports.engine.util.JRTextMeasurerUtil; //导入依赖的package包/类
@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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:21,代码来源:TextFieldConverter.java

示例3: convert

import net.sf.jasperreports.engine.util.JRTextMeasurerUtil; //导入依赖的package包/类
@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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:15,代码来源:StaticTextConverter.java

示例4: createTextMeasurer

import net.sf.jasperreports.engine.util.JRTextMeasurerUtil; //导入依赖的package包/类
private void createTextMeasurer()
{
	textMeasurer = JRTextMeasurerUtil.getInstance(filler.getJasperReportsContext()).createTextMeasurer(this);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:5,代码来源:JRFillTextElement.java

示例5: animatorFinished

import net.sf.jasperreports.engine.util.JRTextMeasurerUtil; //导入依赖的package包/类
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;
                        }
                }
            }
        }
    }
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:59,代码来源:DefaultTableCellElementsLayout.java

示例6: animatorFinished

import net.sf.jasperreports.engine.util.JRTextMeasurerUtil; //导入依赖的package包/类
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;
                            }
                    }
                }
            }
        }
    }
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:61,代码来源:DefaultCellElementsLayout.java


注:本文中的net.sf.jasperreports.engine.util.JRTextMeasurerUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。