Beispiel #1
0
 def parse_metadata_shapes(self, metadata: Dict[str, Any]) -> None:
     # load saved shapes
     shapes_config = metadata.get("shapes")
     if not shapes_config:
         return
     shapes_config = json.loads(shapes_config)
     for shape_config in shapes_config:
         logger.debug("loading shape: %s", shape_config)
         Shape.from_metadata(self.app, shape_config)
Beispiel #2
0
    def parse_metadata(self) -> None:
        # canvas setting
        config = self.session.metadata
        canvas_config = config.get("canvas")
        logging.debug("canvas metadata: %s", canvas_config)
        if canvas_config:
            canvas_config = json.loads(canvas_config)
            self.app.manager.parse_metadata(canvas_config)

        # load saved shapes
        shapes_config = config.get("shapes")
        if shapes_config:
            shapes_config = json.loads(shapes_config)
            for shape_config in shapes_config:
                logging.debug("loading shape: %s", shape_config)
                Shape.from_metadata(self.app, shape_config)

        # load edges config
        edges_config = config.get("edges")
        if edges_config:
            edges_config = json.loads(edges_config)
            logging.info("edges config: %s", edges_config)
            for edge_config in edges_config:
                edge = self.links[edge_config["token"]]
                edge.width = edge_config["width"]
                edge.color = edge_config["color"]
                edge.redraw()

        # read hidden nodes
        hidden = config.get("hidden")
        if hidden:
            hidden = json.loads(hidden)
            for _id in hidden:
                canvas_node = self.canvas_nodes.get(_id)
                if canvas_node:
                    canvas_node.hide()
                else:
                    logging.warning("invalid node to hide: %s", _id)