Class StoredLayout

java.lang.Object
it.univr.di.cstnu.gui.layout.StoredLayout
All Implemented Interfaces:
GraphLayout

public final class StoredLayout extends Object implements 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()].
A non-finite coordinate is treated as if it fell outside the area on the side of its sign (negative → minimum, positive or NaN → maximum), then clamped accordingly.
Author:
posenato
  • Constructor Details

    • StoredLayout

      public StoredLayout()
      Sole constructor — no configuration needed.
  • Method Details

    • displayName

      @Nonnull public String displayName()
      Description copied from interface: GraphLayout
      Returns a human-readable name suitable for display in a UI menu.
      Specified by:
      displayName in interface GraphLayout
      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 through positions after clamping to area. Coordinates that are already valid and inside the area are not changed.
      Specified by:
      apply in interface GraphLayout
      Parameters:
      graph - the graph whose nodes are processed, not null
      positions - the position store to read from and write to, not null
      area - 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)
      Clamps value to [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 clamp
      min - the minimum (finite) boundary, must be ≤ max
      max - the maximum (finite) boundary, must be ≥ min
      Returns:
      the clamped value in [min, max]