def checkVisibility(self): if self.srclinked and self.sinklinked: self.props.line_dash = goocanvas.LineDash([]) self.updateEndpoints() else: self.props.line_dash = goocanvas.LineDash([3.0, 3.0]) return False
def _get_dash(branch): dash = None if branch=="future": dash = goocanvas.LineDash([2.0,2.0]) elif branch=="experimental": dash = goocanvas.LineDash([2.0,5.0]) elif branch=="lts": dash = goocanvas.LineDash([10.0,2.0]) elif branch=="past": dash = goocanvas.LineDash([10.0,10.0]) return dash
def __init__(self, parent_canvas_item, sta, dev): """! Initialize function. @param self The object pointer. @param parent_canvas_item: parent canvas @param sta The STA node @param dev The dev """ self.node1 = sta self.dev = dev self.node2 = None # ap self.canvas_item = goocanvas.Group(parent=parent_canvas_item) self.invisible_line = goocanvas.Polyline( parent=self.canvas_item, line_width=25.0, visibility=goocanvas.ITEM_HIDDEN) self.visible_line = goocanvas.Polyline(parent=self.canvas_item, line_width=1.0, stroke_color_rgba=0xC00000FF, line_dash=goocanvas.LineDash( [2.0, 2.0])) self.invisible_line.props.pointer_events = ( goocanvas.EVENTS_STROKE_MASK | goocanvas.EVENTS_FILL_MASK | goocanvas.EVENTS_PAINTED_MASK) self.canvas_item.set_data("pyviz-object", self) self.canvas_item.lower(None) self.set_ap(None)
def tux_move(self): # The sea area is defined in the global self.sea_area step_x = (self.sea_area[2] - self.sea_area[0]) / 20 * 2 step_y = (self.sea_area[3] - self.sea_area[1]) / 10 # Original boat position bx = self.right_boat.x by = self.right_boat.y ba = 0 one_path = [] # X loop while (bx <= self.sea_area[2] and bx >= self.sea_area[0]): score = 10000 # By default, go straight coord = (bx, by, ba, int(step_x)) # angle loop for boat_angle in [-45, 0, 45]: a_pi = boat_angle * math.pi / 180 # Find the point from current boat position with angle a and distance step_x x = bx + math.cos(a_pi) * step_x y = by + math.sin(a_pi) * step_x # Manage the wrapping line_style = goocanvas.LineDash([1.0]) if (y < self.sea_area[1]): y = self.sea_area[3] - (self.sea_area[1] - y) line_style = goocanvas.LineDash([5.0, 1.0, 5.0]) elif (y > self.sea_area[3]): y = self.sea_area[1] + (y - self.sea_area[3]) line_style = goocanvas.LineDash([5.0, 1.0, 5.0]) # Find shortest path to previous calculated point condition = self.get_absolute_weather_condition(x, y) wind = self.get_wind_score(boat_angle, condition) if (wind < score): score = wind coord = (x, y, boat_angle, step_x, line_style ) # x y angle distance line_style # ---------- goocanvas.Polyline(parent=self.root_weather_item, points=goocanvas.Points([(bx, by), (coord[0], coord[1])]), stroke_color_rgba=0x00CC00FFL, line_width=2.0, line_dash=coord[4]) bx = coord[0] by = coord[1] ba = coord[2] one_path.append(coord) # -------------------------------------------------------------- # Translate the previous calculation in a string for Tux program # -------------------------------------------------------------- ba = 0 # Boat angle cumulative_distance = 0 tux_move = "" for c in one_path: #print "X,Y,A,D=" + str(c) x = c[0] y = c[1] a = c[2] # angle d = c[3] # distance if (ba - a < 0): if (cumulative_distance): tux_move += _("forward") + " " + str( cumulative_distance) + "\n" cumulative_distance = 0 tux_move += _("right") + " " + str(abs(int(ba - a))) + "\n" ba += abs(int(ba - a)) elif (ba - a > 0): if (cumulative_distance): tux_move += _("forward") + " " + str( cumulative_distance) + "\n" cumulative_distance = 0 tux_move += _("left") + " " + str(abs(int(ba - a))) + "\n" ba -= abs(int(ba - a)) cumulative_distance += int(d / self.sea_ratio) # Final move, add an ofset because we loose space in abs() tux_move += _("forward") + " " + str(cumulative_distance + 2) + "\n" self.right_boat.tb.set_text(tux_move) self.right_boat.tv.set_editable(False)
def create_events_area (canvas, area_num, pointer_events, label): row = area_num / 3 col = area_num % 3 x = col * 200 y = row * 150 root = canvas.get_root_item () dash = goocanvas.LineDash ([2.0, 5.0, 5.0]) ''' Create invisible item. ''' rect = goocanvas.Rect (parent = root, x = x + 45, y = y + 35, width = 30, height = 30, fill_color = "red", visibility = goocanvas.ITEM_INVISIBLE, line_width = 5.0, pointer_events = pointer_events) view_id = "%s invisible" % label rect.set_data ("id", view_id) setup_item_signals (rect) ''' Display a thin rect around it to indicate it is there. ''' rect = goocanvas.Rect (parent = root, x = x + 42.5, y = y + 32.5, width = 36, height = 36, line_dash = dash, line_width = 1.0, stroke_color = "gray") ''' Create unpainted item. ''' rect = goocanvas.Rect (parent = root, x = x + 85, y = y + 35, width = 30, height = 30, line_width = 5.0, pointer_events = pointer_events) view_id = "%s unpainted" % label rect.set_data ("id", view_id) setup_item_signals (rect) ''' Display a thin rect around it to indicate it is there. ''' rect = goocanvas.Rect (parent = root, x = x + 82.5, y = y + 32.5, width = 36, height = 36, line_dash = dash, line_width = 1.0, stroke_color = "gray") ''' Create stroked item. ''' rect = goocanvas.Rect (parent = root, x = x + 125, y = y + 35, width = 30, height = 30, line_width = 5.0, pointer_events = pointer_events) view_id = "%s stroked" % label rect.set_data ("id", view_id) setup_item_signals (rect) ''' Create filled item. ''' rect = goocanvas.Rect (parent = root, x = x + 60, y = y + 75, width = 30, height = 30, fill_color = "red", line_width = 5.0, pointer_events = pointer_events) view_id = "%s filled" % label rect.set_data ("id", view_id) setup_item_signals (rect) ''' Create stroked & filled item. ''' rect = goocanvas.Rect (parent = root, x = x + 100, y = y + 75, width = 30, height = 30, fill_color = "red", line_width = 5.0, pointer_events = pointer_events) view_id = "%s stroked & filled" % label rect.set_data ("id", view_id) setup_item_signals (rect) goocanvas.Text (parent = root, text = label, x = x + 100, y = y + 130, width = -1, anchor = gtk.ANCHOR_CENTER, font = "Sans 12", fill_color = "blue")
title=title, label_x=xlabel, label_y=ylabel) graph.show() now = datetime.now() crawl_start = datetime(2008, 10, 17) pre_crawl_start = datetime(2008, 10, 16) d6m = timedelta(weeks=26) d1y = timedelta(weeks=54) for key, distro in distros: branch = distro.branch dash = None if branch == "future": dash = goocanvas.LineDash([2.0, 2.0]) elif branch == "experimental": dash = goocanvas.LineDash([2.0, 5.0]) elif branch == "lts": dash = goocanvas.LineDash([10.0, 2.0]) elif branch == "past": dash = goocanvas.LineDash([10.0, 10.0]) if not COUNT: notes = [] if NOTES: notes = distro.notes graph.add(key, distro.timeline[pre_crawl_start:now], notes, distro.color, dash) elif BINARY: graph.add(key, distro.bin_obs_timeline[pre_crawl_start:now], [],
"font": "Sans 8", "text": "A Pad", "width": 40, "height": 15, }, {}, ) link_arrow = (goocanvas.Polyline, { "stroke_color": "red", "end_arrow": "true", }, {}) link_tool = (goocanvas.Polyline, { "stroke_color": "red", "line_dash": goocanvas.LineDash([1.5, 1.5]) }, {}) selection_box = (goocanvas.Rect, { "stroke_color_rgba": 0x33CCFF66, "fill_color_rgba": 0x33CCFF66, }, {}) target = [('GST_ELEMENT_NAME', 0, 0)] ## App-Specific Functions class LinkError(Exception): pass