Package com.bc.ceres.grender
Interface Viewport
-
- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
DefaultViewport
public interface Viewport extends Cloneable
AViewport
allows to view a certain part of graphical data representations given in coordinates defined in some model coordinate system. TheViewport
assumes that there is an affine similiarity transformation (translation, rotation, scaling) from the view to the model coordiate system. Shearing transformations are not supported, but the coordinate system's Y-axes may point in different directions.The view coordinate system is a cartesian coordinate system with the X-axis pointing to the right and the Y-axis pointing downwards.
The model coordinate system is assumed to be cartesian coordinate system with the X-axis pointing to the right and the Y-axis pointing either upwards or downwards. See method
isModelYAxisDown()
.
-
-
Method Summary
All Methods Instance Methods Abstract 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.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 viewDeltaX, double viewDeltaY)
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 otherViewport)
Modifies this viewport so that it matches the given one.void
setViewBounds(Rectangle bounds)
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.void
zoom(Rectangle2D modelArea)
Zooms to the given area given in model coordinates.
-
-
-
Method Detail
-
isModelYAxisDown
boolean isModelYAxisDown()
- Returns:
- If
true
, the model coordinate's Y-axis points downwards. Returnsfalse
by default.
-
setModelYAxisDown
void setModelYAxisDown(boolean modelYAxisDown)
- Parameters:
modelYAxisDown
- Iftrue
, the model coordinate's Y-axis points downwards.
-
getViewBounds
Rectangle getViewBounds()
- Returns:
- The bounds in view coordinates.
-
setViewBounds
void setViewBounds(Rectangle bounds)
- Parameters:
bounds
- The bounds in view coordinates.
-
getViewToModelTransform
AffineTransform getViewToModelTransform()
- Returns:
- The affine transformation from view to model coordinates.
-
getModelToViewTransform
AffineTransform getModelToViewTransform()
- Returns:
- The affine transformation from model to view coordinates.
-
getOffsetX
double getOffsetX()
- Returns:
- The viewport's absolute X-offset in model coordinates.
-
getOffsetY
double getOffsetY()
- Returns:
- The viewport's absolute Y-offset in model coordinates.
-
setOffset
void setOffset(double offsetX, double offsetY)
Sets the viewport's absolute offset in model coordinates.- Parameters:
offsetX
- The X-offset in model coordinates.offsetY
- The Y-offset in model coordinates.
-
moveViewDelta
void moveViewDelta(double viewDeltaX, double viewDeltaY)
Moves the model CS by translating it into the opposite direction of the given vector in view coordinates.- Parameters:
viewDeltaX
- the X delta in view coordinatesviewDeltaY
- the Y delta in view coordinates
-
getZoomFactor
double getZoomFactor()
Gets the zoom factor. The zoom factor is equal to the number of model units per view unit.- Returns:
- The zoom factor.
-
setZoomFactor
void setZoomFactor(double zoomFactor)
Sets the zoom factor relative to the viewport bound's center point.- Parameters:
zoomFactor
- The new zoom factor, must be greater than zero.- Throws:
IllegalArgumentException
- if zoomFactor is less than or equal to zero- See Also:
getZoomFactor()
-
setZoomFactor
void setZoomFactor(double zoomFactor, double modelCenterX, double modelCenterY)
Zooms to the given point given in model coordinates.- 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.- Throws:
IllegalArgumentException
- if zoomFactor is less than or equal to zero
-
zoom
void zoom(Rectangle2D modelArea)
Zooms to the given area given in model coordinates.- Parameters:
modelArea
- the area in model coordinates
-
getOrientation
double getOrientation()
- Returns:
- The rotation angle in radians.
-
setOrientation
void setOrientation(double orientation)
Sets the orientation angle relative to the viewport bound's center point.- Parameters:
orientation
- the new orientation angle in radians
-
setTransform
void setTransform(Viewport otherViewport)
Modifies this viewport so that it matches the given one.- Parameters:
otherViewport
- The view port to synchronize with.
-
addListener
void addListener(ViewportListener listener)
Adds a change listener to this viewport.- Parameters:
listener
- The listener.
-
removeListener
void removeListener(ViewportListener listener)
Removes a change listener from this viewport.- Parameters:
listener
- The listener.
-
getListeners
ViewportListener[] getListeners()
Gets all listeners added to this viewport.- Returns:
- The listeners.
-
clone
Viewport clone()
Creates a clone of this viewport. The clone is a deep copy of this viewport but doesn't copy its listeners.- Returns:
- The clone.
-
-