<s> import sys <EOL> import traceback <EOL> from colorsys import hsv_to_rgb <EOL> from muntjac . ui . window import Window <EOL> from muntjac . ui . button import IClickListener , Button <EOL> from muntjac . ui . tab_sheet import TabSheet <EOL> from muntjac . ui . vertical_layout import VerticalLayout <EOL> from muntjac . addon . colorpicker . color import Color <EOL> from muntjac . addon . colorpicker . color_picker import ICoordinates2Color , IColorChangeListener <EOL> from muntjac . addon . colorpicker . color_picker_history import ColorPickerHistory <EOL> from muntjac . addon . colorpicker . color_change_event import ColorChangeEvent <EOL> from muntjac . addon . colorpicker . color_picker_preview import ColorPickerPreview <EOL> from muntjac . addon . colorpicker . color_picker_select import ColorPickerSelect <EOL> from muntjac . addon . colorpicker . color_selector import IColorSelector <EOL> from muntjac . addon . colorpicker . color_picker_gradient import ColorPickerGradient <EOL> from muntjac . ui . horizontal_layout import HorizontalLayout <EOL> from muntjac . ui . alignment import Alignment <EOL> from muntjac . ui . slider import Slider , ValueOutOfBoundsException <EOL> from muntjac . data . property import IValueChangeListener <EOL> _COLOR_CHANGE_METHOD = getattr ( IColorChangeListener , '<STR_LIT>' ) <EOL> class ColorPickerPopup ( Window , IClickListener , IColorChangeListener , <EOL> IColorSelector ) : <EOL> """<STR_LIT>""" <EOL> _STYLENAME = '<STR_LIT>' <EOL> def __init__ ( self , initialColor ) : <EOL> """<STR_LIT>""" <EOL> self . _tabs = TabSheet ( ) <EOL> self . _layout = VerticalLayout ( ) <EOL> self . _ok = Button ( '<STR_LIT:OK>' ) <EOL> self . _cancel = Button ( '<STR_LIT>' ) <EOL> self . _resize = Button ( '<STR_LIT>' ) <EOL> self . _selectedColor = Color . WHITE <EOL> self . _history = None <EOL> self . _historyContainer = None <EOL> self . _rgbGradient = None <EOL> self . _hsvGradient = None <EOL> self . _redSlider = None <EOL> self . _greenSlider = None <EOL> self . _blueSlider = None <EOL> self . _hueSlider = None <EOL> self . _saturationSlider = None <EOL> self . _valueSlider = None <EOL> self . _rgbPreview = None <EOL> self . _hsvPreview = None <EOL> self . _selPreview = None <EOL> self . _colorSelect = None <EOL> self . _selectors = set ( ) <EOL> super ( ColorPickerPopup , self ) . __init__ ( ) <EOL> self . _selectedColor = initialColor <EOL> self . setWidth ( '<STR_LIT>' ) <EOL> self . setScrollable ( False ) <EOL> self . setStyleName ( self . _STYLENAME ) <EOL> self . setResizable ( False ) <EOL> self . setImmediate ( True ) <EOL> self . _history = ColorPickerHistory ( ) <EOL> self . _history . addListener ( self , IColorChangeListener ) <EOL> self . _rgbPreview = ColorPickerPreview ( self . _selectedColor ) <EOL> self . _rgbPreview . setWidth ( '<STR_LIT>' ) <EOL> self . _rgbPreview . setHeight ( '<STR_LIT>' ) <EOL> self . _rgbPreview . addListener ( self , IColorChangeListener ) <EOL> self . _selectors . add ( self . _rgbPreview ) <EOL> self . _hsvPreview = ColorPickerPreview ( self . _selectedColor ) <EOL> self . _hsvPreview . setWidth ( '<STR_LIT>' ) <EOL> self . _hsvPreview . setHeight ( '<STR_LIT>' ) <EOL> self . _hsvPreview . addListener ( self , IColorChangeListener ) <EOL> self . _selectors . add ( self . _hsvPreview ) <EOL> self . _selPreview = ColorPickerPreview ( self . _selectedColor ) <EOL> self . _selPreview . setWidth ( '<STR_LIT>' ) <EOL> self . _selPreview . setHeight ( '<STR_LIT>' ) <EOL> self . _selPreview . addListener ( self , IColorChangeListener ) <EOL> self . _selectors . add ( self . _selPreview ) <EOL> self . _layout . setSpacing ( False ) <EOL> self . _layout . setSizeFull ( ) <EOL> self . setContent ( self . _layout ) <EOL> self . _rgbTab = self . createRGBTab ( self . _selectedColor ) <EOL> self . _tabs . addTab ( self . _rgbTab , '<STR_LIT>' , None ) <EOL> self . _hsvTab = self . createHSVTab ( self . _selectedColor ) <EOL> self . _tabs . addTab ( self . _hsvTab , '<STR_LIT>' , None ) <EOL> self . _swatchesTab = self . createSelectTab ( ) <EOL> self . _tabs . addTab ( self . _swatchesTab , '<STR_LIT>' , None ) <EOL> self . _tabs . setWidth ( '<STR_LIT>' ) <EOL> self . _layout . addComponent ( self . _tabs ) <EOL> self . _history . setWidth ( '<STR_LIT>' ) <EOL> self . _history . setHeight ( '<STR_LIT>' ) <EOL> defaultColors = list ( ) <EOL> defaultColors . append ( Color . BLACK ) <EOL> defaultColors . append ( Color . WHITE ) <EOL> innerContainer = VerticalLayout ( ) <EOL> innerContainer . setSizeFull ( ) <EOL> innerContainer . addComponent ( self . _history ) <EOL> innerContainer . setExpandRatio ( self . _history , <NUM_LIT:1> ) <EOL> outerContainer = VerticalLayout ( ) <EOL> outerContainer . setWidth ( '<STR_LIT>' ) <EOL> outerContainer . setHeight ( '<STR_LIT>' ) <EOL> outerContainer . addComponent ( innerContainer ) <EOL> self . _historyContainer = outerContainer <EOL> self . _layout . addComponent ( self . _historyContainer ) <EOL> self . _resize . addListener ( self , IClickListener ) <EOL> self . _resize . setData ( False ) <EOL> self . _resize . setWidth ( '<STR_LIT>' ) <EOL> self . _resize . setHeight ( '<STR_LIT>' ) <EOL> self . _resize . setStyleName ( '<STR_LIT>' ) <EOL> self . _layout . addComponent ( self . _resize ) <EOL> self . _ok . setWidth ( '<STR_LIT>' ) <EOL> self . _ok . addListener ( self , IClickListener ) <EOL> self . _cancel . setWidth ( '<STR_LIT>' ) <EOL> self . _cancel . addListener ( self , IClickListener ) <EOL> buttons = HorizontalLayout ( ) <EOL> buttons . addComponent ( self . _ok ) <EOL> buttons . addComponent ( self . _cancel ) <EOL> buttons . setWidth ( '<STR_LIT>' ) <EOL> buttons . setHeight ( '<STR_LIT>' ) <EOL> buttons . setComponentAlignment ( self . _ok , Alignment . MIDDLE_CENTER ) <EOL> buttons . setComponentAlignment ( self . _cancel , Alignment . MIDDLE_CENTER ) <EOL> self . _layout . addComponent ( buttons ) <EOL> self . setHeight ( self . calculateHeight ( ) ) <EOL> def calculateHeight ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _historyContainer . isVisible ( ) : <EOL> historyHeight = self . _historyContainer . getHeight ( ) <EOL> else : <EOL> historyHeight = <NUM_LIT:0> <EOL> tabsHeight = <NUM_LIT:0> if self . _tabs . areTabsHidden ( ) else <NUM_LIT:32> <EOL> contentHeight = <NUM_LIT> <EOL> buttonsHeight = <NUM_LIT:30> <EOL> previewHeight = <NUM_LIT:20> if self . _rgbPreview . isVisible ( ) else <NUM_LIT:0> <EOL> return ( str ( historyHeight + tabsHeight + contentHeight + buttonsHeight <EOL> + previewHeight + <NUM_LIT:10> ) + '<STR_LIT>' ) <EOL> def createRGBTab ( self , color ) : <EOL> """<STR_LIT>""" <EOL> rgbLayout = VerticalLayout ( ) <EOL> rgbLayout . setMargin ( False , False , True , False ) <EOL> rgbLayout . addComponent ( self . _rgbPreview ) <EOL> self . _rgbGradient = ColorPickerGradient ( '<STR_LIT>' , RGBConverter ( ) ) <EOL> self . _rgbGradient . setColor ( color ) <EOL> self . _rgbGradient . addListener ( self , IColorChangeListener ) <EOL> rgbLayout . addComponent ( self . _rgbGradient ) <EOL> self . _selectors . add ( self . _rgbGradient ) <EOL> sliders = VerticalLayout ( ) <EOL> sliders . setStyleName ( '<STR_LIT>' ) <EOL> self . _redSlider = Slider ( '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> try : <EOL> self . _redSlider . setValue ( color . getRed ( ) ) <EOL> except ValueOutOfBoundsException : <EOL> pass <EOL> self . _redSlider . setImmediate ( True ) <EOL> self . _redSlider . setWidth ( '<STR_LIT>' ) <EOL> self . _redSlider . setStyleName ( '<STR_LIT>' ) <EOL> self . _redSlider . addStyleName ( '<STR_LIT>' ) <EOL> self . _redSlider . addListener ( RedValueChangeListener ( self ) , <EOL> IValueChangeListener ) <EOL> sliders . addComponent ( self . _redSlider ) <EOL> self . _greenSlider = Slider ( '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> try : <EOL> self . _greenSlider . setValue ( color . getGreen ( ) ) <EOL> except ValueOutOfBoundsException : <EOL> pass <EOL> self . _greenSlider . setStyleName ( '<STR_LIT>' ) <EOL> self . _greenSlider . addStyleName ( '<STR_LIT>' ) <EOL> self . _greenSlider . setWidth ( '<STR_LIT>' ) <EOL> self . _greenSlider . setImmediate ( True ) <EOL> self . _greenSlider . addListener ( GreenValueChangeListener ( self ) , <EOL> IValueChangeListener ) <EOL> sliders . addComponent ( self . _greenSlider ) <EOL> self . _blueSlider = Slider ( '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> try : <EOL> self . _blueSlider . setValue ( color . getBlue ( ) ) <EOL> except ValueOutOfBoundsException : <EOL> pass <EOL> self . _blueSlider . setStyleName ( '<STR_LIT>' ) <EOL> self . _blueSlider . setStyleName ( '<STR_LIT>' ) <EOL> self . _blueSlider . setImmediate ( True ) <EOL> self . _blueSlider . setWidth ( '<STR_LIT>' ) <EOL> self . _blueSlider . addListener ( BlueValueChangeListener ( self ) , <EOL> IValueChangeListener ) <EOL> sliders . addComponent ( self . _blueSlider ) <EOL> rgbLayout . addComponent ( sliders ) <EOL> return rgbLayout <EOL> def createHSVTab ( self , color ) : <EOL> """<STR_LIT>""" <EOL> hsvLayout = VerticalLayout ( ) <EOL> hsvLayout . setMargin ( False , False , True , False ) <EOL> hsvLayout . addComponent ( self . _hsvPreview ) <EOL> self . _hsvGradient = ColorPickerGradient ( '<STR_LIT>' , <EOL> HSVConverter ( self ) ) <EOL> self . _hsvGradient . setColor ( color ) <EOL> self . _hsvGradient . addListener ( self , IColorChangeListener ) <EOL> hsvLayout . addComponent ( self . _hsvGradient ) <EOL> self . _selectors . add ( self . _hsvGradient ) <EOL> hsv = color . getHSV ( ) <EOL> sliders = VerticalLayout ( ) <EOL> sliders . setStyleName ( '<STR_LIT>' ) <EOL> self . _hueSlider = Slider ( '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT> ) <EOL> try : <EOL> self . _hueSlider . setValue ( hsv [ <NUM_LIT:0> ] ) <EOL> except ValueOutOfBoundsException : <EOL> pass <EOL> self . _hueSlider . setStyleName ( '<STR_LIT>' ) <EOL> self . _hueSlider . addStyleName ( '<STR_LIT>' ) <EOL> self . _hueSlider . setWidth ( '<STR_LIT>' ) <EOL> self . _hueSlider . setImmediate ( True ) <EOL> self . _hueSlider . addListener ( HueValueChangeListener ( self ) , <EOL> IColorChangeListener ) <EOL> sliders . addComponent ( self . _hueSlider ) <EOL> self . _saturationSlider = Slider ( '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:100> ) <EOL> try : <EOL> self . _saturationSlider . setValue ( hsv [ <NUM_LIT:1> ] ) <EOL> except ValueOutOfBoundsException : <EOL> pass <EOL> self . _saturationSlider . setStyleName ( '<STR_LIT>' ) <EOL> self . _saturationSlider . setWidth ( '<STR_LIT>' ) <EOL> self . _saturationSlider . setImmediate ( True ) <EOL> self . _saturationSlider . addListener ( SaturationValueChangeListener ( self ) , <EOL> IColorChangeListener ) <EOL> sliders . addComponent ( self . _saturationSlider ) <EOL> self . _valueSlider = Slider ( '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:100> ) <EOL> try : <EOL> self . _valueSlider . setValue ( hsv [ <NUM_LIT:2> ] ) <EOL> except ValueOutOfBoundsException : <EOL> pass <EOL> self . _valueSlider . setStyleName ( '<STR_LIT>' ) <EOL> self . _valueSlider . setWidth ( '<STR_LIT>' ) <EOL> self . _valueSlider . setImmediate ( True ) <EOL> self . _valueSlider . addListener ( BrightnessValueChangeListener ( self ) , <EOL> IColorChangeListener ) <EOL> sliders . addComponent ( self . _valueSlider ) <EOL> hsvLayout . addComponent ( sliders ) <EOL> return hsvLayout <EOL> def createSelectTab ( self ) : <EOL> """<STR_LIT>""" <EOL> selLayout = VerticalLayout ( ) <EOL> selLayout . setMargin ( False , False , True , False ) <EOL> selLayout . addComponent ( self . _selPreview ) <EOL> self . _colorSelect = ColorPickerSelect ( ) <EOL> self . _colorSelect . addListener ( self , IColorChangeListener ) <EOL> selLayout . addComponent ( self . _colorSelect ) <EOL> return selLayout <EOL> def buttonClick ( self , event ) : <EOL> if event . getButton ( ) == self . _resize : <EOL> state = self . _resize . getData ( ) <EOL> if state : <EOL> self . _historyContainer . setHeight ( '<STR_LIT>' ) <EOL> self . _history . setHeight ( '<STR_LIT>' ) <EOL> else : <EOL> self . _historyContainer . setHeight ( '<STR_LIT>' ) <EOL> self . _history . setHeight ( '<STR_LIT>' ) <EOL> self . setHeight ( self . calculateHeight ( ) ) <EOL> self . _resize . setData ( bool ( not state ) ) <EOL> elif event . getButton ( ) == self . _ok : <EOL> self . _history . setColor ( self . getColor ( ) ) <EOL> self . fireColorChanged ( ) <EOL> self . close ( ) <EOL> elif event . getButton ( ) == self . _cancel : <EOL> self . close ( ) <EOL> def fireColorChanged ( self ) : <EOL> """<STR_LIT>""" <EOL> self . fireEvent ( ColorChangeEvent ( self , self . getColor ( ) ) ) <EOL> def getHistory ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _history <EOL> def setColor ( self , color ) : <EOL> if color is None : <EOL> return <EOL> self . _selectedColor = color <EOL> self . _hsvGradient . setColor ( self . _selectedColor ) <EOL> self . _hsvPreview . setColor ( self . _selectedColor ) <EOL> self . _rgbGradient . setColor ( self . _selectedColor ) <EOL> self . _rgbPreview . setColor ( self . _selectedColor ) <EOL> self . _selPreview . setColor ( self . _selectedColor ) <EOL> def getColor ( self ) : <EOL> return self . _selectedColor <EOL> def getColorHistory ( self ) : <EOL> """<STR_LIT>""" <EOL> return list ( self . _history . getHistory ( ) ) <EOL> def colorChanged ( self , event ) : <EOL> self . _selectedColor = event . getColor ( ) <EOL> try : <EOL> self . _redSlider . setValue ( self . _selectedColor . getRed ( ) ) <EOL> self . _blueSlider . setValue ( self . _selectedColor . getBlue ( ) ) <EOL> self . _greenSlider . setValue ( self . _selectedColor . getGreen ( ) ) <EOL> hsv = self . _selectedColor . getHSV ( ) <EOL> self . _hueSlider . setValue ( hsv [ <NUM_LIT:0> ] * <NUM_LIT> ) <EOL> self . _saturationSlider . setValue ( hsv [ <NUM_LIT:1> ] * <NUM_LIT> ) <EOL> self . _valueSlider . setValue ( hsv [ <NUM_LIT:2> ] * <NUM_LIT> ) <EOL> except ValueOutOfBoundsException : <EOL> traceback . print_exc ( file = sys . stdout ) <EOL> for s in self . _selectors : <EOL> if ( event . getSource ( ) != s and s is not self <EOL> and s . getColor ( ) != self . _selectedColor ) : <EOL> s . setColor ( self . _selectedColor ) <EOL> def addListener ( self , listener , iface = None ) : <EOL> """<STR_LIT>""" <EOL> if ( isinstance ( listener , IColorChangeListener ) and <EOL> ( iface is None or issubclass ( iface , IColorChangeListener ) ) ) : <EOL> self . registerListener ( ColorChangeEvent , listener , <EOL> _COLOR_CHANGE_METHOD ) <EOL> super ( ColorPickerPopup , self ) . addListener ( listener , iface ) <EOL> def addCallback ( self , callback , eventType = None , * args ) : <EOL> if eventType is None : <EOL> eventType = callback . _eventType <EOL> if issubclass ( eventType , ColorChangeEvent ) : <EOL> self . registerCallback ( ColorChangeEvent , callback , None , * args ) <EOL> else : <EOL> super ( ColorPickerPopup , self ) . addCallback ( callback , eventType , <EOL> * args ) <EOL> def removeListener ( self , listener , iface = None ) : <EOL> """<STR_LIT>""" <EOL> if ( isinstance ( listener , IColorChangeListener ) and <EOL> ( iface is None or issubclass ( iface , IColorChangeListener ) ) ) : <EOL> self . withdrawListener ( ColorChangeEvent , listener ) <EOL> super ( ColorPickerPopup , self ) . removeListener ( listener , iface ) <EOL> def removeCallback ( self , callback , eventType = None ) : <EOL> if eventType is None : <EOL> eventType = callback . _eventType <EOL> if issubclass ( eventType , ColorChangeEvent ) : <EOL> self . withdrawCallback ( ColorChangeEvent , callback ) <EOL> else : <EOL> super ( ColorPickerPopup , self ) . removeCallback ( callback , eventType ) <EOL> def tabIsVisible ( self , tab ) : <EOL> """<STR_LIT>""" <EOL> tabIterator = self . _tabs . getComponentIterator ( ) <EOL> for t in tabIterator : <EOL> if t == tab : <EOL> return True <EOL> return False <EOL> def tabsNumVisible ( self ) : <EOL> """<STR_LIT>""" <EOL> tabIterator = self . _tabs . getComponentIterator ( ) <EOL> tabCounter = <NUM_LIT:0> <EOL> for _ in tabIterator : <EOL> tabCounter += <NUM_LIT:1> <EOL> return tabCounter <EOL> def checkIfTabsNeeded ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . tabsNumVisible ( ) == <NUM_LIT:1> : <EOL> self . _tabs . hideTabs ( True ) <EOL> self . setHeight ( self . calculateHeight ( ) ) <EOL> else : <EOL> self . _tabs . hideTabs ( False ) <EOL> self . setHeight ( self . calculateHeight ( ) ) <EOL> def setRGBTabVisible ( self , visible ) : <EOL> """<STR_LIT>""" <EOL> if visible and not self . tabIsVisible ( self . _rgbTab ) : <EOL> self . _tabs . addTab ( self . _rgbTab , '<STR_LIT>' , None ) <EOL> self . checkIfTabsNeeded ( ) <EOL> elif not visible and self . tabIsVisible ( self . _rgbTab ) : <EOL> self . _tabs . removeComponent ( self . _rgbTab ) <EOL> self . checkIfTabsNeeded ( ) <EOL> def setHSVTabVisible ( self , visible ) : <EOL> """<STR_LIT>""" <EOL> if visible and not self . tabIsVisible ( self . _hsvTab ) : <EOL> self . _tabs . addTab ( self . _hsvTab , '<STR_LIT>' , None ) <EOL> self . checkIfTabsNeeded ( ) <EOL> elif not visible and self . tabIsVisible ( self . _hsvTab ) : <EOL> self . _tabs . removeComponent ( self . _hsvTab ) <EOL> self . checkIfTabsNeeded ( ) <EOL> def setSwatchesTabVisible ( self , visible ) : <EOL> """<STR_LIT>""" <EOL> if visible and not self . tabIsVisible ( self . _swatchesTab ) : <EOL> self . _tabs . addTab ( self . _swatchesTab , '<STR_LIT>' , None ) <EOL> self . checkIfTabsNeeded ( ) <EOL> elif not visible and self . tabIsVisible ( self . _swatchesTab ) : <EOL> self . _tabs . removeComponent ( self . _swatchesTab ) <EOL> self . checkIfTabsNeeded ( ) <EOL> def setHistoryVisible ( self , visible ) : <EOL> """<STR_LIT>""" <EOL> self . _historyContainer . setVisible ( visible ) <EOL> self . _resize . setVisible ( visible ) <EOL> self . setHeight ( self . calculateHeight ( ) ) <EOL> def setPreviewVisible ( self , visible ) : <EOL> """<STR_LIT>""" <EOL> self . _hsvPreview . setVisible ( visible ) <EOL> self . _rgbPreview . setVisible ( visible ) <EOL> self . _selPreview . setVisible ( visible ) <EOL> self . setHeight ( self . calculateHeight ( ) ) <EOL> def attach ( self ) : <EOL> self . setHeight ( self . calculateHeight ( ) ) <EOL> class RGBConverter ( ICoordinates2Color ) : <EOL> def calculate ( self , c_or_x , y = None ) : <EOL> if y is None : <EOL> c = c_or_x <EOL> hsv = c . getHSV ( ) <EOL> x = round ( hsv [ <NUM_LIT:0> ] * <NUM_LIT> ) <EOL> y = <NUM_LIT:0> <EOL> if hsv [ <NUM_LIT:1> ] == <NUM_LIT:1.0> : <EOL> y = round ( <NUM_LIT> - ( ( hsv [ <NUM_LIT:1> ] + hsv [ <NUM_LIT:2> ] ) * <NUM_LIT> ) ) <EOL> else : <EOL> y = round ( hsv [ <NUM_LIT:1> ] * <NUM_LIT> ) <EOL> return [ x , y ] <EOL> else : <EOL> x = c_or_x <EOL> h = x / <NUM_LIT> <EOL> s = <NUM_LIT:1.0> <EOL> v = <NUM_LIT:1.0> <EOL> if y < <NUM_LIT> : <EOL> s = y / <NUM_LIT> <EOL> elif y > <NUM_LIT> : <EOL> v = <NUM_LIT:1.0> - ( ( y - <NUM_LIT> ) / <NUM_LIT> ) <EOL> return Color ( * hsv_to_rgb ( h , s , v ) ) <EOL> class HSVConverter ( ICoordinates2Color ) : <EOL> def __init__ ( self , cpp ) : <EOL> self . _cpp = cpp <EOL> def calculate ( self , c_or_x , y = None ) : <EOL> if y is None : <EOL> c = c_or_x <EOL> hsv = c . getHSV ( ) <EOL> x = round ( hsv [ <NUM_LIT:2> ] * <NUM_LIT> ) <EOL> y = round ( <NUM_LIT> - ( hsv [ <NUM_LIT:1> ] * <NUM_LIT> ) ) <EOL> bgColor = Color ( * hsv_to_rgb ( hsv [ <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT:1.0> ) ) <EOL> self . _cpp . _hsvGradient . setBackgroundColor ( bgColor ) <EOL> return [ x , y ] <EOL> else : <EOL> x = c_or_x <EOL> saturation = <NUM_LIT:1.0> - ( y / <NUM_LIT> ) <EOL> value = x / <NUM_LIT> <EOL> hue = float ( str ( self . _cpp . _hueSlider . getValue ( ) ) ) / <NUM_LIT> <EOL> color = Color ( * hsv_to_rgb ( hue , saturation , value ) ) <EOL> return color <EOL> class _ColorValueChangeListener ( IValueChangeListener ) : <EOL> def __init__ ( self , cpp ) : <EOL> self . _cpp = cpp <EOL> class RedValueChangeListener ( _ColorValueChangeListener ) : <EOL> def valueChange ( self , event ) : <EOL> red = event . getProperty ( ) . getValue ( ) <EOL> newColor = Color ( int ( red ) , self . _cpp . _selectedColor . getGreen ( ) , <EOL> self . _cpp . _selectedColor . getBlue ( ) ) <EOL> self . _cpp . setColor ( newColor ) <EOL> class GreenValueChangeListener ( _ColorValueChangeListener ) : <EOL> def valueChange ( self , event ) : <EOL> green = event . getProperty ( ) . getValue ( ) <EOL> newColor = Color ( self . _cpp . _selectedColor . getRed ( ) , int ( green ) , <EOL> self . _cpp . _selectedColor . getBlue ( ) ) <EOL> self . _cpp . setColor ( newColor ) <EOL> class BlueValueChangeListener ( _ColorValueChangeListener ) : <EOL> def valueChange ( self , event ) : <EOL> blue = event . getProperty ( ) . getValue ( ) <EOL> newColor = Color ( self . _cpp . _selectedColor . getRed ( ) , <EOL> self . _cpp . _selectedColor . getGreen ( ) , int ( blue ) ) <EOL> self . _cpp . setColor ( newColor ) <EOL> class HueValueChangeListener ( _ColorValueChangeListener ) : <EOL> def valueChange ( self , event ) : <EOL> hue = float ( str ( event . getProperty ( ) . getValue ( ) ) ) / <NUM_LIT> <EOL> saturation = float ( str ( self . _cpp . _saturationSlider . getValue ( ) ) ) / <NUM_LIT> <EOL> value = float ( str ( self . _cpp . _valueSlider . getValue ( ) ) ) / <NUM_LIT> <EOL> color = Color ( * hsv_to_rgb ( hue , saturation , value ) ) <EOL> self . _cpp . setColor ( color ) <EOL> bgColor = Color ( * hsv_to_rgb ( hue , <NUM_LIT:1.0> , <NUM_LIT:1.0> ) ) <EOL> self . _cpp . _hsvGradient . setBackgroundColor ( bgColor ) <EOL> class SaturationValueChangeListener ( _ColorValueChangeListener ) : <EOL> def valueChange ( self , event ) : <EOL> hue = float ( str ( self . _cpp . _hueSlider . getValue ( ) ) ) / <NUM_LIT> <EOL> saturation = float ( str ( event . getProperty ( ) . getValue ( ) ) ) / <NUM_LIT> <EOL> value = float ( str ( self . _cpp . _valueSlider . getValue ( ) ) ) / <NUM_LIT> <EOL> self . _cpp . setColor ( Color ( * hsv_to_rgb ( hue , saturation , value ) ) ) <EOL> class BrightnessValueChangeListener ( _ColorValueChangeListener ) : <EOL> def valueChange ( self , event ) : <EOL> hue = float ( str ( self . _cpp . _hueSlider . getValue ( ) ) ) / <NUM_LIT> <EOL> saturation = float ( str ( self . _cpp . _saturationSlider . getValue ( ) ) ) / <NUM_LIT> <EOL> value = float ( str ( event . getProperty ( ) . getValue ( ) ) ) / <NUM_LIT> <EOL> self . _cpp . setColor ( Color ( * hsv_to_rgb ( hue , saturation , value ) ) ) </s>
