public class ViewportModel extends java.lang.Object implements IPropertyChangeNotifier
ViewportModel
stores viewport width and height, horizontal and
vertical translation, and a general contents transformation.Modifier and Type | Class and Description |
---|---|
static class |
ViewportModel.ViewportState
Representation of a viewport's state, which manifests itself in x and y
translation, width and height, as well as a contents transform.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
VIEWPORT_CONTENTS_TRANSFORM_PROPERTY
When the contents transform changes, this is the property name reported
by a corresponding property change event.
|
static java.lang.String |
VIEWPORT_HEIGHT_PROPERTY
When the viewport height changes, this is the property name reported by a
corresponding property change event.
|
static java.lang.String |
VIEWPORT_TRANSLATE_X_PROPERTY
When the viewport translateX-position changes, this is the property name
reported by a corresponding property change event.
|
static java.lang.String |
VIEWPORT_TRANSLATE_Y_PROPERTY
When the viewport translateY-position changes, this is the property name
reported by a corresponding property change event.
|
static java.lang.String |
VIEWPORT_WIDTH_PROPERTY
When the viewport width changes, this is the property name reported by a
corresponding property change event.
|
Constructor and Description |
---|
ViewportModel() |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
applyState(ViewportModel.ViewportState state,
boolean ignoreTranslateX,
boolean ignoreTranslateY,
boolean ignoreWidth,
boolean ignoreHeight,
boolean ignoreContentsTransform)
Applies the given
ViewportModel.ViewportState to this ViewportModel . |
AffineTransform |
getContentsTransform()
Returns the contents transformation.
|
double |
getHeight()
Returns the height of the current viewport, i.e. rectangular area in
which the viewer/editor is rendered.
|
double |
getTranslateX()
Returns the horizontal translation of the contents in this model.
|
double |
getTranslateY()
Returns the vertical translation of the contents in this model.
|
double |
getWidth()
Returns the width of the current viewport, i.e. rectangular area in which
the viewer/editor is rendered.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
ViewportModel.ViewportState |
retrieveState(boolean ignoreTranslateX,
boolean ignoreTranslateY,
boolean ignoreWidth,
boolean ignoreHeight,
boolean ignoreContentsTransform)
Creates a new
ViewportModel.ViewportState representing the current state of
this ViewportModel . |
void |
setContentsTransform(AffineTransform contentsTransform)
Sets the contents transformation to the given value.
|
void |
setHeight(double height)
Sets the height of the viewport in this model.
|
void |
setTranslateX(double translateX)
Sets the horizontal translation of the contents in this model.
|
void |
setTranslateY(double translateY)
Sets the vertical translation of the contents in this model.
|
void |
setWidth(double width)
Sets the width of the viewport in this model.
|
public static final java.lang.String VIEWPORT_TRANSLATE_X_PROPERTY
public static final java.lang.String VIEWPORT_TRANSLATE_Y_PROPERTY
public static final java.lang.String VIEWPORT_WIDTH_PROPERTY
public static final java.lang.String VIEWPORT_HEIGHT_PROPERTY
public static final java.lang.String VIEWPORT_CONTENTS_TRANSFORM_PROPERTY
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface IPropertyChangeNotifier
public void applyState(ViewportModel.ViewportState state, boolean ignoreTranslateX, boolean ignoreTranslateY, boolean ignoreWidth, boolean ignoreHeight, boolean ignoreContentsTransform)
ViewportModel.ViewportState
to this ViewportModel
.
Only the specified properties are transferred.state
- The ViewportModel.ViewportState
to apply.ignoreTranslateX
- true
if the horizontal translation should not be
transferred, otherwise false
.ignoreTranslateY
- true
if the vertical translation should not be
transferred, otherwise false
.ignoreWidth
- true
if the viewport width should not be
transferred, otherwise false
.ignoreHeight
- true
if the viewport height should not be
transferred, otherwise false
.ignoreContentsTransform
- true
if the contents transform should not be
transferred, otherwise false
.public AffineTransform getContentsTransform()
public double getHeight()
public double getTranslateX()
public double getTranslateY()
public double getWidth()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface IPropertyChangeNotifier
public ViewportModel.ViewportState retrieveState(boolean ignoreTranslateX, boolean ignoreTranslateY, boolean ignoreWidth, boolean ignoreHeight, boolean ignoreContentsTransform)
ViewportModel.ViewportState
representing the current state of
this ViewportModel
. Only the specified properties are saved in
the ViewportModel.ViewportState
.ignoreTranslateX
- true
if the horizontal translation should not be
retrieved, otherwise false
.ignoreTranslateY
- true
if the vertical translation should not be
retrieved, otherwise false
.ignoreWidth
- true
if the viewport width should not be
retrieved, otherwise false
.ignoreHeight
- true
if the viewport height should not be
retrieved, otherwise false
.ignoreContentsTransform
- true
if the contents transform should not be
retrieved, otherwise false
.ViewportModel.ViewportState
representing the current state of
this ViewportModel
.public void setContentsTransform(AffineTransform contentsTransform)
contentsTransform
- The new contents transformation.public void setHeight(double height)
Sets the height of the viewport in this model. This should be called when the size of the rectangular area in which the viewer/editor is rendered changes.
Fires a property change event for the VIEWPORT_HEIGHT_PROPERTY
.
height
- new viewport heightpublic void setTranslateX(double translateX)
translateX
- The new horizontal translation.public void setTranslateY(double translateY)
translateY
- The new vertical translation.public void setWidth(double width)
Sets the width of the viewport in this model. This should be called when the size of the rectangular area in which the viewer/editor is rendered changes.
Fires a property change event for the VIEWPORT_WIDTH_PROPERTY
.
width
- new viewport widthCopyright (c) 2014 itemis AG and others. All rights reserved.