[]
        
(Showing Draft Content)

IGraphicsInfo

Interface IGraphicsInfo


public interface IGraphicsInfo
Provides graphics measurement information required for workbook layout calculations.

Implement this interface when you need to provide custom text measurement information for workbook layout calculations.


 class CustomGraphicsInfo implements IGraphicsInfo {
     @Override
     public double getDigitWidth(TextFormatInfo textFormat) {
         if ("Calibri".equals(textFormat.getFontFamily())) {
             return 8 * textFormat.getFontSize() / 11;
         }
         return 7 * textFormat.getFontSize() / 11;
     }
 }
 IGraphicsInfo graphicsInfo = new CustomGraphicsInfo();
 workbook.setGraphicsInfo(graphicsInfo);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Gets the maximum width of the digits 0 through 9, in device-independent pixels.
  • Method Details

    • getDigitWidth

      double getDigitWidth(TextFormatInfo textFormat)
      Gets the maximum width of the digits 0 through 9, in device-independent pixels.

      Use this method in a custom IGraphicsInfo implementation to return the digit width used by workbook layout calculations for the supplied text format.

      
       IGraphicsInfo graphicsInfo = new IGraphicsInfo() {
           @Override
           public double getDigitWidth(TextFormatInfo textFormat) {
               if ("Calibri".equals(textFormat.getFontFamily())) {
                   return 8 * textFormat.getFontSize() / 11;
               }
               return 7 * textFormat.getFontSize() / 11;
           }
       };
       TextFormatInfo textFormat = new TextFormatInfo();
       textFormat.setFontFamily("Calibri");
       textFormat.setFontSize(11);
       double digitWidth = graphicsInfo.getDigitWidth(textFormat);
       
      Parameters:
      textFormat - The text format used to measure the digits.
      Returns:
      The maximum width of the digits 0 through 9, in device-independent pixels.