Package com.bc.ceres.grender.support
Class DefaultViewport
- java.lang.Object
-
- com.bc.ceres.grender.support.DefaultViewport
-
-
Constructor Summary
Constructors Constructor Description DefaultViewport()
DefaultViewport(boolean modelYAxisDown)
DefaultViewport(Rectangle viewBounds)
DefaultViewport(Rectangle viewBounds, boolean modelYAxisDown)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(ViewportListener listener)
Adds a change listener to this viewport.Viewport
clone()
Creates a clone of this viewport.protected void
fireViewportChanged(boolean orientationChanged)
ViewportListener[]
getListeners()
Gets all listeners added to this viewport.AffineTransform
getModelToViewTransform()
double
getOffsetX()
double
getOffsetY()
double
getOrientation()
Rectangle
getViewBounds()
AffineTransform
getViewToModelTransform()
double
getZoomFactor()
Gets the zoom factor.boolean
isModelYAxisDown()
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.String
toString()
void
zoom(Rectangle2D modelBounds)
Zooms to the given area given in model coordinates.
-
-
-
Method Detail
-
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
public Rectangle getViewBounds()
- Specified by:
getViewBounds
in interfaceViewport
- Returns:
- The bounds in view coordinates.
-
setViewBounds
public void setViewBounds(Rectangle viewBounds)
- Specified by:
setViewBounds
in interfaceViewport
- Parameters:
viewBounds
- The bounds in view coordinates.
-
getViewToModelTransform
public AffineTransform getViewToModelTransform()
- Specified by:
getViewToModelTransform
in interfaceViewport
- Returns:
- The affine transformation from view to model coordinates.
-
getModelToViewTransform
public AffineTransform 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:
Viewport.getZoomFactor()
-
zoom
public void zoom(Rectangle2D modelBounds)
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
public void addListener(ViewportListener listener)
Description copied from interface:Viewport
Adds a change listener to this viewport.- Specified by:
addListener
in interfaceViewport
- Parameters:
listener
- The listener.
-
removeListener
public void removeListener(ViewportListener listener)
Description copied from interface:Viewport
Removes a change listener from this viewport.- Specified by:
removeListener
in interfaceViewport
- Parameters:
listener
- The listener.
-
getListeners
public ViewportListener[] getListeners()
Description copied from interface:Viewport
Gets all listeners added to this viewport.- Specified by:
getListeners
in interfaceViewport
- Returns:
- The listeners.
-
setTransform
public void setTransform(Viewport other)
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)
-
-