public abstract class AbstractColorPicker extends AbstractField<Color>
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractColorPicker.Coordinates2Color
Interface for converting 2d-coordinates to a Color.
|
static class |
AbstractColorPicker.PopupStyle
The style of the color picker popup.
|
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
Modifier and Type | Field and Description |
---|---|
protected Color |
color
The currently selected color.
|
protected boolean |
historyVisible |
protected boolean |
hsvVisible |
protected AbstractColorPicker.PopupStyle |
popupStyle |
protected boolean |
rgbVisible |
protected static String |
STYLENAME_AREA |
protected static String |
STYLENAME_BUTTON |
protected static String |
STYLENAME_DEFAULT |
protected boolean |
swatchesVisible |
protected boolean |
textfieldVisible |
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doSetValue(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 the
AbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. |
Color |
getEmptyValue()
Returns the value that represents an empty value.
|
boolean |
getHistoryVisibility()
Gets the visibility of the Color history.
|
boolean |
getHSVVisibility()
Gets the visibility of the HSV tab.
|
AbstractColorPicker.PopupStyle |
getPopupStyle()
Gets the style for the popup window.
|
boolean |
getRGBVisibility()
Gets the visibility of the RGB Tab.
|
protected AbstractColorPickerState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected AbstractColorPickerState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
boolean |
getSwatchesVisibility()
Gets the visibility of the Swatches (palette) tab.
|
boolean |
getTextfieldVisibility()
Gets the visibility of CSS color code text field.
|
Color |
getValue()
Returns the current selected color of this color picker.
|
void |
hidePopup()
Hides a popup-window for color selection.
|
boolean |
isDefaultCaptionEnabled()
Returns true if the component shows the default caption (css-code for the
currently selected color, e.g.
|
boolean |
isModal()
Checks the modality of the dialog.
|
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Reads the component state from the given design.
|
void |
setDefaultCaptionEnabled(boolean enabled)
Set true if the component should show a default caption (css-code for the
currently selected color, e.g.
|
protected abstract void |
setDefaultStyles()
Sets the default styles of the component.
|
void |
setHistoryVisibility(boolean visible)
Sets the visibility of the color history, displaying recently picked
colors.
|
void |
setHSVVisibility(boolean visible)
Sets the visibility of the HSV Tab.
|
void |
setModal(boolean modal)
Sets ColorPicker modality.
|
void |
setPopupStyle(AbstractColorPicker.PopupStyle style)
Sets the style of the popup window.
|
void |
setPosition(int x,
int y)
Sets the position of the popup window.
|
void |
setRGBVisibility(boolean visible)
Sets the visibility of the RGB tab.
|
void |
setSwatchesVisibility(boolean visible)
Sets the visibility of the Swatches (palette) tab.
|
void |
setTextfieldVisibility(boolean visible)
Sets the visibility of the CSS color code text field.
|
void |
setValue(Color color)
Sets the selected color of this color picker.
|
void |
showPopup()
Shows a popup-window for color selection.
|
protected void |
showPopup(boolean open)
Shows or hides the popup window depending on the given parameter.
|
void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
addValueChangeListener, createValueChange, focus, getTabIndex, isDifferentValue, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible, setTabIndex, setValue
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, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined
addAttachListener, addDetachListener, addExtension, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
clear, getDefaultValidator, getOptionalValue, isEmpty
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
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
protected static final String STYLENAME_DEFAULT
protected static final String STYLENAME_BUTTON
protected static final String STYLENAME_AREA
protected AbstractColorPicker.PopupStyle popupStyle
protected Color color
protected boolean rgbVisible
protected boolean hsvVisible
protected boolean swatchesVisible
protected boolean historyVisible
protected boolean textfieldVisible
public AbstractColorPicker()
public AbstractColorPicker(String popupCaption)
popupCaption
- the caption of the popup windowpublic Color getValue()
public void setValue(Color color)
ValueChangeEvent
.setValue
in interface HasValue<Color>
setValue
in class AbstractField<Color>
color
- the new selected color, not nullNullPointerException
- if color
is null
public void setDefaultCaptionEnabled(boolean enabled)
enabled
- true
to enable the default caption, false
to
disablepublic boolean isDefaultCaptionEnabled()
true
if the default caption is enabled, false
otherwisepublic void setPosition(int x, int y)
x
- the x-coordinatey
- the y-coordinatepublic void setPopupStyle(AbstractColorPicker.PopupStyle style)
style
- the popup window stylepublic AbstractColorPicker.PopupStyle getPopupStyle()
public void setRGBVisibility(boolean visible)
visible
- true
to display the RGB tab, false
to hide itpublic boolean getRGBVisibility()
public void setHSVVisibility(boolean visible)
visible
- true
to display the HSV tab, false
to hide itpublic boolean getHSVVisibility()
true
if the HSV tab is currently displayed, false
otherwisepublic void setSwatchesVisibility(boolean visible)
visible
- true
to display the Swatches tab, false
to
hide itpublic boolean getSwatchesVisibility()
true
if the Swatches tab is currently displayed,
false
otherwisepublic void setHistoryVisibility(boolean visible)
visible
- true
to display the history, false
to hide itpublic boolean getHistoryVisibility()
true
if the history is currently displayed, false
otherwisepublic void setTextfieldVisibility(boolean visible)
visible
- true
to display the CSS text field, false
to
hide itpublic boolean getTextfieldVisibility()
true
if the CSS text field is currently displayed,
false
otherwiseprotected AbstractColorPickerState getState()
AbstractComponent
getState
in class AbstractField<Color>
protected AbstractColorPickerState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractField<Color>
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
protected abstract void setDefaultStyles()
public void showPopup()
public void hidePopup()
protected void showPopup(boolean open)
open
- true
to display the popup, false
to hide itpublic void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
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.
readDesign
in interface Component
readDesign
in class AbstractField<Color>
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the designpublic void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
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.
writeDesign
in interface Component
writeDesign
in class AbstractField<Color>
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 designprotected Collection<String> getCustomAttributes()
AbstractComponent
AbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext)
methods. Typically these
are handled in a custom way in the overridden versions of the above
methodsgetCustomAttributes
in class AbstractField<Color>
protected void doSetValue(Color color)
AbstractField
IllegalArgumentException
if the value is invalid. Typically saves
the value to shared state.doSetValue
in class AbstractField<Color>
color
- the new value of the fieldpublic Color getEmptyValue()
HasValue
By default HasValue
is expected to support null
as empty
values. Specific implementations might not support this.
Binder#bind(HasValue, ValueProvider, Setter)
public void setModal(boolean modal)
Note: It must be set to true
if ColorPicker is a child of modal
Window
modal
- true if modality is to be turned onWindow.setModal(boolean)
public boolean isModal()
setModal(boolean)
Copyright © 2018 Vaadin Ltd. All rights reserved.