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

项目:jasperreports    文件:JRBaseObjectFactory.java   
@Override
public void visitStaticText(JRStaticText staticText)
{
    JRBaseStaticText baseStaticText = null;

    if (staticText != null)
    {
        baseStaticText = (JRBaseStaticText)get(staticText);
        if (baseStaticText == null)
        {
            baseStaticText = new JRBaseStaticText(staticText, this);
        }
    }

    setVisitResult(baseStaticText);
}
项目:jasperreports    文件:JRFillObjectFactory.java   
@Override
public void visitStaticText(JRStaticText staticText)
{
    JRFillStaticText fillStaticText = null;

    if (staticText != null)
    {
        fillStaticText = (JRFillStaticText)get(staticText);
        if (fillStaticText == null)
        {
            fillStaticText = new JRFillStaticText(filler, staticText, this);
        }
    }

    setVisitResult(fillStaticText);
}
项目:jasperreports    文件:JRFillStaticText.java   
/**
 *
 */
protected JRFillStaticText(
        JRBaseFiller filler,
        JRStaticText staticText, 
        JRFillObjectFactory factory
        )
    {
        super(filler, staticText, factory);

        String text = processMarkupText(staticText.getText());
        if (text == null)
        {
            text = "";
        }
        setRawText(text);
    }
项目:jasperreports    文件:HeaderLabelUtil.java   
/**
 * 
 */
public static HeaderLabelBuiltinExpression alterHeaderLabel(JRDesignFrame frame, String suffix)
{
    HeaderLabelBuiltinExpression evaluator = null;

    JRElement[] elements = frame.getElements();
    JRElement element = (elements == null || elements.length == 0) ? null : elements[0];

    if (element instanceof JRStaticText)
    {
        JRElement elementProxy = getProxy((JRStaticText)element, suffix); 
        frame.getChildren().set(0, elementProxy);
    }
    else if (element instanceof JRTextField)
    {
        evaluator = new HeaderLabelBuiltinExpression(((JRTextField)element).getExpression(), suffix); 
    }


    return evaluator;
}
项目:jasperreports    文件:TableReport.java   
protected JRExpression getColumnHeaderLabelExpression(Cell header)
{
    List<JRChild> detailElements = header == null ? null : header.getChildren();
    // only consider cells with a single text fields
    if (detailElements == null || detailElements.size() != 1)
    {
        return null;
    }

    JRChild detailElement = detailElements.get(0);
    if (detailElement instanceof JRTextField)
    {
        return ((JRTextField) detailElement).getExpression();
    }

    if (detailElement instanceof JRStaticText)
    {
        return builtinEvaluatorFactory.createConstantExpression(((JRStaticText)detailElement).getText());
    }

    return null;
}
项目:jasperreports    文件:JRBaseStaticText.java   
/**
 * Initializes the element properties. 
 */
protected JRBaseStaticText(JRStaticText staticText, JRBaseObjectFactory factory)
{
    super(staticText, factory);

    text = staticText.getText();
}
项目: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    文件:ConvertVisitor.java   
@Override
public void visitStaticText(JRStaticText staticText)
{
    JRPrintElement printText = StaticTextConverter.getInstance().convert(reportConverter, staticText);
    addElement(parentFrame, printText);
    addContour(reportConverter, parentFrame, printText);
}
项目:jasperreports    文件:XmlWriterVisitor.java   
@Override
public void visitStaticText(JRStaticText staticText)
{
    try
    {
        xmlWriter.writeStaticText(staticText);
    }
    catch (IOException e)
    {
        throw new JRRuntimeException(e);
    }
}
项目:jasperreports    文件:JRXmlWriter.java   
/**
 *
 */
public void writeStaticText(JRStaticText staticText) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_staticText, getNamespace());

    writeReportElement(staticText);
    writeBox(staticText.getLineBox());
    writeTextElement(staticText);

    writer.writeCDATAElement(JRXmlConstants.ELEMENT_text, staticText.getText());

    writer.closeElement();
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 *
 */
public void writeStaticText( JRStaticText staticText, String staticTextName)
{
    if(staticText != null)
    {
        write( "JRDesignStaticText " + staticTextName + " = new JRDesignStaticText(jasperDesign);\n");
        writeReportElement( staticText, staticTextName);
        writeBox( staticText.getLineBox(), staticTextName + ".getLineBox()");
        writeTextElement( staticText, staticTextName);
        write( staticTextName + ".setText(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(staticText.getText()));
        flush();
    }
}
项目:jasperreports    文件:JRVerifier.java   
public void verifyElement(JRElement element)
{
    if (element instanceof JRStaticText)
    {
        verifyStaticText((JRStaticText)element);
    }
    else if (element instanceof JRTextField)
    {
        verifyTextField((JRTextField)element);
    }
    else if (element instanceof JRImage)
    {
        verifyImage((JRImage)element);
    }
    else if (element instanceof JRSubreport)
    {
        verifySubreport((JRSubreport)element);
    }
    else if (element instanceof JRCrosstab)
    {
        verifyCrosstab((JRDesignCrosstab) element);
    }
    else if (element instanceof JRChart)
    {
        verifyChart((JRChart) element);
    }
    else if (element instanceof JRFrame)
    {
        verifyFrame((JRFrame) element);
    }
    else if (element instanceof JRComponentElement)
    {
        verifyComponentElement((JRComponentElement) element);
    }
    else if (element instanceof JRGenericElement)
    {
        verifyGenericElement((JRGenericElement) element);
    }
}
项目:jasperreports    文件:JRFillCrosstab.java   
protected JRDesignComponentElement createIconLabelElement(SortOrderEnum order, JRFillTextElement textElement,
        BuiltinExpressionEvaluatorFactory builtinExpressions)
{
    JRTextElement parentElement = (JRTextElement) textElement.getParent();

    JRDesignComponentElement designIconLabelElement = 
        IconLabelComponentUtil.getInstance(filler.getJasperReportsContext()).createIconLabelComponentElement(parentElement, textElement);
    IconLabelComponent iconLabelComponent = (IconLabelComponent)designIconLabelElement.getComponent();

    JRDesignTextField labelTextField = (JRDesignTextField)iconLabelComponent.getLabelTextField();
    JRDesignTextField iconTextField = (JRDesignTextField)iconLabelComponent.getIconTextField();

    designIconLabelElement.setStyle(textElement.getInitStyle());
    labelTextField.setStyle(textElement.getInitStyle());
    iconTextField.setStyle(textElement.getInitStyle());

    if (textElement instanceof JRTextField) 
    {
        labelTextField.setExpression(((JRTextField) textElement).getExpression());
    }
    else if (textElement instanceof JRStaticText) 
    {
        String text = ((JRStaticText) textElement).getText();
        labelTextField.setExpression(builtinExpressions.createConstantExpression(text));
    }

    String iconText =
            order == SortOrderEnum.ASCENDING ? filler.getPropertiesUtil().getProperty(TableReport.PROPERTY_UP_ARROW_CHAR)
            : (order == SortOrderEnum.DESCENDING ? filler.getPropertiesUtil().getProperty(TableReport.PROPERTY_DOWN_ARROW_CHAR) : "");
    iconTextField.setExpression(builtinExpressions.createConstantExpression(" " + iconText)); 

    designIconLabelElement.getPropertiesMap().setProperty(
            MatcherExporterFilter.PROPERTY_MATCHER_EXPORT_FILTER_KEY, 
            TableReport.TABLE_HEADER_ICON_LABEL_MATCHER_EXPORT_KEY
            );

    return designIconLabelElement;
}
项目:jasperreports    文件:JRTemplateText.java   
/**
 *
 */
protected JRTemplateText(JROrigin origin, JRDefaultStyleProvider defaultStyleProvider, JRStaticText staticText)
{
    super(origin, defaultStyleProvider);

    setStaticText(staticText);
}
项目:jasperreports    文件:HeaderLabelUtil.java   
/**
 * 
 */
private static JRStaticText getProxy(final JRStaticText staticText, final String suffix)
{
    return 
        (JRStaticText)Proxy.newProxyInstance(
            HeaderLabelUtil.class.getClassLoader(), 
            new Class<?>[]{JRStaticText.class}, 
            new InvocationHandler() 
            {
                @Override
                public Object invoke(
                    Object proxy, 
                    Method method, 
                    Object[] args
                    ) throws Throwable 
                {
                    if ("getText".equals(method.getName()))
                    {
                        return 
                            staticText.getText() 
                            + suffix;
                    }
                    if ("visit".equals(method.getName()))
                    {
                        ((JRVisitor)args[0]).visitStaticText((JRStaticText)proxy);
                        return null;
                    }
                    return method.invoke(staticText, args);
                }
            }
        );
}
项目:jasperreports    文件:TableReport.java   
protected void addIconLabelComponent(Column column, JRDesignFrame frame, String suffix)
{
    List<JRChild> children = frame.getChildren();
    if (children.size() > 0)
    {
        JRBaseTextElement headerTextElement = (JRBaseTextElement)children.get(0);
        if (headerTextElement != null) 
        {
            JRComponentElement componentElement = 
                IconLabelComponentUtil.getInstance(fillContext.getFiller().getJasperReportsContext()).createIconLabelComponentElement(headerTextElement);
            IconLabelComponent iconLabelComponent = (IconLabelComponent)componentElement.getComponent();

            JRDesignTextField labelTextField = (JRDesignTextField)iconLabelComponent.getLabelTextField();
            if (headerTextElement instanceof JRTextField) 
            {
                labelTextField.setExpression(((JRTextField) headerTextElement).getExpression());
            }
            else if (headerTextElement instanceof JRStaticText) 
            {
                labelTextField.setExpression(builtinEvaluatorFactory.createConstantExpression(((JRStaticText)headerTextElement).getText()));
            }

            JRDesignTextField iconTextField = (JRDesignTextField)iconLabelComponent.getIconTextField();
            iconTextField.setExpression(builtinEvaluatorFactory.createConstantExpression(suffix));

            componentElement.getPropertiesMap().setProperty(MatcherExporterFilter.PROPERTY_MATCHER_EXPORT_FILTER_KEY, TABLE_HEADER_ICON_LABEL_MATCHER_EXPORT_KEY);

            JRBaseElement element = (JRBaseElement)frame.getChildren().get(0);
            element.getPropertiesMap().setProperty(MatcherExporterFilter.PROPERTY_MATCHER_EXPORT_FILTER_KEY, TABLE_HEADER_LABEL_MATCHER_EXPORT_KEY);

            //frame.getChildren().remove(0);
            frame.getChildren().add(componentElement);
        }
    }
}
项目:PDFReporter-Studio    文件:MStaticText.java   
@Override
public HashMap<String, Object> getStylesDescriptors() {
    HashMap<String, Object> result = super.getStylesDescriptors();
    if (getValue() == null)
        return result;
    JRStaticText element = (JRStaticText) getValue();
    result.put(JRDesignStyle.PROPERTY_FONT_NAME, element.getOwnFontName());
    result.put(JRDesignStyle.PROPERTY_HORIZONTAL_ALIGNMENT, element.getOwnHorizontalAlignmentValue());
    result.put(JRDesignStyle.PROPERTY_MARKUP, element.getOwnMarkup());
    result.put(JRDesignStyle.PROPERTY_VERTICAL_ALIGNMENT, element.getOwnVerticalAlignmentValue());
    return result;
}
项目:PDFReporter-Studio    文件:MStaticText.java   
@Override
public String getDisplayText() {
    if (getValue() != null) {
        return ((JRStaticText) getValue()).getText();
    }
    return getIconDescriptor().getTitle();
}
项目:PDFReporter-Studio    文件:StaticTextFigure.java   
@Override
protected void draw(JSSDrawVisitor drawVisitor, JRElement jrElement) {
    if (cachedGraphics == null || model.hasChangedProperty()){
        model.setChangedProperty(false);
        Graphics2D oldGraphics = drawVisitor.getGraphics2d();
        cachedGraphics = new StackGraphics2D(oldGraphics);
        drawVisitor.setGraphics2D(cachedGraphics);
        drawVisitor.visitStaticText((JRStaticText) jrElement);
        drawVisitor.setGraphics2D(oldGraphics);
    }
    cachedGraphics.setRealDrawer(drawVisitor.getGraphics2d());
    cachedGraphics.paintStack();
}
项目:ireport-fork    文件:ElementNameVisitor.java   
/**
 *
 */
public void visitStaticText(JRStaticText staticText)
{
    // Take just few characters...
    String s = staticText.getText();
    if (s.length() > 15)
    {
        s = s.substring(0,15) + "...";
    }
    name = staticText.getText();
}
项目:jasperreports    文件:JRDelegationVisitor.java   
@Override
public void visitStaticText(JRStaticText staticText)
{
    visitor.visitStaticText(staticText);
}
项目:jasperreports    文件:UniformElementVisitor.java   
@Override
public void visitStaticText(JRStaticText staticText)
{
    visitElement(staticText);
}
项目:jasperreports    文件:JRApiWriter.java   
@Override
public void visitStaticText(JRStaticText staticText)
{
    apiWriter.writeStaticText(staticText, name);
}
项目:jasperreports    文件:JRVisitorSupport.java   
@Override
public void visitStaticText(JRStaticText staticText)
{
    // NOOP
}
项目:jasperreports    文件:JRVerifier.java   
/**
 *
 */
private void verifyStaticText(JRStaticText staticText)
{
    verifyReportElement(staticText);
}
项目:jasperreports    文件:JRTemplateText.java   
/**
 *
 */
protected void setStaticText(JRStaticText staticText)
{
    setTextElement(staticText);
}
项目:ireport-fork    文件:ElementNodeVisitor.java   
/**
 *
 */
public void visitStaticText(JRStaticText staticText)
{
    node = new ElementNode(jasperDesign, (JRDesignStaticText)staticText,doLkp);
    node.setIconBaseWithExtension(ICON_STATIC_TEXT);
}
项目:ireport-fork    文件:HasExpressionVisitor.java   
/**
 *
 */
public void visitStaticText(JRStaticText staticText)
{
    collector.collect(staticText);
}
项目:ireport-fork    文件:NodeCellRenderer.java   
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

   label.setIcon(null);

   if (value instanceof Node)
   {
       Node node = (Node)value;
       String text = node.getDisplayName();

       if (node instanceof ElementNode)
       {
           text = "";
           JRDesignElement element = ((ElementNode)node).getElement();
           if (element instanceof JRBreak) text += "Break";
           if (element instanceof JRChart) text += "Chart";
           if (element instanceof JRCrosstab) text += "Crosstab";
           if (element instanceof JRElementGroup) text += "Element Group";
           if (element instanceof JREllipse) text += "Ellipse";
           if (element instanceof JRFrame) text += "Frame";
           if (element instanceof JRImage) text += "Image";
           if (element instanceof JRLine) text += "Line";
           if (element instanceof JRRectangle) text += "Rectangle";
           if (element instanceof JRStaticText) text += "Static Text";
           if (element instanceof JRSubreport) text += "Subreport";
           if (element instanceof JRTextField) text += "Text Field";

           JRElementGroup parent = ModelUtils.getTopElementGroup(element);
           if (parent != null && parent instanceof JRDesignBand) text += " in band " + ModelUtils.nameOf(((JRDesignBand)parent).getOrigin());
           else if (parent != null && parent instanceof JRDesignCellContents) text += " in cell " + ModelUtils.nameOf(((JRDesignCellContents)parent).getOrigin());

           text += " " + node.getDisplayName();
       }

       label.setText(text);
       label.setIcon( new ImageIcon(node.getIcon(BeanInfo.ICON_COLOR_16x16)));
   }
   else if (value instanceof JRDesignExpression)
   {
       JRDesignExpression exp = (JRDesignExpression)value;
       label.setText(exp.getText());
       label.setIcon(expressionIcon);
   }

   return label;
}
项目:VaadinUtils    文件:JasperManager.java   
/**
 * replace the place holder in the targetBand with the report title, also
 * add a set of dynamically generated user friendly report parameter fields
 * to this band and add parameters to the report for them if not already
 * present.
 *
 * @param designFile
 * @param templateBand
 * @param targetBand
 * @param margin
 * @return
 * @throws JRException
 */
private int determineSizeOfTemplateBandAndReplaceTitlePlaceHolder(JasperDesign designFile, JRBand templateBand,
        JRDesignBand targetBand, int margin) throws JRException
{
    int maxY = 0;
    for (JRElement element : templateBand.getElements())
    {

        JRDesignElement de = (JRDesignElement) element;
        if (element instanceof JRStaticText)
        {
            JRStaticText st = (JRStaticText) element;
            if (st.getText().equalsIgnoreCase("report name place holder"))
            {
                st.setText(reportProperties.getReportTitle());
                st.setWidth((designFile.getPageWidth() - st.getX()) - (margin * 2));
            }
        }

        if (element instanceof JRDesignImage)
        {
            JRDesignImage im = (JRDesignImage) element;
            String expr = im.getExpression().getText();
            if (expr.contains("logo.png"))
            {
                int height = 140;
                final int imageWidth = designFile.getPageWidth() - (margin * 2);
                String fileName = reportProperties.generateDynamicHeaderImage(imageWidth, height,
                        reportProperties.getReportTitle());
                im.setWidth(imageWidth);
                // im.setHeight(height);
                im.setX(-8);

                expr = expr.replace("logo.png", fileName);
                im.setExpression(new JRDesignExpression(expr));
            }
        }

        maxY = Math.max(maxY, de.getY() + de.getHeight());

        targetBand.addElement(de);

    }

    JRDesignStaticText paramElement = new JRDesignStaticText();
    paramElement.setText("Parameters");
    paramElement.setWidth(525);
    paramElement.setHeight(15);
    paramElement.setBackcolor(new Color(95, 96, 98));
    paramElement.setForecolor(new Color(255, 255, 255));
    paramElement.setMode(ModeEnum.OPAQUE);

    paramElement.setX(0);
    paramElement.setY(maxY + 2);
    paramElement.setFontName("Arial");
    paramElement.setBold(true);
    paramElement.setFontSize(12);
    paramElement.setHorizontalAlignment(HorizontalAlignEnum.CENTER);
    paramElement.setVerticalAlignment(VerticalAlignEnum.MIDDLE);

    targetBand.addElement(paramElement);
    maxY = paramElement.getY() + paramElement.getHeight();

    maxY = addParametersToDisplayReportParameters(designFile, targetBand, maxY);
    return maxY;
}
项目:PDFReporter-Studio    文件:MStaticText.java   
/**
 * Instantiates a new m static text.
 * 
 * @param parent
 *          the parent
 * @param jrStaticText
 *          the jr static text
 * @param newIndex
 *          the new index
 */
public MStaticText(ANode parent, JRStaticText jrStaticText, int newIndex) {
    super(parent, newIndex);
    setValue(jrStaticText);
}