Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVG public API and xml entity handling #4521

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion tool/src/org/antlr/v4/gui/TreeViewer.java
Expand Up @@ -273,7 +273,7 @@ protected void generateBox(Writer writer, Tree parent) throws IOException {
"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("<","&lt;").replace(">","&gt;");
String line = getText(parent).replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("\"","&quot;").replace("'","&apos;");
int fontSize = 10;
int x = (int) box.x + 2;
int y = (int) box.y + fontSize - 1;
Expand Down Expand Up @@ -588,6 +588,14 @@ private static void generateSVGFile(TreeViewer viewer, JFrame dialog) {
}
}

public void toSVG(Writer writer) throws IOException {
writer.write("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">");
paintSVG(writer);
writer.write("</svg>");
writer.flush();
writer.close();
}

private static File generateNonExistingFile(String extension) {

final String parent = ".";
Expand Down