pic

package module
v0.0.0-...-d7aad85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package pic defines the Plug-in Chart API for EngageOne® Designer/Generate. It provides the export functions called by Designer/Generate to create a chart image, and functions to help parse the chart configuration settings.

To use this package you must implement the pic.Client and pic.Builder interfaces. Tell pic about your Client implementation by calling the pic.SetClient() method in the init() function of your main.go file. When Designer/Generate needs to create a chart image, pic will call your Client.NewBuilder() method to create the image via your Builder implementation.

You must build your application with the -buildmode=c-shared option in order to create a .dll file that can be loaded by Designer and Generate. If you run Generate on Linux you will also need to build a .so file.

Index

Constants

View Source
const Inch = 144000.0

Inch defines the number of units in one inch.

Variables

View Source
var DefaultColor = Color{K: 100}

DefaultColor represents the default colour value (black).

View Source
var DefaultFont = Font{}

DefaultFont can be used to query the default font from Designer/Generate.

Functions

func SetClient

func SetClient(c Client, o Options)

SetClient specifies the implementation.

Types

type Builder

type Builder interface {
	SetFormat(format *ImageFormat, colorSpace *ColorSpace)
	SetSize(width, height Twiplet, dpi int32)
	Render() (*bytes.Buffer, error)
}

Builder creates a chart image.

type Client

type Client interface {
	NewBuilder(c *Config) Builder
}

Client is responsible for creating the chart Builder.

type Color

type Color struct {
	R, G, B    uint8
	C, M, Y, K uint8
}

Color represents a colour value from the chart configuration.

type ColorSpace

type ColorSpace int32

ColorSpace represents the preferred image colour space.

Image colour spaces understood by Designer/Generate.

func (ColorSpace) String

func (cs ColorSpace) String() string

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config represents the configuration of the chart to be rendered.

func (*Config) Color

func (c *Config) Color(name string) Color

Color gets the value of a property as a Color.

func (*Config) Data

func (c *Config) Data() *Data

Data gets all of the data properties from the configuration.

func (*Config) DataColors

func (c *Config) DataColors() (colors []Color)

DataColors gets the data colours dataset from the configuration.

func (*Config) DataFonts

func (c *Config) DataFonts() (fonts []Font)

DataFonts gets the data fonts dataset from the configuration.

func (*Config) DataFormats

func (c *Config) DataFormats() DataStyles

DataFormats gets the data formats dataset from the configuration.

func (*Config) DataLabels

func (c *Config) DataLabels() []Value

DataLabels gets the data labels dataset from the configuration.

func (*Config) DataStyles

func (c *Config) DataStyles() DataStyles

DataStyles gets the data styles dataset from the configuration.

func (*Config) DataTitles

func (c *Config) DataTitles() (titles []Value)

DataTitles gets the data titles dataset from the configuration.

func (*Config) DataValues

func (c *Config) DataValues() Dataset

DataValues gets the data values dataset from the configuration.

func (*Config) Dataset

func (c *Config) Dataset(name string) Dataset

Dataset gets a set of data values from the configuration.

func (*Config) Font

func (c *Config) Font(name string) Font

Font gets the value of a property as a Font.

func (*Config) Integer

func (c *Config) Integer(name string) int32

Integer gets the value of a property as an integer. Zero is returned if the string is empty or the conversion fails.

func (*Config) Name

func (c *Config) Name() string

Name gets the configuration name.

func (*Config) Number

func (c *Config) Number(name string) float64

Number gets the value of a property as a number. Zero is returned if the string is empty or the conversion fails.

func (*Config) NumberFormat

func (c *Config) NumberFormat() NumberFormat

NumberFormat defines how a number should be formatted for display.

func (*Config) ResolveFont

func (c *Config) ResolveFont(f Font) *FontStyle

ResolveFont gets a font resource from a Font value.

func (*Config) ResolveInteger

func (c *Config) ResolveInteger(v Value) int32

ResolveInteger converts a value to an integer. Zero is returned if the string is empty or the conversion fails.

func (*Config) ResolveNumber

func (c *Config) ResolveNumber(v Value) float64

ResolveNumber converts a value to a number. Zero is returned if the string is empty or the conversion fails.

func (*Config) ResolveTwiplet

func (c *Config) ResolveTwiplet(v Value) Twiplet

ResolveTwiplet converts a value to a Twiplet. Zero is returned if the string is empty or the conversion fails.

func (*Config) Twiplet

func (c *Config) Twiplet(name string) Twiplet

Twiplet gets the value of a property as a Twiplet. Zero is returned if the string is empty or the conversion fails.

func (*Config) Value

func (c *Config) Value(name string) Value

Value gets the value of a property from the configuration.

type Data

type Data struct {
	Values  Dataset
	Titles  []Value
	Colors  []Color
	Styles  DataStyles
	Labels  []Value
	Fonts   []Font
	Formats DataStyles
}

Data represents the chart data properties.

type DataStyle

type DataStyle struct {
	Type     string
	Settings map[string]Value
}

DataStyle represents a style to apply to a data value.

type DataStyles

type DataStyles [][]DataStyle

DataStyles represents a set of styles to apply to the data values.

func (DataStyles) At

func (ds DataStyles) At(row, col int) *DataStyle

At returns the data style of a particular data value.

func (DataStyles) CustomFormat

func (ds DataStyles) CustomFormat(row, col int) Value

CustomFormat determines the special custom format setting of a data value.

func (DataStyles) Setting

func (ds DataStyles) Setting(row, col int, name string) Value

Setting determines a data style setting for a particular data value.

type DataType

type DataType int32

DataType represents a data field type.

Data types understood by Designer/Generate.

type Dataset

type Dataset [][]Value

Dataset represents a set of data values from the chart configuration.

type Font

type Font struct {
	IsStyle bool
	GUID
	Color
	Underline bool
}

Font represents a font value from the chart configuration.

type FontAttribute

type FontAttribute uint16

FontAttribute represents the attributes of a font.

Font attributes understood by Designer/Generate.

type FontResource

type FontResource struct {
	Typeface     string
	PointSize    float64
	Attributes   FontAttribute
	Filename     string
	TruetypeFont *truetype.Font
}

FontResource represents a font resource from Designer/Generate.

func (*FontResource) Bold

func (fr *FontResource) Bold() bool

Bold determines whether the font has the Bold attribute.

func (*FontResource) EmulateBold

func (fr *FontResource) EmulateBold() bool

EmulateBold determines whether the font has the EmulateBold attribute.

func (*FontResource) EmulateItalic

func (fr *FontResource) EmulateItalic() bool

EmulateItalic determines whether the font has the EmulateItalic attribute.

func (*FontResource) EmulateTypeface

func (fr *FontResource) EmulateTypeface() bool

EmulateTypeface determines whether the font has the EmulateTypeface attribute.

func (*FontResource) Italic

func (fr *FontResource) Italic() bool

Italic determines whether the font has the Italic attribute.

type FontStyle

type FontStyle struct {
	*FontResource
	Color
	Underline bool
}

FontStyle represents a font style from Designer/Generate.

type GUID

type GUID [16]byte

GUID represents a GUID value from the chart configuration.

func (*GUID) IsZero

func (g *GUID) IsZero() bool

IsZero determines whether the GUID is all zeroes.

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image represents the chart image requirements.

type ImageFormat

type ImageFormat int32

ImageFormat represents the preferred image format.

Image formats understood by Designer/Generate.

func (ImageFormat) String

func (f ImageFormat) String() string

type LogLevel

type LogLevel int

LogLevel specifies which information will be logged.

const (
	LogErrors LogLevel = iota
	LogInfo
)

LogLevel enumeration.

type NumberFormat

type NumberFormat struct {
	ThousandsSeparator, DecimalPoint rune
}

NumberFormat defines how a number should be formatted for display.

type Options

type Options struct {
	LogLevel
	LogFileName string
}

Options supplied by the client of the API.

func (Options) LogInfo

func (o Options) LogInfo() bool

LogInfo determines whether info level logging is enabled.

type ReturnCode

type ReturnCode int32

ReturnCode represents the API return codes.

API return codes understood by Designer/Generate.

func EnchCreateImage

func EnchCreateImage(
	callbackPtr unsafe.Pointer,
	propertiesPtr, symbolsPtr *C.char,
	imagePtr unsafe.Pointer,
) (rc ReturnCode)

EnchCreateImage is called by Designer/Generate to create a chart image from a list of configuration settings (propertiesPtr). These settings appear in the form name=value where value may be a constant, or refer to a field in the symbol table (symbolsPtr). Image information is conveyed via imagePtr; a C pointer represented by the Image struct. The callbackPtr parameter contains pointers to functions defined by Designer/Generate to resolve data values, fonts and locale information.

func EnchDestroyImage

func EnchDestroyImage(imagePtr unsafe.Pointer) ReturnCode

EnchDestroyImage is called by Designer/Generate to destroy the chart image data created by EnchCreateImage.

func EnchTerminate

func EnchTerminate() ReturnCode

EnchTerminate is called by Generate to tidy up before the program exits. The Failed ReturnCode is returned here to indicate that it is unsafe for Generate to unload this module as the Go runtime may still need to do some garbage collection.

func (ReturnCode) String

func (rc ReturnCode) String() string

type Twiplet

type Twiplet int32

Twiplet represents a unit of measure in 1/100ths of a twip.

func (Twiplet) Inches

func (t Twiplet) Inches() float64

Inches converts the measurement to inches.

func (Twiplet) Pixels

func (t Twiplet) Pixels(dpi int32) int

Pixels converts the measurement to pixels.

type Value

type Value string

Value represents a value of a property from the configuration.

func (Value) Text

func (v Value) Text() string

Text converts the value to displayable text by removing the escape sequence identifying the value type.

func (Value) True

func (v Value) True() bool

True determines whether a bool value is true.

func (Value) Type

func (v Value) Type() DataType

Type returns the value type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL