ibm_ilog.diagram.widget.Viewport
The Viewport class is an abstract class that provides basic infrastructure over which to construct concrete Diagram viewports.
A Viewport object is a collaborator of the Diagram widget that abstracts this notion of viewport. The Diagram widget can then deal with the the viewport independently of how it is actually implemented.
The main responsibility of the viewport object is to control the current viewable rectangle of the Diagram and report updates to it.
The following concept definitions help understand the Viewport API:
Content Rectangle The area inside which the viewport can move, mostly based on the content bounding box.
View Rectangle The rectangular portion of the content that is currently visible in the viewport.
Client Size The size of the UI space that allows the contents to be viewed.
authors: AV
Method Summary
- bringIntoView(node, margin) translate the view just enough so that a given element is fully visible
- centerAt(p, options) Centers the viewport at the requested point, without changing the zoom.
- clientToContent() returns a matrix that transforms a client coordinate into a content coordinate
- contentToClient() returns a matrix that transforms a content coordinate into a client coordinate
- destroy() Gracefully destroys the receiver
- eventClientLocation(e)
- eventContentLocation(e)
- getAirFactor() Returns the content air percentage with respect to the client size
- getAnimLength()
- getAnimSteps()
- getAnimated()
- getBackgroundShape()
- getClientSize() Returns the current viewport client size
- getContent()
- getContentRect() The current content size in pixels, which defines the available navigation area.
- getDiagram()
- getEventSource()
- getEventSourceBackground()
- getHudLayer()
- getHudSize()
- getMaxZoom() Returns the current maximum zoom constraint.
- getMinZoom() Returns the current minimum zoom constraint.
- getOverlayLayer()
- getRefreshContentsInterval()
- getRefreshContentsSuspended()
- getResizeMode()
- getSurface()
- getUnderlayLayer()
- getViewRect() The currently displayed area in diagram coordinates.
- getViewportInverseTransform()
- getViewportTransform()
- getZoom() Returns the current zoom level based on the current view rectangle and content size.
- initialize(diagram) Constructs a Viewport for collaborating with the diagram.
- isHudEnabled()
- isHudZoomFeedbackEnabled()
- isInitialized() Returns whether the initialization process is done.
- pointClientToContent(p) transforms a client coordinate into a content coordinate
- pointContentToClient(p) transforms a content coordinate into a client coordinate
- prepareViewRect(r, viewRect) Pre-apply corrections to r that would otherwise be applied at the moment r is set as the View Rectangle
- refresh() Forces a refresh contents procedure, where the content rect is updated and consequently associated scrollbars and other features.
- registerHudComponent(component)
- reset()
- setAirFactor(factor) Sets the content air percentage with respect to the client size
- setAnimLength(milliseconds)
- setAnimSteps(steps)
- setAnimated(animated)
- setClientSize(sz) Sets the Client Size
- setHudEnabled(b)
- setHudZoomFeedbackEnabled(b)
- setMaxZoom(z) Sets a maximum zoom and updates the view rectangle based on new constraints.
- setMinZoom(z) Sets a minimum zoom and updates the view rectangle based on new constraints.
- setRefreshContentsInverval(msInterval)
- setRefreshContentsSuspended(suspended)
- setResizeMode(m)
- setSize(sz) Sets the Viewport Size
- setViewRect(r, options) Sets the currently displayed area.
- setZoom(zoom, options) This method is a helper that actually controls setSourceRect expanding or shrinking the view rectangle size to achieve the zoom effect.
- stopAnimation()
- templateString() This method is must return the template that the Diagram widget must use in order to use the receiver as viewport. diagram: ibm_ilog.diagram.widget.Diagram The diagram
- toString()
- visualizeArea(r, options) Makes the r rectangle visible, givin it an extra air between the area and the borders of the viewport if possible. The view may be zoomed out if required, but it is never zoomed in.
- whenLoaded(cb, eb) Registers a callback to be executed after the instance has been initialized, or executes immediately if already initialized.
- zoomAt(p, z, options) Scales the current zooms by a given factor z, using point p as pivot.
Event Summary
- onClientSizeChanged() The viewport has been resized (implies the related onSourceChanged event)
- onContentRectChanged() Event triggered when the content rect has changed.
- onLayoutHud()
- onViewRectChanged() The view rectangle has been updated. scrollbars may have reappeared/disappeared
Attached Objects
Methods
Parameter | Type | Description |
---|---|---|
node | ibm_ilog.diagram.Node | |
margin | Number | Optional. |
Parameter | Type | Description |
---|---|---|
p | Point | |
options |
This value is updated by content BB change notifications (see _onContentBoundingBoxChanged)
Parameter | Type | Description |
---|---|---|
diagram | ibm_ilog.diagram.widget.Diagram | The diagram |
Parameter | Type | Description |
---|---|---|
p | Point |
Parameter | Type | Description |
---|---|---|
p | Point |
Some corrections may be applied to r before assigning it as the current View Rectangle:
if width xor height are set, set the other based on current viewport aspect ratio
for each axis:
- if origin is not defined and length is, make origin so that center is preserved
if origin is defined but width is not, keep current length
if both width and height are set but the aspect ratio is not correct, correct short side to match correct aspect ratio and maintain visibility of desired area.
if r goes beyond height or width, constrain location to make r within
if r lies before the origin, set location to origin
apply zoom constraints
Parameter | Type | Description |
---|---|---|
r | dojox.gfx.Rectangle | |
viewRect | dojox.gfx.Rectangle |
Parameter | Type | Description |
---|---|---|
factor | Number |
Parameter | Type | Description |
---|---|---|
z | Number |
Parameter | Type | Description |
---|---|---|
z | Number |
Some corrections are applied to r. See prepareViewRect.
Parameter | Type | Description |
---|---|---|
r | dojox.gfx.Rectangle | |
options | Obj | Optional. .animate animation of the viewport
.instant
cancel animated viewport
.forceApply
causes the view rect to be applied even if it has not changed
.center
causes the view rect to be centered |
Parameter | Type | Description |
---|---|---|
zoom | Number | |
options | .animate | animation of the viewport .instant cancel animated viewport .forceApply causes the view rect to be applied even if it has not changed |
Parameter | Type | Description |
---|---|---|
r | dojox.gfx.Rectangle | The area to make visible. airFactor: Percent of the area that is reserved as air. Overrides the default air factor defined bu the member _focusAirFactor. |
options | {expandCurrent,airFactor} |
Parameter | Type | Description |
---|---|---|
cb | ||
eb |
Parameter | Type | Description |
---|---|---|
p | Point | |
z | Number | |
options |