Example usage for com.vaadin.ui Embedded setAlternateText

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

Introduction

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

Prototype

public void setAlternateText(String altText) 

Source Link

Document

Sets this component's "alt-text", that is, an alternate text that can be presented instead of this component's normal content, for accessibility purposes.

Usage

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

License:Apache License

@Override
public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) {
    try {//w  w w.ja  v a2s  .c o m

        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);// w  w w  .  ja v  a 2  s.  c  om

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

From source file:com.rdonasco.common.vaadin.view.utils.EmbeddedResourceBuilder.java

License:Apache License

public Embedded createEmbedded() throws InvalidBuilderParameter {
    if (null == application) {
        throw new InvalidBuilderParameter("application not set");
    }//w w w. ja  va 2 s  . co  m
    if (null == name) {
        throw new InvalidBuilderParameter("name not set");
    }
    Embedded embedded = null;
    if (null != bytes) {
        embedded = createUsingStreamSource();
    } else if (null != resourceId) {
        embedded = createUsingResourceId();
    } else {
        throw new InvalidBuilderParameter("bytes or resource ID is not set");
    }
    embedded.setDescription(description);
    embedded.setAlternateText(alternateText);
    if (null != height) {
        embedded.setHeight(height, units);
    }
    if (null != width) {
        embedded.setWidth(width, units);
    }

    return embedded;
}