public String getPS() { // generate the edges and boxes (with text) generateEdges(getTree().getRoot()); for (Tree node : treeLayout.getNodeBounds().keySet()) { generateNode(node); } Dimension size = treeLayout.getBounds().getBounds().getSize(); doc.boundingBox(size.width, size.height); doc.close(); return doc.getPS(); }
protected void generateNode(Tree t) { // draw the text on top of the box (possibly multiple lines) String[] lines = getText(t).split("\n"); Rectangle2D.Double box = getBoundsOfNode(t); // for debugging, turn this on to see boundingbox of nodes //doc.rect(box.x, box.y, box.width, box.height); // make error nodes from parse tree red by default if ( t instanceof ErrorNode ) { doc.highlight(box.x, box.y, box.width, box.height); } double x = box.x+nodeWidthPadding; double y = box.y+nodeHeightPaddingBelow; for (int i = 0; i < lines.length; i++) { doc.text(lines[i], x, y); y += doc.getLineHeight(); } }
@Override public double getWidth(Tree tree) { String s = getText(tree); return doc.getWidth(s) + nodeWidthPadding*2; }
@Override public double getHeight(Tree tree) { String s = getText(tree); double h = doc.getLineHeight() + nodeHeightPaddingAbove + nodeHeightPaddingBelow; String[] lines = s.split("\n"); return h * lines.length; } }
public TreePostScriptGenerator(List<String> ruleNames, Tree root, String fontName, int fontSize) { this.root = root; setTreeTextProvider(new TreeViewer.DefaultTreeTextProvider(ruleNames)); doc = new PostScriptDocument(fontName, fontSize); boolean compareNodeIdentities = true; this.treeLayout = new TreeLayout<Tree>(getTreeLayoutAdaptor(root), new VariableExtentProvide(), new DefaultConfiguration<Tree>(gapBetweenLevels, gapBetweenNodes, Configuration.Location.Bottom), compareNodeIdentities); }
public String getPS() { // generate the edges and boxes (with text) generateEdges(getTree().getRoot()); for (Tree node : treeLayout.getNodeBounds().keySet()) { generateNode(node); } Dimension size = treeLayout.getBounds().getBounds().getSize(); doc.boundingBox(size.width, size.height); doc.close(); return doc.getPS(); }
protected void generateNode(Tree t) { // draw the text on top of the box (possibly multiple lines) String[] lines = getText(t).split("\n"); Rectangle2D.Double box = getBoundsOfNode(t); // for debugging, turn this on to see boundingbox of nodes //doc.rect(box.x, box.y, box.width, box.height); // make error nodes from parse tree red by default if ( t instanceof ErrorNode ) { doc.highlight(box.x, box.y, box.width, box.height); } double x = box.x+nodeWidthPadding; double y = box.y+nodeHeightPaddingBelow; for (int i = 0; i < lines.length; i++) { doc.text(lines[i], x, y); y += doc.getLineHeight(); } }
@Override public double getWidth(Tree tree) { String s = getText(tree); return doc.getWidth(s) + nodeWidthPadding*2; }
@Override public double getHeight(Tree tree) { String s = getText(tree); double h = doc.getLineHeight() + nodeHeightPaddingAbove + nodeHeightPaddingBelow; String[] lines = s.split("\n"); return h * lines.length; } }
public TreePostScriptGenerator(List<String> ruleNames, Tree root, String fontName, int fontSize) { this.root = root; setTreeTextProvider(new TreeViewer.DefaultTreeTextProvider(ruleNames)); doc = new PostScriptDocument(fontName, fontSize); boolean compareNodeIdentities = true; this.treeLayout = new TreeLayout<Tree>(getTreeLayoutAdaptor(root), new VariableExtentProvide(), new DefaultConfiguration<Tree>(gapBetweenLevels, gapBetweenNodes, Configuration.Location.Bottom), compareNodeIdentities); }
public String getPS() { // generate the edges and boxes (with text) generateEdges(getTree().getRoot()); for (Tree node : treeLayout.getNodeBounds().keySet()) { generateNode(node); } Dimension size = treeLayout.getBounds().getBounds().getSize(); doc.boundingBox(size.width, size.height); doc.close(); return doc.getPS(); }
protected void generateNode(Tree t) { // draw the text on top of the box (possibly multiple lines) String[] lines = getText(t).split("\n"); Rectangle2D.Double box = getBoundsOfNode(t); // for debugging, turn this on to see boundingbox of nodes //doc.rect(box.x, box.y, box.width, box.height); // make error nodes from parse tree red by default if ( t instanceof ErrorNode ) { doc.highlight(box.x, box.y, box.width, box.height); } double x = box.x+nodeWidthPadding; double y = box.y+nodeHeightPaddingBelow; for (int i = 0; i < lines.length; i++) { doc.text(lines[i], x, y); y += doc.getLineHeight(); } }