forked from jasder/antlr
use Horstmann's PS save not mine; it'll handle Japanese char etc.. this way.
This commit is contained in:
parent
96654531b7
commit
47362b2951
|
@ -268,15 +268,17 @@ public class RuleContext implements ParseTree.RuleNode {
|
||||||
public void save(Parser parser, String fileName)
|
public void save(Parser parser, String fileName)
|
||||||
throws IOException, PrintException
|
throws IOException, PrintException
|
||||||
{
|
{
|
||||||
Trees.writePS(this, parser, fileName);
|
TreeViewer viewer = new TreeViewer(parser, this);
|
||||||
|
viewer.save(fileName);
|
||||||
|
// Trees.writePS(this, parser, fileName); // parrt routine
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(Parser parser, String fileName,
|
// public void save(Parser parser, String fileName,
|
||||||
String fontName, int fontSize)
|
// String fontName, int fontSize)
|
||||||
throws IOException
|
// throws IOException
|
||||||
{
|
// {
|
||||||
Trees.writePS(this, parser, fileName, fontName, fontSize);
|
// Trees.writePS(this, parser, fileName, fontName, fontSize);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/** Print out a whole tree, not just a node, in LISP format
|
/** Print out a whole tree, not just a node, in LISP format
|
||||||
* (root child1 .. childN). Print just a node if this is a leaf.
|
* (root child1 .. childN). Print just a node if this is a leaf.
|
||||||
|
|
|
@ -30,7 +30,12 @@
|
||||||
package org.antlr.v4.runtime.misc;
|
package org.antlr.v4.runtime.misc;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.print.*;
|
import javax.print.DocFlavor;
|
||||||
|
import javax.print.DocPrintJob;
|
||||||
|
import javax.print.PrintException;
|
||||||
|
import javax.print.PrintService;
|
||||||
|
import javax.print.SimpleDoc;
|
||||||
|
import javax.print.StreamPrintServiceFactory;
|
||||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||||
import javax.print.attribute.PrintRequestAttributeSet;
|
import javax.print.attribute.PrintRequestAttributeSet;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -105,6 +110,7 @@ public class GraphicsSupport {
|
||||||
job.print(doc, attributes);
|
job.print(doc, attributes);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// parrt: doesn't seem to do .pdf. 0-length file generated
|
||||||
Rectangle rect = comp.getBounds();
|
Rectangle rect = comp.getBounds();
|
||||||
BufferedImage image = new BufferedImage(rect.width, rect.height,
|
BufferedImage image = new BufferedImage(rect.width, rect.height,
|
||||||
BufferedImage.TYPE_INT_RGB);
|
BufferedImage.TYPE_INT_RGB);
|
||||||
|
|
|
@ -34,11 +34,13 @@ import org.abego.treelayout.TreeForTreeLayout;
|
||||||
import org.abego.treelayout.TreeLayout;
|
import org.abego.treelayout.TreeLayout;
|
||||||
import org.abego.treelayout.util.DefaultConfiguration;
|
import org.abego.treelayout.util.DefaultConfiguration;
|
||||||
import org.antlr.v4.runtime.Parser;
|
import org.antlr.v4.runtime.Parser;
|
||||||
|
import org.antlr.v4.runtime.misc.GraphicsSupport;
|
||||||
import org.antlr.v4.runtime.misc.Utils;
|
import org.antlr.v4.runtime.misc.Utils;
|
||||||
import org.antlr.v4.runtime.tree.ParseTree;
|
import org.antlr.v4.runtime.tree.ParseTree;
|
||||||
import org.antlr.v4.runtime.tree.Tree;
|
import org.antlr.v4.runtime.tree.Tree;
|
||||||
import org.antlr.v4.runtime.tree.Trees;
|
import org.antlr.v4.runtime.tree.Trees;
|
||||||
|
|
||||||
|
import javax.print.PrintException;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
|
@ -47,6 +49,7 @@ import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.geom.CubicCurve2D;
|
import java.awt.geom.CubicCurve2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@ -324,7 +327,6 @@ public class TreeViewer extends JComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This does not always seem to render the postscript properly
|
|
||||||
public void save(String fileName) throws IOException, PrintException {
|
public void save(String fileName) throws IOException, PrintException {
|
||||||
JDialog dialog = new JDialog();
|
JDialog dialog = new JDialog();
|
||||||
Container contentPane = dialog.getContentPane();
|
Container contentPane = dialog.getContentPane();
|
||||||
|
@ -335,10 +337,8 @@ public class TreeViewer extends JComponent {
|
||||||
dialog.pack();
|
dialog.pack();
|
||||||
dialog.setLocationRelativeTo(null);
|
dialog.setLocationRelativeTo(null);
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
// dialog.setVisible(true);
|
|
||||||
GraphicsSupport.saveImage(this, fileName);
|
GraphicsSupport.saveImage(this, fileName);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// ---------------------------------------------------
|
// ---------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue