當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。