diff --git a/service/border/processor.go b/service/border/handler.go similarity index 88% rename from service/border/processor.go rename to service/border/handler.go index dee4cdf..530046f 100644 --- a/service/border/processor.go +++ b/service/border/handler.go @@ -13,12 +13,26 @@ import ( "strings" ) +type Style string + +const ( + StyleSimple Style = "simple" + StyleTextBottom Style = "text_bottom" +) + +type Parameterizable interface { + Input() string + SetInput(input string) + Output() string + SetOutput(output string) +} + type StyleProcessor struct { style Style - params Parameter + params Parameterizable } -func NewStyleProcessor(style Style, params Parameter) *StyleProcessor { +func NewStyleProcessor(style Style, params Parameterizable) *StyleProcessor { return &StyleProcessor{ style: style, params: params, diff --git a/service/border/parameter.go b/service/border/parameter.go deleted file mode 100644 index 830df26..0000000 --- a/service/border/parameter.go +++ /dev/null @@ -1,99 +0,0 @@ -package border - -import ( - "github.com/sincerefly/capybara/utils" - "image/color" - "path/filepath" -) - -type Style string - -const ( - StyleSimple Style = "simple" - StyleTextBottom Style = "text_bottom" -) - -type GeneralParameter struct { - style Style - input string - output string - borderWidth int - borderColor color.Color -} - -func NewGeneralParameter() GeneralParameter { - return GeneralParameter{} -} - -func (p *GeneralParameter) SetStyle(style Style) *GeneralParameter { - p.style = style - return p -} - -func (p *GeneralParameter) SetDefaultStyle() *GeneralParameter { - p.style = StyleSimple - return p -} - -func (p *GeneralParameter) GetStyle() Style { - return p.style -} - -func (p *GeneralParameter) SetInput(inputDir string) *GeneralParameter { - p.input = inputDir - return p -} - -func (p *GeneralParameter) SetDefaultInput() *GeneralParameter { - dir, err := utils.ExecutableDir() - if err != nil { - return nil - } - p.input = filepath.Join(dir, "input") - return p -} - -func (p *GeneralParameter) Input() string { - return p.input -} - -func (p *GeneralParameter) SetOutput(outputDir string) *GeneralParameter { - p.output = outputDir - return p -} - -func (p *GeneralParameter) SetDefaultOutput() *GeneralParameter { - dir, err := utils.ExecutableDir() - if err != nil { - return nil - } - p.output = filepath.Join(dir, "output") - return p -} - -func (p *GeneralParameter) Output() string { - return p.output -} - -func (p *GeneralParameter) SetBorderWidth(borderWidth int) *GeneralParameter { - p.borderWidth = borderWidth - return p -} - -func (p *GeneralParameter) GetBorderWidth() int { - return p.borderWidth -} - -func (p *GeneralParameter) SetBorderColor(color color.Color) *GeneralParameter { - p.borderColor = color - return p -} - -func (p *GeneralParameter) GetBorderColor() color.Color { - return p.borderColor -} - -type Parameter interface { - Input() string - Output() string -}