@Test public void smoke() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); writer.writeTo(graph, Graph.class, null, null, CustomMediaTypes.IMAGE_PNG_TYPE, null, os); String image = new String(os.toByteArray(), Charsets.UTF_8); assertThat(image, is(notNullValue())); }
@Override public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException { Integer width = Integer.parseInt(Optional.ofNullable(request.getParameter("width")).orElse(DEFAULT_WIDTH)); Integer height = Integer.parseInt(Optional.ofNullable(request.getParameter("height")).orElse(DEFAULT_HEIGHT)); String layoutName = Optional.ofNullable(request.getParameter("layout")).orElse(DEFAULT_LAYOUT); GraphJung<Graph> graph = new GraphJung<Graph>(data); AbstractLayout<Vertex, Edge> layout = getLayout(graph, layoutName); layout.setSize(new Dimension(width, height)); BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<>(layout); viz.setPreferredSize(new Dimension(width, height)); viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer); viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); viz.getRenderContext().setVertexFillPaintTransformer(vertexColorTransformer); BufferedImage bi = renderImage(viz); String imageType = null; if (mediaType.equals(CustomMediaTypes.IMAGE_JPEG_TYPE)) { imageType = "jpg"; } else if (mediaType.equals(CustomMediaTypes.IMAGE_PNG_TYPE)) { imageType = "png"; } ImageIO.write(bi, imageType, out); }
ImageWriter extends GraphWriter { @Override public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException { Integer width = Integer.parseInt(Optional.ofNullable(request.getParameter("width")).orElse(DEFAULT_WIDTH)); Integer height = Integer.parseInt(Optional.ofNullable(request.getParameter("height")).orElse(DEFAULT_HEIGHT)); String layoutName = Optional.ofNullable(request.getParameter("layout")).orElse(DEFAULT_LAYOUT); GraphJung<Graph> graph = new GraphJung<Graph>(data); AbstractLayout<Vertex, Edge> layout = getLayout(graph, layoutName); layout.setSize(new Dimension(width, height)); BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<>(layout); viz.setPreferredSize(new Dimension(width, height)); viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer); viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); viz.getRenderContext().setVertexFillPaintTransformer(vertexColorTransformer); BufferedImage bi = renderImage(viz); String imageType = null; if (mediaType.equals(CustomMediaTypes.IMAGE_JPEG_TYPE)) { imageType = "jpg"; } else if (mediaType.equals(CustomMediaTypes.IMAGE_PNG_TYPE)) { imageType = "png"; } ImageIO.write(bi, imageType, out); } }
ImageWriter extends GraphWriter { @Override public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException { Integer width = Integer.parseInt(Optional.ofNullable(request.getParameter("width")).orElse(DEFAULT_WIDTH)); Integer height = Integer.parseInt(Optional.ofNullable(request.getParameter("height")).orElse(DEFAULT_HEIGHT)); String layoutName = Optional.ofNullable(request.getParameter("layout")).orElse(DEFAULT_LAYOUT); GraphJung<Graph> graph = new GraphJung<Graph>(data); AbstractLayout<Vertex, Edge> layout = getLayout(graph, layoutName); layout.setSize(new Dimension(width, height)); BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<>(layout); viz.setPreferredSize(new Dimension(width, height)); viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer); viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); viz.getRenderContext().setVertexFillPaintTransformer(vertexColorTransformer); BufferedImage bi = renderImage(viz); String imageType = null; if (mediaType.equals(CustomMediaTypes.IMAGE_JPEG_TYPE)) { imageType = "jpg"; } else if (mediaType.equals(CustomMediaTypes.IMAGE_PNG_TYPE)) { imageType = "png"; } ImageIO.write(bi, imageType, out); }  }
ImageWriter extends GraphWriter { @Override public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException { Integer width = Integer.parseInt(Optional.ofNullable(request.getParameter("width")).orElse(DEFAULT_WIDTH)); Integer height = Integer.parseInt(Optional.ofNullable(request.getParameter("height")).orElse(DEFAULT_HEIGHT)); String layoutName = Optional.ofNullable(request.getParameter("layout")).orElse(DEFAULT_LAYOUT); GraphJung<Graph> graph = new GraphJung<Graph>(data); AbstractLayout<Vertex, Edge> layout = getLayout(graph, layoutName); layout.setSize(new Dimension(width, height)); BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<>(layout); viz.setPreferredSize(new Dimension(width, height)); viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer); viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); viz.getRenderContext().setVertexFillPaintTransformer(vertexColorTransformer); BufferedImage bi = renderImage(viz); String imageType = null; if (mediaType.equals(CustomMediaTypes.IMAGE_JPEG_TYPE)) { imageType = "jpg"; } else if (mediaType.equals(CustomMediaTypes.IMAGE_PNG_TYPE)) { imageType = "png"; } ImageIO.write(bi, imageType, out); }  @Override void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations,
      MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out); }
ImageWriter extends GraphWriter { @Override public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException { Integer width = Integer.parseInt(Optional.ofNullable(request.getParameter("width")).orElse(DEFAULT_WIDTH)); Integer height = Integer.parseInt(Optional.ofNullable(request.getParameter("height")).orElse(DEFAULT_HEIGHT)); String layoutName = Optional.ofNullable(request.getParameter("layout")).orElse(DEFAULT_LAYOUT); GraphJung<Graph> graph = new GraphJung<Graph>(data); AbstractLayout<Vertex, Edge> layout = getLayout(graph, layoutName); layout.setSize(new Dimension(width, height)); BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<>(layout); viz.setPreferredSize(new Dimension(width, height)); viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer); viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); viz.getRenderContext().setVertexFillPaintTransformer(vertexColorTransformer); BufferedImage bi = renderImage(viz); String imageType = null; if (mediaType.equals(CustomMediaTypes.IMAGE_JPEG_TYPE)) { imageType = "jpg"; } else if (mediaType.equals(CustomMediaTypes.IMAGE_PNG_TYPE)) { imageType = "png"; } ImageIO.write(bi, imageType, out); }  @Override void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations,
      MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out);  }