yfiles/client/svg/widget/SVGViewPort
Class SVGViewPort

A container that handles zoom and translation for displayed SVG

 
All Parent Classes:
dijit/_WidgetBase
dijit/_TemplatedMixin
 
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

svgContainer

HTMLDivElement svgContainer

Container for the SVG


svgElement

Element svgElement

The outer g node


svgRoot

Element svgRoot

The outer svg node


templateString

undefined templateString
 
Constructor Detail

SVGViewPort

SVGViewPort(Object|null params, DOMNode|String srcNodeRef)

Create the widget.

Parameters:
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:

  • use srcNodeRef.innerHTML as my contents
  • if this is a behavioral widget then apply behavior to that srcNodeRef
  • otherwise, replace srcNodeRef with my generated DOM tree
Method Detail

applyTransform

 applyTransform(SVGMatrix scaleTransform)

Applies the given transform to the svgRoot by multiplying the current transform with the provided matrix.

Parameters:
scaleTransform -

The matrix the current transform should be multiplied with.


cloneSVG_DOM

DOMNode cloneSVG_DOM(Element sourceSVGElement)

Returns a cloned version of the provided svg element.

Parameters:
sourceSVGElement -

The original svg element


copyAttribute

 copyAttribute(DOMNode original, Attribute originalAttribute, DOMNode targetNode)

copy a single attribute from the original node to the copied instance

Parameters:
original -

The original node

originalAttribute -

The original attribute instance

targetNode -

The target node


copyNodeAttributes

 copyNodeAttributes(DOMNode original, DOMNode copy)

Copies all attributes from the original element to the copy.

Parameters:
original -

The node to be copied

copy -

The target node


getCurrentZoom

Number getCurrentZoom()

Returns the current zoom level.


getWorldBounds

yfiles/client/tiles/GraphBounds getWorldBounds()

Returns the world bounds of the SVG document at zoom level 1.


getWorldPoint

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.

Parameters:
viewX -

The x coordinate of the view.

viewY -

The y coordinate of the view.


hasValidSVGRoot

boolean hasValidSVGRoot()

Returns true if the svg root is set and has a CTM


postCreate

 postCreate()

Invoked after an object of this type has been created


setCanvas

 setCanvas(GraphCanvas canvas)

Sets the canvas this viewport operates on.

Parameters:
canvas -

The canvas


setCustomCopyAttribute

 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)

Parameters:
customCopyAttribute -

A function that accepts the following parameters: myCustomCopyAttribute(originalNode,attribute,targetNode,originalCopyFunction)


setScale

 setScale(Number sx, Number sy)

Modifies the transform of the svg root to the specified scale.

Also invokes updateSVGElementSize and updateSVGContainerPosition.

Parameters:
sx -

The horizontal scaling factor

sy -

The vertical scaling factor


setTransform

 setTransform(SVGElement element, SVGMatrix matrix)

Sets the transform matrix on the element.

Parameters:
element -

The element

matrix -

The matrix


setViewPoint

 setViewPoint(Number vpX, Number vpY)

Sets the view point

Parameters:
vpX -

The new x coordinate of the view point

vpY -

The new y coordinate of the view point


showSVG

 showSVG(Element svg, Number zoom)

Replaces the currently displayed svg with the provided svg document.

Parameters:
svg -

The new svg.

zoom -

The zoom level that was used to create the SVG.


updateSVGContainerPosition

 updateSVGContainerPosition()

Updates the position of the svgContainer.


updateSVGElementSize

 updateSVGElementSize()

Updates the size of the svgElement.


zoom

 zoom(Number newZoom)

Zooms to the specified amount

Parameters:
newZoom -

The new zoom level


zoomTo

 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.

Parameters:
zoomDelta -

The factor by which the zoom should be increased (if > 1) or decreased (if < 1).

clientX -

The x coordinate

clientY -

The y coordinate


Copyright © 2006-2013 yWorks GmbH. All rights reserved.