Trait railroad::Node

source ·
pub trait Node {
    // Required methods
    fn entry_height(&self) -> i64;
    fn height(&self) -> i64;
    fn width(&self) -> i64;
    fn draw(&self, x: i64, y: i64, h_dir: HDir) -> Element;

    // Provided method
    fn height_below_entry(&self) -> i64 { ... }
}
Expand description

A diagram is built from a set of primitives which implement Node.

A primitive is a geometric box, within which it can draw whatever it wants. Simple primitives (e.g. Start) have fixed width, height etc.. Complex primitives, which wrap other primitives (e.g. Sequence), use the methods defined here to compute their own geometry. When the time comes for a primitive to be drawn, the wrapping primitive computes the desired location of the wrapped primitive(s) and calls .draw() on them. It is the primitive’s job to ensure that it uses only the space it announced.

Required Methods§

source

fn entry_height(&self) -> i64

The vertical distance from this element’s top to where the entering, connecting path is drawn.

By convention, the path connecting primitives enters from the left.

source

fn height(&self) -> i64

This primitives’s total height.

source

fn width(&self) -> i64

This primitive’s total width.

source

fn draw(&self, x: i64, y: i64, h_dir: HDir) -> Element

Draw this element as an svg::Element.

Provided Methods§

source

fn height_below_entry(&self) -> i64

The vertical distance from the height of the connecting path to the bottom.

Trait Implementations§

source§

impl Debug for dyn Node

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementations on Foreign Types§

source§

impl<'a, N> Node for &'a Nwhere N: Node + ?Sized,

source§

fn entry_height(&self) -> i64

source§

fn height(&self) -> i64

source§

fn width(&self) -> i64

source§

fn draw(&self, x: i64, y: i64, h_dir: HDir) -> Element

source§

impl<N> Node for Box<N>where N: Node + ?Sized,

source§

fn entry_height(&self) -> i64

source§

fn height(&self) -> i64

source§

fn width(&self) -> i64

source§

fn draw(&self, x: i64, y: i64, h_dir: HDir) -> Element

source§

impl<'a, N> Node for &'a mut Nwhere N: Node + ?Sized,

source§

fn entry_height(&self) -> i64

source§

fn height(&self) -> i64

source§

fn width(&self) -> i64

source§

fn draw(&self, x: i64, y: i64, h_dir: HDir) -> Element

source§

impl<N> Node for Rc<N>where N: Node + ?Sized,

source§

fn entry_height(&self) -> i64

source§

fn height(&self) -> i64

source§

fn width(&self) -> i64

source§

fn draw(&self, x: i64, y: i64, h_dir: HDir) -> Element

source§

impl<N> Node for Arc<N>where N: Node + ?Sized,

source§

fn entry_height(&self) -> i64

source§

fn height(&self) -> i64

source§

fn width(&self) -> i64

source§

fn draw(&self, x: i64, y: i64, h_dir: HDir) -> Element

Implementors§

source§

impl Node for Comment

source§

impl Node for Empty

source§

impl Node for End

source§

impl Node for NonTerminal

source§

impl Node for SimpleEnd

source§

impl Node for SimpleStart

source§

impl Node for Start

source§

impl Node for Terminal

source§

impl<I, R> Node for Repeat<I, R>where I: Node, R: Node,

source§

impl<N> Node for Choice<N>where N: Node,

source§

impl<N> Node for Diagram<N>where N: Node,

source§

impl<N> Node for HorizontalGrid<N>where N: Node,

source§

impl<N> Node for Link<N>where N: Node,

source§

impl<N> Node for Optional<N>where N: Node,

source§

impl<N> Node for Sequence<N>where N: Node,

source§

impl<N> Node for Stack<N>where N: Node,

source§

impl<N: Node> Node for VerticalGrid<N>

source§

impl<T, U> Node for LabeledBox<T, U>where T: Node, U: Node,