IBM ILOG Dojo Diagrammer 1.1.1 API Documentation
Legend: Array Boolean Constructor Date DomNode Error Function Namespace Number Object RegExp Singleton String

ibm_ilog.diagram.widget.GfxViewport

Object » ibm_ilog.diagram.util.DeferredInitialization » ibm_ilog.diagram.widget.Viewport » ibm_ilog.diagram.widget.GfxViewport
dojo.require("ibm_ilog.diagram.widget.GfxViewport");

DivViewport depends on a div declared at Diagram.html with attachPoint=scrollbarsNode. This div encloses the diagram Surface.

The diagram Surface is extended to enclose the whole diagram tightly. The div is constrained to the desired client size using its width and height properties. The view rectangle is then associated with the div scroll positions, scrollTop and scrollLeft. Setting the view rectangle then updates scrollTop and scrollLeft.

The zoom level is derived from the view rectangle, but is mapped entirely different than its position. Instead, the zoom controls a scale transformation of the entire Diagram. If the view rectangle is small, the Diagram is zoomed in to fit the requested portion into the viewport window. With this also the Surface is scaled, as it is required that the entire Graph fits the surface exactly so that the scrollTop/scrollLeft properties work.

note: the zooming service required from the Diagram object should be at a UI level and should not affect, for example, the bouding box of the the Graph objects. One option is to define an intermediate node between the Surface root and the Graph node, which controls this transformation.

Method Summary

Event Summary

Methods

bringIntoView
translate the view just enough so that a given element is fully visible
ParameterTypeDescription
nodeibm_ilog.diagram.Node
marginNumber
Optional.
centerAt
Centers the viewport at the requested point, without changing the zoom.
ParameterTypeDescription
pPoint
options
clientToContent
returns a matrix that transforms a client coordinate into a content coordinate
constructor
contentToClient
returns a matrix that transforms a content coordinate into a client coordinate
destroy
Gracefully destroys the receiver
eventClientLocation
ParameterTypeDescription
e
eventContentLocation
ParameterTypeDescription
e
getAirFactor
Returns the content air percentage with respect to the client size
getClientSize
Returns the current viewport client size
getContentRect

This value is updated by content BB change notifications (see _onContentBoundingBoxChanged)

getMaxZoom
Returns the current maximum zoom constraint.
getMinZoom
Returns the current minimum zoom constraint.
getViewRect
The currently displayed area in diagram coordinates.
getZoom
Returns the current zoom level based on the current view rectangle and content size.
gfxConnector
ParameterTypeDescription
src
evt
object
handler
gfxDisconnector
ParameterTypeDescription
handle
src
initialize
Initializes a Viewport for collaborating with the diagram.
ParameterTypeDescription
diagramibm_ilog.diagram.widget.DiagramThe diagram this._scrollbars = diagram.scrollbarsNode; this._scrollbarsContent = diagram.scrollbarsContentNode;
pointClientToContent
transforms a client coordinate into a content coordinate
ParameterTypeDescription
pPoint
pointContentToClient
transforms a content coordinate into a client coordinate
ParameterTypeDescription
pPoint
prepareViewRect

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

ParameterTypeDescription
rdojox.gfx.Rectangle
viewRectdojox.gfx.Rectangle
refresh
Forces a refresh contents procedure, where the content rect is updated and consequently associated scrollbars and other features.
registerHudComponent
ParameterTypeDescription
component
setAirFactor
Sets the content air percentage with respect to the client size
ParameterTypeDescription
factorNumber
setAnimLength
ParameterTypeDescription
millisecondsNumber
setAnimSteps
ParameterTypeDescription
stepsNumber
setAnimated
ParameterTypeDescription
animatedBoolean
setClientSize
Sets the client Size
ParameterTypeDescription
szSize
setHudEnabled
ParameterTypeDescription
bBoolean
setHudZoomFeedbackEnabled
ParameterTypeDescription
bBoolean
setMaxZoom
Sets a maximum zoom and updates the view rectangle based on new constraints.
ParameterTypeDescription
zNumber
setMinZoom
Sets a minimum zoom and updates the view rectangle based on new constraints.
ParameterTypeDescription
zNumber
setRefreshContentsInverval
ParameterTypeDescription
msIntervalNumber
setRefreshContentsSuspended
ParameterTypeDescription
suspendedBoolean
setResizeMode
ParameterTypeDescription
mNumber
setSize
Sets the Viewport Size
ParameterTypeDescription
szSize
setViewRect

Some corrections are applied to r. See prepareViewRect.

ParameterTypeDescription
rdojox.gfx.Rectangle
optionsObj
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
setZoom
This method is a helper that actually controls setSourceRect expanding or shrinking the view rectangle size to achieve the zoom effect.
ParameterTypeDescription
zoomNumber
options.animateanimation of the viewport .instant cancel animated viewport .forceApply causes the view rect to be applied even if it has not changed
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
updateScrollbarVisibilityFlags
visualizeArea
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.
ParameterTypeDescription
rdojox.gfx.RectangleThe 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}
zoomAt
Scales the current zooms by a given factor z, using point p as pivot.
ParameterTypeDescription
pPoint
zNumber
options

Events

onClientSizeChanged
The viewport has been resized (implies the related onSourceChanged event)
onContentRectChanged
Event triggered when the content rect has changed.
onViewRectChanged
The view rectangle has been updated. scrollbars may have reappeared/disappeared