public function createPalette($name = null)
    {
        if ($this->palette) {
            $this->finishPalette();
        }

        $palette = $this->paletteClass->newInstance();

        if ($name) {
            $palette->setName($name);
        }

        $event = new CreatePaletteEvent($palette, $this);
        $this->dispatchEvent($event);
        $this->palette = $event->getPalette();

        return $this;
    }