LayeredLayout.Compaction.OneD
- Package
- purescript-layered-layout
- Repository
- markgrafhq/purescript-layered-layout
Constraint-graph data model and infrastructure for the post-routing one-dimensional compactor.
This is a port of ELK's org.eclipse.elk.alg.common.compaction.oned
package: CGraph / CGroup / CNode / Quadruplet /
ISpacingsHandler / ICompactionAlgorithm /
IConstraintCalculationAlgorithm / OneDimensionalCompactor.
The Java code mutates the state in place. The PureScript port
threads an OneDState a record through each step. The origin
field on a CNode is polymorphic so the layered package can
tag it with LNode | VerticalSegment without this module
knowing the concrete sum.
Phase 2 of the post-routing compaction port (the network simplex
algorithm lives in LayeredLayout.NetworkSimplex; the layered-graph
bridge lives in LayeredLayout.Compaction.LGraphTransformer /
LayeredLayout.Compaction.HorizontalGraphCompactor).
#isHorizontalDir Source
isHorizontalDir :: Direction -> Boolean#isVerticalDir Source
isVerticalDir :: Direction -> Boolean#CNode Source
type CNode a = { cGroup :: Maybe CGroupId, cGroupOffset :: KVec, constraints :: Array CNodeId, hitbox :: Rect, hitboxPreCompaction :: Rect, id :: CNodeId, ignoreSpacing :: Quadruplet, kind :: Maybe String, origin :: Maybe a, startPos :: Number }Node in the constraint graph.
The origin field is polymorphic — the layered-graph bridge
tags it with a sum of LNode and VerticalSegment, but this
module does not need to look inside.
#CGroup Source
type CGroup = { cNodes :: Array CNodeId, delta :: Number, deltaNormalized :: Number, id :: CGroupId, incomingConstraints :: Array CNodeId, master :: Maybe CNodeId, outDegree :: Int, outDegreeReal :: Int, reference :: Maybe CNodeId, startPos :: Number }Group of nodes whose relative offsets are preserved during compaction.
#CGraph Source
type CGraph a = { cGroupOrder :: Array CGroupId, cGroups :: Map CGroupId CGroup, cNodeOrder :: Array CNodeId, cNodes :: Map CNodeId (CNode a), nextCGroupId :: Int, nextCNodeId :: Int, predefinedHorizontalConstraints :: Array (CNodeId /\ CNodeId), predefinedVerticalConstraints :: Array (CNodeId /\ CNodeId), supportedDirections :: Set Direction }Constraint graph.
#OneDState Source
type OneDState a = { cGraph :: CGraph a, compactionAlgorithm :: Maybe (ICompactionAlgorithm a), constraintAlgorithm :: Maybe (IConstraintCalculationAlgorithm a), direction :: Direction, finished :: Boolean, lockFun :: Maybe (ILockFunction a), spacingsHandler :: ISpacingsHandler a }#IConstraintCalculationAlgorithm Source
newtype IConstraintCalculationAlgorithm aConstructors
#runCompactionAlgorithm Source
runCompactionAlgorithm :: forall a. ICompactionAlgorithm a -> OneDState a -> OneDState a#runConstraintAlgorithm Source
runConstraintAlgorithm :: forall a. IConstraintCalculationAlgorithm a -> OneDState a -> CGraph a#Quadruplet Source
type Quadruplet = { down :: Boolean, left :: Boolean, right :: Boolean, up :: Boolean }#quadSet Source
quadSet :: Direction -> Boolean -> Quadruplet -> Quadruplet#quadOr Source
quadOr :: Quadruplet -> Quadruplet -> Quadruplet#defaultSpacingsHandler Source
defaultSpacingsHandler :: forall a. ISpacingsHandler a#addCNode Source
addCNode :: forall a. { hitbox :: Rect, kind :: Maybe String, origin :: Maybe a } -> CGraph a -> { graph :: CGraph a, id :: CNodeId }Create a new free-standing CNode in the graph. The node is not placed in any group yet — the OneDimensionalCompactor constructor wraps every group-less node in a singleton group.
#addCNodeToGroup Source
addCNodeToGroup :: forall a. CNodeId -> CGroupId -> CGraph a -> CGraph aMove a node into a group. Mirrors CGroup.addCNode (which
throws if the node already belongs to a group). The first node
added becomes the group's reference.
#removeCNodeFromGroup Source
removeCNodeFromGroup :: forall a. CNodeId -> CGroupId -> CGraph a -> CGraph a#setCNodeIgnoreSpacing Source
setCNodeIgnoreSpacing :: forall a. CNodeId -> Quadruplet -> CGraph a -> CGraph aOR q into the CNode's existing ignoreSpacing flags. Mirrors
the merge semantics of VerticalSegment.unionInto so flags set
by the transformer accumulate when a node is touched multiple
times.
#allCGroups Source
allCGroups :: forall a. CGraph a -> Array CGroupIterate every CGroup in insertion order.
#setSpacingsHandler Source
setSpacingsHandler :: forall a. ISpacingsHandler a -> OneDState a -> OneDState a#setCompactionAlgorithm Source
setCompactionAlgorithm :: forall a. ICompactionAlgorithm a -> OneDState a -> OneDState a#setConstraintAlgorithm Source
setConstraintAlgorithm :: forall a. IConstraintCalculationAlgorithm a -> OneDState a -> OneDState a#setLockFunction Source
setLockFunction :: forall a. ILockFunction a -> OneDState a -> OneDState a#changeDirection Source
changeDirection :: forall a. Direction -> OneDState a -> OneDState aSwitch compaction direction. Mirrors / transposes hitboxes as needed and either recalculates the constraints or reverses them (for the LEFT<->RIGHT and UP<->DOWN flips).
#calculateGroupOffsets Source
calculateGroupOffsets :: forall a. OneDState a -> OneDState aPublic re-export of calculateGroupOffsetsGraph operating on
the full state.
#forceConstraintsRecalculation Source
forceConstraintsRecalculation :: forall a. OneDState a -> OneDState aRun the constraint calculation again without changing direction.
- Modules
- LayeredLayout
- LayeredLayout.
Aesthetics - LayeredLayout.
Compaction. EdgeAwareScanlineConstraints - LayeredLayout.
Compaction. HorizontalGraphCompactor - LayeredLayout.
Compaction. LGraphToCGraphTransformer - LayeredLayout.
Compaction. NetworkSimplexCompaction - LayeredLayout.
Compaction. OneD - LayeredLayout.
Compaction. VerticalSegment - LayeredLayout.
Components - LayeredLayout.
CoordAssignment - LayeredLayout.
CrossingMin - LayeredLayout.
CrossingMin. Constraints - LayeredLayout.
CrossingMin. NorthSouth - LayeredLayout.
CrossingMin. Ports - LayeredLayout.
CycleRemoval - LayeredLayout.
DummyNodes - LayeredLayout.
EdgeLabels - LayeredLayout.
EdgeLabels. SelfLoops - LayeredLayout.
EdgeLabels. SelfLoops. Model - LayeredLayout.
EdgeLabels. SelfLoops. Routing - LayeredLayout.
EdgeRouting - LayeredLayout.
EdgeRouting. HyperEdgeCycleDetector - LayeredLayout.
EdgeRouting. HyperEdges - LayeredLayout.
EdgeRouting. LineJump - LayeredLayout.
EdgeRouting. Orthogonal - LayeredLayout.
EdgeRouting. PortAssignment - LayeredLayout.
Graph - LayeredLayout.
Grid - LayeredLayout.
JavaRandom - LayeredLayout.
LayerAssignment - LayeredLayout.
LayerAssignment. NetworkSimplex - LayeredLayout.
NetworkSimplex - LayeredLayout.
PortDistribution - LayeredLayout.
PortDummies - LayeredLayout.
Result