Example usage for com.vaadin.ui Embedded setStandby

List of usage examples for com.vaadin.ui Embedded setStandby

Introduction

In this page you can find the example usage for com.vaadin.ui Embedded setStandby.

Prototype

public void setStandby(String standby) 

Source Link

Document

This attribute specifies a message that a user agent may render while loading the object's implementation and data.

Usage

From source file:annis.visualizers.component.AbstractDotVisualizer.java

License:Apache License

@Override
public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) {
    try {/*ww  w .j  a v a 2s .c  om*/

        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());
}

From source file:annis.visualizers.component.AbstractImageVisualizer.java

License:Apache License

@Override
public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) {

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    writeOutput(visInput, out);/*from  w  w w .  j  a  v a 2 s .  co m*/

    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);
}