Esempio n. 1
0
def mime_data_put_panel(mime_data: UserInterface.MimeData,
                        display_item: typing.Optional[DisplayItem.DisplayItem],
                        d: typing.Sequence) -> None:
    if display_item:
        d = dict(d)
        d["display_item_specifier"] = display_item.project.create_specifier(
            display_item).write()
    mime_data.set_data_as_string(DISPLAY_PANEL_MIME_TYPE, json.dumps(d))
Esempio n. 2
0
def mime_data_put_display_item(mime_data: UserInterface.MimeData,
                               display_item: DisplayItem.DisplayItem) -> None:
    mime_data_content = {
        "display_item_specifier":
        display_item.project.create_specifier(display_item).write()
    }
    mime_data.set_data_as_string(DISPLAY_ITEM_MIME_TYPE,
                                 json.dumps(mime_data_content))
Esempio n. 3
0
def mime_data_put_graphics(
        mime_data: UserInterface.MimeData,
        graphics: typing.Sequence[Graphics.Graphic]) -> None:
    graphic_dict_list = list()
    for graphic in graphics:
        graphic_dict_list.append(graphic.mime_data_dict())
    graphics_dict = {"graphics": graphic_dict_list}
    mime_data.set_data_as_string(GRAPHICS_MIME_TYPE, json.dumps(graphics_dict))
Esempio n. 4
0
def mime_data_put_display_items(
        mime_data: UserInterface.MimeData,
        display_items: typing.Sequence[DisplayItem.DisplayItem]) -> None:
    mime_data_content = [{
        "display_item_specifier":
        display_item.project.create_specifier(display_item).write()
    } for display_item in display_items]
    mime_data.set_data_as_string(DISPLAY_ITEMS_MIME_TYPE,
                                 json.dumps(mime_data_content))
Esempio n. 5
0
def mime_data_put_layer(mime_data: UserInterface.MimeData, index: int, display_item: DisplayItem.DisplayItem, label: str, fill_color: str, stroke_color: str) -> None:
    legend_data = {
        "index": index,
        "label": label,
        "fill_color": fill_color,
        "stroke_color": stroke_color,
    }
    mime_dict = {
        "legend_data": legend_data,
        "display_item_specifier": display_item.project.create_specifier(display_item, allow_partial=False).write()
    }
    mime_data.set_data_as_string(LAYER_MIME_TYPE, json.dumps(mime_dict))
Esempio n. 6
0
def mime_data_put_data_source(
        mime_data: UserInterface.MimeData,
        display_item: DisplayItem.DisplayItem,
        graphic: typing.Optional[Graphics.Graphic]) -> None:
    mime_data_content = dict()
    mime_data_content[
        "display_item_specifier"] = display_item.project.create_specifier(
            display_item).write()
    if graphic:
        mime_data_content[
            "graphic_specifier"] = graphic.project.create_specifier(
                graphic).write()
    mime_data.set_data_as_string(DATA_SOURCE_MIME_TYPE,
                                 json.dumps(mime_data_content))
Esempio n. 7
0
def mime_data_put_layer(mime_data: UserInterface.MimeData, index: int, display_item: DisplayItem.DisplayItem, label: typing.Optional[str], fill_color: typing.Optional[str], stroke_color: typing.Optional[str]) -> None:
    legend_data: Persistence.PersistentDictType = {
        "index": index,
    }
    if label:
        legend_data["label"] = label
    if fill_color:
        legend_data["fill_color"] = fill_color
    if stroke_color:
        legend_data["stroke_color"] = stroke_color
    mime_dict = {
        "legend_data": legend_data,
        "display_item_specifier": Persistence.write_persistent_specifier(display_item.uuid)
    }
    mime_data.set_data_as_string(LAYER_MIME_TYPE, json.dumps(mime_dict))
Esempio n. 8
0
def mime_data_put_display_item(mime_data: UserInterface.MimeData, display_item: DisplayItem.DisplayItem) -> None:
    mime_data_content = {"display_item_specifier": Persistence.write_persistent_specifier(display_item.uuid)}
    mime_data.set_data_as_string(DISPLAY_ITEM_MIME_TYPE, json.dumps(mime_data_content))
Esempio n. 9
0
def mime_data_put_panel(mime_data: UserInterface.MimeData, display_item: typing.Optional[DisplayItem.DisplayItem], d: Persistence.PersistentDictType) -> None:
    if display_item:
        d = dict(d)
        d["display_item_specifier"] = Persistence.write_persistent_specifier(display_item.uuid)
    mime_data.set_data_as_string(DISPLAY_PANEL_MIME_TYPE, json.dumps(d))