JFLib

diagram_core/src/layout/adjust.rs#

Source: lib/diagram_core/src/layout/adjust.rs

layout/adjust -- (JD21) small adjustments of connected shapes: Automatische Ausrichtung und
Abstände and Automatischer Abstand (CN-14, RS-25), Diagramm drehen (RS-25), Von
Seitenumbrüchen verschieben and Seitenumbrüche vermeiden (PR-03); the rules in layout.rs

  align_space(doc, owner, only, align, space, spacing) -> moves   each child (downstream over
                      a connector) lined up with its parent and set at the spacing from it,
                      its siblings on that side at the spacing from each other, everything
                      further downstream carried along
  turn(doc, owner, only, Turn, spacing) -> moves   each connected part (a selection: one)
                      turned or flipped about the middle of its box, the shapes upright;
                      distances grow where shapes would come too close
  off_breaks(doc, owner, only, &xs, &ys, margin) -> moves   shapes across a page break
                      moved to the side where more of them lies, `margin` from the break

The moves are applied with layout::move_nodes (members and callouts along) and the
connectors follow with layout::reroute, all in the caller's transaction.
  • fn align_space(doc: &Document, owner: Owner, only: &[ShapeRef], align: bool, space: bool, spacing: [f64; 2]) -> Vec<(ShapeRef, [f64; 2])> Automatische Ausrichtung und Abstände (align and space), Automatischer Abstand (space alone), automatisch ausrichten (align alone) on the connected shapes of owner (only not empty: the selected ones adjust, what lies downstream of them is carried along) -> the moves of the shapes (see the file header)

  • enum Turn Diagramm drehen: VisLayoutDirection's four (0 right, 1 left, 2 vertical, 3 horizontal)

    • Right -- 90 degrees clockwise
    • Left -- 90 degrees anticlockwise
    • FlipV -- top and bottom exchanged
    • FlipH -- left and right exchanged
  • fn turn(doc: &Document, owner: Owner, only: &[ShapeRef], how: Turn, spacing: [f64; 2]) -> Vec<(ShapeRef, [f64; 2])> Diagramm drehen: every connected part of two or more shapes of owner (only not empty: the selected shapes as one part) turned or flipped about the middle of its box; the shapes keep their own orientation, fixed ones stay; after a turn the distances along an axis grow where two shapes would come closer than spacing on both axes -> the moves

  • fn off_breaks(doc: &Document, owner: Owner, only: &[ShapeRef], xs: &[f64], ys: &[f64], margin: f64) -> Vec<(ShapeRef, [f64; 2])> Von Seitenumbrüchen verschieben: the shapes of owner (only not empty: those; members move with their containers, fixed shapes stay) that lie across a page break (xs: the vertical lines, ys: the horizontal ones, drawing units) moved to the side where more of them lies, margin from the break -> the moves

Source: docs/API.md in the JFLib repository.