use of annis.libgui.ImagePanel in project ANNIS by korpling.
the class AbstractImageVisualizer method createComponent.
@Override
public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
writeOutput(visInput, out);
String fileName = "vis_" + UUID.randomUUID().toString() + ".png";
StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
@Override
public InputStream getStream() {
return new ByteArrayInputStream(out.toByteArray());
}
}, fileName);
Embedded emb = new Embedded("", resource);
emb.setMimeType(getContentType());
emb.setSizeUndefined();
emb.setStandby("loading image");
emb.setAlternateText("Visualization of the result");
return new ImagePanel(emb);
}
use of annis.libgui.ImagePanel in project ANNIS by korpling.
the class AbstractDotVisualizer method createComponent.
@Override
public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) {
try {
final PipedOutputStream out = new PipedOutputStream();
final PipedInputStream in = new PipedInputStream(out);
new Thread(new Runnable() {
@Override
public void run() {
writeOutput(visInput, out);
}
}).start();
String fileName = "dotvis_" + new Random().nextInt(Integer.MAX_VALUE) + ".png";
StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
@Override
public InputStream getStream() {
return in;
}
}, fileName);
Embedded emb = new Embedded("", resource);
emb.setMimeType("image/png");
emb.setSizeFull();
emb.setStandby("loading image");
emb.setAlternateText("DOT graph visualization");
return new ImagePanel(emb);
} catch (IOException ex) {
log.error(null, ex);
}
return new ImagePanel(new Embedded());
}
Aggregations