Class ViewTransform
java.lang.Object
it.univr.di.cstnu.gui.ViewTransform
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault scale (1:1).static final doubleMaximum allowed scale factor.static final doubleMinimum allowed scale factor. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new transform initialized to identity (scale 1, no translation). -
Method Summary
Modifier and TypeMethodDescriptionvoidfitTo(Rectangle2D modelBounds, Dimension viewSize, double marginPx) FitmodelBoundsintoviewSizewithmarginPxmargin on each side.doublegetScale()voidpanBy(double viewDx, double viewDy) Pan by (viewDx, viewDy) in view space.voidreset()Reset to identity (scale=1, no translation).Convert view coordinates to model coordinates.Convert model coordinates to view coordinates.voidZoom byfactorkeepingpivotInViewstationary.
-
Field Details
-
DEFAULT_SCALE
public static final double DEFAULT_SCALEDefault scale (1:1).- See Also:
-
MAX_SCALE
public static final double MAX_SCALEMaximum allowed scale factor.- See Also:
-
MIN_SCALE
public static final double MIN_SCALEMinimum allowed scale factor.- See Also:
-
-
Constructor Details
-
ViewTransform
public ViewTransform()Creates a new transform initialized to identity (scale 1, no translation).
-
-
Method Details
-
fitTo
FitmodelBoundsintoviewSizewithmarginPxmargin on each side.- Parameters:
modelBounds- the bounding box in model space to fit, not nullviewSize- the size of the view in pixels, not nullmarginPx- margin, in pixels, to leave on each side
-
getScale
public double getScale()- Returns:
- the current scale factor
-
panBy
public void panBy(double viewDx, double viewDy) Pan by (viewDx, viewDy) in view space.- Parameters:
viewDx- horizontal displacement in view coordinatesviewDy- vertical displacement in view coordinates
-
reset
public void reset()Reset to identity (scale=1, no translation). -
toAffineTransform
- Returns:
- an
AffineTransformequivalent to this transform
-
toModel
-
toView
-
zoomBy
Zoom byfactorkeepingpivotInViewstationary. The model point that was underpivotInViewbefore the call stays underpivotInViewafter the call.- Parameters:
factor- the multiplicative zoom factor (> 1 zooms in, < 1 zooms out)pivotInView- the pivot point in view coordinates, not null
-