download PrintManager.java
Language: Java
License: LGPL
Copyright: (c) 1996-1999 Steve Lawson. E-Mail steve@e-i-s.co.uk Latest version can be
LOC: 61
Project Info
Jipe
Server: SourceForge
Type: cvs
...\j\jipe\jipe\jipe\src\jipe\
   BoxComment.java
   BrowserLauncher.java
   ClassBrowser.java
   ClassFilter.java
   DeleteLine.java
   Editor.java
   ExtensionFilter.java
   Find.java
   FindInFiles.java
   HelpConsole.java
   HtmlFilter.java
   IDEOptions.java
   JarFileManager.java
   JavaFilter.java
   JavaOptions.java
   Jipe.java
   JipeCodeCompleter.java
   JipeCompiler.java
   JipeConsole.java
   JipeDecompiler.java
   JipeMethodFinder.java
   JipeProjectManager.java
   JipeUtilities.java
   JSBeautifier.java
   JSFormatter.java
   JSLineBreaker.java
   JspFilter.java
   LeftIndent.java
   ListAllFiles.java
   MasterFilter.java
   Print.java
   PrintManager.java
   ProjectFilter.java
   PropertiesManager.java
   RemoveSpaces.java
   RightIndent.java
   SimpleComment.java
   SpecialFileFilters.java
   StatusBar.java
   StringParser.java
   TextFilter.java
   ToLowerCase.java
   ToUpperCase.java
   WingComment.java

/**
 * PrintManager.java - Printing class for use with the Jipe Project.  Copyright 
 * (c) 1996-1999 Steve Lawson.  E-Mail steve@e-i-s.co.uk Latest version can be 
 * found at http://e-i-s.co.uk/jipe
 * 
 * This library is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or (at your 
 * option) any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
 * License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License 
 * along with this library; if not, write to the Free Software Foundation, 
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 */
package jipe;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import javax.swing.*;


public class PrintManager extends JFrame
{

    BufferedReader br;
    StringReader sr;
    boolean PrintSwitch = true;
    String str = null;
    String textarea;
    public PrintManager(Frame parent, String text)
    {
        textarea = text;
        PrintJob pjob = getToolkit().getPrintJob(parent, "Printing", null);
        if (pjob != null)
        {
            Graphics pg = null;
            while (PrintSwitch == true)
            {
                pg = pjob.getGraphics();
                printPage(pg, pjob);
                if (str == null)
                    PrintSwitch = false;
                pg.dispose();                                // flush page
            }
            pjob.end();
        }
        dispose();
    }
    public void printPage(Graphics pg, PrintJob pj)
    {
        Dimension page_size = pj.getPageDimension();
        int width = page_size.width;
        int height = page_size.height;
        pg.setFont(new Font("Helvetica", Font.PLAIN, 10));
        FontMetrics metrics = pg.getFontMetrics();
        int line_height = metrics.getHeight() + metrics.getLeading();
        int line = 20;
        try
        {
            if (br == null)
            {
                sr = new StringReader(textarea);
                br = new BufferedReader(sr);
                str = "";
            }
            while (str != null && line <= (height - 20))
            {
                str = br.readLine();
                pg.drawString(str, 10, line);
                line += line_height;
            }
        }
        catch (Exception err)
        {
        }
    }
}

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us