Class ParaGraph.ViewState
Object
ViewState
- Enclosing class:
ParaGraph
Helper that caches derived view quantities for the current bounds, ranges,
and zoom factor.
- Author:
- Christoph Hauert
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleCached x-axis range for the base view.private doubleCached y-axis range for the base view.private doubleCached minimum x-axis value for the base range.private doubleCached minimum y-axis value for the base range.private doubleCached frame height in pixels.private booleanCached validity flag.private doubleCached frame width in pixels.private doubleCached x-axis zoom factor.private doubleCached y-axis zoom factor. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcomputeZoom(double factor) Compute per-axis zoom factors after applying domain constraints.private doubledataXFromLocal(double localX) Convert a local x-coordinate into data coordinates.private doubledataYFromLocal(double localY) Convert a local y-coordinate into data coordinates.private ParaGraph.ViewStateupdate(double baseXMin, double baseXMax, double baseYMin, double baseYMax, double factor) Update the cached view state for the provided base ranges and zoom factor.private doubleviewCornerXForMin(double desiredMin) Compute a view corner value that aligns the visible minimum withdesiredMin.private doubleviewCornerYForMax(double desiredMax) Compute a view corner value that aligns the visible maximum withdesiredMax.
-
Field Details
-
w
private double wCached frame width in pixels. -
h
private double hCached frame height in pixels. -
baseXMin
private double baseXMinCached minimum x-axis value for the base range. -
baseYMin
private double baseYMinCached minimum y-axis value for the base range. -
baseRangeX
private double baseRangeXCached x-axis range for the base view. -
baseRangeY
private double baseRangeYCached y-axis range for the base view. -
zoomX
private double zoomXCached x-axis zoom factor. -
zoomY
private double zoomYCached y-axis zoom factor. -
valid
private boolean validCached 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 valuebaseXMax- maximum x-axis valuebaseYMin- minimum y-axis valuebaseYMax- maximum y-axis valuefactor- 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 withdesiredMin.- 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 withdesiredMax.- 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
-