pub struct Graph2D { /* private fields */ }Expand description
2D 知识图谱画布。
Implementations§
Source§impl Graph2D
impl Graph2D
Sourcepub fn new(
id: impl Into<SharedString>,
graph: KnowledgeGraph,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new( id: impl Into<SharedString>, graph: KnowledgeGraph, cx: &mut Context<'_, Self>, ) -> Self
带后台力导向布局创建(推荐入口)。
Sourcepub fn new_static(
id: impl Into<SharedString>,
graph: KnowledgeGraph,
positions: Vec<Vec2>,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new_static( id: impl Into<SharedString>, graph: KnowledgeGraph, positions: Vec<Vec2>, cx: &mut Context<'_, Self>, ) -> Self
使用预先算好的坐标创建(跳过后台布局;坐标按 NodeId 升序对齐)。
Sourcepub fn aria_label(self, label: impl Into<SharedString>) -> Self
pub fn aria_label(self, label: impl Into<SharedString>) -> Self
无障碍名称。
Sourcepub fn fit_on_mount(self) -> Self
pub fn fit_on_mount(self) -> Self
首个布局快照到达后自动适配视图。
Sourcepub fn rendered_counts(&self) -> RenderCounts
pub fn rendered_counts(&self) -> RenderCounts
最近一次渲染统计。
Sourcepub fn zoom_by(
&mut self,
factor: f32,
_window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn zoom_by( &mut self, factor: f32, _window: &mut Window, cx: &mut Context<'_, Self>, )
以画布中心为锚缩放。
Sourcepub fn kind_filter(&self) -> Option<KindId>
pub fn kind_filter(&self) -> Option<KindId>
当前类型筛选。
Sourcepub fn set_kind_filter(
&mut self,
kind: Option<KindId>,
cx: &mut Context<'_, Self>,
)
pub fn set_kind_filter( &mut self, kind: Option<KindId>, cx: &mut Context<'_, Self>, )
按类型筛选视图:只保留该类型节点(及两端都可见的边)。
None 取消筛选。双击可见节点可临时展开其一度邻居(Self::expand)。
Sourcepub fn set_pinned(
&mut self,
id: NodeId,
pinned: bool,
cx: &mut Context<'_, Self>,
)
pub fn set_pinned( &mut self, id: NodeId, pinned: bool, cx: &mut Context<'_, Self>, )
固定或解除固定。拖动后保持固定;调用此方法传 false 可恢复力导向布局。
pub fn is_pinned(&self, id: NodeId) -> bool
Sourcepub fn node_label(&self, id: NodeId) -> Option<&str>
pub fn node_label(&self, id: NodeId) -> Option<&str>
节点显示名称(组合搜索结果列表时使用)。
Sourcepub fn fly_to(&mut self, id: NodeId, cx: &mut Context<'_, Self>)
pub fn fly_to(&mut self, id: NodeId, cx: &mut Context<'_, Self>)
平滑飞到节点(相机弹簧;reduced motion 立即跳转)并选中它。
Sourcepub fn expand(&mut self, id: NodeId, cx: &mut Context<'_, Self>) -> usize
pub fn expand(&mut self, id: NodeId, cx: &mut Context<'_, Self>) -> usize
双击展开:把节点的一度邻居中当前被筛选隐藏的节点临时揭示出来(带进场动效)。 返回本次揭示的数量。
因筛选被隐藏的节点数。
Trait Implementations§
Source§impl Focusable for Graph2D
impl Focusable for Graph2D
Source§fn focus_handle(&self, _cx: &App) -> FocusHandle
fn focus_handle(&self, _cx: &App) -> FocusHandle
Returns the focus handle associated with this view.
Auto Trait Implementations§
impl !RefUnwindSafe for Graph2D
impl !UnwindSafe for Graph2D
impl Forget for Graph2D
impl Freeze for Graph2Dwhere
&'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 Graph2Dwhere
&'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 Graph2Dwhere
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 Graph2Dwhere
&'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 Graph2Dwhere
&'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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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