示例#1
0
// TxExpose draws the poem.
func txExpose(tx sparta.Widget, e interface{}) bool {
	data := tx.Property(sparta.Data).(*pageData)
	rect := tx.Property(sparta.Geometry).(image.Rectangle)
	c := tx.(*widget.Canvas)

	// Text store the text to be drawing
	txt := widget.Text{}
	txt.Pos.X = 2
	for i, ln := range poem[data.pos:] {
		// The position of the text is the top-right corner of
		// the rectange that enclose the text.
		txt.Pos.Y = (i * sparta.HeightUnit) + 2
		if txt.Pos.Y > rect.Dy() {
			break
		}
		txt.Text = ln
		c.Draw(txt)
	}
	return false
}
示例#2
0
文件: tx.nav.go 项目: js-arias/jdh
func txNavInfoExpose(tx sparta.Widget, e interface{}) bool {
	d := tx.Property(sparta.Data)
	if d == nil {
		return false
	}
	data := d.(*txTaxAnc)
	c := tx.(*widget.Canvas)
	txt := widget.Text{}
	txt.Pos.X = 2
	txt.Pos.Y = 2
	txt.Text = "Id: " + data.tax.Id
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	txt.Text = data.tax.Name
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	txt.Text = data.tax.Authority
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	txt.Text = data.tax.Rank.String()
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	if data.tax.IsValid {
		txt.Text = "Valid"
		c.Draw(txt)
		if data.anc != nil {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "Parent: " + data.anc.Name
			c.Draw(txt)

		}
	} else {
		txt.Text = "Synonym of " + data.anc.Name
		c.Draw(txt)

	}
	if len(data.tax.Extern) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Extern ids:"
		c.Draw(txt)
		for _, e := range data.tax.Extern {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "    " + e
			c.Draw(txt)
		}
	}
	if len(data.tax.Comment) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Comments:"
		c.Draw(txt)
		cmt := strings.Split(data.tax.Comment, "\n")
		for _, e := range cmt {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "  " + e
			c.Draw(txt)
		}
	}
	return false
}
示例#3
0
文件: sp.nav.go 项目: js-arias/jdh
func spNavInfoExpose(tx sparta.Widget, e interface{}) bool {
	d := tx.Property(sparta.Data)
	if d == nil {
		return false
	}
	data := d.(*spInfo)
	c := tx.(*widget.Canvas)
	txt := widget.Text{}
	txt.Pos.X = 2
	txt.Pos.Y = 2
	txt.Text = "Id: " + data.spe.Id
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	txt.Text = "Taxon: " + data.tax.Name
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	txt.Text = "Basis: " + data.spe.Basis.String()
	c.Draw(txt)
	if len(data.spe.Reference) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Ref: " + data.spe.Reference
		c.Draw(txt)
	}
	if data.set != nil {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Dataset: " + data.set.Title
		c.Draw(txt)
	}
	if len(data.spe.Catalog) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Catalog: " + data.spe.Catalog
		c.Draw(txt)
	}
	if len(data.spe.Determiner) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Determiner: " + data.spe.Determiner
		c.Draw(txt)
	}
	if len(data.spe.Collector) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Taxon: " + data.spe.Collector
		c.Draw(txt)
	}
	if !data.spe.Date.IsZero() {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Date:: " + data.spe.Date.Format(jdh.Iso8601)
		c.Draw(txt)
	}
	if len(data.spe.Geography.Country) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Country: " + data.spe.Geography.Country.Name()
		c.Draw(txt)
	}
	if len(data.spe.Geography.State) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "State: " + data.spe.Geography.State
		c.Draw(txt)
	}
	if len(data.spe.Locality) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Locality: " + data.spe.Locality
		c.Draw(txt)
	}
	if data.spe.Georef.IsValid() {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = fmt.Sprintf("LonLat: %.3f,%.3f", data.spe.Georef.Point.Lon, data.spe.Georef.Point.Lat)
		c.Draw(txt)
		if data.spe.Georef.Uncertainty != 0 {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = fmt.Sprintf("Uncert: %d", data.spe.Georef.Uncertainty)
			c.Draw(txt)
		}
		if len(data.spe.Georef.Source) > 0 {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "Source: " + data.spe.Georef.Source
			c.Draw(txt)
		}
		if len(data.spe.Georef.Validation) > 0 {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "Val: " + data.spe.Georef.Validation
			c.Draw(txt)
		}
	}
	if len(data.spe.Extern) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Extern ids:"
		c.Draw(txt)
		for _, e := range data.spe.Extern {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "    " + e
			c.Draw(txt)
		}
	}
	if len(data.spe.Comment) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Comments:"
		c.Draw(txt)
		cmt := strings.Split(data.spe.Comment, "\n")
		for _, e := range cmt {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "  " + e
			c.Draw(txt)
		}
	}
	if data.set != nil {
		if len(data.set.Citation) > 0 {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "Citation: " + data.set.Citation
			c.Draw(txt)
		}
		if len(data.set.License) > 0 {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "License: " + data.set.License
			c.Draw(txt)
		}
	}
	return false
}