예제 #1
0
    def draw(self):
        if not self.data_source.items: return
        topNodesFrame = self.data_source.items[0]['node']['frame']
        topNodeCentroid = self.centroid(topNodesFrame)

        # need to account for orgins of parents.  need to walk down the tree
        for item in self.data_source.items:
            title = item['title']
            node = item['node']
            level = node['level']
            frame = node['frame']
            uuid = node['uuid']
            try:
                parent = node['parent']
            except KeyError:
                print "Keyerror on node['parent']\n"
                print item
                sys.exit(1)
            isSelected = item['selected']
            isHidden = item['hidden']
            offset = [0, 0]
            ctr = 0
            while parent != 'ROOT_UUID':
                # work back through lineage until no more offsets.
                ctr += 1
                if ctr > 30:
                    sys.exit(1)
                parentFrame, grandParent = walker.frameByUUID[parent]
                offset = [
                    offset[0] + parentFrame[0], offset[1] + parentFrame[1]
                ]
                parent = grandParent

            try:
                xframe = [
                    frame[0] + offset[0], frame[1] + offset[1], frame[2],
                    frame[3]
                ]
            except TypeError:
                print "Type error in collect"
                print "frame", xframe, "offset", offset
            if not isHidden and level:
                scaledFrame = [x * self.ratio for x in xframe]
                path = ui.Path.rect(*scaledFrame)
                ui.set_color((depthColors[level]) + (0.5, ))
                path.fill()
                ui.set_color(0.5)
                path.line_width = 5 if isSelected else 2
                path.stroke()
 def create_grid_image(self):
     s = self.width / self.row if self.row > self.column else self.height / self.column
     path = ui.Path.rect(0, 0, *self.frame[2:])
     with ui.ImageContext(*self.frame[2:]) as ctx:
         ui.set_color((0, 0, 0, 0))
         path.fill()
         path.line_width = 2
         for y in xrange(self.column):
             for x in xrange(self.row):
                 pixel = Pixel(x * s, y * s, s, s)
                 path.append_path(ui.Path.rect(*pixel))
                 self.pixels.append(pixel)
         ui.set_color('gray')
         path.stroke()
         return ctx.get_image()
	def create_grid_image(self):
		s = self.width/self.row if self.row > self.column else self.height/self.column
		path = ui.Path.rect(0, 0, *self.frame[2:])
		with ui.ImageContext(*self.frame[2:]) as ctx:
			ui.set_color((0, 0, 0, 0))
			path.fill()
			path.line_width = 2
			for y in xrange(self.column):
				for x in xrange(self.row):
					pixel = Pixel(x*s, y*s, s, s)
					path.append_path(ui.Path.rect(*pixel))
					self.pixels.append(pixel)
			ui.set_color('gray')
			path.stroke()
			return ctx.get_image()
예제 #4
0
	def draw(self):
		if not self.data_source.items: return
		topNodesFrame = self.data_source.items[0]['node']['frame']
		topNodeCentroid = self.centroid(topNodesFrame)
		
# need to account for orgins of parents.  need to walk down the tree
		for item in self.data_source.items:
			title = item['title']
			node = item['node']
			level = node['level']
			frame = node['frame']
			uuid = node['uuid']
			try:
				parent = node['parent']
			except KeyError:
				print "Keyerror on node['parent']\n"
				print item
				sys.exit(1)
			isSelected = item['selected']
			isHidden = item['hidden']
			offset = [0,0]
			ctr = 0
			while parent != 'ROOT_UUID': 
 # work back through lineage until no more offsets.
				ctr +=1
				if ctr > 30:
					sys.exit(1)
				parentFrame,grandParent = walker.frameByUUID[parent]
				offset = [offset[0] + parentFrame[0], offset[1] +parentFrame[1]]
				parent = grandParent
					
			try:
				xframe = [frame[0] + offset[0], frame[1] + offset[1], frame[2], frame[3]]	
			except TypeError:
				print "Type error in collect"
				print "frame", xframe, "offset", offset
			if not isHidden and level:
				scaledFrame = [x*self.ratio for x in xframe]
				path = ui.Path.rect(*scaledFrame)
				ui.set_color((depthColors[level]) + (0.5,))
				path.fill()
				ui.set_color(0.5)
				path.line_width = 5 if isSelected else 2
				path.stroke()