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

org.dominokit.domino.ui.icons.UrlIcon Maven / Gradle / Ivy

There is a newer version: 1.0.139
Show newest version
package org.dominokit.domino.ui.icons;

import org.dominokit.domino.ui.utils.DominoElement;

import static java.util.Objects.nonNull;
import static org.jboss.elemento.Elements.img;

public class UrlIcon extends BaseIcon {

    private final String url;

    private UrlIcon(String url, String name) {
        this.url = url;
        this.name = name;
        this.icon = DominoElement.of(img(url).element());
        init(this);
    }

    public static UrlIcon create(String url, String name) {
        return new UrlIcon(url, name);
    }

    @Override
    public UrlIcon copy() {
        return new UrlIcon(url, name);
    }

    @Override
    protected UrlIcon doToggle() {
        if (nonNull(toggleName)) {
            if (this.style.contains(originalName)) {
                this.style.remove(originalName);
                this.style.add(toggleName);
            } else {
                this.style.add(originalName);
                this.style.remove(toggleName);
            }
        }
        return this;
    }

    @Override
    public UrlIcon changeTo(BaseIcon icon) {
        style.remove(getName());
        style.add(icon.getName());
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy