Class PlainTextPage

  • public class PlainTextPage
    extends Object
    The plain text page is used to buffer a complete page and to write the buffered data when the page is closed.
    Thomas Morgner
    • Constructor Detail

      • PlainTextPage

        public PlainTextPage​(Paper pageFormat,
                             PrinterDriver driver,
                             String defaultEncoding)
        Creates a new PlainTextPage with the given dimensions and the specified PrinterCommandSet.
        driver - the command-set for printing and formatting the text.
    • Method Detail

      • correctedDivisionFloor

        public static int correctedDivisionFloor​(double c,
                                                 double d)
        Fixes some floating point errors when calculating positions.
        c - the divisor
        d - the dividend
        the corrected division result.
      • getWidth

        public int getWidth()
        Returns the page width in characters.
        the page width.
      • getHeight

        public int getHeight()
        Returns the page height in lines.
        the page height.
      • addTextChunk

        public void addTextChunk​(int x,
                                 int y,
                                 int w,
                                 String text,
                                 StyleSheet format)
        Adds a new text chunk to this PlainTextPage. A chunk consists of a single line of text.
        x - the column of the first character of the text
        y - the row where to print the text
        w - the number of characters to print.
        text - the text that should be printed.
        format - the font definition used to format the text.
      • writePage

        public void writePage()
                       throws IOException
        Writes the contents of the page using the printer command set.
        IOException - if an I/O error occured while writing the page.