Пример #1
0
    def createHSVTab(self, color):
        """Creates the hsv tab.

        @return: the component
        """
        hsvLayout = VerticalLayout()
        hsvLayout.setMargin(False, False, True, False)
        hsvLayout.addComponent(self._hsvPreview)

        # Add the hsv gradient
        self._hsvGradient = ColorPickerGradient('hsv-gradient',
                HSVConverter(self))
        self._hsvGradient.setColor(color)
        self._hsvGradient.addListener(self, IColorChangeListener)
        hsvLayout.addComponent(self._hsvGradient)
        self._selectors.add(self._hsvGradient)

        # Add the hsv sliders
        hsv = color.getHSV()
        sliders = VerticalLayout()
        sliders.setStyleName('hsv-sliders')

        self._hueSlider = Slider('Hue', 0, 360)
        try:
            self._hueSlider.setValue(hsv[0])
        except ValueOutOfBoundsException:
            pass

        self._hueSlider.setStyleName('hsv-slider')
        self._hueSlider.addStyleName('hue-slider')
        self._hueSlider.setWidth('220px')
        self._hueSlider.setImmediate(True)
        self._hueSlider.addListener(HueValueChangeListener(self),
                IColorChangeListener)
        sliders.addComponent(self._hueSlider)

        self._saturationSlider = Slider('Saturation', 0, 100)
        try:
            self._saturationSlider.setValue(hsv[1])
        except ValueOutOfBoundsException:
            pass

        self._saturationSlider.setStyleName('hsv-slider')
        self._saturationSlider.setWidth('220px')
        self._saturationSlider.setImmediate(True)
        self._saturationSlider.addListener(SaturationValueChangeListener(self),
                IColorChangeListener)
        sliders.addComponent(self._saturationSlider)

        self._valueSlider = Slider('Value', 0, 100)
        try:
            self._valueSlider.setValue(hsv[2])
        except ValueOutOfBoundsException:
            pass

        self._valueSlider.setStyleName('hsv-slider')
        self._valueSlider.setWidth('220px')
        self._valueSlider.setImmediate(True)
        self._valueSlider.addListener(BrightnessValueChangeListener(self),
                IColorChangeListener)
        sliders.addComponent(self._valueSlider)

        hsvLayout.addComponent(sliders)

        return hsvLayout
Пример #2
0
    def createRGBTab(self, color):
        """Creates the rgb tab.

        @return: the component
        """
        rgbLayout = VerticalLayout()
        rgbLayout.setMargin(False, False, True, False)
        rgbLayout.addComponent(self._rgbPreview)

        # Add the RGB color gradient
        self._rgbGradient = ColorPickerGradient('rgb-gradient', RGBConverter())
        self._rgbGradient.setColor(color)
        self._rgbGradient.addListener(self, IColorChangeListener)
        rgbLayout.addComponent(self._rgbGradient)
        self._selectors.add(self._rgbGradient)

        # Add the RGB sliders
        sliders = VerticalLayout()
        sliders.setStyleName('rgb-sliders')

        self._redSlider = Slider('Red', 0, 255)
        try:
            self._redSlider.setValue(color.getRed())
        except ValueOutOfBoundsException:
            pass

        self._redSlider.setImmediate(True)
        self._redSlider.setWidth('220px')
        self._redSlider.setStyleName('rgb-slider')
        self._redSlider.addStyleName('red')
        self._redSlider.addListener(RedValueChangeListener(self),
                IValueChangeListener)
        sliders.addComponent(self._redSlider)

        self._greenSlider = Slider('Green', 0, 255)
        try:
            self._greenSlider.setValue(color.getGreen())
        except ValueOutOfBoundsException:
            pass

        self._greenSlider.setStyleName('rgb-slider')
        self._greenSlider.addStyleName('green')
        self._greenSlider.setWidth('220px')
        self._greenSlider.setImmediate(True)
        self._greenSlider.addListener(GreenValueChangeListener(self),
                IValueChangeListener)
        sliders.addComponent(self._greenSlider)

        self._blueSlider = Slider('Blue', 0, 255)
        try:
            self._blueSlider.setValue(color.getBlue())
        except ValueOutOfBoundsException:
            pass

        self._blueSlider.setStyleName('rgb-slider')
        self._blueSlider.setStyleName('blue')
        self._blueSlider.setImmediate(True)
        self._blueSlider.setWidth('220px')
        self._blueSlider.addListener(BlueValueChangeListener(self),
                IValueChangeListener)
        sliders.addComponent(self._blueSlider)

        rgbLayout.addComponent(sliders)

        return rgbLayout