Skip to main content

Graph2D

Struct Graph2D 

Source
pub struct Graph2D { /* private fields */ }
Expand description

2D 知识图谱画布。

Implementations§

Source§

impl Graph2D

Source

pub fn new( id: impl Into<SharedString>, graph: KnowledgeGraph, cx: &mut Context<'_, Graph2D>, ) -> Graph2D

带后台力导向布局创建(推荐入口)。

Source

pub fn new_static( id: impl Into<SharedString>, graph: KnowledgeGraph, positions: Vec<Vec2>, cx: &mut Context<'_, Graph2D>, ) -> Graph2D

使用预先算好的坐标创建(跳过后台布局;坐标按 NodeId 升序对齐)。

Source

pub fn aria_label(self, label: impl Into<SharedString>) -> Graph2D

无障碍名称。

Source

pub fn fit_on_mount(self) -> Graph2D

首个布局快照到达后自动适配视图。

Source

pub fn viewport(&self) -> Viewport

当前视口。

Source

pub fn rendered_counts(&self) -> RenderCounts

最近一次渲染统计。

Source

pub fn positions(&self) -> &Arc<Vec<Vec2>> ⓘ

槽位坐标(与 GraphPayload.node_ids 对齐),测试与 story 状态栏用。

Source

pub fn fit_view(&mut self, _window: &mut Window, cx: &mut Context<'_, Graph2D>)

适配视图(包含全部节点与半径)。

Source

pub fn zoom_by( &mut self, factor: f32, _window: &mut Window, cx: &mut Context<'_, Graph2D>, )

以画布中心为锚缩放。

Source

pub fn kinds(&self) -> impl Iterator<Item = &NodeKind>

图中的全部类型(story 筛选按钮用)。

Source

pub fn kind_filter(&self) -> Option<KindId>

当前类型筛选。

Source

pub fn set_kind_filter( &mut self, kind: Option<KindId>, cx: &mut Context<'_, Graph2D>, )

按类型筛选视图:只保留该类型节点(及两端都可见的边)。 None 取消筛选。双击可见节点可临时展开其一度邻居(Self::expand)。

Source

pub fn set_pinned( &mut self, id: NodeId, pinned: bool, cx: &mut Context<'_, Graph2D>, )

固定或解除固定。拖动后保持固定;调用此方法传 false 可恢复力导向布局。

Source

pub fn is_pinned(&self, id: NodeId) -> bool

Source

pub fn node_label(&self, id: NodeId) -> Option<&str>

节点显示名称(组合搜索结果列表时使用)。

Source

pub fn selection(&self) -> &[NodeId]

当前选中节点(保序)。

Source

pub fn hover(&self) -> Option<NodeId>

当前悬停节点。

Source

pub fn search(&self, query: &str) -> Vec<NodeId>

搜索节点(大小写不敏感包含匹配,按度数降序,最多 20 个)。

Source

pub fn fly_to(&mut self, id: NodeId, cx: &mut Context<'_, Graph2D>)

平滑飞到节点(相机弹簧;reduced motion 立即跳转)并选中它。

Source

pub fn expand(&mut self, id: NodeId, cx: &mut Context<'_, Graph2D>) -> usize

双击展开:把节点的一度邻居中当前被筛选隐藏的节点临时揭示出来(带进场动效)。 返回本次揭示的数量。

Source

pub fn hidden_count(&self) -> usize

因筛选被隐藏的节点数。

Trait Implementations§

Source§

impl Focusable for Graph2D

Source§

fn focus_handle(&self, _cx: &App) -> FocusHandle

Returns the focus handle associated with this view.
Source§

impl Render for Graph2D

Source§

fn render( &mut self, window: &mut Window, cx: &mut Context<'_, Graph2D>, ) -> impl IntoElement

Render this view into an element tree.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Graph2D

§

impl !UnwindSafe for Graph2D

§

impl Forget for Graph2D

§

impl Freeze for Graph2D
where &'static str: Freeze, *const ArcInner<str> is !null: Freeze, PhantomData<ArcInner<str>>: Freeze, NonZero<u32>: Freeze, *const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: Freeze, PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: Freeze, *const LeafNode<KindId, NodeKind> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(KindId, NodeKind)>>: Freeze, *const LeafNode<NodeId, Node> is !null: Freeze, PhantomData<Box<(NodeId, Node)>>: Freeze, *const LeafNode<EdgeId, Edge> is !null: Freeze, PhantomData<Box<(EdgeId, Edge)>>: Freeze, *const LeafNode<NodeId, Adjacency> is !null: Freeze, PhantomData<Box<(NodeId, Adjacency)>>: Freeze, *const u8 is !null: Freeze, PhantomData<NodeId>: Freeze, PhantomData<f32>: Freeze, PhantomData<bool>: Freeze, PhantomData<(u32, u32, f32)>: Freeze, PhantomData<u32>: Freeze, *mut Counter<Channel<LayoutCommand<Vec2>>>: Freeze, *mut Counter<Channel<LayoutCommand<Vec2>>>: Freeze, *mut Counter<Channel<LayoutCommand<Vec2>>>: Freeze, *const ArcInner<Mutex<Option<LayoutMessage<Vec2>>>> is !null: Freeze, PhantomData<ArcInner<Mutex<Option<LayoutMessage<Vec2>>>>>: Freeze, *const ArcInner<Atomic<bool>> is !null: Freeze, PhantomData<ArcInner<Atomic<bool>>>: Freeze, *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze, *const ArcInner<Packet<'static, ()>> is !null: Freeze, PhantomData<ArcInner<Packet<'static, ()>>>: Freeze, *const ArcInner<GraphPayload> is !null: Freeze, PhantomData<ArcInner<GraphPayload>>: Freeze, *const ArcInner<Vec<Vec2>> is !null: Freeze, PhantomData<ArcInner<Vec<Vec2>>>: Freeze, PhantomData<((i32, i32), Vec<u32>)>: Freeze, PhantomData<(u32, Rect)>: Freeze, PhantomData<(u32, u32)>: Freeze, *const ArcInner<Mutex<Option<Bounds<Pixels>>>> is !null: Freeze, PhantomData<ArcInner<Mutex<Option<Bounds<Pixels>>>>>: Freeze, PhantomData<(NodeId, Tween)>: Freeze, PhantomData<(NodeId, ())>: Freeze, PhantomData<(u32, ())>: Freeze, PhantomData<(NodeId, u32)>: Freeze, PhantomData<((SharedString, u32), f32)>: Freeze,

§

impl Move for Graph2D

§

impl Send for Graph2D
where &'static str: Send, Arc<str>: Send, NonZero<u32>: Send, Arc<RwLock<RawRwLock, FocusMap>>: Send, NodeRef<Owned, KindId, NodeKind, LeafOrInternal>: Send, BoxRaw<(KindId, NodeKind)>: Send, NodeRef<Owned, NodeId, Node, LeafOrInternal>: Send, BoxRaw<(NodeId, Node)>: Send, NodeRef<Owned, EdgeId, Edge, LeafOrInternal>: Send, BoxRaw<(EdgeId, Edge)>: Send, NodeRef<Owned, NodeId, Adjacency, LeafOrInternal>: Send, BoxRaw<(NodeId, Adjacency)>: Send, RawVecInner: Send, Sender<LayoutCommand<Vec2>>: Send, Arc<Mutex<Option<LayoutMessage<Vec2>>>>: Send, Arc<Atomic<bool>>: Send, JoinHandle<()>: Send, Arc<GraphPayload>: Send, Arc<Vec<Vec2>>: Send, RawTable<((i32, i32), Vec<u32>)>: Send, RawTable<(u32, Rect)>: Send, Arc<Mutex<Option<Bounds<Pixels>>>>: Send, RawTable<(NodeId, Tween)>: Send, RawTable<(NodeId, ())>: Send, RawTable<(u32, ())>: Send, RawTable<(NodeId, u32)>: Send, RawTable<((SharedString, u32), f32)>: Send,

§

impl Sync for Graph2D
where Arc<str>: Sync, NonZero<u32>: Sync, Arc<RwLock<RawRwLock, FocusMap>>: Sync, NodeRef<Owned, KindId, NodeKind, LeafOrInternal>: Sync, BoxRaw<(KindId, NodeKind)>: Sync, NodeRef<Owned, NodeId, Node, LeafOrInternal>: Sync, BoxRaw<(NodeId, Node)>: Sync, NodeRef<Owned, EdgeId, Edge, LeafOrInternal>: Sync, BoxRaw<(EdgeId, Edge)>: Sync, NodeRef<Owned, NodeId, Adjacency, LeafOrInternal>: Sync, BoxRaw<(NodeId, Adjacency)>: Sync, RawVecInner: Sync, Sender<LayoutCommand<Vec2>>: Sync, Arc<Mutex<Option<LayoutMessage<Vec2>>>>: Sync, Arc<Atomic<bool>>: Sync, JoinHandle<()>: Sync, Arc<GraphPayload>: Sync, Arc<Vec<Vec2>>: Sync, RawTable<((i32, i32), Vec<u32>)>: Sync, RawTable<(u32, Rect)>: Sync, Arc<Mutex<Option<Bounds<Pixels>>>>: Sync, RawTable<(NodeId, Tween)>: Sync, RawTable<(NodeId, ())>: Sync, RawTable<(u32, ())>: Sync, RawTable<(NodeId, u32)>: Sync, RawTable<((SharedString, u32), f32)>: Sync,

§

impl Unpin for Graph2D
where &'static str: Unpin, Arc<str>: Unpin, NonZero<u32>: Unpin, Arc<RwLock<RawRwLock, FocusMap>>: Unpin, *const LeafNode<KindId, NodeKind> is !null: Unpin, Box<(KindId, NodeKind)>: Unpin, *const LeafNode<NodeId, Node> is !null: Unpin, Box<(NodeId, Node)>: Unpin, *const LeafNode<EdgeId, Edge> is !null: Unpin, Box<(EdgeId, Edge)>: Unpin, *const LeafNode<NodeId, Adjacency> is !null: Unpin, Box<(NodeId, Adjacency)>: Unpin, *const u8 is !null: Unpin, *mut Counter<Channel<LayoutCommand<Vec2>>>: Unpin, *mut Counter<Channel<LayoutCommand<Vec2>>>: Unpin, *mut Counter<Channel<LayoutCommand<Vec2>>>: Unpin, Arc<Mutex<Option<LayoutMessage<Vec2>>>>: Unpin, Arc<Atomic<bool>>: Unpin, Arc<Inner, System>: Unpin, Arc<Packet<'static, ()>>: Unpin, Arc<GraphPayload>: Unpin, Arc<Vec<Vec2>>: Unpin, Arc<Mutex<Option<Bounds<Pixels>>>>: Unpin,

§

impl UnsafeUnpin for Graph2D
where &'static str: UnsafeUnpin, *const ArcInner<str> is !null: UnsafeUnpin, PhantomData<ArcInner<str>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, *const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: UnsafeUnpin, PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: UnsafeUnpin, *const LeafNode<KindId, NodeKind> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(KindId, NodeKind)>>: UnsafeUnpin, *const LeafNode<NodeId, Node> is !null: UnsafeUnpin, PhantomData<Box<(NodeId, Node)>>: UnsafeUnpin, *const LeafNode<EdgeId, Edge> is !null: UnsafeUnpin, PhantomData<Box<(EdgeId, Edge)>>: UnsafeUnpin, *const LeafNode<NodeId, Adjacency> is !null: UnsafeUnpin, PhantomData<Box<(NodeId, Adjacency)>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<NodeId>: UnsafeUnpin, PhantomData<f32>: UnsafeUnpin, PhantomData<bool>: UnsafeUnpin, PhantomData<(u32, u32, f32)>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, *mut Counter<Channel<LayoutCommand<Vec2>>>: UnsafeUnpin, *mut Counter<Channel<LayoutCommand<Vec2>>>: UnsafeUnpin, *mut Counter<Channel<LayoutCommand<Vec2>>>: UnsafeUnpin, *const ArcInner<Mutex<Option<LayoutMessage<Vec2>>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Option<LayoutMessage<Vec2>>>>>: UnsafeUnpin, *const ArcInner<Atomic<bool>> is !null: UnsafeUnpin, PhantomData<ArcInner<Atomic<bool>>>: UnsafeUnpin, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin, *const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin, PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin, *const ArcInner<GraphPayload> is !null: UnsafeUnpin, PhantomData<ArcInner<GraphPayload>>: UnsafeUnpin, *const ArcInner<Vec<Vec2>> is !null: UnsafeUnpin, PhantomData<ArcInner<Vec<Vec2>>>: UnsafeUnpin, PhantomData<((i32, i32), Vec<u32>)>: UnsafeUnpin, PhantomData<(u32, Rect)>: UnsafeUnpin, PhantomData<(u32, u32)>: UnsafeUnpin, *const ArcInner<Mutex<Option<Bounds<Pixels>>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Option<Bounds<Pixels>>>>>: UnsafeUnpin, PhantomData<(NodeId, Tween)>: UnsafeUnpin, PhantomData<(NodeId, ())>: UnsafeUnpin, PhantomData<(u32, ())>: UnsafeUnpin, PhantomData<(NodeId, u32)>: UnsafeUnpin, PhantomData<((SharedString, u32), f32)>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more