Package com.bc.ceres.grender.support
Class DefaultViewport
java.lang.Object
com.bc.ceres.grender.support.DefaultViewport
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultViewport
(boolean modelYAxisDown) DefaultViewport
(Rectangle viewBounds) DefaultViewport
(Rectangle viewBounds, boolean modelYAxisDown) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(ViewportListener listener) Adds a change listener to this viewport.clone()
Creates a clone of this viewport.protected void
fireViewportChanged
(boolean orientationChanged) Gets all listeners added to this viewport.double
double
double
double
Gets the zoom factor.boolean
void
moveViewDelta
(double deltaX, double deltaY) Moves the model CS by translating it into the opposite direction of the given vector in view coordinates.void
removeListener
(ViewportListener listener) Removes a change listener from this viewport.void
setModelYAxisDown
(boolean modelYAxisDown) void
setOffset
(double offsetX, double offsetY) Sets the viewport's absolute offset in model coordinates.void
setOrientation
(double orientation) Sets the orientation angle relative to the viewport bound's center point.void
setTransform
(Viewport other) Modifies this viewport so that it matches the given one.void
setViewBounds
(Rectangle viewBounds) void
setZoomFactor
(double zoomFactor) Sets the zoom factor relative to the viewport bound's center point.void
setZoomFactor
(double zoomFactor, double modelCenterX, double modelCenterY) Zooms to the given point given in model coordinates.toString()
void
zoom
(Rectangle2D modelBounds) Zooms to the given area given in model coordinates.
-
Constructor Details
-
DefaultViewport
public DefaultViewport() -
DefaultViewport
-
DefaultViewport
public DefaultViewport(boolean modelYAxisDown) -
DefaultViewport
-
-
Method Details
-
isModelYAxisDown
public boolean isModelYAxisDown()- Specified by:
isModelYAxisDown
in interfaceViewport
- Returns:
- If
true
, the model coordinate's Y-axis points downwards. Returnsfalse
by default.
-
setModelYAxisDown
public void setModelYAxisDown(boolean modelYAxisDown) - Specified by:
setModelYAxisDown
in interfaceViewport
- Parameters:
modelYAxisDown
- Iftrue
, the model coordinate's Y-axis points downwards.
-
getViewBounds
- Specified by:
getViewBounds
in interfaceViewport
- Returns:
- The bounds in view coordinates.
-
setViewBounds
- Specified by:
setViewBounds
in interfaceViewport
- Parameters:
viewBounds
- The bounds in view coordinates.
-
getViewToModelTransform
- Specified by:
getViewToModelTransform
in interfaceViewport
- Returns:
- The affine transformation from view to model coordinates.
-
getModelToViewTransform
- Specified by:
getModelToViewTransform
in interfaceViewport
- Returns:
- The affine transformation from model to view coordinates.
-
getOrientation
public double getOrientation()- Specified by:
getOrientation
in interfaceViewport
- Returns:
- The rotation angle in radians.
-
setOrientation
public void setOrientation(double orientation) Description copied from interface:Viewport
Sets the orientation angle relative to the viewport bound's center point.- Specified by:
setOrientation
in interfaceViewport
- Parameters:
orientation
- the new orientation angle in radians
-
getOffsetX
public double getOffsetX()- Specified by:
getOffsetX
in interfaceViewport
- Returns:
- The viewport's absolute X-offset in model coordinates.
-
getOffsetY
public double getOffsetY()- Specified by:
getOffsetY
in interfaceViewport
- Returns:
- The viewport's absolute Y-offset in model coordinates.
-
setOffset
public void setOffset(double offsetX, double offsetY) Description copied from interface:Viewport
Sets the viewport's absolute offset in model coordinates. -
moveViewDelta
public void moveViewDelta(double deltaX, double deltaY) Description copied from interface:Viewport
Moves the model CS by translating it into the opposite direction of the given vector in view coordinates.- Specified by:
moveViewDelta
in interfaceViewport
- Parameters:
deltaX
- the X delta in view coordinatesdeltaY
- the Y delta in view coordinates
-
getZoomFactor
public double getZoomFactor()Description copied from interface:Viewport
Gets the zoom factor. The zoom factor is equal to the number of model units per view unit.- Specified by:
getZoomFactor
in interfaceViewport
- Returns:
- The zoom factor.
-
setZoomFactor
public void setZoomFactor(double zoomFactor) Description copied from interface:Viewport
Sets the zoom factor relative to the viewport bound's center point.- Specified by:
setZoomFactor
in interfaceViewport
- Parameters:
zoomFactor
- The new zoom factor, must be greater than zero.- See Also:
-
zoom
Description copied from interface:Viewport
Zooms to the given area given in model coordinates. -
setZoomFactor
public void setZoomFactor(double zoomFactor, double modelCenterX, double modelCenterY) Description copied from interface:Viewport
Zooms to the given point given in model coordinates.- Specified by:
setZoomFactor
in interfaceViewport
- Parameters:
zoomFactor
- The new zoom factor, must be greater than zero.modelCenterX
- New X of the view's center point in model coordinates.modelCenterY
- New Y of the view's center point in model coordinates.
-
addListener
Description copied from interface:Viewport
Adds a change listener to this viewport.- Specified by:
addListener
in interfaceViewport
- Parameters:
listener
- The listener.
-
removeListener
Description copied from interface:Viewport
Removes a change listener from this viewport.- Specified by:
removeListener
in interfaceViewport
- Parameters:
listener
- The listener.
-
getListeners
Description copied from interface:Viewport
Gets all listeners added to this viewport.- Specified by:
getListeners
in interfaceViewport
- Returns:
- The listeners.
-
setTransform
Description copied from interface:Viewport
Modifies this viewport so that it matches the given one.- Specified by:
setTransform
in interfaceViewport
- Parameters:
other
- The view port to synchronize with.
-
fireViewportChanged
protected void fireViewportChanged(boolean orientationChanged) -
toString
-
clone
Description copied from interface:Viewport
Creates a clone of this viewport. The clone is a deep copy of this viewport but doesn't copy its listeners.
-