Class StoredLayout
java.lang.Object
it.univr.di.cstnu.gui.layout.StoredLayout
- All Implemented Interfaces:
GraphLayout
The "Saved" layout: does not recompute positions; it leaves each node where
its stored coordinates say it is.
This layout exists so that the UI can offer three uniform choices
(Saved / Force-directed / Circle) through the same GraphLayout interface.
Clamping rule: if a node's stored coordinate is not finite
(i.e. NaN or infinite)
or falls outside area, it is clamped to the nearest boundary of area.
Specifically:
- x is clamped to [
area.getMinX(),area.getMaxX()]; - y is clamped to [
area.getMinY(),area.getMaxY()].
- Author:
- posenato
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(TemporalConstraintGraph<?> graph, NodePositions positions, Rectangle2D area) Reads each node's stored coordinates and writes them back throughpositionsafter clamping toarea.(package private) static doubleclamp(double value, double min, double max) Clampsvalueto [min,max].Returns a human-readable name suitable for display in a UI menu.
-
Constructor Details
-
StoredLayout
public StoredLayout()Sole constructor — no configuration needed.
-
-
Method Details
-
displayName
Description copied from interface:GraphLayoutReturns a human-readable name suitable for display in a UI menu.- Specified by:
displayNamein interfaceGraphLayout- Returns:
- the display name of this layout, never
null
-
apply
public void apply(@Nonnull TemporalConstraintGraph<?> graph, @Nonnull NodePositions positions, @Nonnull Rectangle2D area) Reads each node's stored coordinates and writes them back throughpositionsafter clamping toarea. Coordinates that are already valid and inside the area are not changed.- Specified by:
applyin interfaceGraphLayout- Parameters:
graph- the graph whose nodes are processed, not nullpositions- the position store to read from and write to, not nullarea- the bounding rectangle; every node is guaranteed to lie inside this after the call, not null
-
clamp
static double clamp(double value, double min, double max) Clampsvalueto [min,max]. Non-finite values are treated as out-of-range and clamped to the nearest boundary: negative-infinity → min, positive-infinity or NaN → max.- Parameters:
value- the value to clampmin- the minimum (finite) boundary, must be ≤ maxmax- the maximum (finite) boundary, must be ≥ min- Returns:
- the clamped value in [min, max]
-