Documentation ¶
Index ¶
- func SVG(lay Layout) (string, error)
- type AncestorChart
- type AncestorLayout
- func (l *AncestorLayout) Blurbs() []*Blurb
- func (l *AncestorLayout) Connectors() []*Connector
- func (l *AncestorLayout) Debug() bool
- func (l *AncestorLayout) Height() Pixel
- func (l *AncestorLayout) Margin() Pixel
- func (l *AncestorLayout) Notes() []TextElement
- func (l *AncestorLayout) Title() TextElement
- func (l *AncestorLayout) Width() Pixel
- type AncestorLayoutOptions
- type AncestorPerson
- type Blurb
- type Connector
- type DescendantChart
- type DescendantFamily
- type DescendantLayout
- func (l *DescendantLayout) Blurbs() []*Blurb
- func (l *DescendantLayout) Connectors() []*Connector
- func (l *DescendantLayout) Debug() bool
- func (l *DescendantLayout) Height() Pixel
- func (l *DescendantLayout) Margin() Pixel
- func (l *DescendantLayout) Notes() []TextElement
- func (l *DescendantLayout) Title() TextElement
- func (l *DescendantLayout) Width() Pixel
- type DescendantPerson
- type Layout
- type LayoutOptions
- type Parser
- type Pixel
- type Point
- type TextElement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AncestorChart ¶
type AncestorChart struct { Title string Notes []string Root *AncestorPerson }
func (*AncestorChart) Layout ¶
func (ch *AncestorChart) Layout(opts *AncestorLayoutOptions) *AncestorLayout
type AncestorLayout ¶
type AncestorLayout struct {
// contains filtered or unexported fields
}
func (*AncestorLayout) Blurbs ¶
func (l *AncestorLayout) Blurbs() []*Blurb
func (*AncestorLayout) Connectors ¶
func (l *AncestorLayout) Connectors() []*Connector
func (*AncestorLayout) Debug ¶
func (l *AncestorLayout) Debug() bool
func (*AncestorLayout) Height ¶
func (l *AncestorLayout) Height() Pixel
func (*AncestorLayout) Margin ¶
func (l *AncestorLayout) Margin() Pixel
func (*AncestorLayout) Notes ¶
func (l *AncestorLayout) Notes() []TextElement
func (*AncestorLayout) Title ¶
func (l *AncestorLayout) Title() TextElement
func (*AncestorLayout) Width ¶
func (l *AncestorLayout) Width() Pixel
type AncestorLayoutOptions ¶
type AncestorLayoutOptions struct { Debug bool LineWidth Pixel // width of any drawn lines Margin Pixel // margin to add to entire drawing Hspace Pixel // the horizontal space to leave between blurbs in different generations Vspace Pixel // the vertical space to leave between blurbs in the same generation LineGap Pixel // the distance to leave between a connecting line and any text HookLength Pixel // the length of the line drawn from the parent or a child to the vertical line that joins them TitleFontSize Pixel // size of the font to use for the title of the chart TitleLineHeight Pixel // vertical distance to use for spacing the title of the chart NoteFontSize Pixel // size of the font to use for the notes of the chart NoteLineHeight Pixel // vertical distance to use for spacing the notes of the chart HeadingFontSize Pixel // size of the font to use for the first line of each blurb HeadingLineHeight Pixel // vertical distance to use for spacing the first line of each blurb DetailFontSize Pixel // size of the font to use for the subsequent lines of each blurb DetailLineHeight Pixel // vertical distance to use for spacing the fsubsequent lines of each blurb DetailWrapWidth Pixel // maximum width of detail text before wrapping to a new line }
func DefaultAncestorLayoutOptions ¶
func DefaultAncestorLayoutOptions() *AncestorLayoutOptions
type AncestorPerson ¶
type AncestorPerson struct { ID int Details []string Father *AncestorPerson Mother *AncestorPerson }
type Blurb ¶
type Blurb struct { ID int HeadingText string HeadingFontSize Pixel HeadingLineHeight Pixel DetailTexts []string DetailFontSize Pixel DetailLineHeight Pixel // Text []string CentreText bool // true if the text for this blurb is better presented as centred Width Pixel // Width is the horizontal extent of the Blurb AbsolutePositioning bool // when true, the position of the blurb is controlled by TopPos and LeftPos, otherwise it is calclated relative to neighbours TopPos Pixel // TopPos is the absolute vertical position of the upper edge of the Blurb LeftPos Pixel // LeftPos is the absolute horizontal position of the left edge of the Blurb Height Pixel // Height is the vertical extent of the Blurb Col int // column the blurb appears in for layouts that use columns Row int // row the blurb appears in for layouts that use rows LeftPad Pixel // required padding to left of blurb to separate families LeftShift Pixel // optional padding that shifts blurb to right for alignment NoShift bool // when true the left shift will not be changed KeepWith []*Blurb KeepRightOf []*Blurb LeftNeighbour *Blurb // the blurb to the left of this one, when non-nil will be used for horizontal positioning Parent *Blurb LeftStop *Blurb // the blurb whose center must not be passed when shifting left RightStop *Blurb // the blurb whose center must not be passed when shifting right TopHookOffset Pixel // TopHookOffset is the offset from the left of the blurb where any dropped connecting line should finish (ensures it is within the bounds of the name, even if subsequent detail lines are longer) SideHookOffset Pixel // SideHookOffset is the offset from the top of the blurb where any connecting line should finish }
type DescendantChart ¶
type DescendantChart struct { Title string Notes []string Root *DescendantPerson }
func (*DescendantChart) Layout ¶
func (ch *DescendantChart) Layout(opts *LayoutOptions) *DescendantLayout
type DescendantFamily ¶
type DescendantFamily struct { Other *DescendantPerson Details []string Children []*DescendantPerson }
type DescendantLayout ¶
type DescendantLayout struct {
// contains filtered or unexported fields
}
func (*DescendantLayout) Blurbs ¶
func (l *DescendantLayout) Blurbs() []*Blurb
func (*DescendantLayout) Connectors ¶
func (l *DescendantLayout) Connectors() []*Connector
func (*DescendantLayout) Debug ¶
func (l *DescendantLayout) Debug() bool
func (*DescendantLayout) Height ¶
func (l *DescendantLayout) Height() Pixel
func (*DescendantLayout) Margin ¶
func (l *DescendantLayout) Margin() Pixel
func (*DescendantLayout) Notes ¶
func (l *DescendantLayout) Notes() []TextElement
func (*DescendantLayout) Title ¶
func (l *DescendantLayout) Title() TextElement
func (*DescendantLayout) Width ¶
func (l *DescendantLayout) Width() Pixel
type DescendantPerson ¶
type DescendantPerson struct { ID int Details []string Families []*DescendantFamily }
type Layout ¶
type Layout interface { Height() Pixel Width() Pixel Margin() Pixel Title() TextElement Notes() []TextElement Blurbs() []*Blurb Connectors() []*Connector Debug() bool }
type LayoutOptions ¶
type LayoutOptions struct { FontSize Pixel // size of the font to use for the main text of each blurb (first line) DetailFontSize Pixel // size of the font to use for the detail text of each blurb (subsequent lines) TextLineHeight Pixel // vertical distance between lines of text in heading of a blurb DetailLineHeight Pixel // vertical distance between lines of text in detail of a blurb DetailWrapWidth Pixel // maximum width of detail text before wrapping to a new line Hspace Pixel // horizontal spacing between blurbs within the same family LineWidth Pixel Margin Pixel // margin to add to entire drawing FamilyDrop Pixel // length of line to draw down from parents to the children group line ChildDrop Pixel // the length of the line drawn from the children group line to a child LineGap Pixel // the distance to leave between a connecting line and any text Debug bool // emit logging and debug information TitleFontSize Pixel // size of the font to use for the title of the chart NoteFontSize Pixel // size of the font to use for the notes of the chart TitleLineHeight Pixel // vertical distance to use for spacing the title of the chart NoteLineHeight Pixel // vertical distance to use for spacing the notes of the chart }
func DefaultLayoutOptions ¶
func DefaultLayoutOptions() *LayoutOptions
type Parser ¶
type Parser struct{}
A Parser parses a textual descendent list.
A descendant list consists of a list of person entries, one per line. A person entry line consists of a prefix followed by detail text.
The prefix of each line denotes the relationship of the person to an earlier person. A prefix consists of zero or more leading whitespace characters and some context text followed by a dot (period).
A prefix may include leading whitespace which indicates the relationship of the person to the preceding persons.
The context text may be a number which indicates that the person is a child of the first preceding person with less leading whitespace. The number value is not used. People in a family group are placed in the order the lines are read from the input.
Alternatively the context text may be the two characters 'sp' which indicates that the person is the spouse of the first preceding person with equal or less leading whitespace.
The remaining text after the prefix is parsed as follows to build a list of detail strings for the person:
- If no matching parentheses or semicolons are found in the line then the detail list will consist of a single entry containing the text up to the end of the line.
- Otherwise, the text is divided into segments by scanning left to right. A semicolon starts a new segment. A left paranthesis also starts a new segment that includes all text up to the matching right paranthesis(including semicolons and other parantheses). The delimiting semicolons or parantheses do not form part of the text segment.
All entries in the detail list are trimmed to remove leading and trailing whitespace.
Identifiers are assigned using the line number of the person's entry.