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

com.vaadin.flow.component.charts.model.AnnotationItem Maven / Gradle / Ivy

There is a newer version: 24.5.4
Show newest version
/**
 * Copyright 2000-2024 Vaadin Ltd.
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See {@literal } for the full
 * license.
 */
package com.vaadin.flow.component.charts.model;

import java.util.ArrayList;
import java.util.List;

/**
 * Container for labels on the chart
 */
public class AnnotationItem extends AbstractConfigurationObject {

    private List labels;

    /**
     * @see #setLabels(AnnotationItemLabel...)
     * @return Labels
     */
    public List getLabels() {
        if (labels == null) {
            labels = new ArrayList<>();
        }
        return labels;
    }

    /**
     * Sets labels that can be positioned anywhere in the chart area.
     *
     * @param labels
     */
    public void setLabels(AnnotationItemLabel... labels) {
        clearLabels();
        addLabels(labels);
    }

    /**
     * Adds multiple labels
     *
     * @see #setLabels(AnnotationItemLabel...)
     * @param labels
     */
    public void addLabels(AnnotationItemLabel... labels) {
        for (AnnotationItemLabel label : labels) {
            addLabel(label);
        }
    }

    /**
     * Adds a single label
     *
     * @see #setLabels(AnnotationItemLabel...)
     * @param label
     */
    public void addLabel(AnnotationItemLabel label) {
        getLabels().add(label);
    }

    /**
     * Clears all labels
     *
     * @see #setLabels(AnnotationItemLabel...)
     */
    public void clearLabels() {
        getLabels().clear();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy