@Test public void dotImport() { Shell shell = new Shell(); DotImport importer = new DotImport("digraph Sample{1;2;1->2}"); Graph graph = importer.newGraphInstance(shell, SWT.NONE); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertEquals(ZestStyles.CONNECTIONS_DIRECTED, graph.getConnectionStyle()); // open(shell); }
@Test public void minimalUsage() { Shell shell = new Shell(); /* The DOT input, can be given as a String, File or IFile: */ DotImport dotImport = new DotImport("digraph Simple { 1;2; 1->2 }"); /* Create a Zest graph instance in a parent, with a style: */ Graph graph = dotImport.newGraphInstance(shell, SWT.NONE); // open(shell); // sets title, layout, and size, opens the shell System.out.println(graph); }
/** * {@inheritDoc} * * @see org.eclipse.zest.dot.IGraphCreator#create(org.eclipse.swt.widgets.Composite, int) */ public Graph create(final Composite parent, final int style, final String dot) { /* * The trick we use to avoid nasty classloader trouble when reloading * newer versions of the same class: we give each generated class a * unique name (as this is unused, it has been removed from the API): */ DotImport dotImport = new DotImport(dot /*, System.currentTimeMillis() + ""*/); File zestFile = dotImport.newGraphSubclass(); URL outputDirUrl = compileWithJavaCompiler(zestFile, dotImport.getName()); Graph graph = ExperimentalDotImport.loadGraph(dotImport.getName(), outputDirUrl, parent, style); return graph; }