Skip to content

Commit

Permalink
Introduce parameter minScaleX and minScaleY to InertialScreenTransfor…
Browse files Browse the repository at this point in the history
…mEventHandler in grapher package

* Initialized with the existing static default values
  • Loading branch information
stefanhahmann authored and tinevez committed Sep 23, 2024
1 parent 1fe976c commit faeb41e
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ public void getCommandDescriptions( final CommandDescriptions descriptions )
*/
private boolean stayFullyZoomedOut;

private double minScaleX;

private double minScaleY;

/**
* Timer that runs {@link #currentTimerTask}.
*/
Expand All @@ -240,6 +244,8 @@ public InertialScreenTransformEventHandler( final ScreenTransformState transform
zoomScrollBehaviourX = new ZoomScrollBehaviour( ZOOM_X, ScrollAxis.X );
zoomScrollBehaviourY = new ZoomScrollBehaviour( ZOOM_Y, ScrollAxis.Y );
zoomScrollBehaviourXY = new ZoomScrollBehaviour( ZOOM_XY, ScrollAxis.XY );
minScaleX = DEFAULT_MIN_SCALE_X;
minScaleY = DEFAULT_MIN_SCALE_Y;
}

@Override
Expand Down Expand Up @@ -289,18 +295,18 @@ public synchronized void layoutChanged( final DataGraphLayout< ?, ? > layout )
boundYMin = layout.getCurrentLayoutMinY() - boundYLayoutBorder;
boundYMax = layout.getCurrentLayoutMaxY() + boundYLayoutBorder;

if ( boundXMax - boundXMin < DEFAULT_MIN_SCALE_X )
if ( boundXMax - boundXMin < minScaleX )
{
final double c = ( boundXMax + boundXMin ) / 2;
boundXMin = c - DEFAULT_MIN_SCALE_X / 2;
boundXMax = c + DEFAULT_MIN_SCALE_X / 2;
boundXMin = c - minScaleX / 2;
boundXMax = c + minScaleX / 2;
}
updateMaxSizeX( transform.getScreenWidth() );
if ( boundYMax - boundYMin < DEFAULT_MIN_SCALE_X )
if ( boundYMax - boundYMin < minScaleX )
{
final double c = ( boundYMax + boundYMin ) / 2;
boundYMin = c - DEFAULT_MIN_SCALE_X / 2;
boundYMax = c + DEFAULT_MIN_SCALE_X / 2;
boundYMin = c - minScaleX / 2;
boundYMax = c + minScaleX / 2;
}
updateMaxSizeY( transform.getScreenHeight() );

Expand Down Expand Up @@ -331,11 +337,11 @@ public void setLayoutRangeY( final double layoutMinY, final double layoutMaxY )
boundYMin = layoutMinY - boundYLayoutBorder;
boundYMax = layoutMaxY + boundYLayoutBorder;

if ( boundYMax - boundYMin < DEFAULT_MIN_SCALE_Y )
if ( boundYMax - boundYMin < minScaleY )
{
final double c = ( boundYMax + boundYMin ) / 2;
boundYMin = c - DEFAULT_MIN_SCALE_Y / 2;
boundYMax = c + DEFAULT_MIN_SCALE_Y / 2;
boundYMin = c - minScaleY / 2;
boundYMax = c + minScaleY / 2;
}

updateMaxSizeY( transformState.get().getScreenHeight() );
Expand All @@ -345,7 +351,7 @@ private void constrainTransform( final ScreenTransform transform )
{
ConstrainScreenTransform.constrainTransform(
transform,
DEFAULT_MIN_SCALE_X, DEFAULT_MIN_SCALE_Y,
minScaleX, minScaleY,
maxSizeX, maxSizeY,
boundXMin, boundXMax, boundYMin, boundYMax,
borderRatioX, borderRatioY,
Expand Down Expand Up @@ -374,12 +380,12 @@ private void zoomOutFullyY( final ScreenTransform transform )

private boolean hasMinSizeX( final ScreenTransform transform )
{
return ConstrainScreenTransform.hasMinSizeX( transform, DEFAULT_MIN_SCALE_X + EPSILON );
return ConstrainScreenTransform.hasMinSizeX( transform, minScaleX + EPSILON );
}

private boolean hasMinSizeY( final ScreenTransform transform )
{
return ConstrainScreenTransform.hasMinSizeY( transform, DEFAULT_MIN_SCALE_Y + EPSILON );
return ConstrainScreenTransform.hasMinSizeY( transform, minScaleY + EPSILON );
}

private boolean hasMaxSizeX( final ScreenTransform transform )
Expand Down

0 comments on commit faeb41e

Please sign in to comment.