@Test public void execute() throws Exception { DiagramGeneratorMojo mojo = new DiagramGeneratorMojo(); File input = new File(getClass().getResource("/spring/").getFile()); mojo.setInput(input.getPath()); mojo.setOutput(input.getParentFile().getParentFile()); mojo.setType("camel"); mojo.setFileType("xml"); mojo.setFormat("png"); mojo.setWidth(480); mojo.setHeight(640); mojo.setView(false); mojo.execute(); assertTrue(new File(mojo.getOutput(), "camel.png").exists()); }
@Override public void execute() throws MojoExecutionException, MojoFailureException { final Loader loader = LoaderHelper.getLoader(type); final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); final ClassLoader cl = classloader(); Thread.currentThread().setContextClassLoader(cl); try { final List<Diagram> diagrams = loader.load(input, FileType.valueOf(fileType.toUpperCase())); for (Diagram diagram : diagrams) { final Dimension outputSize = new Dimension(width, height); final LevelLayout layout = new LevelLayout(diagram); final VisualizationViewer<Node, Edge> viewer = new GraphViewer(layout); layout.setVertexShapeTransformer(viewer.getRenderContext().getVertexShapeTransformer()); layout.setSize(outputSize); layout.setIgnoreSize(adjust); layout.reset(); viewer.setPreferredSize(layout.getSize()); viewer.setSize(layout.getSize()); final JFrame window = createWindow(viewer, diagram.getName()); if (!output.exists()) { output.mkdirs(); } saveView(layout.getSize(), outputSize, diagram.getName(), viewer); if (view) { CountDownLatch latch = new CountDownLatch(1); CloseWindowWaiter waiter = new CloseWindowWaiter(latch); window.setVisible(true); window.addWindowListener(waiter); try { latch.await(); } catch (InterruptedException e) { getLog().error("can't await window close event", e); } } else { window.dispose(); } } } finally { Thread.currentThread().setContextClassLoader(oldCl); } }
DiagramGeneratorMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { final Loader loader = LoaderHelper.getLoader(type); final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); final ClassLoader cl = classloader(); Thread.currentThread().setContextClassLoader(cl); try { final List<Diagram> diagrams = loader.load(input, FileType.valueOf(fileType.toUpperCase())); for (Diagram diagram : diagrams) { final Dimension outputSize = new Dimension(width, height); final LevelLayout layout = new LevelLayout(diagram); final VisualizationViewer<Node, Edge> viewer = new GraphViewer(layout); layout.setVertexShapeTransformer(viewer.getRenderContext().getVertexShapeTransformer()); layout.setSize(outputSize); layout.setIgnoreSize(adjust); layout.reset(); viewer.setPreferredSize(layout.getSize()); viewer.setSize(layout.getSize()); final JFrame window = createWindow(viewer, diagram.getName()); if (!output.exists()) { output.mkdirs(); } saveView(layout.getSize(), outputSize, diagram.getName(), viewer); if (view) { CountDownLatch latch = new CountDownLatch(1); CloseWindowWaiter waiter = new CloseWindowWaiter(latch); window.setVisible(true); window.addWindowListener(waiter); try { latch.await(); } catch (InterruptedException e) { getLog().error("can't await window close event", e); } } else { window.dispose(); } } } finally { Thread.currentThread().setContextClassLoader(oldCl); } } }
DiagramGeneratorMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { final Loader loader = LoaderHelper.getLoader(type); final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); final ClassLoader cl = classloader(); Thread.currentThread().setContextClassLoader(cl); try { final List<Diagram> diagrams = loader.load(input, FileType.valueOf(fileType.toUpperCase())); for (Diagram diagram : diagrams) { final Dimension outputSize = new Dimension(width, height); final LevelLayout layout = new LevelLayout(diagram); final VisualizationViewer<Node, Edge> viewer = new GraphViewer(layout); layout.setVertexShapeTransformer(viewer.getRenderContext().getVertexShapeTransformer()); layout.setSize(outputSize); layout.setIgnoreSize(adjust); layout.reset(); viewer.setPreferredSize(layout.getSize()); viewer.setSize(layout.getSize()); final JFrame window = createWindow(viewer, diagram.getName()); if (!output.exists()) { output.mkdirs(); } saveView(layout.getSize(), outputSize, diagram.getName(), viewer); if (view) { CountDownLatch latch = new CountDownLatch(1); CloseWindowWaiter waiter = new CloseWindowWaiter(latch); window.setVisible(true); window.addWindowListener(waiter); try { latch.await(); } catch (InterruptedException e) { getLog().error("can't await window close event", e); } } else { window.dispose(); } } } finally { Thread.currentThread().setContextClassLoader(oldCl); } }  }
DiagramGeneratorMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { final Loader loader = LoaderHelper.getLoader(type); final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); final ClassLoader cl = classloader(); Thread.currentThread().setContextClassLoader(cl); try { final List<Diagram> diagrams = loader.load(input, FileType.valueOf(fileType.toUpperCase())); for (Diagram diagram : diagrams) { final Dimension outputSize = new Dimension(width, height); final LevelLayout layout = new LevelLayout(diagram); final VisualizationViewer<Node, Edge> viewer = new GraphViewer(layout); layout.setVertexShapeTransformer(viewer.getRenderContext().getVertexShapeTransformer()); layout.setSize(outputSize); layout.setIgnoreSize(adjust); layout.reset(); viewer.setPreferredSize(layout.getSize()); viewer.setSize(layout.getSize()); final JFrame window = createWindow(viewer, diagram.getName()); if (!output.exists()) { output.mkdirs(); } saveView(layout.getSize(), outputSize, diagram.getName(), viewer); if (view) { CountDownLatch latch = new CountDownLatch(1); CloseWindowWaiter waiter = new CloseWindowWaiter(latch); window.setVisible(true); window.addWindowListener(waiter); try { latch.await(); } catch (InterruptedException e) { getLog().error("can't await window close event", e); } } else { window.dispose(); } } } finally { Thread.currentThread().setContextClassLoader(oldCl); } }  @Override void execute(); List<String> getAdditionalClasspathElements(); void setAdditionalClasspathElements(List<String> additionalClasspathElements); String getInput(); void setInput(String input); File getOutput(); void setOutput(File output); String getType(); void setType(String type); String getFileType(); void setFileType(String fileType); String getFormat(); void setFormat(String format); int getWidth(); void setWidth(int width); int getHeight(); void setHeight(int height); boolean isView(); void setView(boolean view); boolean getAdjust(); void setAdjust(boolean adjust); }
DiagramGeneratorMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { final Loader loader = LoaderHelper.getLoader(type); final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); final ClassLoader cl = classloader(); Thread.currentThread().setContextClassLoader(cl); try { final List<Diagram> diagrams = loader.load(input, FileType.valueOf(fileType.toUpperCase())); for (Diagram diagram : diagrams) { final Dimension outputSize = new Dimension(width, height); final LevelLayout layout = new LevelLayout(diagram); final VisualizationViewer<Node, Edge> viewer = new GraphViewer(layout); layout.setVertexShapeTransformer(viewer.getRenderContext().getVertexShapeTransformer()); layout.setSize(outputSize); layout.setIgnoreSize(adjust); layout.reset(); viewer.setPreferredSize(layout.getSize()); viewer.setSize(layout.getSize()); final JFrame window = createWindow(viewer, diagram.getName()); if (!output.exists()) { output.mkdirs(); } saveView(layout.getSize(), outputSize, diagram.getName(), viewer); if (view) { CountDownLatch latch = new CountDownLatch(1); CloseWindowWaiter waiter = new CloseWindowWaiter(latch); window.setVisible(true); window.addWindowListener(waiter); try { latch.await(); } catch (InterruptedException e) { getLog().error("can't await window close event", e); } } else { window.dispose(); } } } finally { Thread.currentThread().setContextClassLoader(oldCl); } }  @Override void execute(); List<String> getAdditionalClasspathElements(); void setAdditionalClasspathElements(List<String> additionalClasspathElements); String getInput(); void setInput(String input); File getOutput(); void setOutput(File output); String getType(); void setType(String type); String getFileType(); void setFileType(String fileType); String getFormat(); void setFormat(String format); int getWidth(); void setWidth(int width); int getHeight(); void setHeight(int height); boolean isView(); void setView(boolean view); boolean getAdjust(); void setAdjust(boolean adjust);  }