<commit_before>//
// $Id$
// 
// viztool - a tool for visualizing collections of java classes
// Copyright (C) 2001 <NAME>
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2.1 of the License, or (at your
// option) any later version.
// 
// This program 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
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.samskivert.viztool;

import java.awt.*;
import java.awt.print.*;

import com.samskivert.swing.util.SwingUtil;
import com.samskivert.viztool.enum.*;

import com.samskivert.viztool.hierarchy.HierarchyVisualizer;
import com.samskivert.viztool.summary.SummaryVisualizer;
import com.samskivert.viztool.util.FontPicker;

/**
 * The application driver. This class parses the command line arguments
 * and invokes the visualization code.
 */
public class Driver
{
    public static void main (String[] args)
    {
        if (args.length < 1) {
            System.err.println(USAGE);
            System.exit(-1);
        }

        // parse our arguments
        String pkgroot = "";
        String regexp = null;
        boolean print = false;
        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("-print")) {
                print = true;
            } else if (regexp == null) {
                regexp = args[i];
            }
        }

        // run ourselves on the classpath
        String classpath = System.getProperty("java.class.path");
        // System.err.println("Scanning " + classpath + ".");
        ClassEnumerator enum = new ClassEnumerator(classpath);

        // print out the warnings
        ClassEnumerator.Warning[] warnings = enum.getWarnings();
        for (int i = 0; i < warnings.length; i++) {
            System.err.println("Warning: " + warnings[i].reason);
        }

        // initialize the font picker
        FontPicker.init(print);

        // and finally generate the visualization
        FilterEnumerator fenum = null;
        try {
            fenum = new RegexpEnumerator(regexp, enum);
        } catch  (Exception e) {
            Log.warning("Invalid package regular expression " +
                        "[regexp=" + regexp + ", error=" + e + "].");
            System.exit(-1);
        }

        // Visualizer viz = new HierarchyVisualizer(pkgroot, penum);
        Visualizer viz = new SummaryVisualizer(pkgroot, fenum);

        if (print) {
            // we use the print system to render things
            PrinterJob job = PrinterJob.getPrinterJob();

            // pop up a dialog to format our pages
            // PageFormat format = job.pageDialog(job.defaultPage());
            PageFormat format = job.defaultPage();

            // use sensible margins
            Paper paper = new Paper();
            paper.setImageableArea(72*0.5, 72*0.5, 72*7.5, 72*10);
            format.setPaper(paper);

            // use our configured page format
            job.setPrintable(viz, format);

            // pop up a dialog to control printing
            if (job.printDialog()) {
                try {
                    // invoke the printing process
                    job.print();
                } catch (PrinterException pe) {
                    pe.printStackTrace(System.err);
                }

            } else {
                Log.info("Printing cancelled.");
            }

            // printing starts up the AWT threads, so we have to
            // explicitly exit at this point
            System.exit(0);

        } else {
            VizFrame frame = new VizFrame(viz);
            frame.pack();
            SwingUtil.centerWindow(frame);
            frame.setVisible(true);
        }
    }

    protected static final String USAGE =
        "Usage: Driver [-mode hier|sum] [-print] package_regexp " +
        "[package_root]\n" +
        "       hier = class hierarchy visualization\n" +
        "       sum = class summary visualization\n"
        ;
}
<commit_msg>Added ability to generate postscript output file.<commit_after>//
// $Id$
// 
// viztool - a tool for visualizing collections of java classes
// Copyright (C) 2001 <NAME>
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2.1 of the License, or (at your
// option) any later version.
// 
// This program 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
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.samskivert.viztool;

import java.awt.*;
import java.awt.print.*;
import java.util.ArrayList;

import com.samskivert.swing.util.SwingUtil;
import com.samskivert.viztool.enum.*;

import com.samskivert.viztool.hierarchy.HierarchyVisualizer;
import com.samskivert.viztool.summary.SummaryVisualizer;
import com.samskivert.viztool.util.FontPicker;

/**
 * The application driver. This class parses the command line arguments
 * and invokes the visualization code.
 */
public class Driver
{
    public static void main (String[] args)
    {
        if (args.length < 1) {
            System.err.println(USAGE);
            System.exit(-1);
        }

        // parse our arguments
        String pkgroot = "";
        String regexp = null;
        boolean print = false;
        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("-print")) {
                print = true;
            } else if (regexp == null) {
                regexp = args[i];
            }
        }

        // run ourselves on the classpath
        String classpath = System.getProperty("java.class.path");
        // System.err.println("Scanning " + classpath + ".");
        ClassEnumerator enum = new ClassEnumerator(classpath);

        // print out the warnings
        ClassEnumerator.Warning[] warnings = enum.getWarnings();
        for (int i = 0; i < warnings.length; i++) {
            System.err.println("Warning: " + warnings[i].reason);
        }

        // initialize the font picker
        FontPicker.init(print);

        // and finally generate the visualization
        FilterEnumerator fenum = null;
        try {
            fenum = new RegexpEnumerator(regexp, enum);
        } catch  (Exception e) {
            Log.warning("Invalid package regular expression " +
                        "[regexp=" + regexp + ", error=" + e + "].");
            System.exit(-1);
        }

        ArrayList classes = new ArrayList();
        while (fenum.hasNext()) {
            String cname = (String)fenum.next();
            // skip inner classes, the visualizations pick those up
            // themselves
            if (cname.indexOf("$") != -1) {
                continue;
            }
            try {
                classes.add(Class.forName(cname));
            } catch (Throwable t) {
                Log.warning("Unable to introspect class [class=" + cname +
                            ", error=" + t + "].");
            }
        }

        // Visualizer viz = new HierarchyVisualizer(pkgroot, penum);
        Visualizer viz = new SummaryVisualizer();
        viz.setPackageRoot(pkgroot);
        viz.setClasses(classes.iterator());

        if (print) {
            // we use the print system to render things
            PrinterJob job = PrinterJob.getPrinterJob();

            // pop up a dialog to format our pages
            // PageFormat format = job.pageDialog(job.defaultPage());
            PageFormat format = job.defaultPage();

            // use sensible margins
            Paper paper = new Paper();
            paper.setImageableArea(72*0.5, 72*0.5, 72*7.5, 72*10);
            format.setPaper(paper);

            // use our configured page format
            job.setPrintable(viz, format);

            // pop up a dialog to control printing
            if (job.printDialog()) {
                try {
                    // invoke the printing process
                    job.print();
                } catch (PrinterException pe) {
                    pe.printStackTrace(System.err);
                }

            } else {
                Log.info("Printing cancelled.");
            }

            // printing starts up the AWT threads, so we have to
            // explicitly exit at this point
            System.exit(0);

        } else {
            VizFrame frame = new VizFrame(viz);
            frame.pack();
            SwingUtil.centerWindow(frame);
            frame.setVisible(true);
        }
    }

    protected static final String USAGE =
        "Usage: Driver [-mode hier|sum] [-print] package_regexp " +
        "[package_root]\n" +
        "       hier = class hierarchy visualization\n" +
        "       sum = class summary visualization\n"
        ;
}

{'fraction_non_alphanumeric': 0.10463409519815475, 'fraction_numerical': 0.00891172153491298, 'mean_word_length': 1.8398332837153915, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3423390', 'n_tokens_mistral': 2602, 'n_tokens_neox': 2491, 'n_words': 810}