fixes to accomodate default PDF output; no API changes for now

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3413 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2009-04-03 19:08:50 +00:00
parent 98c651fee4
commit 50a19ca3f9
2 changed files with 33 additions and 22 deletions

View File

@ -20,7 +20,6 @@ import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.graph.Graph; import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.graph.InferGraphRoots; import com.ibm.wala.util.graph.InferGraphRoots;
import com.ibm.wala.util.warnings.WalaException; import com.ibm.wala.util.warnings.WalaException;
import com.ibm.wala.viz.DotUtil.DotOutputType;
/** /**
* Explore the result of an IFDS problem with an SWT viewer and ghostview. * Explore the result of an IFDS problem with an SWT viewer and ghostview.
@ -33,16 +32,16 @@ public class IFDSExplorer {
protected static String dotExe = null; protected static String dotExe = null;
/** /**
* Absolute path name to invoke ghostview * Absolute path name to invoke viewer
*/ */
protected static String gvExe = null; protected static String viewerExe = null;
public static void setDotExe(String newDotExe) { public static void setDotExe(String newDotExe) {
dotExe = newDotExe; dotExe = newDotExe;
} }
public static void setGvExe(String newGvExe) { public static void setGvExe(String newGvExe) {
gvExe = newGvExe; viewerExe = newGvExe;
} }
public static <T, P, F> void viewIFDS(TabulationResult<T, P, F> r, Collection<? extends P> roots) throws WalaException { public static <T, P, F> void viewIFDS(TabulationResult<T, P, F> r, Collection<? extends P> roots) throws WalaException {
@ -72,7 +71,19 @@ public class IFDSExplorer {
// dump the domain to stderr // dump the domain to stderr
System.err.println("Domain:\n" + r.getProblem().getDomain().toString()); System.err.println("Domain:\n" + r.getProblem().getDomain().toString());
String outputFile = scratchDirectory + File.separatorChar + (DotUtil.getOutputType() == DotOutputType.PS ? "ir.ps" : "ir.svg"); String irFileName = null;
switch (DotUtil.getOutputType()) {
case PDF:
irFileName = "ir.pdf";
break;
case PS:
irFileName = "ir.ps";
break;
case SVG:
irFileName = "ir.svg";
break;
}
String outputFile = scratchDirectory + File.separatorChar + irFileName;
String dotFile = scratchDirectory + File.separatorChar + "ir.dt"; String dotFile = scratchDirectory + File.separatorChar + "ir.dt";
final SWTTreeViewer v = new SWTTreeViewer(); final SWTTreeViewer v = new SWTTreeViewer();
@ -81,7 +92,7 @@ public class IFDSExplorer {
v.setBlockInput(true); v.setBlockInput(true);
v.setRootsInput(roots); v.setRootsInput(roots);
ViewIFDSLocalAction<T, P, F> action = (labels == null ? new ViewIFDSLocalAction<T, P, F>(v, r, outputFile, dotFile, dotExe, ViewIFDSLocalAction<T, P, F> action = (labels == null ? new ViewIFDSLocalAction<T, P, F>(v, r, outputFile, dotFile, dotExe,
gvExe) : new ViewIFDSLocalAction<T, P, F>(v, r, outputFile, dotFile, dotExe, gvExe, labels)); viewerExe) : new ViewIFDSLocalAction<T, P, F>(v, r, outputFile, dotFile, dotExe, viewerExe, labels));
v.getPopUpActions().add(action); v.getPopUpActions().add(action);
v.run(); v.run();
@ -103,7 +114,7 @@ public class IFDSExplorer {
} }
public static String getGvExe() { public static String getGvExe() {
return gvExe; return viewerExe;
} }
} }

View File

@ -47,9 +47,9 @@ public class ViewIFDSLocalAction<T, P, F> extends Action {
private final ISupergraph<T, P> supergraph; private final ISupergraph<T, P> supergraph;
/** /**
* name of postscript file to generate * name of PDF file to generate
*/ */
private final String psFile; private final String pdfFile;
/** /**
* name of dot file to generate * name of dot file to generate
@ -62,23 +62,23 @@ public class ViewIFDSLocalAction<T, P, F> extends Action {
private final String dotExe; private final String dotExe;
/** /**
* path to ghostview executable * path to pdf view executable
*/ */
private final String gvExe; private final String pdfViewExe;
private final NodeDecorator labels; private final NodeDecorator labels;
public ViewIFDSLocalAction(SWTTreeViewer viewer, TabulationResult<T, P, F> result, String psFile, String dotFile, String dotExe, public ViewIFDSLocalAction(SWTTreeViewer viewer, TabulationResult<T, P, F> result, String pdfFile, String dotFile, String dotExe,
String gvExe, NodeDecorator labels) { String pdfViewExe, NodeDecorator labels) {
if (result == null) { if (result == null) {
throw new IllegalArgumentException("null result"); throw new IllegalArgumentException("null result");
} }
this.viewer = viewer; this.viewer = viewer;
this.supergraph = result.getProblem().getSupergraph(); this.supergraph = result.getProblem().getSupergraph();
this.psFile = psFile; this.pdfFile = pdfFile;
this.dotFile = dotFile; this.dotFile = dotFile;
this.dotExe = dotExe; this.dotExe = dotExe;
this.gvExe = gvExe; this.pdfViewExe = pdfViewExe;
this.labels = labels; this.labels = labels;
setText("View Local Supergraph"); setText("View Local Supergraph");
} }
@ -90,10 +90,10 @@ public class ViewIFDSLocalAction<T, P, F> extends Action {
} }
this.viewer = viewer; this.viewer = viewer;
this.supergraph = result.getProblem().getSupergraph(); this.supergraph = result.getProblem().getSupergraph();
this.psFile = psFile; this.pdfFile = psFile;
this.dotFile = dotFile; this.dotFile = dotFile;
this.dotExe = dotExe; this.dotExe = dotExe;
this.gvExe = gvExe; this.pdfViewExe = gvExe;
this.labels = new Labels<T, P, F>(result); this.labels = new Labels<T, P, F>(result);
setText("View Local Supergraph"); setText("View Local Supergraph");
} }
@ -181,10 +181,10 @@ public class ViewIFDSLocalAction<T, P, F> extends Action {
// spawn the viewer // spawn the viewer
System.err.println("Spawn Viewer for " + proc); System.err.println("Spawn Viewer for " + proc);
DotUtil.dotify(localGraph, labels, dotFile, psFile, dotExe); DotUtil.dotify(localGraph, labels, dotFile, pdfFile, dotExe);
if (DotUtil.getOutputType() == DotUtil.DotOutputType.PS) { if (DotUtil.getOutputType() == DotUtil.DotOutputType.PDF) {
PDFViewUtil.launchPDFView(psFile, gvExe); PDFViewUtil.launchPDFView(pdfFile, pdfViewExe);
} }
} catch (WalaException e) { } catch (WalaException e) {
e.printStackTrace(); e.printStackTrace();
@ -221,10 +221,10 @@ public class ViewIFDSLocalAction<T, P, F> extends Action {
} }
protected String getGvExe() { protected String getGvExe() {
return gvExe; return pdfViewExe;
} }
protected String getPsFile() { protected String getPsFile() {
return psFile; return pdfFile;
} }
} }