Documentation ¶
Index ¶
- Constants
- func GetParameterStatusString(params ...RenderParameter) string
- func GetParameterValueAsString(p RenderParameter) string
- func InitializeBasicRenderModel(m *BasicRenderModel)
- func InitializeEmptyRenderModel(m *EmptyRenderModel)
- func ParseComplex(v string) (complex128, error)
- func SetParameterValueFromString(p RenderParameter, v string)
- type BasicRenderModel
- type ChangeMonitor
- type Complex128RenderParameter
- type EmptyParameter
- func (e *EmptyParameter) GetHint() int
- func (e *EmptyParameter) GetName() string
- func (e *EmptyParameter) GetType() string
- func (e *EmptyParameter) GetValueComplex128() complex128
- func (e *EmptyParameter) GetValueFloat64() float64
- func (e *EmptyParameter) GetValueInt() int
- func (e *EmptyParameter) GetValueString() string
- func (e *EmptyParameter) GetValueUInt32() uint32
- func (e *EmptyParameter) SetHint(value int)
- func (e *EmptyParameter) SetValueComplex128(value complex128) complex128
- func (e *EmptyParameter) SetValueFloat64(value float64) float64
- func (e *EmptyParameter) SetValueInt(value int) int
- func (e *EmptyParameter) SetValueString(value string) string
- func (e *EmptyParameter) SetValueUInt32(value uint32) uint32
- type EmptyRenderModel
- func (e *EmptyRenderModel) AddParameters(Params ...RenderParameter)
- func (e *EmptyRenderModel) GetHintedParameterNames(hints int) []string
- func (e *EmptyRenderModel) GetHintedParameterNamesWithFallback(hints int) []string
- func (e *EmptyRenderModel) GetParameter(name string) RenderParameter
- func (e *EmptyRenderModel) GetParameterNames() []string
- func (e *EmptyRenderModel) GetRequestPaintFunc() func()
- func (e *EmptyRenderModel) Render() image.Image
- func (e *EmptyRenderModel) SetRequestPaintFunc(f func())
- type Float64RenderParameter
- type IntRenderParameter
- type RenderModel
- type RenderParameter
- type StringRenderParameter
- type UInt32RenderParameter
Constants ¶
const ( HINT_NONE = 1 << iota HINT_HIDE = 1 << iota HINT_SIDEBAR = 1 << iota HINT_FOOTER = 1 << iota HINT_FULLTEXT = 1 << iota )
const ( OPT_NONE = iota // 0 OPT_CENTER_ZOOM = 1 << iota // 1 OPT_AUTO_ZOOM = 1 << iota // 2 )
const ZOOM_RATE = 0.1
Variables ¶
This section is empty.
Functions ¶
func GetParameterStatusString ¶
func GetParameterStatusString(params ...RenderParameter) string
func GetParameterValueAsString ¶
func GetParameterValueAsString(p RenderParameter) string
GetParameterValueAsString replaces the need to implement GetValueString on each parameter. Custom parameters should override GetValueString to override this behavior.
func InitializeBasicRenderModel ¶
func InitializeBasicRenderModel(m *BasicRenderModel)
Use Initialize to set up a BasicRenderModel when you have embedded it in your own model Remember to add a go m.GoRender() or call Start()
func InitializeEmptyRenderModel ¶
func InitializeEmptyRenderModel(m *EmptyRenderModel)
InitializeEmptyRenderModel should be called to initialize the EmptyRenderModel when embedded in your own struct.
func ParseComplex ¶
func ParseComplex(v string) (complex128, error)
func SetParameterValueFromString ¶
func SetParameterValueFromString(p RenderParameter, v string)
SetParameterValueAsString replaces the need to implement SetValueString on each parameter. Custom parameters should override SetValueString to override this behavior.
Types ¶
type BasicRenderModel ¶
type BasicRenderModel struct { EmptyRenderModel RequestRender chan interface{} NeedsRender bool Rendering bool Img image.Image InnerRender func() // contains filtered or unexported fields }
BasicRenderModel should suffice for many users, and can be embedded to provide its functionality to your own models. It provides an easy way to attach your own rendering implementation that will be called in a separate goroutine.
func NewBasicRenderModel ¶
func NewBasicRenderModel() *BasicRenderModel
func (*BasicRenderModel) GoRender ¶
func (m *BasicRenderModel) GoRender()
GoRender is called by Start and calls your provided InnerRender function when needed.
func (*BasicRenderModel) Render ¶
func (m *BasicRenderModel) Render() image.Image
Called by RenderView
func (*BasicRenderModel) Start ¶
func (m *BasicRenderModel) Start()
Start only needs to be called if you have embedded BasicRenderModel in your own struct.
type ChangeMonitor ¶
type ChangeMonitor struct { sync.Mutex Params []RenderParameter // contains filtered or unexported fields }
ChangeMonitor implements comparing the value of a subset of parameters to determine whether a redraw or recalculation is required
func NewChangeMonitor ¶
func NewChangeMonitor() *ChangeMonitor
func (*ChangeMonitor) AddParameters ¶
func (c *ChangeMonitor) AddParameters(params ...RenderParameter)
func (*ChangeMonitor) HasChanged ¶
func (c *ChangeMonitor) HasChanged() bool
type Complex128RenderParameter ¶
type Complex128RenderParameter struct { EmptyParameter Value complex128 }
func NewComplex128RP ¶
func NewComplex128RP(name string, value complex128) *Complex128RenderParameter
func (*Complex128RenderParameter) GetValueComplex128 ¶
func (e *Complex128RenderParameter) GetValueComplex128() complex128
func (*Complex128RenderParameter) SetValueComplex128 ¶
func (e *Complex128RenderParameter) SetValueComplex128(v complex128) complex128
type EmptyParameter ¶
func (*EmptyParameter) GetHint ¶
func (e *EmptyParameter) GetHint() int
func (*EmptyParameter) GetName ¶
func (e *EmptyParameter) GetName() string
func (*EmptyParameter) GetType ¶
func (e *EmptyParameter) GetType() string
func (*EmptyParameter) GetValueComplex128 ¶
func (e *EmptyParameter) GetValueComplex128() complex128
func (*EmptyParameter) GetValueFloat64 ¶
func (e *EmptyParameter) GetValueFloat64() float64
func (*EmptyParameter) GetValueInt ¶
func (e *EmptyParameter) GetValueInt() int
func (*EmptyParameter) GetValueString ¶
func (e *EmptyParameter) GetValueString() string
func (*EmptyParameter) GetValueUInt32 ¶
func (e *EmptyParameter) GetValueUInt32() uint32
func (*EmptyParameter) SetHint ¶
func (e *EmptyParameter) SetHint(value int)
func (*EmptyParameter) SetValueComplex128 ¶
func (e *EmptyParameter) SetValueComplex128(value complex128) complex128
func (*EmptyParameter) SetValueFloat64 ¶
func (e *EmptyParameter) SetValueFloat64(value float64) float64
func (*EmptyParameter) SetValueInt ¶
func (e *EmptyParameter) SetValueInt(value int) int
func (*EmptyParameter) SetValueString ¶
func (e *EmptyParameter) SetValueString(value string) string
func (*EmptyParameter) SetValueUInt32 ¶
func (e *EmptyParameter) SetValueUInt32(value uint32) uint32
type EmptyRenderModel ¶
type EmptyRenderModel struct { sync.Mutex Params []RenderParameter RequestPaint func() }
EmptyRenderModel concretizes the most important elements of the RenderModel, the bag of Parameters (Params) and the RequestPaint function (which the view sets) - call this latter function to inform the view that you have provided a new image or set of information needing a render. It is not usable as a RenderModel by itself, as the implementation of Render simply returns nil. Embed it in your RenderModel struct.
func (*EmptyRenderModel) AddParameters ¶
func (e *EmptyRenderModel) AddParameters(Params ...RenderParameter)
AddParameters accepts any number of parameters and adds them to the Params bag. It does not do ANY checking for duplication!
func (*EmptyRenderModel) GetHintedParameterNames ¶
func (e *EmptyRenderModel) GetHintedParameterNames(hints int) []string
GetHintedParameterNames returns a list of parameters with one of the passed hints
func (*EmptyRenderModel) GetHintedParameterNamesWithFallback ¶
func (e *EmptyRenderModel) GetHintedParameterNamesWithFallback(hints int) []string
GetHintedParameterNamesWithFallback retrieves the names of parameters matching hints, if that is the empty set, it retrieves the names of parameters with no hints
func (*EmptyRenderModel) GetParameter ¶
func (e *EmptyRenderModel) GetParameter(name string) RenderParameter
GetParameter returns a named parameter. If you implement your own RenderModel from scratch, without using the EmptyRenderModel as a basis, you must either include ALL the default parameters, or duplicate the behavior of EmptyRenderModel in returning an EmptyParameter when a non-existent parameter is requested.
func (*EmptyRenderModel) GetParameterNames ¶
func (e *EmptyRenderModel) GetParameterNames() []string
GetParameterNames returns a list of valid parameter names
func (*EmptyRenderModel) GetRequestPaintFunc ¶
func (e *EmptyRenderModel) GetRequestPaintFunc() func()
Included for completeness. In general, there is no need for your code to use the RenderModel interface instead of a concrete form, so you can simply access e.RequestPaint directly.
func (*EmptyRenderModel) Render ¶
func (e *EmptyRenderModel) Render() image.Image
func (*EmptyRenderModel) SetRequestPaintFunc ¶
func (e *EmptyRenderModel) SetRequestPaintFunc(f func())
Used by the RenderView to supply a function you can call to inform the view that it should perform a repaint.
type Float64RenderParameter ¶
type Float64RenderParameter struct { EmptyParameter Value float64 }
func NewFloat64RP ¶
func NewFloat64RP(name string, value float64) *Float64RenderParameter
func (*Float64RenderParameter) GetValueFloat64 ¶
func (e *Float64RenderParameter) GetValueFloat64() float64
func (*Float64RenderParameter) SetValueFloat64 ¶
func (e *Float64RenderParameter) SetValueFloat64(v float64) float64
type IntRenderParameter ¶
type IntRenderParameter struct { EmptyParameter Value int }
func NewIntRP ¶
func NewIntRP(name string, value int) *IntRenderParameter
func (*IntRenderParameter) GetValueInt ¶
func (e *IntRenderParameter) GetValueInt() int
func (*IntRenderParameter) SetValueInt ¶
func (e *IntRenderParameter) SetValueInt(v int) int
type RenderModel ¶
type RenderModel interface { Lock() Unlock() GetParameterNames() []string GetHintedParameterNames(hint int) []string GetHintedParameterNamesWithFallback(hint int) []string GetParameter(name string) RenderParameter Render() image.Image SetRequestPaintFunc(func()) GetRequestPaintFunc() func() }
RenderModel is the interface you will implement to stand between your visualization code and the RenderView. You are primarily responsible for providing a set of RenderParameters and providing an Image upon request via Render.
type RenderParameter ¶
type RenderParameter interface { GetName() string GetType() string GetHint() int SetHint(int) GetValueInt() int GetValueUInt32() uint32 GetValueFloat64() float64 GetValueComplex128() complex128 GetValueString() string SetValueInt(value int) int SetValueUInt32(value uint32) uint32 SetValueFloat64(value float64) float64 SetValueComplex128(value complex128) complex128 SetValueString(value string) string }
func DefaultParameters ¶
func SetHints ¶
func SetHints(hint int, params ...RenderParameter) []RenderParameter
type StringRenderParameter ¶
type StringRenderParameter struct { EmptyParameter Value string }
func NewStringRP ¶
func NewStringRP(name string, value string) *StringRenderParameter
func (*StringRenderParameter) GetValueString ¶
func (e *StringRenderParameter) GetValueString() string
func (*StringRenderParameter) SetValueString ¶
func (e *StringRenderParameter) SetValueString(v string) string
type UInt32RenderParameter ¶
type UInt32RenderParameter struct { EmptyParameter Value uint32 }
func NewUInt32RP ¶
func NewUInt32RP(name string, value uint32) *UInt32RenderParameter
func (*UInt32RenderParameter) GetValueString ¶
func (e *UInt32RenderParameter) GetValueString() string
func (*UInt32RenderParameter) GetValueUInt32 ¶
func (e *UInt32RenderParameter) GetValueUInt32() uint32
func (*UInt32RenderParameter) SetValueString ¶
func (e *UInt32RenderParameter) SetValueString(v string) string
func (*UInt32RenderParameter) SetValueUInt32 ¶
func (e *UInt32RenderParameter) SetValueUInt32(v uint32) uint32