Java 类net.sf.jasperreports.engine.base.JRBasePrintText 实例源码

项目:jasperreports    文件:BaseChartHandler.java   
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;
}
项目: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    文件:TextElementConverter.java   
/**
 *
 */
protected void copyTextElement(ReportConverter reportConverter, JRTextElement textElement, JRBasePrintText printText)
{
    copyElement(reportConverter, textElement, printText);

    printText.copyBox(textElement.getLineBox());
    printText.copyParagraph(textElement.getParagraph());

    printText.setBold(textElement.isOwnBold());
    printText.setFontName(textElement.getOwnFontName());
    printText.setFontSize(textElement.getOwnFontsize());
    printText.setHorizontalTextAlign(textElement.getOwnHorizontalTextAlign());
    printText.setItalic(textElement.isOwnItalic());
    printText.setPdfEmbedded(textElement.isOwnPdfEmbedded());
    printText.setPdfEncoding(textElement.getOwnPdfEncoding());
    printText.setPdfFontName(textElement.getOwnPdfFontName());
    printText.setRotation(textElement.getOwnRotationValue());
    printText.setStrikeThrough(textElement.isOwnStrikeThrough());
    printText.setMarkup(textElement.getOwnMarkup());
    printText.setUnderline(textElement.isOwnUnderline());
    printText.setVerticalTextAlign(textElement.getOwnVerticalTextAlign());
}
项目:jasperreports    文件:JRPdfExporter.java   
protected void writePageAnchor(int pageIndex) throws DocumentException 
{
    Map<Attribute,Object> attributes = new HashMap<Attribute,Object>();
    fontUtil.getAttributesWithoutAwtFont(attributes, new JRBasePrintText(jasperPrint.getDefaultStyleProvider()));
    Font pdfFont = getFont(attributes, getLocale(), false);
    Chunk chunk = new Chunk(" ", pdfFont);

    chunk.setLocalDestination(JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1));

    tagHelper.startPageAnchor();

    ColumnText colText = new ColumnText(pdfContentByte);
    colText.setSimpleColumn(
        new Phrase(chunk),
        0,
        pageFormat.getPageHeight(),
        1,
        1,
        0,
        Element.ALIGN_LEFT
        );

    colText.go();

    tagHelper.endPageAnchor();
}
项目:jasperreports    文件:PptxRunHelper.java   
/**
 *
 */
private Map<Attribute,Object> getAttributes(JRStyle style)//FIXMEDOCX put this in util?
{
    JRPrintText text = new JRBasePrintText(null);
    text.setStyle(style);

    Map<Attribute,Object> styledTextAttributes = new HashMap<Attribute,Object>(); 
    //JRFontUtil.getAttributes(styledTextAttributes, text, (Locale)null);//FIXMEDOCX getLocale());
    fontUtil.getAttributesWithoutAwtFont(styledTextAttributes, text);
    styledTextAttributes.put(TextAttribute.FOREGROUND, text.getForecolor());
    if (text.getModeValue() == ModeEnum.OPAQUE)
    {
        styledTextAttributes.put(TextAttribute.BACKGROUND, text.getBackcolor());
    }

    return styledTextAttributes;
}
项目:jasperreports    文件:XlsxRunHelper.java   
/**
 *
 */
private Map<Attribute,Object> getAttributes(JRStyle style)//FIXMEDOCX put this in util?
{
    JRPrintText text = new JRBasePrintText(null);
    text.setStyle(style);

    Map<Attribute,Object> styledTextAttributes = new HashMap<Attribute,Object>(); 
    //JRFontUtil.getAttributes(styledTextAttributes, text, (Locale)null);//FIXMEDOCX getLocale());
    fontUtil.getAttributesWithoutAwtFont(styledTextAttributes, text);
    styledTextAttributes.put(TextAttribute.FOREGROUND, text.getForecolor());
    if (text.getModeValue() == ModeEnum.OPAQUE)
    {
        styledTextAttributes.put(TextAttribute.BACKGROUND, text.getBackcolor());
    }

    return styledTextAttributes;
}
项目:jasperreports    文件:DocxRunHelper.java   
/**
 *
 */
private Map<Attribute,Object> getAttributes(JRStyle style)//FIXMEDOCX put this in util?
{
    Map<Attribute,Object> styledTextAttributes = new HashMap<Attribute,Object>(); 

    if (style != null)
    {
        JRPrintText text = new JRBasePrintText(null);
        text.setStyle(style);

        //JRFontUtil.getAttributes(styledTextAttributes, text, (Locale)null);//FIXMEDOCX getLocale());
        fontUtil.getAttributesWithoutAwtFont(styledTextAttributes, text);
        styledTextAttributes.put(TextAttribute.FOREGROUND, text.getForecolor());
        if (text.getModeValue() == ModeEnum.OPAQUE)
        {
            styledTextAttributes.put(TextAttribute.BACKGROUND, text.getBackcolor());
        }
    }

    return styledTextAttributes;
}
项目:jasperreports    文件:TextElementTest.java   
@Test 
public void basePrintText()
{
    JRBasePrintText text = new JRBasePrintText(null);
    text.setUUID(UUID.randomUUID());
    text.setX(10);
    text.setY(20);
    text.setWidth(50);
    text.setHeight(30);
    text.setText("foo bar");
    text.setValue("foo bar");
    text.setLineSpacingFactor(1.2f);
    text.setLeadingOffset(2f);
    text.setTextHeight(20f);

    JRBasePrintText read = passThroughSerialization(text);
    compareXml(read, text);
}
项目:PDFReporter-Studio    文件:LineBoxRectangle.java   
/**
 * Request the painting of the border
 */
@Override
public void paint(Graphics graphics) {
    try {
        Graphics2D g = ComponentFigure.getG2D(graphics);
        if (g != null) {

            Rectangle b = getBounds();

            JRPrintElement pe = new JRBasePrintText(null);
            pe.setX(b.x + 10);
            pe.setY(b.y + 10);
            pe.setWidth(b.width - 20);
            pe.setHeight(b.height - 20);
            bd.drawBox(g, lineBox, pe);
        } else {
            graphics.drawRectangle(0, 0, 100, 100);
        }
    } catch (Exception e) {
        // when a font is missing exception is thrown by DrawVisitor
        // FIXME: maybe draw something, else?
        e.printStackTrace();
    }
}
项目:jasperreports    文件:StaticTextConverter.java   
@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;
}
项目:jasperreports    文件:DocxSettingsHelper.java   
/**
 * 
 */
public void export(JasperPrint jasperPrint)
{
    write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
    write("<w:settings\n");
    write(" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">\n"); 
    write("  <w:defaultTabStop w:val=\"" +
            LengthUtil.twip(new JRBasePrintText(jasperPrint.getDefaultStyleProvider()).getParagraph().getTabStopWidth()) +
            "\"/>\n");
    write("</w:settings>");
}
项目:PDFReporter-Studio    文件:LineBoxRectangle.java   
/**
 * Request the painting of the border
 */
@Override
public void paint(Graphics graphics) {
    try {
        Graphics2D g = ComponentFigure.getG2D(graphics);
        if (g != null) {

            Rectangle b = getBounds();

            JRPrintElement pe = new JRBasePrintText(null);
            pe.setX(b.x + 10);
            pe.setY(b.y + 10);
            pe.setWidth(b.width - 20);
            pe.setHeight(b.height - 20);
            if (section.getElement() instanceof ILineBox && section.getElement() != null)
                bd.drawBox(g, ((ILineBox) section.getElement()).getBoxContainer().getLineBox(), pe);
            else if (section.getElement() instanceof MStyle) {
                MStyle styleModel = (MStyle) section.getElement();
                bd.drawBox(g, ((JRStyle) styleModel.getValue()).getLineBox(), pe);
            }
        } else {
            graphics.drawRectangle(0, 0, 100, 100);
        }
    } catch (Exception e) {
        // when a font is missing exception is thrown by DrawVisitor
        // FIXME: maybe draw something, else?
        e.printStackTrace();
    }
}
项目:jasperreports    文件:StyleBuilder.java   
/**
 * 
 */
public void buildBeforeAutomaticStyles(JasperPrint jasperPrint)
{
    writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");

    writer.write("<office:document-styles");
    writer.write(" xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"");
    writer.write(" xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\"");
    writer.write(" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\"");
    writer.write(" xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\"");
    writer.write(" xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\"");
    writer.write(" xmlns:fo=\"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\"");
    writer.write(" xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
    writer.write(" xmlns:dc=\"http://purl.org/dc/elements/1.1/\"");
    writer.write(" xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\"");
    writer.write(" xmlns:number=\"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\"");
    writer.write(" xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\"");
    writer.write(" xmlns:chart=\"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\"");
    writer.write(" xmlns:dr3d=\"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\"");
    writer.write(" xmlns:math=\"http://www.w3.org/1998/Math/MathML\"");
    writer.write(" xmlns:form=\"urn:oasis:names:tc:opendocument:xmlns:form:1.0\"");
    writer.write(" xmlns:script=\"urn:oasis:names:tc:opendocument:xmlns:script:1.0\"");
    writer.write(" xmlns:ooo=\"http://openoffice.org/2004/office\"");
    writer.write(" xmlns:ooow=\"http://openoffice.org/2004/writer\"");
    writer.write(" xmlns:oooc=\"http://openoffice.org/2004/calc\"");
    writer.write(" xmlns:dom=\"http://www.w3.org/2001/xml-events\"");
    writer.write(" xmlns:xforms=\"http://www.w3.org/2002/xforms\"");
    writer.write(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"");
    writer.write(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    writer.write(" office:version=\"");     
    writer.write(ContentBuilder.VERSION);       
    writer.write("\">\n");      

    writer.write(" <office:styles>\n"); 
    writer.write("<draw:stroke-dash draw:name=\"Dashed\" draw:display-name=\"Dashed\" " +
        "draw:style=\"rect\" draw:dots1=\"1\" draw:dots1-length=\"0.05cm\" draw:dots2=\"1\" " +
        "draw:dots2-length=\"0.05cm\" draw:distance=\"0.05cm\"/>");
    writer.write(" <style:default-style style:family=\"paragraph\"><style:paragraph-properties style:tab-stop-distance=\"" +
            LengthUtil.inchFloor4Dec(new JRBasePrintText(jasperPrint.getDefaultStyleProvider()).getParagraph().getTabStopWidth()) +
            "in\"/></style:default-style>\n");  
    writer.write(" </office:styles>\n");    
    writer.write(" <office:automatic-styles>\n");   
}
项目:omr    文件:JazzOMRXMLHandler.java   
/**
 * Exporta bullet para alternativa de questao
 * @param exporterContext
 * @param element
 * @param eqaKey
 */
protected void exportAlternativeBullet(JRXmlExporterContext exporterContext, JRGenericPrintElement element, Object eqaKey ) {
    int x = element.getX() + exporterContext.getOffsetX();
    int y = element.getY() - exporterContext.getOffsetY();
    int x2 = x + element.getWidth();
    int y2 = element.getY() - exporterContext.getOffsetY() - element.getHeight();

    int w = x2 - x;
    int h = y - y2;

    JRXmlExporter xmlExporter = (JRXmlExporter) exporterContext.getExporter();
    JRDefaultStyleProvider defaultStyleProvider = element.getDefaultStyleProvider();

    if (log.isDebugEnabled()) {
        log.debug("id=" + eqaKey + " x=" + x + ",y=" + y + ",w=" + w + ",h=" + h + "");
    }

    JRBasePrintEllipse ellipse = new JRBasePrintEllipse(defaultStyleProvider);

    //darcio 25/06/2013 nao sera mais necessario marcar a p�gina por aqui
    //Object actualPage = element.getParameterValue("actualPage");
    //ellipse.setKey("" + eqaKey + "-" + actualPage);

    ellipse.setKey("" + eqaKey);
    ellipse.setX(x);
    ellipse.setY(y);
    ellipse.setHeight(h);
    ellipse.setWidth(w);
    JRPrintText text = new JRBasePrintText(defaultStyleProvider);

    text.setForecolor(Color.RED);
    text.setX(x + 20);
    text.setY(y + 3);
    text.setHeight(10);
    text.setWidth(200);
    text.setText(eqaKey + " x=" + x + " y=" + y);

    try {
        xmlExporter.exportElement(ellipse);
        xmlExporter.exportText(text);
    } catch (Exception e) {
        throw new RuntimeException("Erro ao tentar exportar elemento", e);
    }
}
项目:omr    文件:JazzOMRXMLHandler.java   
/**
 * Exporta bullet para alternativa de questao
 * @param exporterContext
 * @param element
 * @param eqaKey
 */
protected void exportAlternativeBullet(JRXmlExporterContext exporterContext, JRGenericPrintElement element, Object eqaKey ) {
    int x = element.getX() + exporterContext.getOffsetX();
    int y = element.getY() - exporterContext.getOffsetY();
    int x2 = x + element.getWidth();
    int y2 = element.getY() - exporterContext.getOffsetY() - element.getHeight();

    int w = x2 - x;
    int h = y - y2;

    JRXmlExporter xmlExporter = (JRXmlExporter) exporterContext.getExporter();
    JRDefaultStyleProvider defaultStyleProvider = element.getDefaultStyleProvider();

    if (log.isDebugEnabled()) {
        log.debug("id=" + eqaKey + " x=" + x + ",y=" + y + ",w=" + w + ",h=" + h + "");
    }

    JRBasePrintEllipse ellipse = new JRBasePrintEllipse(defaultStyleProvider);

    //darcio 25/06/2013 nao sera mais necessario marcar a p�gina por aqui
    //Object actualPage = element.getParameterValue("actualPage");
    //ellipse.setKey("" + eqaKey + "-" + actualPage);

    ellipse.setKey("" + eqaKey);
    ellipse.setX(x);
    ellipse.setY(y);
    ellipse.setHeight(h);
    ellipse.setWidth(w);
    JRPrintText text = new JRBasePrintText(defaultStyleProvider);

    text.setForecolor(Color.RED);
    text.setX(x + 20);
    text.setY(y + 3);
    text.setHeight(10);
    text.setWidth(200);
    text.setText(eqaKey + " x=" + x + " y=" + y);

    try {
        xmlExporter.exportElement(ellipse);
        xmlExporter.exportText(text);
    } catch (Exception e) {
        throw new RuntimeException("Erro ao tentar exportar elemento", e);
    }
}
项目:omr    文件:JazzOMRXMLHandler.java   
/**
 * Exporta bullet para alternativa de questao
 * @param exporterContext
 * @param element
 * @param eqaKey
 */
protected void exportAlternativeBullet(JRXmlExporterContext exporterContext, JRGenericPrintElement element, Object eqaKey ) {
    int x = element.getX() + exporterContext.getOffsetX();
    int y = element.getY() - exporterContext.getOffsetY();
    int x2 = x + element.getWidth();
    int y2 = element.getY() - exporterContext.getOffsetY() - element.getHeight();

    int w = x2 - x;
    int h = y - y2;

    JRXmlExporter xmlExporter = (JRXmlExporter) exporterContext.getExporter();
    JRDefaultStyleProvider defaultStyleProvider = element.getDefaultStyleProvider();

    if (log.isDebugEnabled()) {
        log.debug("id=" + eqaKey + " x=" + x + ",y=" + y + ",w=" + w + ",h=" + h + "");
    }

    JRBasePrintEllipse ellipse = new JRBasePrintEllipse(defaultStyleProvider);

    Object actualPage = element.getParameterValue("actualPage");

    ellipse.setKey("" + eqaKey + "-" + actualPage);
    ellipse.setX(x);
    ellipse.setY(y);
    ellipse.setHeight(h);
    ellipse.setWidth(w);
    JRPrintText text = new JRBasePrintText(defaultStyleProvider);

    text.setForecolor(Color.RED);
    text.setX(x + 20);
    text.setY(y + 3);
    text.setHeight(10);
    text.setWidth(200);
    text.setText(eqaKey + " x=" + x + " y=" + y);

    try {
        xmlExporter.exportElement(ellipse);
        xmlExporter.exportText(text);
    } catch (Exception e) {
        throw new RuntimeException("Erro ao tentar exportar elemento", e);
    }
}
项目:omr    文件:JazzOMRXMLHandler.java   
/**
 * Exporta bullet para alternativa de questao
 * @param exporterContext
 * @param element
 * @param eqaKey
 */
protected void exportAlternativeBullet(JRXmlExporterContext exporterContext, JRGenericPrintElement element, Object eqaKey ) {
    int x = element.getX() + exporterContext.getOffsetX();
    int y = element.getY() - exporterContext.getOffsetY();
    int x2 = x + element.getWidth();
    int y2 = element.getY() - exporterContext.getOffsetY() - element.getHeight();

    int w = x2 - x;
    int h = y - y2;

    JRXmlExporter xmlExporter = (JRXmlExporter) exporterContext.getExporter();
    JRDefaultStyleProvider defaultStyleProvider = element.getDefaultStyleProvider();

    if (log.isDebugEnabled()) {
        log.debug("id=" + eqaKey + " x=" + x + ",y=" + y + ",w=" + w + ",h=" + h + "");
    }

    JRBasePrintEllipse ellipse = new JRBasePrintEllipse(defaultStyleProvider);

    Object actualPage = element.getParameterValue("actualPage");

    ellipse.setKey("" + eqaKey + "-" + actualPage);
    ellipse.setX(x);
    ellipse.setY(y);
    ellipse.setHeight(h);
    ellipse.setWidth(w);
    JRPrintText text = new JRBasePrintText(defaultStyleProvider);

    text.setForecolor(Color.RED);
    text.setX(x + 20);
    text.setY(y + 3);
    text.setHeight(10);
    text.setWidth(200);
    text.setText(eqaKey + " x=" + x + " y=" + y);

    try {
        xmlExporter.exportElement(ellipse);
        xmlExporter.exportText(text);
    } catch (Exception e) {
        throw new RuntimeException("Erro ao tentar exportar elemento", e);
    }
}
项目:omr    文件:JazzOMRXMLHandler.java   
/**
 * Exporta bullet para alternativa de questao
 * @param exporterContext
 * @param element
 * @param eqaKey
 */
protected void exportAlternativeBullet(JRXmlExporterContext exporterContext, JRGenericPrintElement element, Object eqaKey ) {
    int x = element.getX() + exporterContext.getOffsetX();
    int y = element.getY() - exporterContext.getOffsetY();
    int x2 = x + element.getWidth();
    int y2 = element.getY() - exporterContext.getOffsetY() - element.getHeight();

    int w = x2 - x;
    int h = y - y2;

    JRXmlExporter xmlExporter = (JRXmlExporter) exporterContext.getExporter();
    JRDefaultStyleProvider defaultStyleProvider = element.getDefaultStyleProvider();

    if (log.isDebugEnabled()) {
        log.debug("id=" + eqaKey + " x=" + x + ",y=" + y + ",w=" + w + ",h=" + h + "");
    }

    JRBasePrintEllipse ellipse = new JRBasePrintEllipse(defaultStyleProvider);

    Object actualPage = element.getParameterValue("actualPage");

    ellipse.setKey("" + eqaKey + "-" + actualPage);
    ellipse.setX(x);
    ellipse.setY(y);
    ellipse.setHeight(h);
    ellipse.setWidth(w);
    JRPrintText text = new JRBasePrintText(defaultStyleProvider);

    text.setForecolor(Color.RED);
    text.setX(x + 20);
    text.setY(y + 3);
    text.setHeight(10);
    text.setWidth(200);
    text.setText(eqaKey + " x=" + x + " y=" + y);

    try {
        xmlExporter.exportElement(ellipse);
        xmlExporter.exportText(text);
    } catch (Exception e) {
        throw new RuntimeException("Erro ao tentar exportar elemento", e);
    }
}