Class ParaGraph.ViewState

Object
ViewState
Enclosing class:
ParaGraph

private final class ParaGraph.ViewState extends Object
Helper that caches derived view quantities for the current bounds, ranges, and zoom factor.
Author:
Christoph Hauert
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
    Cached x-axis range for the base view.
    private double
    Cached y-axis range for the base view.
    private double
    Cached minimum x-axis value for the base range.
    private double
    Cached minimum y-axis value for the base range.
    private double
    Cached frame height in pixels.
    private boolean
    Cached validity flag.
    private double
    Cached frame width in pixels.
    private double
    Cached x-axis zoom factor.
    private double
    Cached y-axis zoom factor.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Private constructor for the ViewState class.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    computeZoom(double factor)
    Compute per-axis zoom factors after applying domain constraints.
    private double
    dataXFromLocal(double localX)
    Convert a local x-coordinate into data coordinates.
    private double
    dataYFromLocal(double localY)
    Convert a local y-coordinate into data coordinates.
    update(double baseXMin, double baseXMax, double baseYMin, double baseYMax, double factor)
    Update the cached view state for the provided base ranges and zoom factor.
    private double
    viewCornerXForMin(double desiredMin)
    Compute a view corner value that aligns the visible minimum with desiredMin.
    private double
    viewCornerYForMax(double desiredMax)
    Compute a view corner value that aligns the visible maximum with desiredMax.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • w

      private double w
      Cached frame width in pixels.
    • h

      private double h
      Cached frame height in pixels.
    • baseXMin

      private double baseXMin
      Cached minimum x-axis value for the base range.
    • baseYMin

      private double baseYMin
      Cached minimum y-axis value for the base range.
    • baseRangeX

      private double baseRangeX
      Cached x-axis range for the base view.
    • baseRangeY

      private double baseRangeY
      Cached y-axis range for the base view.
    • zoomX

      private double zoomX
      Cached x-axis zoom factor.
    • zoomY

      private double zoomY
      Cached y-axis zoom factor.
    • valid

      private boolean valid
      Cached validity flag.
  • Constructor Details

    • ViewState

      private ViewState()
      Private constructor for the ViewState class. Prevents external instantiation of ViewState objects, ensuring that ViewState instances can only be created within the enclosing class. This follows the typical use for inner classes that represent internal state or configuration but remain hidden from outside.
  • Method Details

    • update

      private ParaGraph.ViewState update(double baseXMin, double baseXMax, double baseYMin, double baseYMax, double factor)
      Update the cached view state for the provided base ranges and zoom factor.
      Parameters:
      baseXMin - minimum x-axis value
      baseXMax - maximum x-axis value
      baseYMin - minimum y-axis value
      baseYMax - maximum y-axis value
      factor - zoom factor to apply
      Returns:
      this view state
    • dataXFromLocal

      private double dataXFromLocal(double localX)
      Convert a local x-coordinate into data coordinates.
      Parameters:
      localX - x-coordinate relative to the frame
      Returns:
      x value in data coordinates
    • dataYFromLocal

      private double dataYFromLocal(double localY)
      Convert a local y-coordinate into data coordinates.
      Parameters:
      localY - y-coordinate relative to the frame
      Returns:
      y value in data coordinates
    • viewCornerXForMin

      private double viewCornerXForMin(double desiredMin)
      Compute a view corner value that aligns the visible minimum with desiredMin.
      Parameters:
      desiredMin - desired visible minimum
      Returns:
      view corner x-position in pixels
    • viewCornerYForMax

      private double viewCornerYForMax(double desiredMax)
      Compute a view corner value that aligns the visible maximum with desiredMax.
      Parameters:
      desiredMax - desired visible maximum
      Returns:
      view corner y-position in pixels
    • computeZoom

      private void computeZoom(double factor)
      Compute per-axis zoom factors after applying domain constraints.
      Parameters:
      factor - requested zoom factor