|
|||||
SUMMARY: FIELD | CONSTR | METHOD| EVENT | DETAIL: FIELD | CONSTR | METHOD| EVENT |
A container that handles zoom and translation for displayed SVG
Field Summary | |
---|---|
HTMLDivElement |
svgContainer
Container for the SVG |
Element |
svgElement
The outer g node |
Element |
svgRoot
The outer svg node |
undefined |
templateString
|
Constructor Summary | |
---|---|
SVGViewPort(Object|null params, DOMNode|String srcNodeRef)
Create the widget. |
Method Summary | |
---|---|
|
applyTransform(SVGMatrix scaleTransform)
Applies the given transform to the svgRoot by multiplying the current transform with the provided matrix. |
DOMNode |
cloneSVG_DOM(Element sourceSVGElement)
Returns a cloned version of the provided svg element. |
|
copyAttribute(DOMNode original, Attribute originalAttribute, DOMNode targetNode)
copy a single attribute from the original node to the copied instance |
|
copyNodeAttributes(DOMNode original, DOMNode copy)
Copies all attributes from the original element to the copy. |
Number |
getCurrentZoom()
Returns the current zoom level. |
yfiles/client/tiles/GraphBounds |
getWorldBounds()
Returns the world bounds of the SVG document at zoom level 1. |
SVGPoint |
getWorldPoint(Number viewX, Number viewY)
Returns the world point for the given position. |
boolean |
hasValidSVGRoot()
Returns true if the svg root is set and has a CTM |
|
postCreate()
Invoked after an object of this type has been created |
|
setCanvas(GraphCanvas canvas)
Sets the canvas this viewport operates on. |
|
setCustomCopyAttribute(function customCopyAttribute)
set a custom copy attribute handler that will be invoked instead of the default implementation |
|
setScale(Number sx, Number sy)
Modifies the transform of the svg root to the specified scale. |
|
setTransform(SVGElement element, SVGMatrix matrix)
Sets the transform matrix on the element. |
|
setViewPoint(Number vpX, Number vpY)
Sets the view point |
|
showSVG(Element svg, Number zoom)
Replaces the currently displayed svg with the provided svg document. |
|
updateSVGContainerPosition()
Updates the position of the svgContainer. |
|
updateSVGElementSize()
Updates the size of the svgElement. |
|
zoom(Number newZoom)
Zooms to the specified amount |
|
zoomTo(Number zoomDelta, Number clientX, Number clientY)
Zooms by the specified amount in relation to the specified coordinates. |
Field Detail |
---|
HTMLDivElement svgContainer
Container for the SVG
Element svgElement
The outer g node
Element svgRoot
The outer svg node
undefined templateString
Constructor Detail |
---|
SVGViewPort(Object|null params, DOMNode|String srcNodeRef)
Create the widget.
params
- Hash of initialization parameters for widget, including scalar values (like title, duration etc.) and functions, typically callbacks like onClick. The hash can contain any of the widget's properties, excluding read-only properties.
srcNodeRef
- If a srcNodeRef (DOM node) is specified:
Method Detail |
---|
applyTransform(SVGMatrix scaleTransform)
Applies the given transform to the svgRoot by multiplying the current transform with the provided matrix.
scaleTransform
- The matrix the current transform should be multiplied with.
DOMNode cloneSVG_DOM(Element sourceSVGElement)
Returns a cloned version of the provided svg element.
sourceSVGElement
- The original svg element
copyAttribute(DOMNode original, Attribute originalAttribute, DOMNode targetNode)
copy a single attribute from the original node to the copied instance
original
- The original node
originalAttribute
- The original attribute instance
targetNode
- The target node
copyNodeAttributes(DOMNode original, DOMNode copy)
Copies all attributes from the original element to the copy.
original
- The node to be copied
copy
- The target node
Number getCurrentZoom()
Returns the current zoom level.
yfiles/client/tiles/GraphBounds getWorldBounds()
Returns the world bounds of the SVG document at zoom level 1.
SVGPoint getWorldPoint(Number viewX, Number viewY)
Returns the world point for the given position.
Transforms the given parameter with the svgRoot transform into a world point.
viewX
- The x coordinate of the view.
viewY
- The y coordinate of the view.
boolean hasValidSVGRoot()
Returns true if the svg root is set and has a CTM
postCreate()
Invoked after an object of this type has been created
setCanvas(GraphCanvas canvas)
Sets the canvas this viewport operates on.
canvas
- The canvas
setCustomCopyAttribute(function customCopyAttribute)
set a custom copy attribute handler that will be invoked instead of the default implementation
The callback has to implement the following signature:
myCustomCopyAttribute(originalNode,attribute,targetNode,originalCopyFunction)
customCopyAttribute
- A function that accepts the following parameters:
myCustomCopyAttribute(originalNode,attribute,targetNode,originalCopyFunction)
setScale(Number sx, Number sy)
Modifies the transform of the svg root to the specified scale.
Also invokes updateSVGElementSize and updateSVGContainerPosition.
sx
- The horizontal scaling factor
sy
- The vertical scaling factor
setTransform(SVGElement element, SVGMatrix matrix)
Sets the transform matrix on the element.
element
- The element
matrix
- The matrix
setViewPoint(Number vpX, Number vpY)
Sets the view point
vpX
- The new x coordinate of the view point
vpY
- The new y coordinate of the view point
showSVG(Element svg, Number zoom)
Replaces the currently displayed svg with the provided svg document.
svg
- The new svg.
zoom
- The zoom level that was used to create the SVG.
updateSVGContainerPosition()
Updates the position of the svgContainer.
updateSVGElementSize()
Updates the size of the svgElement.
zoom(Number newZoom)
Zooms to the specified amount
newZoom
- The new zoom level
zoomTo(Number zoomDelta, Number clientX, Number clientY)
Zooms by the specified amount in relation to the specified coordinates.
The coordinates are translated to a world point and then the zoom is multiplied with the current zoom.
zoomDelta
- The factor by which the zoom should be increased (if > 1) or decreased (if < 1).
clientX
- The x coordinate
clientY
- The y coordinate