Class AbstractColorPicker
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractField<Color>
-
- com.vaadin.ui.AbstractColorPicker
-
- All Implemented Interfaces:
HasValue<Color>,ContextClickEvent.ContextClickNotifier,MethodEventSource,ClientConnector,Sizeable,Connector,Component,Component.Focusable,Serializable
- Direct Known Subclasses:
ColorPicker,ColorPickerArea
public abstract class AbstractColorPicker extends AbstractField<Color>
An abstract class that defines default implementation for a color picker component.- Since:
- 7.0.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractColorPicker.Coordinates2ColorInterface for converting 2d-coordinates to a Color.static classAbstractColorPicker.PopupStyleThe style of the color picker popup.-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.data.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
Fields Modifier and Type Field Description protected ColorcolorThe currently selected color.protected booleanhistoryVisibleprotected booleanhsvVisibleprotected AbstractColorPicker.PopupStylepopupStyleprotected booleanrgbVisibleprotected static StringSTYLENAME_AREAprotected static StringSTYLENAME_BUTTONprotected static StringSTYLENAME_DEFAULTprotected booleanswatchesVisibleprotected booleantextfieldVisible-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description AbstractColorPicker()Instantiates a new color picker.AbstractColorPicker(String popupCaption)Instantiates a new color picker.AbstractColorPicker(String popupCaption, Color initialColor)Instantiates a new color picker.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddoSetValue(Color color)Sets the value of this field.protected Collection<String>getCustomAttributes()Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(Element, DesignContext)andAbstractComponent.writeDesign(Element, DesignContext)methods.ColorgetEmptyValue()Returns the value that represents an empty value.booleangetHistoryVisibility()Gets the visibility of the Color history.booleangetHSVVisibility()Gets the visibility of the HSV tab.AbstractColorPicker.PopupStylegetPopupStyle()Gets the style for the popup window.booleangetRGBVisibility()Gets the visibility of the RGB Tab.protected AbstractColorPickerStategetState()Returns the shared state bean with information to be sent from the server to the client.protected AbstractColorPickerStategetState(boolean markAsDirty)Returns the shared state for this connector.booleangetSwatchesVisibility()Gets the visibility of the Swatches (palette) tab.booleangetTextfieldVisibility()Gets the visibility of CSS color code text field.ColorgetValue()Returns the current selected color of this color picker.voidhidePopup()Hides a popup-window for color selection.booleanisDefaultCaptionEnabled()Returns true if the component shows the default caption (css-code for the currently selected color, e.g.booleanisModal()Checks the modality of the dialog.voidreadDesign(org.jsoup.nodes.Element design, DesignContext designContext)Reads the component state from the given design.voidsetDefaultCaptionEnabled(boolean enabled)Set true if the component should show a default caption (css-code for the currently selected color, e.g.protected abstract voidsetDefaultStyles()Sets the default styles of the component.voidsetHistoryVisibility(boolean visible)Sets the visibility of the color history, displaying recently picked colors.voidsetHSVVisibility(boolean visible)Sets the visibility of the HSV Tab.voidsetModal(boolean modal)Sets ColorPicker modality.voidsetPopupStyle(AbstractColorPicker.PopupStyle style)Sets the style of the popup window.voidsetPosition(int x, int y)Sets the position of the popup window.voidsetRGBVisibility(boolean visible)Sets the visibility of the RGB tab.voidsetSwatchesVisibility(boolean visible)Sets the visibility of the Swatches (palette) tab.voidsetTextfieldVisibility(boolean visible)Sets the visibility of the CSS color code text field.voidsetValue(Color color)Sets the selected color of this color picker.voidshowPopup()Shows a popup-window for color selection.protected voidshowPopup(boolean open)Shows or hides the popup window depending on the given parameter.voidwriteDesign(org.jsoup.nodes.Element design, DesignContext designContext)Writes the component state to the given design.-
Methods inherited from class com.vaadin.ui.AbstractField
addValueChangeListener, createValueChange, focus, getTabIndex, isDifferentValue, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible, setTabIndex, setValue
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.data.HasValue
clear, getDefaultValidator, getOptionalValue, isEmpty
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Field Detail
-
STYLENAME_DEFAULT
protected static final String STYLENAME_DEFAULT
- See Also:
- Constant Field Values
-
STYLENAME_BUTTON
protected static final String STYLENAME_BUTTON
- See Also:
- Constant Field Values
-
STYLENAME_AREA
protected static final String STYLENAME_AREA
- See Also:
- Constant Field Values
-
popupStyle
protected AbstractColorPicker.PopupStyle popupStyle
-
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
-
-
Method Detail
-
getValue
public Color getValue()
Returns the current selected color of this color picker.- Returns:
- the selected color, not null
-
setValue
public void setValue(Color color)
Sets the selected color of this color picker. If the new color is not equal to getValue(), fires aHasValue.ValueChangeEvent.- Specified by:
setValuein interfaceHasValue<Color>- Overrides:
setValuein classAbstractField<Color>- Parameters:
color- the new selected color, not null- Throws:
NullPointerException- ifcolorisnull
-
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-trueto enable the default caption,falseto 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:
trueif the default caption is enabled,falseotherwise
-
setPosition
public void setPosition(int x, int y)Sets the position of the popup window.- Parameters:
x- the x-coordinatey- the y-coordinate
-
setPopupStyle
public void setPopupStyle(AbstractColorPicker.PopupStyle style)
Sets the style of the popup window.- Parameters:
style- the popup window style
-
getPopupStyle
public AbstractColorPicker.PopupStyle getPopupStyle()
Gets the style for the popup window.- Returns:
- popup window style
- Since:
- 7.5.0
-
setRGBVisibility
public void setRGBVisibility(boolean visible)
Sets the visibility of the RGB tab.- Parameters:
visible-trueto display the RGB tab,falseto 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-trueto display the HSV tab,falseto hide it
-
getHSVVisibility
public boolean getHSVVisibility()
Gets the visibility of the HSV tab.- Returns:
trueif the HSV tab is currently displayed,falseotherwise- Since:
- 7.5.0
-
setSwatchesVisibility
public void setSwatchesVisibility(boolean visible)
Sets the visibility of the Swatches (palette) tab.- Parameters:
visible-trueto display the Swatches tab,falseto hide it
-
getSwatchesVisibility
public boolean getSwatchesVisibility()
Gets the visibility of the Swatches (palette) tab.- Returns:
trueif the Swatches tab is currently displayed,falseotherwise- Since:
- 7.5.0
-
setHistoryVisibility
public void setHistoryVisibility(boolean visible)
Sets the visibility of the color history, displaying recently picked colors.- Parameters:
visible-trueto display the history,falseto hide it
-
getHistoryVisibility
public boolean getHistoryVisibility()
Gets the visibility of the Color history.- Returns:
trueif the history is currently displayed,falseotherwise- Since:
- 7.5.0
-
setTextfieldVisibility
public void setTextfieldVisibility(boolean visible)
Sets the visibility of the CSS color code text field.- Parameters:
visible-trueto display the CSS text field,falseto hide it
-
getTextfieldVisibility
public boolean getTextfieldVisibility()
Gets the visibility of CSS color code text field.- Returns:
trueif the CSS text field is currently displayed,falseotherwise- Since:
- 7.5.0
-
getState
protected AbstractColorPickerState getState()
Description copied from class:AbstractComponentReturns 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:
getStatein classAbstractField<Color>- Returns:
- updated component shared state
-
getState
protected AbstractColorPickerState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnectorReturns the shared state for this connector.- Overrides:
getStatein classAbstractField<Color>- Parameters:
markAsDirty- true if the connector should automatically be marked dirty, false otherwise- Returns:
- The shared state for this connector. Never null.
- See Also:
AbstractClientConnector.getState()
-
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-trueto display the popup,falseto hide it
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from interface:ComponentReads 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:
readDesignin interfaceComponent- Overrides:
readDesignin classAbstractField<Color>- Parameters:
design- The element to obtain the state fromdesignContext- The DesignContext instance used for parsing the design
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from interface:ComponentWrites 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:
writeDesignin interfaceComponent- Overrides:
writeDesignin classAbstractField<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
-
getCustomAttributes
protected Collection<String> getCustomAttributes()
Description copied from class:AbstractComponentReturns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(Element, DesignContext)andAbstractComponent.writeDesign(Element, DesignContext)methods. Typically these are handled in a custom way in the overridden versions of the above methods- Overrides:
getCustomAttributesin classAbstractField<Color>- Returns:
- the collection of attributes that are not handled by the basic implementation
-
doSetValue
protected void doSetValue(Color color)
Description copied from class:AbstractFieldSets the value of this field. May do sanitization or throwIllegalArgumentExceptionif the value is invalid. Typically saves the value to shared state.- Specified by:
doSetValuein classAbstractField<Color>- Parameters:
color- the new value of the field
-
getEmptyValue
public Color getEmptyValue()
Description copied from interface:HasValueReturns the value that represents an empty value.By default
HasValueis expected to supportnullas 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
trueif ColorPicker is a child of modalWindow- 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)
-
-