All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bklab.flow.factory.ImageFactory Maven / Gradle / Ivy

There is a newer version: 22.0.1
Show newest version
/*
 * Copyright (c) 2008 - 2020. - Broderick Labs.
 * Author: Broderick Johansson
 * E-mail: [email protected]
 * Modify date:2020-06-24 16:33:55
 * _____________________________
 * Project name: fluent-vaadin-flow
 * Class name:org.bklab.flow.factory.ImageFactory
 * Copyright (c) 2008 - 2020. - Broderick Labs.
 */

package org.bklab.flow.factory;

import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.server.AbstractStreamResource;
import com.vaadin.flow.server.StreamResource;
import org.bklab.flow.FlowFactory;
import org.bklab.flow.base.ClickNotifierFactory;
import org.bklab.flow.base.HtmlContainerFactory;
import org.bklab.flow.image.ImageBase;

public class ImageFactory extends FlowFactory
        implements ClickNotifierFactory, HtmlContainerFactory {

    public ImageFactory() {
        this(new Image());
    }

    public ImageFactory(Class base, String name) {
        this();
        get().setSrc(new StreamResource(name, () -> base.getResourceAsStream(name)));
    }

    public ImageFactory(Image component) {
        super(component);
    }

    public ImageFactory(String src, String alt) {
        this(new Image(src, alt));
    }

    public ImageFactory(AbstractStreamResource src, String alt) {
        this(new Image(src, alt));
    }

    public ImageFactory src(String src) {
        get().setSrc(src);
        return this;
    }

    public ImageFactory src(AbstractStreamResource src) {
        get().setSrc(src);
        return this;
    }

    public ImageFactory alt(String alt) {
        get().setAlt(alt);
        return this;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy