com.vaadin.ui.

Class AbstractColorPicker

    • Field Detail

      • color

        protected Color color

        The currently selected color.

      • rgbVisible

        protected boolean rgbVisible
      • hsvVisible

        protected boolean hsvVisible
      • swatchesVisible

        protected boolean swatchesVisible
      • historyVisible

        protected boolean historyVisible
      • textfieldVisible

        protected boolean textfieldVisible
    • Constructor Detail

      • AbstractColorPicker

        public AbstractColorPicker()

        Instantiates a new color picker.

      • AbstractColorPicker

        public AbstractColorPicker​(String popupCaption)

        Instantiates a new color picker.

        Parameters:

        popupCaption - the caption of the popup window

      • AbstractColorPicker

        public AbstractColorPicker​(String popupCaption,
                                   Color initialColor)

        Instantiates a new color picker.

        Parameters:

        popupCaption - the caption of the popup window

        initialColor - the initial color

    • Method Detail

      • getValue

        public Color getValue()

        Returns the current selected color of this color picker.

        Returns:

        the selected color, not null

      • setDefaultCaptionEnabled

        public void setDefaultCaptionEnabled​(boolean enabled)

        Set true if the component should show a default caption (css-code for the currently selected color, e.g. #ffffff) when no other caption is available.

        Parameters:

        enabled - true to enable the default caption, false to disable

      • isDefaultCaptionEnabled

        public boolean isDefaultCaptionEnabled()

        Returns true if the component shows the default caption (css-code for the currently selected color, e.g. #ffffff) if no other caption is available.

        Returns:

        true if the default caption is enabled, false otherwise

      • setPosition

        public void setPosition​(int x,
                                int y)

        Sets the position of the popup window.

        Parameters:

        x - the x-coordinate

        y - the y-coordinate

      • setPopupStyle

        public void setPopupStyle​(AbstractColorPicker.PopupStyle style)

        Sets the style of the popup window.

        Parameters:

        style - the popup window style

      • setRGBVisibility

        public void setRGBVisibility​(boolean visible)

        Sets the visibility of the RGB tab.

        Parameters:

        visible - true to display the RGB tab, false to hide it

      • getRGBVisibility

        public boolean getRGBVisibility()

        Gets the visibility of the RGB Tab.

        Returns:

        visibility of the RGB tab

        Since:

        7.5.0

      • setHSVVisibility

        public void setHSVVisibility​(boolean visible)

        Sets the visibility of the HSV Tab.

        Parameters:

        visible - true to display the HSV tab, false to hide it

      • getHSVVisibility

        public boolean getHSVVisibility()

        Gets the visibility of the HSV tab.

        Returns:

        true if the HSV tab is currently displayed, false otherwise

        Since:

        7.5.0

      • setSwatchesVisibility

        public void setSwatchesVisibility​(boolean visible)

        Sets the visibility of the Swatches (palette) tab.

        Parameters:

        visible - true to display the Swatches tab, false to hide it

      • getSwatchesVisibility

        public boolean getSwatchesVisibility()

        Gets the visibility of the Swatches (palette) tab.

        Returns:

        true if the Swatches tab is currently displayed, false otherwise

        Since:

        7.5.0

      • setHistoryVisibility

        public void setHistoryVisibility​(boolean visible)

        Sets the visibility of the color history, displaying recently picked colors.

        Parameters:

        visible - true to display the history, false to hide it

      • getHistoryVisibility

        public boolean getHistoryVisibility()

        Gets the visibility of the Color history.

        Returns:

        true if the history is currently displayed, false otherwise

        Since:

        7.5.0

      • setTextfieldVisibility

        public void setTextfieldVisibility​(boolean visible)

        Sets the visibility of the CSS color code text field.

        Parameters:

        visible - true to display the CSS text field, false to hide it

      • getTextfieldVisibility

        public boolean getTextfieldVisibility()

        Gets the visibility of CSS color code text field.

        Returns:

        true if the CSS text field is currently displayed, false otherwise

        Since:

        7.5.0

      • getState

        protected AbstractColorPickerState getState()

        Description copied from class: AbstractComponent

        Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

        Overrides:

        getState in class AbstractField<Color>

        Returns:

        updated component shared state

      • setDefaultStyles

        protected abstract void setDefaultStyles()

        Sets the default styles of the component.

      • showPopup

        public void showPopup()

        Shows a popup-window for color selection.

      • hidePopup

        public void hidePopup()

        Hides a popup-window for color selection.

      • showPopup

        protected void showPopup​(boolean open)

        Shows or hides the popup window depending on the given parameter. If there is no such window yet, one is created.

        Parameters:

        open - true to display the popup, false to hide it

      • readDesign

        public void readDesign​(org.jsoup.nodes.Element design,
                               DesignContext designContext)

        Description copied from interface: Component

        Reads the component state from the given design.

        The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.

        It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.

        This method must not modify the design.

        Specified by:

        readDesign in interface Component

        Overrides:

        readDesign in class AbstractField<Color>

        Parameters:

        design - The element to obtain the state from

        designContext - The DesignContext instance used for parsing the design

      • writeDesign

        public void writeDesign​(org.jsoup.nodes.Element design,
                                DesignContext designContext)

        Description copied from interface: Component

        Writes the component state to the given design.

        The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.

        This method must not modify the component state.

        Specified by:

        writeDesign in interface Component

        Overrides:

        writeDesign in class AbstractField<Color>

        Parameters:

        design - The element to write the component state to. Any previous attributes or child nodes are not cleared.

        designContext - The DesignContext instance used for writing the design

      • doSetValue

        protected void doSetValue​(Color color)

        Description copied from class: AbstractField

        Sets the value of this field. May do sanitization or throw IllegalArgumentException if the value is invalid. Typically saves the value to shared state.

        Specified by:

        doSetValue in class AbstractField<Color>

        Parameters:

        color - the new value of the field

      • getEmptyValue

        public Color getEmptyValue()

        Description copied from interface: HasValue

        Returns the value that represents an empty value.

        By default HasValue is expected to support null as empty values. Specific implementations might not support this.

        Returns:

        empty value

        See Also:

        Binder#bind(HasValue, ValueProvider, Setter)

      • setModal

        public void setModal​(boolean modal)

        Sets ColorPicker modality. When a modal ColorPicker is open, components outside that ColorPicker cannot be accessed.

        Note: It must be set to true if ColorPicker is a child of modal Window

        Parameters:

        modal - true if modality is to be turned on

        Since:

        8.4.1

        See Also:

        Window.setModal(boolean)

      • isModal

        public boolean isModal()

        Checks the modality of the dialog.

        Returns:

        true if the dialog is modal, false otherwise

        Since:

        8.4.1

        See Also:

        setModal(boolean)