Package net.sf.jasperreports.engine.base

Examples of net.sf.jasperreports.engine.base.JRBaseFont


   *
   */
  public JRFillBubblePlot( JRBubblePlot bubblePlot, JRFillObjectFactory factory ){
    super( bubblePlot, factory );
   
    xAxisLabelFont = new JRBaseFont(bubblePlot.getChart(), bubblePlot.getXAxisLabelFont());
    xAxisLabelColor = bubblePlot.getOwnXAxisLabelColor();
    xAxisTickLabelFont = new JRBaseFont(bubblePlot.getChart(), bubblePlot.getXAxisTickLabelFont());
    xAxisTickLabelColor = bubblePlot.getOwnXAxisTickLabelColor();
    xAxisLineColor = bubblePlot.getOwnXAxisLineColor();
   
    yAxisLabelFont = new JRBaseFont(bubblePlot.getChart(), bubblePlot.getYAxisLabelFont());
    yAxisLabelColor = bubblePlot.getOwnYAxisLabelColor();
    yAxisTickLabelFont = new JRBaseFont(bubblePlot.getChart(), bubblePlot.getYAxisTickLabelFont());
    yAxisTickLabelColor = bubblePlot.getOwnYAxisTickLabelColor();
    yAxisLineColor = bubblePlot.getOwnYAxisLineColor();
  }
View Full Code Here


    super(plot, chart);
   
    JRBubblePlot bubblePlot = plot instanceof JRBubblePlot ? (JRBubblePlot)plot : null;
    if (bubblePlot == null)
    {
      xAxisLabelFont = new JRBaseFont(chart, null);
      xAxisTickLabelFont = new JRBaseFont(chart, null);
      yAxisLabelFont = new JRBaseFont(chart, null);
      yAxisTickLabelFont = new JRBaseFont(chart, null);
    }
    else
    {
      xAxisLabelFont = new JRBaseFont(chart, bubblePlot.getXAxisLabelFont());
      xAxisTickLabelFont = new JRBaseFont(chart, bubblePlot.getXAxisTickLabelFont());
      yAxisLabelFont = new JRBaseFont(chart, bubblePlot.getYAxisLabelFont());
      yAxisTickLabelFont = new JRBaseFont(chart, bubblePlot.getYAxisTickLabelFont());
    }
  }
View Full Code Here

    super( bubblePlot, factory );
   
    scaleTypeValue = bubblePlot.getScaleTypeValue();
   
    xAxisLabelExpression = factory.getExpression( bubblePlot.getXAxisLabelExpression() );
    xAxisLabelFont = new JRBaseFont(bubblePlot.getChart(), bubblePlot.getXAxisLabelFont());
    xAxisLabelColor = bubblePlot.getOwnXAxisLabelColor();
    xAxisTickLabelFont = new JRBaseFont(bubblePlot.getChart(), bubblePlot.getXAxisTickLabelFont());
    xAxisTickLabelColor = bubblePlot.getOwnXAxisTickLabelColor();
    xAxisTickLabelMask = bubblePlot.getXAxisTickLabelMask();
    xAxisVerticalTickLabels = bubblePlot.getXAxisVerticalTickLabels();
    xAxisLineColor = bubblePlot.getOwnXAxisLineColor();
   
    yAxisLabelExpression = factory.getExpression( bubblePlot.getYAxisLabelExpression() );
    yAxisLabelFont = new JRBaseFont(bubblePlot.getChart(), bubblePlot.getYAxisLabelFont());
    yAxisLabelColor = bubblePlot.getOwnYAxisLabelColor();
    yAxisTickLabelFont = new JRBaseFont(bubblePlot.getChart(), bubblePlot.getYAxisTickLabelFont());
    yAxisTickLabelColor = bubblePlot.getOwnYAxisTickLabelColor();
    yAxisTickLabelMask = bubblePlot.getYAxisTickLabelMask();
    yAxisVerticalTickLabels = bubblePlot.getYAxisVerticalTickLabels();
    yAxisLineColor = bubblePlot.getOwnYAxisLineColor();
   
View Full Code Here

    super(plot, chart);
   
    JRBarPlot barPlot = plot instanceof JRBarPlot ? (JRBarPlot)plot : null;
    if (barPlot == null)
    {
      categoryAxisLabelFont = new JRBaseFont(chart, null);
      categoryAxisTickLabelFont = new JRBaseFont(chart, null);
      valueAxisLabelFont = new JRBaseFont(chart, null);
      valueAxisTickLabelFont = new JRBaseFont(chart, null);
      itemLabel = new JRBaseItemLabel(null, chart);
    }
    else
    {
      categoryAxisLabelFont = new JRBaseFont(chart, barPlot.getCategoryAxisLabelFont());
      categoryAxisTickLabelFont = new JRBaseFont(chart, barPlot.getCategoryAxisTickLabelFont());
      valueAxisLabelFont = new JRBaseFont(chart, barPlot.getValueAxisLabelFont());
      valueAxisTickLabelFont = new JRBaseFont(chart, barPlot.getValueAxisTickLabelFont());
      itemLabel = new JRBaseItemLabel(barPlot.getItemLabel(), chart);
    }
  }
View Full Code Here

    showTickMarks = barPlot.getShowTickMarks();
    showTickLabels = barPlot.getShowTickLabels();
    showLabels = barPlot.getShowLabels();

    categoryAxisLabelExpression = factory.getExpression( barPlot.getCategoryAxisLabelExpression() );
    categoryAxisLabelFont = new JRBaseFont(barPlot.getChart(), barPlot.getCategoryAxisLabelFont());
    categoryAxisLabelColor = barPlot.getOwnCategoryAxisLabelColor();
    categoryAxisTickLabelFont = new JRBaseFont(barPlot.getChart(), barPlot.getCategoryAxisTickLabelFont());
    categoryAxisTickLabelColor = barPlot.getOwnCategoryAxisTickLabelColor();
    categoryAxisTickLabelMask = barPlot.getCategoryAxisTickLabelMask();
    categoryAxisVerticalTickLabels = barPlot.getCategoryAxisVerticalTickLabels();
    categoryAxisLineColor = barPlot.getOwnCategoryAxisLineColor();
    labelRotationDouble = barPlot.getCategoryAxisTickLabelRotation();

    valueAxisLabelExpression = factory.getExpression( barPlot.getValueAxisLabelExpression() );
    domainAxisMinValueExpression = factory.getExpression( barPlot.getDomainAxisMinValueExpression() );
    domainAxisMaxValueExpression = factory.getExpression( barPlot.getDomainAxisMaxValueExpression() );
    rangeAxisMinValueExpression = factory.getExpression( barPlot.getRangeAxisMinValueExpression() );
    rangeAxisMaxValueExpression = factory.getExpression( barPlot.getRangeAxisMaxValueExpression() );
    valueAxisLabelFont = new JRBaseFont(barPlot.getChart(), barPlot.getValueAxisLabelFont());
    valueAxisLabelColor = barPlot.getOwnValueAxisLabelColor();
    valueAxisTickLabelFont = new JRBaseFont(barPlot.getChart(), barPlot.getValueAxisTickLabelFont());
    valueAxisTickLabelColor = barPlot.getOwnValueAxisTickLabelColor();
    valueAxisTickLabelMask = barPlot.getValueAxisTickLabelMask();
    valueAxisVerticalTickLabels = barPlot.getValueAxisVerticalTickLabels();
    valueAxisLineColor = barPlot.getOwnValueAxisLineColor();
   
View Full Code Here

   * @param setFontLines whether to set underline and strikethrough as font style
   * @return the PDF font for the specified attributes
   */
  protected Font getFont(Map attributes, Locale locale, boolean setFontLines)
  {
    JRFont jrFont = new JRBaseFont(attributes);

    Exception initialException = null;

    Color forecolor = (Color)attributes.get(TextAttribute.FOREGROUND);

    // use the same font scale ratio as in JRStyledText.getAwtAttributedString
    float fontSizeScale = 1f;
    Integer scriptStyle = (Integer) attributes.get(TextAttribute.SUPERSCRIPT);
    if (scriptStyle != null && (
        TextAttribute.SUPERSCRIPT_SUB.equals(scriptStyle)
        || TextAttribute.SUPERSCRIPT_SUPER.equals(scriptStyle)))
    {
      fontSizeScale = 2f / 3;
    }
   
    Font font = null;
    PdfFont pdfFont = null;
    FontKey key = new FontKey(jrFont.getFontName(), jrFont.isBold(), jrFont.isItalic());

    if (fontMap != null && fontMap.containsKey(key))
    {
      pdfFont = (PdfFont) fontMap.get(key);
    }
    else
    {
      FontInfo fontInfo = JRFontUtil.getFontInfo(jrFont.getFontName(), locale);
      if (fontInfo == null)
      {
        //fontName NOT found in font extensions
        pdfFont = new PdfFont(jrFont.getPdfFontName(), jrFont.getPdfEncoding(), jrFont.isPdfEmbedded());
      }
      else
      {
        //fontName found in font extensions
        FontFamily family = fontInfo.getFontFamily();
        FontFace face = fontInfo.getFontFace();
        int faceStyle = java.awt.Font.PLAIN;

        if (face == null)
        {
          //fontName matches family name in font extension
          if (jrFont.isBold() && jrFont.isItalic())
          {
            face = family.getBoldItalicFace();
            faceStyle = java.awt.Font.BOLD | java.awt.Font.ITALIC;
          }
         
          if (face == null && jrFont.isBold())
          {
            face = family.getBoldFace();
            faceStyle = java.awt.Font.BOLD;
          }
         
          if (face == null && jrFont.isItalic())
          {
            face = family.getItalicFace();
            faceStyle = java.awt.Font.ITALIC;
          }
         
          if (face == null)
          {
            face = family.getNormalFace();
            faceStyle = java.awt.Font.PLAIN;
          }
           
//          if (face == null)
//          {
//            throw new JRRuntimeException("Font family '" + family.getName() + "' does not have the normal font face.");
//          }
        }
        else
        {
          //fontName matches face name in font extension; not family name
          faceStyle = fontInfo.getStyle();
        }
       
        String pdfFontName = null;
        int pdfFontStyle = java.awt.Font.PLAIN;
        if (jrFont.isBold() && jrFont.isItalic())
        {
          pdfFontName = family.getBoldItalicPdfFont();
          pdfFontStyle = java.awt.Font.BOLD | java.awt.Font.ITALIC;
        }
       
        if (pdfFontName == null && jrFont.isBold())
        {
          pdfFontName = family.getBoldPdfFont();
          pdfFontStyle = java.awt.Font.BOLD;
        }
       
        if (pdfFontName == null && jrFont.isItalic())
        {
          pdfFontName = family.getItalicPdfFont();
          pdfFontStyle = java.awt.Font.ITALIC;
        }
       
        if (pdfFontName == null)
        {
          pdfFontName = family.getNormalPdfFont();
          pdfFontStyle = java.awt.Font.PLAIN;
        }

        if (pdfFontName == null)
        {
          //in theory, face file cannot be null here
          pdfFontName = (face == null || face.getFile() == null ? jrFont.getPdfFontName() : face.getFile());
          pdfFontStyle = faceStyle;//FIXMEFONT not sure this is correct, in case we inherit pdfFontName from default properties
        }

//        String ttf = face.getFile();
//        if (ttf == null)
//        {
//          throw new JRRuntimeException("The '" + face.getName() + "' font face in family '" + family.getName() + "' returns a null file.");
//        }
       
        pdfFont =
          new PdfFont(
            pdfFontName,
            family.getPdfEncoding() == null ? jrFont.getPdfEncoding() : family.getPdfEncoding(),
             family.isPdfEmbedded() == null ? jrFont.isPdfEmbedded() : family.isPdfEmbedded().booleanValue(),
            jrFont.isBold() && ((pdfFontStyle & java.awt.Font.BOLD) == 0),
            jrFont.isItalic() && ((pdfFontStyle & java.awt.Font.ITALIC) == 0)
            );
      }
    }

    int pdfFontStyle = (pdfFont.isPdfSimulatedBold() ? Font.BOLD : 0)
        | (pdfFont.isPdfSimulatedItalic() ? Font.ITALIC : 0);
    if (setFontLines)
    {
      pdfFontStyle |= (jrFont.isUnderline() ? Font.UNDERLINE : 0)
          | (jrFont.isStrikeThrough() ? Font.STRIKETHRU : 0);
    }
   
    try
    {
      font = FontFactory.getFont(
        pdfFont.getPdfFontName(),
        pdfFont.getPdfEncoding(),
        pdfFont.isPdfEmbedded(),
        jrFont.getFontSize() * fontSizeScale,
        pdfFontStyle,
        forecolor
        );

      // check if FontFactory didn't find the font
      if (font.getBaseFont() == null && font.getFamily() == Font.UNDEFINED)
      {
        font = null;
      }
    }
    catch(Exception e)
    {
      initialException = e;
    }

    if (font == null)
    {
      byte[] bytes = null;

      try
      {
        bytes = JRLoader.loadBytesFromLocation(pdfFont.getPdfFontName(), classLoader, urlHandlerFactory, fileResolver);
      }
      catch(JRException e)
      {
        throw //NOPMD
          new JRRuntimeException(
            "Could not load the following font : "
            + "\npdfFontName   : " + pdfFont.getPdfFontName()
            + "\npdfEncoding   : " + pdfFont.getPdfEncoding()
            + "\nisPdfEmbedded : " + pdfFont.isPdfEmbedded(),
            initialException
            );
      }

      BaseFont baseFont = null;

      try
      {
        baseFont =
          BaseFont.createFont(
            pdfFont.getPdfFontName(),
            pdfFont.getPdfEncoding(),
            pdfFont.isPdfEmbedded(),
            true,
            bytes,
            null
            );
      }
      catch(DocumentException e)
      {
        throw new JRRuntimeException(e);
      }
      catch(IOException e)
      {
        throw new JRRuntimeException(e);
      }

      font =
        new Font(
          baseFont,
          jrFont.getFontSize() * fontSizeScale,
          pdfFontStyle,
          forecolor
          );
    }

 
View Full Code Here

   * @param font the font to use when displaying the value
   */
  public void setFont(JRFont font)
  {
    Object old = this.font;
    this.font = new JRBaseFont(getChart(), font);
    getEventSupport().firePropertyChange(PROPERTY_FONT, old, this.font);
  }
View Full Code Here

   *
   */
  public void setCategoryAxisLabelFont(JRFont categoryAxisLabelFont)
  {
    Object old = this.categoryAxisLabelFont;
    this.categoryAxisLabelFont = new JRBaseFont(this.getChart(), categoryAxisLabelFont);
    getEventSupport().firePropertyChange(PROPERTY_CATEGORY_AXIS_LABEL_FONT, old, this.categoryAxisLabelFont);
  }
View Full Code Here

   *
   */
  public void setCategoryAxisTickLabelFont(JRFont categoryAxisTickLabelFont)
  {
    Object old = this.categoryAxisTickLabelFont;
    this.categoryAxisTickLabelFont = new JRBaseFont(this.getChart(), categoryAxisTickLabelFont);
    getEventSupport().firePropertyChange(PROPERTY_CATEGORY_AXIS_TICK_LABEL_FONT, old, this.categoryAxisTickLabelFont);
  }
View Full Code Here

   *
   */
  public void setValueAxisLabelFont(JRFont valueAxisLabelFont)
  {
    Object old = this.valueAxisLabelFont;
    this.valueAxisLabelFont = new JRBaseFont(this.getChart(), valueAxisLabelFont);
    getEventSupport().firePropertyChange(PROPERTY_VALUE_AXIS_LABEL_FONT, old, this.valueAxisLabelFont);
  }
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.engine.base.JRBaseFont

Copyright © 2018 www.massapicom. 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.