protected void generateBox(Writer writer, Tree parent) throws IOException { // draw the box in the background Rectangle2D.Double box = getBoundsOfNode(parent); writer.write(rect(""+box.x, ""+box.y, ""+box.width, ""+box.height, "fill:orange; stroke:rgb(0,0,0);", "rx=\"1\"")); // draw the text on top of the box (possibly multiple lines) String line = getText(parent).replace("<","<").replace(">",">"); int fontSize = 10; int x = (int) box.x + 2; int y = (int) box.y + fontSize - 1; String style = String.format("font-family:sans-serif;font-size:%dpx;", fontSize); writer.write(text(""+x, ""+y, style, line)); }
protected void generateBox(Writer writer, Tree parent) throws IOException { // draw the box in the background Rectangle2D.Double box = getBoundsOfNode(parent); writer.write(rect(""+box.x, ""+box.y, ""+box.width, ""+box.height, "fill:orange; stroke:rgb(0,0,0);", "rx=\"1\"")); // draw the text on top of the box (possibly multiple lines) String line = getText(parent).replace("<","<").replace(">",">"); int fontSize = 10; int x = (int) box.x + 2; int y = (int) box.y + fontSize - 1; String style = String.format("font-family:sans-serif;font-size:%dpx;", fontSize); writer.write(text(""+x, ""+y, style, line)); }
protected void generateBox(Writer writer, Tree parent) throws IOException { // draw the box in the background Rectangle2D.Double box = getBoundsOfNode(parent); writer.write(rect(""+box.x, ""+box.y, ""+box.width, ""+box.height, "fill:orange; stroke:rgb(0,0,0);", "rx=\"1\"")); // draw the text on top of the box (possibly multiple lines) String line = getText(parent).replace("<","<").replace(">",">"); int fontSize = 10; int x = (int) box.x + 2; int y = (int) box.y + fontSize - 1; String style = String.format("font-family:sans-serif;font-size:%dpx;", fontSize); writer.write(text(""+x, ""+y, style, line)); }
protected void generateEdges(Writer writer, Tree parent) throws IOException { if (!getTree().isLeaf(parent)) { Rectangle2D.Double b1 = getBoundsOfNode(parent); double x1 = b1.getCenterX(); double y1 = b1.getCenterY(); for (Tree child : getTree().getChildren(parent)) { Rectangle2D.Double childBounds = getBoundsOfNode(child); double x2 = childBounds.getCenterX(); double y2 = childBounds.getMinY(); writer.write(line(""+x1, ""+y1, ""+x2, ""+y2, "stroke:black; stroke-width:1px;")); generateEdges(writer, child); } } }
protected void paintBox(Graphics g, Tree tree) { Rectangle2D.Double box = getBoundsOfNode(tree);
protected void paintBox(Graphics g, Tree tree) { Rectangle2D.Double box = getBoundsOfNode(tree);
protected void generateEdges(Writer writer, Tree parent) throws IOException { if (!getTree().isLeaf(parent)) { Rectangle2D.Double b1 = getBoundsOfNode(parent); double x1 = b1.getCenterX(); double y1 = b1.getCenterY(); for (Tree child : getTree().getChildren(parent)) { Rectangle2D.Double childBounds = getBoundsOfNode(child); double x2 = childBounds.getCenterX(); double y2 = childBounds.getMinY(); writer.write(line(""+x1, ""+y1, ""+x2, ""+y2, "stroke:black; stroke-width:1px;")); generateEdges(writer, child); } } }
protected void generateEdges(Writer writer, Tree parent) throws IOException { if (!getTree().isLeaf(parent)) { Rectangle2D.Double b1 = getBoundsOfNode(parent); double x1 = b1.getCenterX(); double y1 = b1.getCenterY(); for (Tree child : getTree().getChildren(parent)) { Rectangle2D.Double childBounds = getBoundsOfNode(child); double x2 = childBounds.getCenterX(); double y2 = childBounds.getMinY(); writer.write(line(""+x1, ""+y1, ""+x2, ""+y2, "stroke:black; stroke-width:1px;")); generateEdges(writer, child); } } }
protected void paintBox(Graphics g, Tree tree) { Rectangle2D.Double box = getBoundsOfNode(tree);
protected void paintEdges(Graphics g, Tree parent) { if (!getTree().isLeaf(parent)) { BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); ((Graphics2D)g).setStroke(stroke); Rectangle2D.Double parentBounds = getBoundsOfNode(parent); double x1 = parentBounds.getCenterX(); double y1 = parentBounds.getMaxY(); for (Tree child : getTree().getChildren(parent)) { Rectangle2D.Double childBounds = getBoundsOfNode(child); double x2 = childBounds.getCenterX(); double y2 = childBounds.getMinY(); if (getUseCurvedEdges()) { CubicCurve2D c = new CubicCurve2D.Double(); double ctrlx1 = x1; double ctrly1 = (y1+y2)/2; double ctrlx2 = x2; double ctrly2 = y1; c.setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2); ((Graphics2D) g).draw(c); } else { g.drawLine((int) x1, (int) y1, (int) x2, (int) y2); } paintEdges(g, child); } } }
protected void paintBox(Graphics g, Tree tree) { Rectangle2D.Double box = getBoundsOfNode(tree);
protected void paintEdges(Graphics g, Tree parent) { if (!getTree().isLeaf(parent)) { BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); ((Graphics2D)g).setStroke(stroke); Rectangle2D.Double parentBounds = getBoundsOfNode(parent); double x1 = parentBounds.getCenterX(); double y1 = parentBounds.getMaxY(); for (Tree child : getTree().getChildren(parent)) { Rectangle2D.Double childBounds = getBoundsOfNode(child); double x2 = childBounds.getCenterX(); double y2 = childBounds.getMinY(); if (getUseCurvedEdges()) { CubicCurve2D c = new CubicCurve2D.Double(); double ctrlx1 = x1; double ctrly1 = (y1+y2)/2; double ctrlx2 = x2; double ctrly2 = y1; c.setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2); ((Graphics2D) g).draw(c); } else { g.drawLine((int) x1, (int) y1, (int) x2, (int) y2); } paintEdges(g, child); } } }
protected void paintEdges(Graphics g, Tree parent) { if (!getTree().isLeaf(parent)) { BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); ((Graphics2D)g).setStroke(stroke); Rectangle2D.Double parentBounds = getBoundsOfNode(parent); double x1 = parentBounds.getCenterX(); double y1 = parentBounds.getMaxY(); for (Tree child : getTree().getChildren(parent)) { Rectangle2D.Double childBounds = getBoundsOfNode(child); double x2 = childBounds.getCenterX(); double y2 = childBounds.getMinY(); if (getUseCurvedEdges()) { CubicCurve2D c = new CubicCurve2D.Double(); double ctrlx1 = x1; double ctrly1 = (y1+y2)/2; double ctrlx2 = x2; double ctrly2 = y1; c.setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2); ((Graphics2D) g).draw(c); } else { g.drawLine((int) x1, (int) y1, (int) x2, (int) y2); } paintEdges(g, child); } } }
protected void paintEdges(Graphics g, Tree parent) { if (!getTree().isLeaf(parent)) { BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); ((Graphics2D)g).setStroke(stroke); Rectangle2D.Double parentBounds = getBoundsOfNode(parent); double x1 = parentBounds.getCenterX(); double y1 = parentBounds.getMaxY(); for (Tree child : getTree().getChildren(parent)) { Rectangle2D.Double childBounds = getBoundsOfNode(child); double x2 = childBounds.getCenterX(); double y2 = childBounds.getMinY(); if (getUseCurvedEdges()) { CubicCurve2D c = new CubicCurve2D.Double(); double ctrlx1 = x1; double ctrly1 = (y1+y2)/2; double ctrlx2 = x2; double ctrly2 = y1; c.setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2); ((Graphics2D) g).draw(c); } else { g.drawLine((int) x1, (int) y1, (int) x2, (int) y2); } paintEdges(g, child); } } }