// 布局组件
import Tab from '../ui/layout/tab'
import Container from '../ui/layout/container'
// 基础组件
import Text from '../ui/basic/text'
import Marquee from '../ui/basic/marquee'
import ScrollList from '../ui/basic/scroll_list'
import Image from '../ui/basic/image'
import Video from '../ui/basic/video'
import Timer from '../ui/basic/timer'
import Web from '../ui/basic/web'
import WordCloud from '../ui/basic/word_cloud'
import Slider from '../ui/basic/slider'
import Shape from '../ui/basic/shape'
// 图表
import Table from '../ui/charts/table'
import Bar from '../ui/charts/bar'
import BarCustom from '../ui/charts/bar_custom'
import BarHorizontal from '../ui/charts/bar_h'
import Line from '../ui/charts/line'
import DoubleAxis from '../ui/charts/double_axis'
import Scatter from '../ui/charts/scatter'
import Pie from '../ui/charts/pie'
import Radar from '../ui/charts/radar'
import Funnel from '../ui/charts/funnel'
// 指标
import Metric from '../ui/indicators/metric'
import Flop from '../ui/indicators/flop'
import ProgressBar from '../ui/indicators/progress_bar'
import Circle from '../ui/indicators/circle'
import LiquidFill from '../ui/indicators/liquid_fill'
import Gauge from '../ui/indicators/gauge'
// 交互
import TimeLine from '../ui/interactions/timeline'
import DatePicker from '../ui/interactions/date_picker'
import Button from '../ui/interactions/button'
import Select from '../ui/interactions/select'
import ButtonGroup from '../ui/interactions/button_group'
import Admin from '../ui/interactions/admin'
// 地图
import Map from '../ui/map/map'
import Legend from '../ui/map/legend'
// 自定义
import Custom from '../ui/custom'

class Painter {
  constructor(screen) {
    this.screen = screen
    this._painer = {
      pie: Pie,
      radar: Radar,
      line: Line,
      double_axis: DoubleAxis,
      scatter: Scatter,
      text: Text,
      table: Table,
      image: Image,
      video: Video,
      tab: Tab,
      bar: Bar,
      bar_custom: BarCustom,
      bar_h: BarHorizontal,
      gauge: Gauge,
      timeline: TimeLine,
      timer: Timer,
      web: Web,
      metric: Metric,
      button: Button,
      select: Select,
      button_group: ButtonGroup,
      map: Map,
      progress_bar: ProgressBar,
      flop: Flop,
      circle: Circle,
      marquee: Marquee,
      scroll_list: ScrollList,
      liquid_fill: LiquidFill,
      word_cloud: WordCloud,
      slider: Slider,
      custom: Custom,
      date_picker: DatePicker,
      funnel: Funnel,
      container: Container,
      admin: Admin,
      shape: Shape,
      legend: Legend
    }
  }

  draw(layer) {
    if (!this._painer[layer.type]) {
      throw new Error(
        `Error in component "${layer.name}(${layer.id})": Invalid component type "${layer.type}"`
      )
    }
    let component = new this._painer[layer.type](layer, this.screen)
    return component
  }
}

export default Painter
