Example #1
0
func styleColor(hdm *Hdm, n dfsNode) [3]float32 {
	if n.nn == nil {
		return hdm.colorMap[nex.String(nex.TopType)]
	}

	for _, t := range nex.Supertypes(n.nn.nex.Type()) {

		if col, found := hdm.colorMap[nex.String(t)]; found {
			return col
		}
	}
	return hdm.colorMap[nex.String(nex.TopType)]
}
Example #2
0
func recursiveAddFile(space *hdm.Space, n nex.Nex) {
	if n.Type().IsKindOf(nexsys.Directory) && !strings.HasPrefix(nex.String(n), ".") {
		space.NewSurf().Add(n).Expand(2, nexsys.FileSystem)
		for it, x := nex.IterateRels(n, nex.Sub); x != nil; it, x = it.Next() {
			recursiveAddFile(space, x)
		}
	} else if n.Type().IsKindOf(nexsys.File) && isTextFile(n) {
		textFile := nex.Path(n, nexsys.TextFile)
		if _, rn := nex.IterateRels(n, nex.Elevation); rn != nil {
			tlog.Println("elevated node ", textFile)
			// textFile = rn
		}
		space.NewSurf().Add(textFile).Expand(100, nex.TopType)
	}
}
Example #3
0
func isTextFile(n nex.Nex) bool {
	var m = map[string]bool{
		".go":   true,
		".html": true,
		".js":   true,
		".css":  true,
		".java": true,
		".py":   true,
	}
	for ending := range m {
		if strings.HasSuffix(nex.String(n), ending) {
			return true
		}
	}
	return false
}
Example #4
0
func value(n nex.Nex) string {
	if n.Type().IsKindOf(nex.ByteUnit) && n.Type().IsKindOf(nex.Amount) {
		if v, err := nex.Fixed(n); err == nil {
			if v < 1024 {
				return fmt.Sprintf("%5d B", v)
			} else if v < 1024*1024 {
				return fmt.Sprintf("%5d KB", v/1024.0)
			} else if v < 1024*1024*1024 {
				return fmt.Sprintf("%5d MB", v/(1024*1024))
			} else if v < 1024*1024*1024*1024 {
				return fmt.Sprintf("%5d GB", v/(1024*1024*1024))
			} else if v < 1024*1024*1024*1024 {
				return fmt.Sprintf("%5d TB", v/(1024*1024*1024*1024))
			}
		}
	}
	return nex.String(n)
}