Documentation - v1.5.3
    Preparing search index...

    LabelManager

    This class manages a collection of labels used in annotations.

    Index

    Constructors

    • Constructor for the LabelManager class.

      Parameters

      • OptionalinitialLabels: Label[] = []

        An optional array of initial labels to populate the manager.

      Returns LabelManager

      Initializes the LabelManager with an optional initial set of labels.

    Properties

    currentLabel: undefined | Label

    The currently selected label.

    Accessors

    Methods

    • Adds a new label to the manager.

      Parameters

      • name: string

        The name of the new label to add.

      Returns void

      This method adds a new label with a unique ID and a randomly generated color to the manager. If it's the first label added, it sets it as the current label.

    • Deletes a label by its name.

      Parameters

      • name: string

        The name of the label to delete.

      Returns void

      This method removes a label with the specified name from the manager. If the label is currently selected, it will not change the current label.

    • Checks if a label with the given name already exists.

      Parameters

      • newLabel: string

        The name of the label to check for existence.

      Returns boolean

      True if the label exists, false otherwise.

      This method checks if a label with the specified name already exists in the manager.

    • Generates a random color for a new label.

      Returns string

      A randomly selected color from the labelColors array.

      This method generates a random color from the predefined list of colors.

    • Gets a label by its name.

      Parameters

      • name: string

        The name of the label to retrieve.

      Returns undefined | Label

      The label if found, otherwise undefined.

      This method retrieves a label with the specified name from the manager.

    • Sets the current label by its name.

      Parameters

      • name: string

        The name of the label to set as current.

      Returns void

      This method updates the current label to the one with the specified name.