⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemfactory.java

📁 Java的Web报表库
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   * @param name the name of the new element
   * @param bounds the bounds of the new element
   * @param paint the text color of this text element
   * @param alignment  the horizontal text alignment.
   * @param font the font for this element
   * @param nullString the text used when the value of this element is null
   * @param field the fieldname in the datamodel to retrieve values from
   * @param format the DecimalFormatString used in this text field
   *
   * @return a report element for displaying <code>Number</code> objects.
   *
   * @throws NullPointerException if bounds, name or function are null
   * @throws IllegalArgumentException if the given alignment is invalid
   */
  public static TextElement createNumberElement(final String name,
                                                final Rectangle2D bounds,
                                                final Paint paint,
                                                final int alignment,
                                                final Font font,
                                                final String nullString,
                                                final String format,
                                                final String field)
  {
    return createNumberElement(name, bounds, paint, alignment,
        ElementAlignment.TOP.getOldAlignment(),
        font, nullString,
        format, field);
  }

  /**
   * Creates a new TextElement containing a numeric filter structure.
   *
   * @param name  the name of the new element.
   * @param bounds  the bounds of the new element.
   * @param paint  the text color of this text element.
   * @param alignment  the horizontal text alignment.
   * @param valign  the vertical alignment.
   * @param font  the font for this element.
   * @param nullString t he text used when the value of this element is null.
   * @param field  the fieldname in the datamodel to retrieve values from.
   * @param format  the DecimalFormatString used in this text field.
   *
   * @return a report element for displaying <code>Number</code> objects.
   *
   * @throws NullPointerException if bounds, name or function are null
   * @throws IllegalArgumentException if the given alignment is invalid
   */
  public static TextElement createNumberElement(final String name,
                                                final Rectangle2D bounds,
                                                final Paint paint,
                                                final int alignment,
                                                final int valign,
                                                final Font font,
                                                final String nullString,
                                                final String format,
                                                final String field)
  {
    final NumberFieldTemplate template = new NumberFieldTemplate();
    if (format != null)
    {
      template.setFormat(format);
    }
    template.setNullValue(nullString);
    template.setField(field);

    final TextElement element = new TextElement();
    if (name != null)
    {
      element.setName(name);
    }
    setElementBounds(element, bounds);
    if (paint != null)
    {
      element.getStyle().setStyleProperty(ElementStyleSheet.PAINT, paint);
    }
    if (font != null)
    {
      element.getStyle().setFontDefinitionProperty(new FontDefinition(font));
    }
    element.getStyle().setStyleProperty(
        ElementStyleSheet.ALIGNMENT,
        ElementAlignment.translateHorizontalAlignment(alignment)
    );
    element.getStyle().setStyleProperty(
        ElementStyleSheet.VALIGNMENT,
        ElementAlignment.translateVerticalAlignment(valign)
    );
    element.setDataSource(template);
    return element;
  }

  /**
   * Creates a new TextElement containing a numeric filter structure.
   *
   * @param name the name of the new element
   * @param bounds the bounds of the new element
   * @param paint the text color of this text element
   * @param alignment  the horizontal text alignment.
   * @param font the font for this element
   * @param nullString the text used when the value of this element is null
   * @param function the function to retrieve values from
   * @param format the DecimalFormatString used in this text field
   *
   * @return a report element for displaying <code>Number</code> objects.
   *
   * @throws NullPointerException if bounds, name or function are null
   * @throws IllegalArgumentException if the given alignment is invalid
   *
   * @deprecated use createNumberElement instead
   */
  public static TextElement createNumberFunction(final String name,
                                                 final Rectangle2D bounds,
                                                 final Paint paint,
                                                 final int alignment,
                                                 final Font font,
                                                 final String nullString,
                                                 final String format,
                                                 final String function)
  {
    return createNumberElement(name, bounds, paint, alignment, font, nullString, format, function);
  }

  /**
   * Creates a new TextElement containing a numeric filter structure.
   *
   * @param name the name of the new element
   * @param bounds the bounds of the new element
   * @param paint the text color of this text element
   * @param alignment  the horizontal text alignment.
   * @param font the font for this element
   * @param nullString the text used when the value of this element is null
   * @param function the function to retrieve values from
   * @param format the NumberFormat used in this text field
   *
   * @return a report element for displaying <code>Number</code> objects.
   *
   * @throws NullPointerException if bounds, name or function are null
   * @throws IllegalArgumentException if the given alignment is invalid
   *
   * @deprecated use createNumberElement instead
   */
  public static TextElement createNumberFunction(final String name,
                                                 final Rectangle2D bounds,
                                                 final Paint paint,
                                                 final int alignment,
                                                 final Font font,
                                                 final String nullString,
                                                 final NumberFormat format,
                                                 final String function)
  {
    return createNumberElement(name, bounds, paint, alignment, font, nullString, format, function);
  }

  /**
   * Creates a new TextElement without any additional filtering.
   *
   * @param name the name of the new element
   * @param bounds the bounds of the new element
   * @param paint the text color of this text element
   * @param alignment  the horizontal text alignment.
   * @param font the font for this element
   * @param nullString the text used when the value of this element is null
   * @param field the field in the datamodel to retrieve values from
   *
   * @return a report element for displaying <code>String</code> objects.
   *
   * @throws NullPointerException if bounds, name or function are null
   * @throws IllegalArgumentException if the given alignment is invalid
   */
  public static TextElement createStringElement(final String name,
                                                final Rectangle2D bounds,
                                                final Paint paint,
                                                final int alignment,
                                                final Font font,
                                                final String nullString,
                                                final String field)
  {
    return createStringElement(name,
        bounds,
        paint,
        alignment,
        ElementAlignment.TOP.getOldAlignment(),
        font,
        nullString,
        field);
  }

  /**
   * Creates a new TextElement without any additional filtering.
   *
   * @param name  the name of the new element
   * @param bounds  the bounds of the new element
   * @param paint  the text color of this text element
   * @param alignment  the horizontal text alignment.
   * @param valign  the vertical alignment.
   * @param font  the font for this element
   * @param nullString  the text used when the value of this element is null
   * @param field  the field in the datamodel to retrieve values from
   *
   * @return a report element for displaying <code>String</code> objects.
   *
   * @throws NullPointerException if bounds, name or function are null
   * @throws IllegalArgumentException if the given alignment is invalid
   */
  public static TextElement createStringElement(final String name,
                                                final Rectangle2D bounds,
                                                final Paint paint,
                                                final int alignment,
                                                final int valign,
                                                final Font font,
                                                final String nullString,
                                                final String field)
  {
    final StringFieldTemplate template = new StringFieldTemplate();
    template.setField(field);
    template.setNullValue(nullString);

    final TextElement element = new TextElement();
    if (name != null)
    {
      element.setName(name);
    }
    setElementBounds(element, bounds);
    if (paint != null)
    {
      element.getStyle().setStyleProperty(ElementStyleSheet.PAINT, paint);
    }
    if (font != null)
    {
      element.getStyle().setFontDefinitionProperty(new FontDefinition(font));
    }
    element.getStyle().setStyleProperty(
        ElementStyleSheet.ALIGNMENT,
        ElementAlignment.translateHorizontalAlignment(alignment)
    );
    element.getStyle().setStyleProperty(
        ElementStyleSheet.VALIGNMENT,
        ElementAlignment.translateVerticalAlignment(valign)
    );
    element.setDataSource(template);
    return element;
  }

  /**
   * Creates a new TextElement without any additional filtering.
   *
   * @param name the name of the new element
   * @param bounds the bounds of the new element
   * @param paint the text color of this text element
   * @param alignment  the horizontal text alignment.
   * @param font the font for this element
   * @param nullString the text used when the value of this element is null
   * @param function the name of the function to retrieve values from
   *
   * @return a report element for displaying <code>String</code> objects.
   *
   * @throws NullPointerException if bounds, name or function are null
   * @throws IllegalArgumentException if the given alignment is invalid
   *
   * @deprecated use createStringElement instead
   */
  public static TextElement createStringFunction(final String name,
                                                 final Rectangle2D bounds,
                                                 final Paint paint,
                                                 final int alignment,
                                                 final Font font,
                                                 final String nullString,
                                                 final String function)
  {
    return createStringElement(name, bounds, paint, alignment, font, nullString, function);
  }

  /**
   * Creates a GroupFooter-band with the specified height and the DefaultFont and DefaultPaint
   * given.
   *
   * @param height the height of the band in points
   * @param defaultFont the default font for this band
   * @param defaultPaint the default paint for this band
   *
   * @return the GroupFooter
   */
  public static Band createGroupFooter(final float height, final Font defaultFont, final Paint defaultPaint)
  {
    final GroupFooter footer = new GroupFooter();
    footer.getStyle().setStyleProperty(ElementStyleSheet.MINIMUMSIZE,
        new FloatDimension(0, height));
    if (defaultFont != null)
    {
      footer.getBandDefaults().setFontDefinitionProperty(new FontDefinition(defaultFont));
    }
    if (defaultPaint != null)
    {
      footer.getBandDefaults().setStyleProperty(ElementStyleSheet.PAINT, defaultPaint);
    }
    return footer;
  }

  /**
   * Creates a GroupHeader-band with the specified height and the DefaultFont and DefaultPaint
   * given.
   *
   * @param height the height of the band in points
   * @p

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -