/** * Compute the line height and add it to the page height. * @param line to be checked * @param currentPageHeight current page height without <code>line</code> * @return new page height */ private double updatePageHeight(String line, double currentPageHeight) { double lineHeigth = sizing.computeTextHeight(font, line, Double.MAX_VALUE); currentPageHeight += lineSpacing + lineHeigth; return currentPageHeight; }
double computeTextHeight(Font font, String text, double wrappingWidth) { return computeTextHeight(font, text, wrappingWidth, 0); }
/** * Calculate the dimensions of a string using the font with the number of characters. * The height and width are the maximum value, the width of a character is an average value. * @param size number of carachters for wich to calculate the dimensions * @param font to be used * @return dimensions of a String containing Tg to calculate the heigth and n for the width calculation. */ @Override public Dimension2D calculate(int size, Font font) { double height = computeTextHeight(font, "Tg", Double.MAX_VALUE); double width = computeTextWidth(font, "n", Double.MAX_VALUE); return new Dimension2D(width*size*.8, height*1.2); }
/** * Calculate the dimensions of a string using the font with the characters in the string. * The height and width are the maximum value. The text will not be wrapped. * @param text for which to calculate the dimensions * @param font to be used for the calculation * @return Bounding box for the text using font. */ @Override public Dimension2D calculate(String text, Font font) { double height = computeTextHeight(font, text, Double.MAX_VALUE); double width = computeTextWidth(font, text, Double.MAX_VALUE); return new Dimension2D(width, height*1.2); }