com.vaadin.ui
Class AbstractColorPicker

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractColorPicker
All Implemented Interfaces:
ContextClickEvent.ContextClickNotifier, MethodEventSource, ClientConnector, Sizeable, com.vaadin.shared.Connector, Component, ColorSelector, HasColorChangeListener, Window.CloseListener, java.io.Serializable
Direct Known Subclasses:
ColorPicker, ColorPickerArea

public abstract class AbstractColorPicker
extends AbstractComponent
implements Window.CloseListener, ColorSelector

An abstract class that defines default implementation for a color picker component.

Since:
7.0.0
See Also:
Serialized Form

Nested Class Summary
static interface AbstractColorPicker.Coordinates2Color
          Interface for converting 2d-coordinates to a Color
static class AbstractColorPicker.PopupStyle
           
 
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.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
 
Field Summary
protected  com.vaadin.shared.ui.colorpicker.Color color
          The color.
protected  boolean historyVisible
           
protected  boolean hsvVisible
           
protected  java.lang.String popupCaption
           
protected  AbstractColorPicker.PopupStyle popupStyle
           
protected  boolean rgbVisible
           
protected static java.lang.String STYLENAME_AREA
           
protected static java.lang.String STYLENAME_BUTTON
           
protected static java.lang.String STYLENAME_DEFAULT
           
protected  boolean swatchesVisible
           
protected  boolean textfieldVisible
           
 
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
AbstractColorPicker()
          Instantiates a new color picker.
AbstractColorPicker(java.lang.String popupCaption)
          Instantiates a new color picker.
AbstractColorPicker(java.lang.String popupCaption, com.vaadin.shared.ui.colorpicker.Color initialColor)
          Instantiates a new color picker.
 
Method Summary
 void addColorChangeListener(ColorChangeListener listener)
          Adds a ColorChangeListener to the component.
protected  void colorChanged(ColorChangeEvent event)
          Fired when a color change event occurs
 void fireColorChanged()
          Notifies the listeners that the selected color has changed
 com.vaadin.shared.ui.colorpicker.Color getColor()
          Gets the color.
protected  java.util.Collection<java.lang.String> getCustomAttributes()
          Returns a collection of attributes that should not be handled by the basic implementation of the readDesign and writeDesign methods.
 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  com.vaadin.shared.ui.colorpicker.ColorPickerState getState()
          Returns the shared state bean with information to be sent from the server to the client.
protected  com.vaadin.shared.ui.colorpicker.ColorPickerState getState(boolean markAsDirty)
          Returns the shared state for this connector.
 boolean getSwatchesVisibility()
          Gets the visibility of the Swatches Tab
 boolean getTextfieldVisibility()
          Gets the visibility of CSS color code text field
 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 isHtmlContentAllowed()
          Deprecated. as of , use AbstractComponent.isCaptionAsHtml() instead
 void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
          Reads the component state from the given design.
 void removeColorChangeListener(ColorChangeListener listener)
          Removes a ColorChangeListener from the component.
 void setColor(com.vaadin.shared.ui.colorpicker.Color color)
          Sets the color.
 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
 void setHSVVisibility(boolean visible)
          Set the visibility of the HSV Tab
 void setHtmlContentAllowed(boolean htmlContentAllowed)
          Deprecated. as of , use AbstractComponent.setCaptionAsHtml(boolean) instead
 void setPopupStyle(AbstractColorPicker.PopupStyle style)
          The style for the popup window
 void setPosition(int x, int y)
          Sets the position of the popup window
 void setRGBVisibility(boolean visible)
          Set the visibility of the RGB Tab
 void setSwatchesVisibility(boolean visible)
          Set the visibility of the Swatches Tab
 void setTextfieldVisibility(boolean visible)
          Sets the visibility of the CSS color code text field
 void showPopup()
          Shows a popup-window for color selection.
protected  void showPopup(boolean open)
          Shows or hides popup-window depending on the given parameter.
 void windowClose(Window.CloseEvent e)
          Called when the user closes a window.
 void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
          Writes the component state to the given design.
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
getUI
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 

Field Detail

STYLENAME_DEFAULT

protected static final java.lang.String STYLENAME_DEFAULT
See Also:
Constant Field Values

STYLENAME_BUTTON

protected static final java.lang.String STYLENAME_BUTTON
See Also:
Constant Field Values

STYLENAME_AREA

protected static final java.lang.String STYLENAME_AREA
See Also:
Constant Field Values

popupStyle

protected AbstractColorPicker.PopupStyle popupStyle

color

protected com.vaadin.shared.ui.colorpicker.Color color
The color.


popupCaption

protected java.lang.String popupCaption

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(java.lang.String popupCaption)
Instantiates a new color picker.

Parameters:
popupCaption - the caption of the popup window

AbstractColorPicker

public AbstractColorPicker(java.lang.String popupCaption,
                           com.vaadin.shared.ui.colorpicker.Color initialColor)
Instantiates a new color picker.

Parameters:
popupCaption - the caption of the popup window
initialColor - the initial color
Method Detail

setColor

public void setColor(com.vaadin.shared.ui.colorpicker.Color color)
Description copied from interface: ColorSelector
Sets the color.

Specified by:
setColor in interface ColorSelector
Parameters:
color - the new color

getColor

public com.vaadin.shared.ui.colorpicker.Color getColor()
Description copied from interface: ColorSelector
Gets the color.

Specified by:
getColor in interface ColorSelector
Returns:
the color

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 -

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.


setPosition

public void setPosition(int x,
                        int y)
Sets the position of the popup window

Parameters:
x - the x-coordinate
y - the y-coordinate

addColorChangeListener

public void addColorChangeListener(ColorChangeListener listener)
Description copied from interface: HasColorChangeListener
Adds a ColorChangeListener to the component.

Specified by:
addColorChangeListener in interface HasColorChangeListener

removeColorChangeListener

public void removeColorChangeListener(ColorChangeListener listener)
Description copied from interface: HasColorChangeListener
Removes a ColorChangeListener from the component.

Specified by:
removeColorChangeListener in interface HasColorChangeListener

windowClose

public void windowClose(Window.CloseEvent e)
Description copied from interface: Window.CloseListener
Called when the user closes a window. Use Window.CloseEvent.getWindow() to get a reference to the Window that was closed.

Specified by:
windowClose in interface Window.CloseListener
Parameters:
e - Event containing

colorChanged

protected void colorChanged(ColorChangeEvent event)
Fired when a color change event occurs

Parameters:
event - The color change event

fireColorChanged

public void fireColorChanged()
Notifies the listeners that the selected color has changed


setPopupStyle

public void setPopupStyle(AbstractColorPicker.PopupStyle style)
The style for the popup window

Parameters:
style - The 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)
Set the visibility of the RGB Tab

Parameters:
visible - The visibility

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)
Set the visibility of the HSV Tab

Parameters:
visible - The visibility

getHSVVisibility

public boolean getHSVVisibility()
Gets the visibility of the HSV Tab

Returns:
visibility of the HSV tab
Since:
7.5.0

setSwatchesVisibility

public void setSwatchesVisibility(boolean visible)
Set the visibility of the Swatches Tab

Parameters:
visible - The visibility

getSwatchesVisibility

public boolean getSwatchesVisibility()
Gets the visibility of the Swatches Tab

Returns:
visibility of the swatches tab
Since:
7.5.0

setHistoryVisibility

public void setHistoryVisibility(boolean visible)
Sets the visibility of the Color History

Parameters:
visible - The visibility

getHistoryVisibility

public boolean getHistoryVisibility()
Gets the visibility of the Color History

Returns:
visibility of color history
Since:
7.5.0

setTextfieldVisibility

public void setTextfieldVisibility(boolean visible)
Sets the visibility of the CSS color code text field

Parameters:
visible - The visibility

getTextfieldVisibility

public boolean getTextfieldVisibility()
Gets the visibility of CSS color code text field

Returns:
visibility of css color code text field
Since:
7.5.0

getState

protected com.vaadin.shared.ui.colorpicker.ColorPickerState 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 AbstractComponent
Returns:
updated component shared state

getState

protected com.vaadin.shared.ui.colorpicker.ColorPickerState getState(boolean markAsDirty)
Description copied from class: AbstractClientConnector
Returns the shared state for this connector.

Overrides:
getState in class AbstractComponent
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 popup-window depending on the given parameter. If there is no such window yet, one is created.

Parameters:
open -

setHtmlContentAllowed

@Deprecated
public void setHtmlContentAllowed(boolean htmlContentAllowed)
Deprecated. as of , use AbstractComponent.setCaptionAsHtml(boolean) instead

Set whether the caption text is rendered as HTML or not. You might need to re-theme component to allow higher content than the original text style. If set to true, the captions are passed to the browser as html and the developer is responsible for ensuring no harmful html is used. If set to false, the content is passed to the browser as plain text.

Parameters:
htmlContentAllowed - true if caption is rendered as HTML, false otherwise

isHtmlContentAllowed

@Deprecated
public boolean isHtmlContentAllowed()
Deprecated. as of , use AbstractComponent.isCaptionAsHtml() instead

Return HTML rendering setting

Returns:
true if the caption text is to be rendered as HTML, false otherwise

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 AbstractComponent
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 AbstractComponent
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 java.util.Collection<java.lang.String> getCustomAttributes()
Description copied from class: AbstractComponent
Returns a collection of attributes that should not be handled by the basic implementation of the readDesign and writeDesign methods. Typically these are handled in a custom way in the overridden versions of the above methods

Overrides:
getCustomAttributes in class AbstractComponent
Returns:
the collection of attributes that are not handled by the basic implementation


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.