Beispiel #1
0
 def set_image(self, image):
     # calculate actual size
     actual_size = self.size - self.imgPadding
     # Configure image & draw image
     if isinstance(image, str):
         # construct a cache key
         cache_key = image + f'_{self.size}_{self.imgPadding}'
         # attempt to retrieve image from cache
         self._image = CacheManager.get_cached_image(cache_key)
         # repair image
         if self._image == None:
             # assign image
             self._image = CacheManager.get_or_add_if_absent(
                 cache_key,
                 ImageTk.PhotoImage(
                     Img.open(image).resize((actual_size, actual_size))))
     else:
         self._image = getdisplayableimage(image,
                                           (actual_size, actual_size))
     # display image
     if hasattr(self, 'img_image'):
         self.delete(self.img_image)
     self.img_image = self.create_image(self.size / 2,
                                        self.size / 2,
                                        image=self._image)
Beispiel #2
0
    def draw_at(self, x, y):
        super().draw_at(x, y)

        self.icon = CacheManager.get_cached_image('img_dtstore_' +
                                                  str(self.ICON_SIZE))
        if self.icon == None:
            self.icon = CacheManager.get_or_add_if_absent(
                'img_dtstore_' + str(self.ICON_SIZE),
                ImgTk.PhotoImage(
                    Img.open(
                        'resources/icons/notation/guidatastore.png').resize(
                            (self.ICON_SIZE, self.ICON_SIZE))))
        # draw select background
        self.id.append(self.getcanvas().create_oval(x,
                                                    y,
                                                    x + self.WIDTH,
                                                    y + self.HEIGHT,
                                                    width=0))
        # draw icon
        self.id.append(self.getcanvas().create_image(x + self.WIDTH / 2,
                                                     y + self.HEIGHT / 2,
                                                     image=self.icon))
        # draw text
        self.draw_text(
            self.element.name, x + self.WIDTH / 2,
            y + self.HEIGHT / 2 - (self.ICON_SIZE / 2) - self.TEXT_OFFSET)
Beispiel #3
0
 def draw_at(self, x, y):
     # draw the border
     GUIActivity.draw_at(self, x, y)
     # extract info
     tasktype = self.element.type
     # draw type icon
     if tasktype != TaskType.Default:
         # attempt to retrieve from cache
         cachekey = 'img_' + str(self.element.type) + '_' + str(
             self.ICON_SIZE)
         iconpath = 'resources/icons/notation/' + str(
             tasktype).lower().split('.')[1] + '.png'
         self.type_icon = CacheManager.get_cached_image(cachekey)
         # cache image if not there
         if self.type_icon == None:
             self.type_icon = CacheManager.get_or_add_if_absent(
                 cachekey,
                 imgTk.PhotoImage(
                     img.open(iconpath).resize(
                         (self.ICON_SIZE, self.ICON_SIZE))))
         cnv: Canvas = self.getcanvas()
         self.id.append(
             cnv.create_image(x + self.ICON_MARGIN,
                              y + self.ICON_MARGIN,
                              image=self.type_icon))
     # draw text
     self.draw_text(self.element.name, x + self.WIDTH / 2,
                    y + self.HEIGHT / 2, self.WIDTH)
Beispiel #4
0
 def draw_at(self, x, y):
     GUILinkable.draw_at(self, x, y)
     # extract info
     flag = self.element.flag
     # get canvas
     cnv: Canvas = self.getcanvas()
     # border points
     points = [
         x + self.RADIUS, y, x + self.RADIUS, y,
         x + self.WIDTH - self.RADIUS, y, x + self.WIDTH - self.RADIUS, y,
         x + self.WIDTH, y, x + self.WIDTH, y + self.RADIUS, x + self.WIDTH,
         y + self.RADIUS, x + self.WIDTH, y + self.HEIGHT - self.RADIUS,
         x + self.WIDTH, y + self.HEIGHT - self.RADIUS, x + self.WIDTH,
         y + self.HEIGHT, x + self.WIDTH - self.RADIUS, y + self.HEIGHT,
         x + self.WIDTH - self.RADIUS, y + self.HEIGHT, x + self.RADIUS,
         y + self.HEIGHT, x + self.RADIUS, y + self.HEIGHT, x,
         y + self.HEIGHT, x, y + self.HEIGHT - self.RADIUS, x,
         y + self.HEIGHT - self.RADIUS, x, y + self.RADIUS, x,
         y + self.RADIUS, x, y
     ]
     # draw border
     self.id.append(
         cnv.create_polygon(points,
                            fill=cnv['bg'],
                            width=2,
                            outline=black,
                            smooth=True))
     # draw flag icon
     if flag != ActivityFlag.Default:
         iconpath = str(flag).lower().split('.')[1]
         if 'multiple' in iconpath: iconpath = 'parallelinstance'
         cachekey = 'act_flag_' + str(flag) + '_' + str(self.ICON_SIZE)
         self.flag_icon = CacheManager.get_cached_image(cachekey)
         if self.flag_icon == None:
             self.flag_icon = CacheManager.get_or_add_if_absent(
                 cachekey,
                 imgTk.PhotoImage(
                     img.open('resources/icons/notation/' + iconpath +
                              '.png').resize(
                                  (self.ICON_SIZE, self.ICON_SIZE))))
         # adjusting coords of the icon depending on the element
         flag_x = x + self.WIDTH / 2
         if self.__class__.__name__ == 'GUISubProcess':
             flag_x -= self.ICON_MARGIN / 4
         self.id.append(
             cnv.create_image(flag_x,
                              y + self.HEIGHT - self.ICON_MARGIN,
                              image=self.flag_icon))
Beispiel #5
0
 def draw_at(self, x, y):
     # draw the border
     GUIActivity.draw_at(self, x, y)
     # draw collapsed subprocess icon
     iconpath = 'resources/icons/notation/collapsedsubprocess.png'
     # cache setup
     cachekey = 'img_' + str(self.element.flag)
     self.type_icon = CacheManager.get_cached_image(cachekey)
     if self.type_icon == None:
         # cache it for better performance
         self.type_icon = CacheManager.get_or_add_if_absent(
             cachekey,
             imgTk.PhotoImage(
                 img.open(iconpath).resize(
                     (self.ICON_SIZE, self.ICON_SIZE))))
     cnv: Canvas = self.getcanvas()
     self.id.append(
         cnv.create_image(x + (self.WIDTH / 2) + (self.ICON_MARGIN / 4) +
                          (self.ICON_SIZE / 2),
                          y + self.HEIGHT - self.ICON_MARGIN,
                          image=self.type_icon))
     # draw text
     self.draw_text(self.element.name, x + self.WIDTH / 2,
                    y - self.LABEL_OFFSET)
Beispiel #6
0
 def draw_at(self, x, y):
     GUILinkable.draw_at(self, x, y)
     # Extract info
     eventtype = self.element.type
     eventdefinition = self.element.definition
     text = self.element.name
     # cast
     cnv: Canvas = self.getcanvas()
     # figure out the border width of the circle
     borderwidth = (6 if eventtype == EventType.End else 2)
     # draw borders
     self.id.append(
         cnv.create_oval(x,
                         y,
                         x + self.PERIMETER,
                         y + self.PERIMETER,
                         fill=cnv['bg'],
                         outline=black,
                         width=borderwidth))
     # draw inner border
     if eventtype in [
             EventType.IntermediateCatch, EventType.IntermediateThrow
     ]:
         self.id.append(
             cnv.create_oval(x + 4,
                             y + 4,
                             x + self.PERIMETER - 4,
                             y + self.PERIMETER - 4,
                             fill=cnv['bg'],
                             outline=black,
                             width=borderwidth))
     # draw definition icon
     if eventdefinition != EventDefinition.Default:
         folder = 'resources/icons/notation/'
         pure_name = str(eventdefinition).split('.')[1].lower()
         # correct names
         if eventdefinition == EventDefinition.Message:
             pure_name = 'receive' if eventtype not in [
                 EventType.Start, EventType.IntermediateThrow
             ] else 'send'
         # display icon
         cachekey = 'img_' + str(self.element.definition) + '_' + str(
             self.element.type) + '_' + str(self.ICON_SIZE)
         self.def_icon = CacheManager.get_cached_image(cachekey)
         if self.def_icon == None:
             image = Img.open(folder + pure_name + '.png').resize(
                 (self.ICON_SIZE, self.ICON_SIZE))
             # cache for better performance
             self.def_icon = CacheManager.get_or_add_if_absent(
                 cachekey, ImgTk.PhotoImage(image))
             # add a black overlay if it's end/throw event
             if eventtype in [
                     EventType.End, EventType.IntermediateThrow
             ] and eventdefinition != EventDefinition.Message:
                 overlaid_img = Img.new('RGBA', image.size, color=black)
                 overlaid_img.putalpha(image.getchannel('A'))
                 self.def_icon = ImgTk.PhotoImage(overlaid_img)
                 # update cache
                 CacheManager.add_cache_record(cachekey, self.def_icon)
         self.id.append(
             cnv.create_image(x + self.PERIMETER / 2,
                              y + self.PERIMETER / 2,
                              image=self.def_icon))
     # draw event's name
     self.draw_text(text, x + self.PERIMETER / 2, y - self.LABEL_OFFSET)