Ejemplo n.º 1
0
    def __init__(self, point_model, geo_coord_mapper, detail_parent=None, parent=None, **kwargs):
        """
        :param point_model: The point this view should represent.
        :type point_model: MapPoint
        :param scale_factor: The factor the point position should be scaled in the view.
        :type scale_factor: tuple
        :param parent: The parent node this point is embedded in.
        :type parent: DivNode
        """
        super(MapPointView, self).__init__(**kwargs)
        self.registerInstance(self, parent)
        self.subscribe(avg.Node.KILLED, self.__on_self_killed)

        self.__detail_parent = detail_parent or parent

        self.__label_rect_node = None
        self.__label_words_node = None
        self.__detail_view = None
        self.__detail_view_active = False

        self.__point_model = point_model
        self.__point_model.start_listening(
            level_of_detail_changed=self.__on_level_of_detail_changed,
            size_changed=self.__on_model_size_changed,
            visible_changed=self.__on_model_visible_changed,
            texture_changed=self.__on_model_texture_changed,
            opacity_val_changed=self.__on_model_opacity_changed,
            color_changed=self.__on_model_color_changed,
            selection_state_changed=self.__on_model_state_changed
        )
        self.__visual = ColoredCircleView(point_model=point_model, parent=self)
        if self.__point_model.texture is not None:
            self.__additional_texture_visual = avg.ImageNode(
                parent=self,
                href=self.__point_model.texture,
                size=(self.__point_model.width, self.__point_model.height),
                opacity=self.__point_model.color_opacity
            )
        else:
            self.__additional_texture_visual = None

        self.__geo_coord_mapper = geo_coord_mapper
        self.update_position(geo_coord_mapper)

        self.__was_tap_before = False
        self.__tap_recognizer = gesture.TapRecognizer(
            node=self,
            maxTime=CommonRecognizerDefaults.TAP_MAX_TIME,
            maxDist=CommonRecognizerDefaults.TAP_MAX_DIST,
            detectedHandler=self.__on_tap
        )
        self.__double_tap_recognizer = gesture.DoubletapRecognizer(
            node=self,
            maxTime=CommonRecognizerDefaults.DOUBLE_TAP_MAX_TIME,
            maxDist=CommonRecognizerDefaults.DOUBLE_TAP_MAX_DIST,
            failHandler=self.__on_double_tap_failed,
            detectedHandler=self.__on_double_tap
        )
Ejemplo n.º 2
0
    def draw_map(self):
        """
        Draws the map if called.
        """
        self.__size = avg.Point2D(self.size)

        if self.__map_view is not None:
            self.__lasso_div.unlink(True)
            self.__map_view.unlink(True)

        self.__map_view = MapView(map_model=self.__map,
                                  map_provider=self.__map_background_provider,
                                  parent=self,
                                  size=self.__size)

        # setup selection
        self.__selection_control = SelectionControl(
            elements=self.__map.points,
            div=self.__map_view,
            relative_div=self.__map_view)
        self.__lasso_div = LassoSelectionDiv(
            selection_control=self.__selection_control,
            parent=self.__map_view,
            size=self.__size)

        self.__background_tap_recognizer = gesture.DoubletapRecognizer(
            node=self.__lasso_div,
            maxTime=CommonRecognizerDefaults.DOUBLE_TAP_MAX_TIME,
            maxDist=CommonRecognizerDefaults.DOUBLE_TAP_MAX_DIST,
            detectedHandler=self.__on_background_tap)
        self.__trans_recognizer = gesture.TransformRecognizer(
            eventNode=self.__lasso_div,
            moveHandler=self.__on_transform,
            endHandler=self.__on_transform_end)

        self.__map_view.reorderChild(
            self.__lasso_div,
            1)  # recognition placed between map image and data points
        self.__lasso_div.start_listening(
            selection_changed=lambda sender, selected_nodes: self.
            __on_points_selected(sender, [
                pv for pv in self.point_views
                if pv.point_model in selected_nodes
            ], True))

        self.__map_view.start_listening(
            points_selected=self.__on_points_selected,
            point_deselected=self.__on_point_deselected)

        self.__draw_label(self.__label)

        for callback in self.__callback_content_changed:
            callback(sender=self, content=self.__map)
Ejemplo n.º 3
0
    def __init__(self, text, isDoubleTap, **kwargs):
        super(TapNode, self).__init__(text, **kwargs)

        if isDoubleTap:
            self.recognizer = gesture.DoubletapRecognizer(
                node=self,
                possibleHandler=self.__onPossible,
                detectedHandler=self.__onDetected,
                failHandler=self.__onFail)
        else:
            self.recognizer = gesture.TapRecognizer(
                node=self,
                possibleHandler=self.__onPossible,
                detectedHandler=self.__onDetected,
                failHandler=self.__onFail)
Ejemplo n.º 4
0
    def __init__(self,
                 data,
                 data_keys_for_selection,
                 label,
                 view_id=-1,
                 chart_config=None,
                 selection_label_text_config=None,
                 parent=None,
                 **kwargs):
        """
        :param data: A dictionary with data objects. Each entry has a key (the name of the data object) and a dict with all
                     values for all the axis in the chart. This value dicts key is a string with the label of the data descriptor
                     and the value is a list with all values on the specified axis.
        :type data: list[DataObject]
        :param data_keys_for_selection: The keys for the attributes of this data object that are important for the selection.
        :type data_keys_for_selection: list[str]
        :param label: The name of this chart.
        :type label: str
        :param chart_config: The configuration used to create this chart.
        :type chart_config: ChartConfiguration
        :param selection_label_text_config: The configuration used to create labels for selected data objects.
        :type: TextLabelConfiguration
        :type parent: DivNode
        :param kwargs: All other parameter for the div node.
        """
        super(ChartBase, self).__init__(**kwargs)
        self.registerInstance(self, parent)
        EventDispatcher.__init__(self)

        self._chart_config = chart_config or ChartConfiguration()
        self._selection_label_text_config = selection_label_text_config or TextMarkingConfiguration(
        )
        self._label = label
        self._view_id = view_id

        # dict: key -> label of the axis     value -> the view of the axis
        self._axis_views = {}

        self._grid_lines_div = avg.DivNode(parent=self)
        self._background_div = avg.DivNode(parent=self)
        self._axis_div = avg.DivNode(parent=self)
        self._data_div = avg.DivNode(parent=self)
        self._selection_label_div = avg.DivNode(parent=self, sensitive=False)
        self._label_node = None

        self._background_tap_recognizer = gesture.DoubletapRecognizer(
            node=self._background_div,
            maxTime=CommonRecognizerDefaults.DOUBLE_TAP_MAX_TIME,
            maxDist=CommonRecognizerDefaults.DOUBLE_TAP_MAX_DIST,
            detectedHandler=self._on_background_tap)

        self._padding_size = (self.size[0] - self._chart_config.padding_left -
                              self._chart_config.padding_right,
                              self.size[1] - self._chart_config.padding_top -
                              self._chart_config.padding_bottom)
        # dict: key -> aid line type     value -> aid line controller
        self._aid_line_controllers = {}

        self._data_objects = {d.obj_id: d for d in data}
        # dict: key -> object name     value -> Node
        self._data_object_nodes = {}
        self._data_object_tap_recognizer = {}
        self._data_keys_for_selection = data_keys_for_selection
        self._selection_data_holder = SelectionDataHolder(
            data_keys_for_selection)

        # key -> object name     value -> WordNode
        self._data_object_label_nodes = {}