Examples of JRFont


Examples of net.sf.jasperreports.engine.JRFont

  /**
   *
   */
  public Object createObject(Attributes atts)
  {
    JRFont font = getFont();
    JRXmlLoader xmlLoader = (JRXmlLoader)digester.peek(digester.getCount() - 1);
    JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);

    if (atts.getValue(JRXmlConstants.ATTRIBUTE_reportFont) != null)
    {
      Map fontsMap = jasperDesign.getFontsMap();

      if ( !fontsMap.containsKey(atts.getValue(JRXmlConstants.ATTRIBUTE_reportFont)) )
      {
        xmlLoader.addError(new JRValidationException("Unknown report font : " + atts.getValue(JRXmlConstants.ATTRIBUTE_reportFont), font));
      }

      font.setReportFont((JRReportFont)fontsMap.get(atts.getValue(JRXmlConstants.ATTRIBUTE_reportFont)));
    }

    if (atts.getValue(JRXmlConstants.ATTRIBUTE_fontName) != null)
    {
      font.setFontName(atts.getValue(JRXmlConstants.ATTRIBUTE_fontName));
    }

    if (atts.getValue(JRXmlConstants.ATTRIBUTE_isBold) != null)
    {
      font.setBold(Boolean.valueOf(atts.getValue(JRXmlConstants.ATTRIBUTE_isBold)));
    }
    if (atts.getValue(JRXmlConstants.ATTRIBUTE_isItalic) != null)
    {
      font.setItalic(Boolean.valueOf(atts.getValue(JRXmlConstants.ATTRIBUTE_isItalic)));
    }
    if (atts.getValue(JRXmlConstants.ATTRIBUTE_isUnderline) != null)
    {
      font.setUnderline(Boolean.valueOf(atts.getValue(JRXmlConstants.ATTRIBUTE_isUnderline)));
    }
    if (atts.getValue(JRXmlConstants.ATTRIBUTE_isStrikeThrough) != null)
    {
      font.setStrikeThrough(Boolean.valueOf(atts.getValue(JRXmlConstants.ATTRIBUTE_isStrikeThrough)));
    }
    if (atts.getValue(JRXmlConstants.ATTRIBUTE_size) != null)
    {
      font.setFontSize(Integer.parseInt(atts.getValue(JRXmlConstants.ATTRIBUTE_size)));
    }
    if (atts.getValue(JRXmlConstants.ATTRIBUTE_pdfFontName) != null)
    {
      font.setPdfFontName(atts.getValue(JRXmlConstants.ATTRIBUTE_pdfFontName));
    }
    if (atts.getValue(JRXmlConstants.ATTRIBUTE_pdfEncoding) != null)
    {
      font.setPdfEncoding(atts.getValue(JRXmlConstants.ATTRIBUTE_pdfEncoding));
    }
    if (atts.getValue(JRXmlConstants.ATTRIBUTE_isPdfEmbedded) != null)
    {
      font.setPdfEmbedded(Boolean.valueOf(atts.getValue(JRXmlConstants.ATTRIBUTE_isPdfEmbedded)));
    }
    return font;
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

        writer.write(tabStopAlign + "\\tx" + LengthUtil.twip(tabStop.getPosition()) + " ");
      }
    }

    JRFont font = text;
    if (text.getRunDirectionValue() == RunDirectionEnum.RTL)
    {
      writer.write("\\rtlch");
    }
//    writer.write("\\f");
//    writer.write(String.valueOf(getFontIndex(font)));
//    writer.write("\\cf");
//    writer.write(String.valueOf(getColorIndex(text.getForecolor())));
    writer.write("\\cb");
    writer.write(String.valueOf(getColorIndex(text.getBackcolor())));
    writer.write(" ");

//    if (font.isBold())
//      writer.write("\\b");
//    if (font.isItalic())
//      writer.write("\\i");
//    if (font.isStrikeThrough())
//      writer.write("\\strike");
//    if (font.isUnderline())
//      writer.write("\\ul");
//    writer.write("\\fs");
//    writer.write(String.valueOf(font.getFontSize() * 2));

    switch (text.getHorizontalAlignmentValue())
    {
      case LEFT:
        writer.write("\\ql");
        break;
      case CENTER:
        writer.write("\\qc");
        break;
      case RIGHT:
        writer.write("\\qr");
        break;
      case JUSTIFIED:
        writer.write("\\qj");
        break;
      default:
        writer.write("\\ql");
        break;
    }

    switch (text.getParagraph().getLineSpacing())
    {
      case AT_LEAST:
      {
        writer.write("\\sl" + LengthUtil.twip(text.getParagraph().getLineSpacingSize().floatValue()));
        writer.write(" \\slmult0 ");
        break;
      }
      case FIXED:
      {
        writer.write("\\sl-" + LengthUtil.twip(text.getParagraph().getLineSpacingSize().floatValue()));
        writer.write(" \\slmult0 ");
        break;
      }
      case PROPORTIONAL:
      {
        writer.write("\\sl" + (int)(text.getParagraph().getLineSpacingSize().floatValue() * LINE_SPACING_FACTOR));
        writer.write(" \\slmult1 ");
        break;
      }
      case DOUBLE:
      {
        writer.write("\\sl" + (int)(2f * LINE_SPACING_FACTOR));
        writer.write(" \\slmult1 ");
        break;
      }
      case ONE_AND_HALF:
      {
        writer.write("\\sl" + (int)(1.5f * LINE_SPACING_FACTOR));
        writer.write(" \\slmult1 ");
        break;
      }
      case SINGLE:
      default:
      {
        writer.write("\\sl" + (int)(1f * LINE_SPACING_FACTOR));
        writer.write(" \\slmult1 ");
        break;
      }
    }

    if (text.getAnchorName() != null)
    {
      writeAnchor(text.getAnchorName());
    }

    exportHyperlink(text);

    // add parameters in case of styled text element
    String plainText = styledText.getText();
    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
    while (
      runLimit < styledText.length()
      && (runLimit = iterator.getRunLimit()) <= styledText.length()
      )
    {

      Map styledTextAttributes = iterator.getAttributes();
      JRFont styleFont = new JRBaseFont(styledTextAttributes);
      Color styleForeground = (Color) styledTextAttributes.get(TextAttribute.FOREGROUND);
      Color styleBackground = (Color) styledTextAttributes.get(TextAttribute.BACKGROUND);

      writer.write("\\f");
      writer.write(String.valueOf(getFontIndex(styleFont, getTextLocale(text))));
      writer.write("\\fs");
      writer.write(String.valueOf(2 * styleFont.getFontSize()));

      if (styleFont.isBold())
      {
        writer.write("\\b");
      }
      if (styleFont.isItalic())
      {
        writer.write("\\i");
      }
      if (styleFont.isUnderline())
      {
        writer.write("\\ul");
      }
      if (styleFont.isStrikeThrough())
      {
        writer.write("\\strike");
      }

      if (TextAttribute.SUPERSCRIPT_SUPER.equals(styledTextAttributes.get(TextAttribute.SUPERSCRIPT)))
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
      Map attributes = iterator.getAttributes();
      JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes);
      short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null ?
          getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() :
          forecolor;
      HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale);
      richTextStr.applyFont(iterator.getIndex(), runLimit, font);
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

    if (font != null)
    {
      writer.startElement(JRXmlConstants.ELEMENT_font);
      if (font.getReportFont() != null)
      {
        JRFont baseFont =
          (JRFont)fontsMap.get(
            font.getReportFont().getName()
            );
        if(baseFont != null)
        {
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

  /**
   * @param font the font to set
   */
  public void setFont(JRFont font) {
    JRFont old = getFont();
    this.font = font;
    //this.font = new JRBaseFont(chartSettings.getFont(), font);
    getEventSupport().firePropertyChange(PROPERTY_font, old, getFont());
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

  /**
   * @param labelFont the labelFont to set
   */
  public void setLabelFont(JRFont labelFont)
  {
    JRFont old = getLabelFont();
    this.labelFont = labelFont;
    getEventSupport().firePropertyChange(PROPERTY_labelFont, old, getLabelFont());
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

  /**
   * @param tickLabelFont the tickLabelFont to set
   */
  public void setTickLabelFont(JRFont tickLabelFont)
  {
    JRFont old = getTickLabelFont();
    this.tickLabelFont = tickLabelFont;
    getEventSupport().firePropertyChange(PROPERTY_tickLabelFont, old, getTickLabelFont());
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

  /**
   * @param tickLabelFont the tickLabelFont to set
   */
  public void setTickLabelFont(JRFont tickLabelFont)
  {
    JRFont old = getTickLabelFont();
    this.tickLabelFont = tickLabelFont;
    getEventSupport().firePropertyChange(PROPERTY_tickLabelFont, old, getTickLabelFont());
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

  /**
   * @param displayFont the displayFont to set
   */
  public void setDisplayFont(JRFont displayFont)
  {
    JRFont old = getDisplayFont();
    this.displayFont = displayFont;
    getEventSupport().firePropertyChange(PROPERTY_displayFont, old, getDisplayFont());
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRFont

    // Set the spacing between ticks.  I hate the name "tickSize" since to me it
    // implies I am changing the size of the tick, not the spacing between them.
    double tickInterval = jrPlot.getTickIntervalDouble() == null ? 10.0 : jrPlot.getTickIntervalDouble().doubleValue();
    chartPlot.setTickSize(tickInterval);
   
    JRFont tickLabelFont = jrPlot.getTickLabelFont();
    Integer defaultBaseFontSize = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE);
    Font themeTickLabelFont = getFont((JRFont)getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_TICK_LABEL_FONT), tickLabelFont, defaultBaseFontSize);
    chartPlot.setTickLabelFont(themeTickLabelFont);
   
    Color tickColor = jrPlot.getTickColor() == null ? Color.BLACK : jrPlot.getTickColor();
    chartPlot.setTickPaint(tickColor);
    int dialUnitScale = 1;
   
    Range range = convertRange(jrPlot.getDataRange());
    // Set the meter's range
    if(range != null)
    {
      chartPlot.setRange(range);
      double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound()));
      dialUnitScale = ChartThemesUtilities.getScale(bound);
      if((range.getLowerBound() == (int)range.getLowerBound() &&
          range.getUpperBound() == (int)range.getUpperBound() &&
          tickInterval == (int)tickInterval) ||
          dialUnitScale > 1
          )
      {
        chartPlot.setTickLabelFormat(new DecimalFormat("#,##0"));
      }
      else if(dialUnitScale == 1)
      {
        chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.0"));
      }
      else if(dialUnitScale <= 0)
      {
        chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.00"));
      }
    }
    chartPlot.setTickLabelsVisible(true);

    // Set all the colors we support
    Paint backgroundPaint = jrPlot.getOwnBackcolor() == null ? ChartThemesConstants.TRANSPARENT_PAINT : jrPlot.getOwnBackcolor();
    chartPlot.setBackgroundPaint(backgroundPaint);

    GradientPaint gp =
      new GradientPaint(
        new Point(), Color.LIGHT_GRAY,
        new Point(), Color.BLACK,
        false
        );
   
    if(jrPlot.getMeterBackgroundColor() != null)
    {
      chartPlot.setDialBackgroundPaint(jrPlot.getMeterBackgroundColor());
    }
    else
    {
      chartPlot.setDialBackgroundPaint(gp);
    }
    //chartPlot.setForegroundAlpha(1f);
    Paint needlePaint = jrPlot.getNeedleColor() == null ? new Color(191, 48, 0) : jrPlot.getNeedleColor();
    chartPlot.setNeedlePaint(needlePaint);

    JRValueDisplay display = jrPlot.getValueDisplay();
    if(display != null)
    {
      Color valueColor = display.getColor() == null ? Color.BLACK : display.getColor();
      chartPlot.setValuePaint(valueColor);
      String pattern = display.getMask() != null ? display.getMask() : "#,##0.####";
      if(pattern != null)
        chartPlot.setTickLabelFormat( new DecimalFormat(pattern));
      JRFont displayFont = display.getFont();
      Font themeDisplayFont = getFont((JRFont)getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT), displayFont, defaultBaseFontSize);
 
      if (themeDisplayFont != null)
      {
        chartPlot.setValueFont(themeDisplayFont);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.