tweak
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9261]
This commit is contained in:
parent
3e03259ac0
commit
c17aab708f
|
@ -312,8 +312,14 @@ public class RuleContext implements ParseTree.RuleNode {
|
|||
public void save(BaseRecognizer parser, String fileName)
|
||||
throws IOException, PrintException
|
||||
{
|
||||
TreeViewer viewer = new TreeViewer(parser, this);
|
||||
viewer.save(fileName);
|
||||
Trees.writePS(this, parser, fileName);
|
||||
}
|
||||
|
||||
public void save(BaseRecognizer parser, String fileName,
|
||||
String fontName, int fontSize)
|
||||
throws IOException
|
||||
{
|
||||
Trees.writePS(this, parser, fileName, fontName, fontSize);
|
||||
}
|
||||
|
||||
/** Print out a whole tree, not just a node, in LISP format
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.tree;
|
|||
import org.antlr.v4.runtime.BaseRecognizer;
|
||||
import org.antlr.v4.runtime.tree.gui.TreeViewer;
|
||||
|
||||
import javax.print.PrintException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -262,10 +261,16 @@ public abstract class BaseAST implements AST {
|
|||
}
|
||||
|
||||
public void save(BaseRecognizer parser, String fileName)
|
||||
throws IOException, PrintException
|
||||
throws IOException
|
||||
{
|
||||
TreeViewer viewer = new TreeViewer(parser, this);
|
||||
viewer.save(fileName);
|
||||
Trees.writePS(this, parser, fileName);
|
||||
}
|
||||
|
||||
public void save(BaseRecognizer parser, String fileName,
|
||||
String fontName, int fontSize)
|
||||
throws IOException
|
||||
{
|
||||
Trees.writePS(this, parser, fileName, fontName, fontSize);
|
||||
}
|
||||
|
||||
/** Don't use standard tree printing mechanism since ASTs can have nil
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TreePostScriptGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
protected double gapBetweenLevels = 10;
|
||||
protected double gapBetweenLevels = 17;
|
||||
protected double gapBetweenNodes = 7;
|
||||
protected int nodeWidthPadding = 1; // added to left/right
|
||||
protected int nodeHeightPaddingAbove = 0;
|
||||
|
|
|
@ -34,15 +34,12 @@ import org.abego.treelayout.TreeForTreeLayout;
|
|||
import org.abego.treelayout.TreeLayout;
|
||||
import org.abego.treelayout.util.DefaultConfiguration;
|
||||
import org.antlr.v4.runtime.BaseRecognizer;
|
||||
import org.antlr.v4.runtime.misc.GraphicsSupport;
|
||||
import org.antlr.v4.runtime.tree.Tree;
|
||||
import org.antlr.v4.runtime.tree.Trees;
|
||||
|
||||
import javax.print.PrintException;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
|
@ -86,7 +83,7 @@ public class TreeViewer extends JComponent {
|
|||
protected TreeLayout<Tree> treeLayout;
|
||||
protected java.util.List<Tree> highlightedNodes;
|
||||
|
||||
protected String fontName = Font.SANS_SERIF;
|
||||
protected String fontName = "Helvetica"; //Font.SANS_SERIF;
|
||||
protected int fontStyle = Font.PLAIN;
|
||||
protected int fontSize = 11;
|
||||
protected Font font = new Font(fontName, fontStyle, fontSize);
|
||||
|
@ -164,6 +161,7 @@ public class TreeViewer extends JComponent {
|
|||
}
|
||||
|
||||
public void text(Graphics g, String s, int x, int y) {
|
||||
System.out.println("drawing '"+s+"' @ "+x+","+y);
|
||||
g.drawString(s, x, y);
|
||||
}
|
||||
|
||||
|
@ -172,9 +170,14 @@ public class TreeViewer extends JComponent {
|
|||
super.paint(g);
|
||||
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
// anti-alias the lines
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// Anti-alias the text
|
||||
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
|
||||
paintEdges(g, getTree().getRoot());
|
||||
|
||||
// paint the boxes
|
||||
|
@ -217,6 +220,7 @@ public class TreeViewer extends JComponent {
|
|||
showInDialog(this);
|
||||
}
|
||||
|
||||
/** This does not always seem to render the postscript properly
|
||||
public void save(String fileName) throws IOException, PrintException {
|
||||
JDialog dialog = new JDialog();
|
||||
Container contentPane = dialog.getContentPane();
|
||||
|
@ -230,6 +234,7 @@ public class TreeViewer extends JComponent {
|
|||
// dialog.setVisible(true);
|
||||
GraphicsSupport.saveImage(this, fileName);
|
||||
}
|
||||
*/
|
||||
|
||||
// ---------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue