rings

package
v0.0.0-...-8508f36 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package rings implements a number of graphical representations of genomic features and feature associations using the idioms developed in the Circos distribution.

The rings package borrows significantly from the ideas of Circos and shares some implementation details in order to run as a work-a-like. Circos is available from http://circos.ca/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rectangular

func Rectangular(theta Angle, r vg.Length) vg.Point

Rectangular returns the rectangular coordinates for the location defined by theta and r in polar coordinates.

Types

type Angle

type Angle float64

Angle represents an angle in radians. Angles increase in the counter clockwise direction.

const (
	Clockwise        Angle = -1
	CounterClockwise Angle = 1

	Complete Angle = Angle(2 * math.Pi)
)

func Normalize

func Normalize(theta Angle) Angle

Normalize returns the angle corresponding to theta in the range [0, 2*math.Pi).

func Polar

func Polar(p vg.Point) (theta Angle, r vg.Length)

Polar returns the polar coordinates of a point.

type Arc

type Arc struct {
	Theta Angle // Initial angle of an arc in radians.
	Phi   Angle // The sweep of the arc in radians.
}

Arc represents an arc of a circle.

func (Arc) Arc

func (a Arc) Arc() Arc

Arc returns a copy of the Arc.

func (Arc) Contains

func (a Arc) Contains(alpha Angle) bool

Contains returns a boolean indicating whether the parameter falls within the arc described by the receiver.

type ArcOfer

type ArcOfer interface {
	Arcer

	// ArcOf must return a non-nil error if the Feature is not found by
	// the receiver or the query is nil, unless the receiver is an Arc. When
	// the receiver is an Arc the error returned is always nil.
	ArcOf(loc, f Feature) (Arc, error)
}

ArcOfer is an Arcer that contains a collection of features mapped to its span.

type Arcer

type Arcer interface {
	Arc() Arc
}

Arcer is a type that describes an arc of circle.

type Arcs

type Arcs struct {
	Base Arc             // Base represents the complete span of the Arcs.
	Arcs map[Feature]Arc // Arcs provides a lookup for features within the span.
}

Arcs is the base ArcOfer implementation provided by the rings package.

func NewGappedArcs

func NewGappedArcs(base Arcer, fs []Feature, gap float64) Arcs

NewGappedArcs returns an Arcs that maps the provided features to the base arc with a fractional gap between each feature.

func (Arcs) Arc

func (a Arcs) Arc() Arc

Arc returns the base arc of the Arcs.

func (Arcs) ArcOf

func (a Arcs) ArcOf(loc, f Feature) (Arc, error)

ArcOf returns the arc of a feature in the context of the provided location.

The behaviour of ArcOf depends on the nil status of loc and f:

  • if both loc and f are non-nil, f must have a sub-feature relationship with loc, and the returned arc will be the arc of f.
  • if either of loc or f are nil, then the arc of the non-nil parameter will be returned.
  • if both loc and f are nil, and no nil feature is found in the Arcs, the base arc will be returned.

If no matching feature is found a non-nil error is returned.

type Axis

type Axis struct {
	// Angle specifies the angular location of the axis.
	Angle Angle

	// Label describes the axis label configuration.
	Label AxisLabel

	// LineStyle is the style of the axis line.
	LineStyle draw.LineStyle

	// Tick describes the scale's tick configuration.
	Tick TickConfig

	// Grid is the style of the grid lines.
	Grid draw.LineStyle
}

Axis represents the radial axis of ring, usually a Scores.

type AxisLabel

type AxisLabel struct {
	// Text is the axis label string.
	Text string

	// TextStyle is the style of the axis label text.
	draw.TextStyle

	// Placement determines the text rotation and alignment.
	// If Placement is nil, DefaultPlacement is used.
	Placement TextPlacement
}

AxisLabel describes an axis label format and text.

type Bezier

type Bezier struct {
	// Segments defines the number of segments to draw when rendering the curve.
	Segments int

	// Radius, Crest and Purity define aspects of Bézier geometry.
	//
	// See http://circos.ca/documentation/tutorials/links/geometry/images for a detailed explanation
	// of radius, crest and purity.
	//
	// Radius specifies the Bézier radius of a curve generated by the Bezier.
	Radius LengthDist
	// Crest and Purity specify the crest and purity behaviour of a curve generated by the Bezier.
	// If nil, these values are not used.
	Crest  *FactorDist
	Purity *FactorDist
}

Bezier defines Bézier control points for a link between features represented by Links and Ribbons.

func (*Bezier) ControlPoints

func (b *Bezier) ControlPoints(a [2]Angle, rad [2]vg.Length) []vg.Point

ControlPoints returns a set of Bézier curve control points defining the path between the points defined by the parameters and the Bezier's Radius, Crest and Purity fields.

type Blocks

type Blocks struct {
	// Set holds a collection of features to render.
	Set []Feature

	// Base defines the targets of the rendered blocks.
	Base ArcOfer

	// Color determines the fill color of each block. If Color is not nil each block is rendered
	// filled with the specified color, otherwise no fill is performed. This behaviour is
	// over-ridden if the feature describing the block is a FillColorer.
	Color color.Color

	// LineStyle determines the line style of each block. LineStyle behaviour
	// is over-ridden if the feature describing a block is a LineStyler.
	LineStyle draw.LineStyle

	// Inner and Outer define the inner and outer radii of the blocks.
	Inner, Outer vg.Length

	// X and Y specify rendering location when Plot is called.
	X, Y float64
}

Blocks implements rendering of Features as radial blocks.

func NewBlocks

func NewBlocks(fs []Feature, base ArcOfer, inner, outer vg.Length) (*Blocks, error)

NewBlocks returns a Blocks based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable.

func NewGappedBlocks

func NewGappedBlocks(fs []Feature, base Arcer, inner, outer vg.Length, gap float64) (*Blocks, error)

NewGappedBlocks is a convenience wrapper of NewBlocks that guarantees to provide a valid ArcOfer based of the provided Arcer. If the provided Arcer is an ArcOfer it is tested for validity and a new ArcOfer is created only if needed.

func (*Blocks) Arc

func (r *Blocks) Arc() Arc

Arc returns the base arc of the Blocks.

func (*Blocks) ArcOf

func (r *Blocks) ArcOf(loc, f Feature) (Arc, error)

ArcOf returns the Arc location of the parameter. If the location is not found in the Blocks, an error is returned.

func (*Blocks) DrawAt

func (r *Blocks) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the feature of a Blocks at cen in the specified drawing area, according to the Blocks configuration.

func (*Blocks) GlyphBoxes

func (r *Blocks) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the blocks rendering.

func (*Blocks) Plot

func (r *Blocks) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Blocks' X and Y values as the drawing coordinates.

func (*Blocks) XY

func (r *Blocks) XY() (x, y float64)

XY returns the x and y coordinates of the Blocks.

type ColorFunc

type ColorFunc func(interface{}) color.Color

ColorFunc allows dynamic assignment of color to objects based on passed parameters.

type Conformation

type Conformation int8

Conformation describes whether a feature is linear or circular.

const (
	UndefinedConformation Conformation = iota - 1
	Linear
	Circular
)

func (Conformation) String

func (c Conformation) String() string

type Conformationer

type Conformationer interface {
	Conformation() Conformation
}

Conformationer wraps the Conformation method.

type FactorDist

type FactorDist struct {
	Factor   float64
	Min, Max *float64 // A nil value is interpreted as 1.
}

FactorDist generates a random value in the range [Length*Min, Length*Max), depending on a provided random factor.

func (*FactorDist) Perturb

func (p *FactorDist) Perturb(f float64) float64

Perturb returns a perturbed float value. Calling Perturb on a nil FactorDist will panic.

type Feature

type Feature interface {
	// Start and End indicate the position of the feature within the
	// containing Parent's coordinate system.
	Start() float64
	End() float64

	// Name returns the name of the feature.
	Name() string

	// Parent returns the reference feature on which the feature is located.
	Parent() Feature
}

Feature is a Range whose coordinates are defined relative to a feature location/parent. Start and End return the coordinates of the feature relative to its parent which can be nil. In the latter case callers should make no assumptions whether coordinates of such features are comparable.

type FillColorer

type FillColorer interface {
	FillColor() color.Color
}

FillColorer is a type that can define its fill color. For the purposes of the rings package a FillColoer that returns a nil Color is not rendered filled.

type Heat

type Heat struct {
	Palette   []color.Color
	Underflow color.Color
	Overflow  color.Color

	DrawArea draw.Canvas

	Center       vg.Point
	Inner, Outer vg.Length

	Min, Max float64
}

Heat is a ScoreRenderer that represents feature scores as a color block.

func (*Heat) Close

func (h *Heat) Close()

Close is a no-op.

func (*Heat) Configure

func (h *Heat) Configure(ca draw.Canvas, cen vg.Point, _ ArcOfer, inner, outer vg.Length, min, max float64)

Configure is called by Scores' DrawAt method. The min and max parameters are ignored if the Heat's Min and Max fields are both non-zero.

func (*Heat) Render

func (h *Heat) Render(arc Arc, scorer Scorer)

Render renders the values in scores across the specified arc from inner to outer. Rendering is performed eagerly.

type Highlight

type Highlight struct {
	// Base describes the arc through which the highlight should be drawn.
	Base Arc

	// Color determines the fill color of the highlight.
	Color color.Color

	// LineStyle determines the line style of the highlight.
	LineStyle draw.LineStyle

	// Inner and Outer define the inner and outer radii of the blocks.
	Inner, Outer vg.Length

	// X and Y specify rendering location when Plot is called.
	X, Y float64
}

Highlight implements rendering a colored arc.

func NewHighlight

func NewHighlight(col color.Color, base Arc, inner, outer vg.Length) *Highlight

NewHighlight returns a Highlight based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable.

func (*Highlight) Arc

func (r *Highlight) Arc() Arc

Arc returns the arc of the Highlight.

func (*Highlight) DrawAt

func (r *Highlight) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the feature of a Highlight at cen in the specified drawing area, according to the Highlight configuration.

func (*Highlight) GlyphBoxes

func (r *Highlight) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the highlight rendering.

func (*Highlight) Plot

func (r *Highlight) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Highlight's X and Y values as the drawing coordinates.

func (*Highlight) XY

func (r *Highlight) XY() (x, y float64)

XY returns the x and y coordinates of the Highlight.

type Label

type Label string

Label is a string that satisfies the Labeler interface. A Label may be used to label an Arc or a Highlight.

func (Label) Label

func (l Label) Label() string

Label returns the string used to label a feature.

type Labeler

type Labeler interface {
	Label() string
}

Labeler is a type that can be used to label a block in a ring.

func NameLabels

func NameLabels(fs []Feature) []Labeler

NameLabels returns a Labeler slice built from the provided slice of features. The labels returned are generated from the features' Name() values.

type Labels

type Labels struct {
	// Labels contains the set of labels. Labelers that are Features and are found
	// in the Base ArcOfer will label the identified block with the string returned
	// by their Name method.
	Labels []Labeler

	// Base describes the ring holding the features to be labeled.
	Base ArcOfer

	// TextStyle determines the text style of each label. TextStyle behaviour
	// is over-ridden if the Label describing a block is a TextStyler.
	TextStyle draw.TextStyle

	// Radius defines the inner radius of the labels.
	Radius vg.Length

	// Placement determines the text rotation and alignment. If Placement is
	// nil, DefaultPlacement is used.
	Placement TextPlacement

	// X and Y specify rendering location when Plot is called.
	X, Y float64
}

Labels implements rendering of radial labels.

func NewLabels

func NewLabels(base Arcer, r vg.Length, ls ...Labeler) (*Labels, error)

NewLabels returns a Labels based on the parameters, first checking that the provided set of labels are able to be rendered; an Arc or Highlight may only take a single label, otherwise the labels must be a Feature that can be found in the base ring. An error is returned if the labels are not renderable. If base is an XYer, the returned base XY values are used to populate the Labels' X and Y fields.

func (*Labels) DrawAt

func (r *Labels) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the text of a Labels at cen in the specified drawing area, according to the Labels configuration.

func (*Labels) GlyphBoxes

func (r *Labels) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the label rendering.

func (*Labels) Plot

func (r *Labels) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Labels' X and Y values as the drawing coordinates.

type LengthDist

type LengthDist struct {
	Length   vg.Length
	Min, Max *float64 // A nil value is interpreted as 1.
}

LengthDist generates a random value in the range [Length*Min, Length*Max), depending on a provided random factor.

func (*LengthDist) Perturb

func (p *LengthDist) Perturb(f float64) vg.Length

Perturb returns a perturbed vg.Length value. Calling Perturb on a nil LengthDist will panic.

type LineStyleFunc

type LineStyleFunc func(interface{}) draw.LineStyle

LineStyleFunc allows dynamic assignment of line styles to objects based on passed parameters.

type LineStyler

type LineStyler interface {
	LineStyle() draw.LineStyle
}

LineStyler is a type that can define its drawing line style. For the purposes of the rings package the lines of a LineStyler that returns a nil Color or a LineStyle with width 0 are not rendered.

type Links struct {
	// Set holds a collection of feature pairs to render.
	Set []Pair

	// Ends holds the elements that define the end targets of the rendered ribbons.
	Ends [2]ArcOfer
	// Radii indicates the distance of the ribbon end points from the center of the plot.
	Radii [2]vg.Length

	// Bezier describes the Bézier configuration for link rendering.
	Bezier *Bezier

	// LineStyle determines the line style of each link Bézier curve. LineStyle behaviour
	// is over-ridden if the Pair describing features is a LineStyler.
	LineStyle draw.LineStyle

	// X and Y specify rendering location when Plot is called.
	X, Y float64
}

Links implements rendering of Feature associations as Bézier curves.

func NewLinks(fp []Pair, ends [2]ArcOfer, r [2]vg.Length) (*Links, error)

NewLinks returns a Links based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable. The ends of a Links ring cannot be an Arc or a Highlight.

func (*Links) DrawAt

func (r *Links) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the feature pairs of a Links at cen in the specified drawing area, according to the Links configuration.

func (*Links) GlyphBoxes

func (r *Links) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the links rendering.

func (*Links) Plot

func (r *Links) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Links' X and Y values as the drawing coordinates.

type Orientation

type Orientation int8

Orientation describes whether a feature is oriented forwards or backwards.

const (
	Backward Orientation = iota - 1
	NotOriented
	Forward
)

func (Orientation) String

func (o Orientation) String() string

type Orienter

type Orienter interface {
	Orientation() Orientation
}

Orienter wraps the Orientation method.

type Pair

type Pair interface {
	Features() [2]Feature
}

Pair represents a pair of associated features.

type Ribbons

type Ribbons struct {
	// Set holds a collection of feature pairs to render.
	// If the features are both Orienters this is taken into account according to Twist.
	Set []Pair

	// Ends holds the elements that define the end targets of the rendered ribbons.
	Ends [2]ArcOfer
	// Radii indicates the distance of the ribbon end points from the center of the plot.
	Radii [2]vg.Length

	// Twist indicates how feature orientation should be rendered.
	//
	// None indicates no explicit twist; ribbons are drawn so that the start
	// and end positions of each feature are connected by Bézier curves.
	//
	//  f₀.Start -arc-> f₀.End -Bézier-> f₁.End -arc-> f₁.Start -Bézier-> f₀.Start
	//
	// Flat indicates ribbons should be rendered so that ribbons do not twist; paths are
	// drawn in angle sort order with each feature's end points joined by arcs.
	//
	// Individual allows a feature pair to define its ribbon twist; feature pairs where
	// both features satisfy Orienter are rendered according to the product of their
	// orientations:
	//
	//  +1 - as if the Twist flag were set, ignoring all other flags except Reverse.
	//   0 - according to the states of all other Twist flags.
	//  -1 - as if the Flat flag were set, ignoring all other flags except Reverse.
	//
	// Twisted indicates ribbons should be rendered so that ribbons twist; paths of the
	// first feature are drawn in angle sort order and paths of the second are drawn in
	// reverse angle sort order, with each feature's end points joined by arcs.
	//
	// Reverse inverts all twist behaviour.
	//
	// If Twist has both Flat and Twisted flags set, DrawAt and Plot will panic.
	Twist Twist

	// Bezier describes the Bézier configuration for ribbon rendering.
	Bezier *Bezier

	// Color determines the fill color of each ribbon. If Color is not nil each ribbon is
	// rendered filled with the specified color, otherwise no fill is performed. This
	// behaviour is over-ridden if the feature describing the block is a FillColorer.
	Color color.Color

	// LineStyle determines the line style of each ribbon. LineStyle behaviour is over-ridden
	// for end point arcs if the feature describing an end point is a LineStyler and for
	// Bézier curves if the Pair is a LineStyler.
	LineStyle draw.LineStyle

	// X and Y specify rendering location when Plot is called.
	X, Y float64
}

Ribbons implements rendering of Feature associations as ribbons.

func NewRibbons

func NewRibbons(fp []Pair, ends [2]ArcOfer, r [2]vg.Length) (*Ribbons, error)

NewRibbons returns a Ribbons based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable. The ends of a Ribbons ring cannot be an Arc or a Highlight.

func (*Ribbons) DrawAt

func (r *Ribbons) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the feature pairs of a Ribbons at cen in the specified drawing area, according to the Ribbons configuration. DrawAt will panic if the feature pairs being linked both satisfy Orienter and the product of orientations is not in {Forward,NotOriented,Backward}.

func (*Ribbons) GlyphBoxes

func (r *Ribbons) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the ribbons rendering.

func (*Ribbons) Plot

func (r *Ribbons) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Ribbons' X and Y values as the drawing coordinates.

type Sail

type Sail struct {
	// Set holds a collection of connected features to render.
	// If the features are Orienters this is taken into account according to Twist.
	Set []Feature

	// Base holds the element that defines the end targets of the rendered sail.
	Base ArcOfer
	// Radius indicates the distance of the sail end points from the center of the plot.
	Radius vg.Length

	// Twist indicates how feature orientation should be rendered.
	//
	// None indicates no explicit twist; sail ends are drawn so that the start
	// and end positions of each feature are connected by Bézier curves.
	// Thus if features are numbered in order of their appearance along an arc:
	//
	//  f₀.Start -arc-> f₀.End -Bézier-> f₁.End -arc-> f₁.Start -Bézier-> ... f₀.Start
	//
	// Flat indicates sails should be rendered so that sail ends do not twist; paths are
	// drawn in angle sort order with each feature's end points joined by arcs.
	//
	// Individual allows a feature to define the twist of its sail end depending on its
	// orientation:
	//
	//  -1 - as if the Twist flag were set, ignoring all other flags except Reverse.
	//   0 - according to the states of all other Twist flags.
	//  +1 - as if the Flat flag were set, ignoring all other flags except Reverse.
	//
	// Twisted indicates sails should be rendered so that sail ends twist; the overall
	// progression is in angle sort order with Bézier paths drawn in angle sort order
	// and each feature's end points joined by arcs in reverse angle sort order.
	//
	// Reverse inverts all twist behaviour.
	//
	// If Twist has both Flat and Twisted flags set, DrawAt and Plot will panic.
	Twist Twist

	// Bezier describes the Bézier configuration for sail rendering.
	Bezier *Bezier

	// Color determines the fill color of each sail. If Color is not nil each sail is
	// rendered filled with the specified color, otherwise no fill is performed.
	Color color.Color

	// LineStyle determines the line style of each sail. LineStyle behaviour is over-ridden
	// for end point arcs if the feature describing an end point is a LineStyler.
	LineStyle draw.LineStyle

	// X and Y specify rendering location when Plot is called.
	X, Y float64
}

Sail implements rendering of Feature associations as sails. A sail is conceptually a hyper edge connecting a number of features.

func NewSail

func NewSail(fs []Feature, base ArcOfer, r vg.Length) (*Sail, error)

NewSail returns a Sail based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable. The base of a Sail ring cannot be an Arc or a Highlight.

func (*Sail) DrawAt

func (r *Sail) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the features of a Sail at cen in the specified drawing area, according to the Sail configuration. DrawAt will panic if the feature pairs being linked both satisfy Orienter and the product of orientations is not in {Forward,NotOriented,Backward}.

func (*Sail) GlyphBoxes

func (r *Sail) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the ribbons rendering.

func (*Sail) Plot

func (r *Sail) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Sail's X and Y values as the drawing coordinates.

type Scale

type Scale struct {
	// Set holds a collection of features to render scales for.
	Set []Feature

	// Base defines the targets of the rendered blocks.
	Base ArcOfer

	// Radius defines the radius of the axis.
	Radius vg.Length

	// LineStyle is the style of the axis line.
	LineStyle draw.LineStyle

	// Tick describes the scale's tick configuration.
	Tick TickConfig

	// Grid describes the scales grid configuration.
	Grid ScaleGrid

	X, Y float64
}

Scale represents the circular axis of ring.

func NewScale

func NewScale(fs []Feature, base ArcOfer, r vg.Length) (*Scale, error)

NewScale returns a Scale based on the parameters, first checking that the provided feature scales are able to be rendered. An error is returned if the scales are not renderable.

func (*Scale) DrawAt

func (r *Scale) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the scales at cen in the specified drawing area, according to the Scale configuration.

func (*Scale) GlyphBoxes

func (r *Scale) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the label rendering.

func (*Scale) Plot

func (r *Scale) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Scale's X and Y values as the drawing coordinates.

type ScaleGrid

type ScaleGrid struct {
	// Inner and Outer specify the extend of radial grid lines.
	Inner, Outer vg.Length

	// LineStyle is the style of the axis line.
	LineStyle draw.LineStyle
}

type ScoreRenderer

type ScoreRenderer interface {
	// Configure sets up the ScoreRenderer for set-wide values.
	// The min and max parameters may be ignored by an implementation.
	Configure(ca draw.Canvas, cen vg.Point, base ArcOfer, inner, outer vg.Length, min, max float64)

	// Render renders scores across the specified arc. Rendering may be
	// performed lazily.
	Render(Arc, Scorer)

	// Close finalises the rendering. For ScoreRenderers that do not
	// render lazily, this is a no-op.
	Close()
}

ScoreRenderer is a type that produces a graphical representation of a score series for a Scores ring.

type Scorer

type Scorer interface {
	Feature
	Scores() []float64
}

Scorer describes features that can provide scored values.

type Scores

type Scores struct {
	// Set holds a collection of features to render. Scores does not
	// make any check for Scorer overlap in Set.
	Set []Scorer

	// Base defines the targets of the rendered scores.
	Base ArcOfer

	// Renderer is the rendering implementation used to represent the
	// feature sets score data.
	Renderer ScoreRenderer

	// Min and Max hold the score range.
	Min, Max float64

	// Inner and Outer define the inner and outer radii of the blocks.
	Inner, Outer vg.Length

	// X and Y specify rendering location when Plot is called.
	X, Y float64
}

Scores implements rendering of Features as radial blocks.

func NewScores

func NewScores(fs []Scorer, base ArcOfer, inner, outer vg.Length, renderer ScoreRenderer) (*Scores, error)

NewScores returns a Scores based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable.

func (*Scores) DrawAt

func (r *Scores) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the feature of a Scores at cen in the specified drawing area, according to the Scores configuration.

func (*Scores) GlyphBoxes

func (r *Scores) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the score rendering.

func (*Scores) Plot

func (r *Scores) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Scores' X and Y values as the drawing coordinates.

type Spokes

type Spokes struct {
	// Set holds a collection of features to render.
	Set []Feature

	// Base holds the elements that define the targets of the rendered spokes.
	Base ArcOfer

	// LineStyle determines the line style of each spoke. LineStyle is over-ridden
	// for each spoke if the feature describing the spoke is a LineStyler.
	LineStyle draw.LineStyle

	// Inner and Outer define the inner and outer radii of the spokes.
	Inner, Outer vg.Length

	// X and Y specify rendering location when Plot is called.
	X, Y float64
}

Spokes implements rendering of Features representing 0 or 1 length features as radial lines.

func NewSpokes

func NewSpokes(fs []Feature, base ArcOfer, inner, outer vg.Length) (*Spokes, error)

NewSpokes returns a Spokes based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable. The base of a Spokes ring cannot be an Arc or a Highlight.

func (*Spokes) Arc

func (r *Spokes) Arc() Arc

Arc returns the base arc of the Spokes.

func (*Spokes) ArcOf

func (r *Spokes) ArcOf(loc, f Feature) (Arc, error)

ArcOf returns the Arc location of the parameter. If the location is not found in the Spokes, an error is returned.

func (*Spokes) DrawAt

func (r *Spokes) DrawAt(ca draw.Canvas, cen vg.Point)

DrawAt renders the feature of a Spokes at cen in the specified drawing area, according to the Spokes configuration.

func (*Spokes) GlyphBoxes

func (r *Spokes) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a liberal glyphbox for the blocks rendering.

func (*Spokes) Plot

func (r *Spokes) Plot(ca draw.Canvas, plt *plot.Plot)

Plot calls DrawAt using the Spokes' X and Y values as the drawing coordinates.

func (*Spokes) XY

func (r *Spokes) XY() (x, y float64)

XY returns the x and y coordinates of the Spokes.

type TextPlacement

type TextPlacement func(Angle) (rot Angle, xadjust, yadjust float64)

TextPlacement is used to determine text rotation and alignment by a Labels ring.

var (
	DefaultPlacement TextPlacement = tangential
	Horizontal       TextPlacement = horizontal
	Radial           TextPlacement = radial
	Tangential       TextPlacement = tangential
)

type TextStyler

type TextStyler interface {
	TextStyle() draw.TextStyle
}

TextStyler is a type that can define its text style. For the purposes of the rings package the lines of a LineStyler that returns a nil Color or a TextStyle with Font.Size of 0 are not rendered.

type TickConfig

type TickConfig struct {
	// Label is the TextStyle on the tick labels.
	Label draw.TextStyle

	// LineStyle is the LineStyle of the tick lines.
	LineStyle draw.LineStyle

	// Placement determines the text rotation and alignment.
	// If Placement is nil, DefaultPlacement is used.
	Placement TextPlacement

	// Length is the length of a major tick mark.
	// Minor tick marks are half of the length of major
	// tick marks.
	Length vg.Length

	// Marker returns the tick marks. Any tick marks
	// returned by the Marker function that are not in
	// range of the axis are not drawn.
	Marker plot.Ticker
}

TickConfig describes an axis tick configuration.

type Trace

type Trace struct {
	// LineStyles determines the lines style for each trace.
	LineStyles []draw.LineStyle

	// Join specifies whether adjacent features should be joined with radial lines.
	// It is overridden by the returned value of JoinTrace if the Scorer is a TraceJoiner.
	Join bool

	Base ArcOfer

	DrawArea draw.Canvas

	Center       vg.Point
	Inner, Outer vg.Length

	Min, Max float64

	// Axis represents a radial axis configuration
	Axis *Axis
	// contains filtered or unexported fields
}

Trace is a ScoreRenderer that represents feature scores as a trace line.

func (*Trace) Close

func (t *Trace) Close()

Close renders the added scores and axis.

func (*Trace) Configure

func (t *Trace) Configure(ca draw.Canvas, cen vg.Point, base ArcOfer, inner, outer vg.Length, min, max float64)

Configure is called by Scores' DrawAt method. The min and max parameters are ignored if the Trace's Min and Max fields are both non-zero.

func (*Trace) Render

func (t *Trace) Render(arc Arc, scorer Scorer)

Render add the scores at the specified arc for lazy rendering.

type TraceJoiner

type TraceJoiner interface {
	// JoinTrace returns whether the ith score value should be part of a joined trace.
	JoinTrace(i int) bool
}

TraceJoiner is a type that can specify whether the traces for its scores should be joined when adjacent.

type Twist

type Twist uint

Twist is a flag type used to specify Ribbon and Sail twist behaviour. Specific interpretation of Twist flags is documented in the relevant types.

const (
	None       Twist = 0         // None indicates no explicit twist.
	Flat       Twist = 1 << iota // Render feature connections without twist.
	Individual                   // Individual allows a feature or feature pair to define its ribbon twist.
	Twisted                      // Twisted specifies that feature connections render with twist.
	Invert                       // Invert inverts all twist behaviour.
)

type XYer

type XYer interface {
	XY() (x, y float64)
}

XYer is a type that returns its x and y coordinates.

Jump to

Keyboard shortcuts

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