Class: webCGMPicture

webCGMPicture


new webCGMPicture()

webCGMAppPicture constructor

Methods


applyCompanionFile(file) → {boolean}

Reads an XML Companion File (XCF) into the user agent's object model. If application-specific metadata is found in the companion file (in the form of namespace attributes and namespace children elements), the user agent will create new namespace application structures as children of existing webCGM Application Structures within it's object model. This information will then be accessible using methods found on this webCGMPicture interface, on webCGMAppStructure and on webCGMNode. If the fileIRI parameter of this method is a relative IRI, then that relative IRI is resolved similarly to resolving relative IRIs for XCF resources referenced in the webCGM IRI fragment syntax, i.e., the IRI is resolved relative to location of the CGM resource to which the XCF resource is a companion.
Please refer to the Relationship with XML companion filesection for more discussion.
Parameters:
Name Type Description
file string The file name and location of the XML companion file to load and apply into the object model.
Returns:
true if the implementation was able to load and parse the XML companion file into memory as requested; false otherwise.

Type: boolean


applyLocalCompanionFile(file) → {boolean}

Reads an XML Companion File (XCF) into the user agent's object model. If application-specific metadata is found in the companion file (in the form of namespace attributes and namespace children elements), the user agent will create new namespace application structures as children of existing webCGM Application Structures within it's object model. This information will then be accessible using methods found on this webCGMPicture interface, on webCGMAppStructure and on webCGMNode. If the fileIRI parameter of this method is a relative IRI, then that relative IRI is resolved similarly to resolving relative IRIs for XCF resources referenced in the webCGM IRI fragment syntax, i.e., the IRI is resolved relative to location of the CGM resource to which the XCF resource is a companion.
Please refer to the Relationship with XML companion filesection for more discussion.
Parameters:
Name Type Description
file string The file name and location of the XML companion file to load and apply into the object model.
Returns:
true if the implementation was able to load and parse the XML companion file into memory as requested; false otherwise.

Type: boolean


clearHighlight()

Clears highlighting for all currently highlighted APSs in the picture. The behavior is identical to the special-form object behavior fragment, id(*,clearHighlight), that is defined in the enumeration of behaviors of the fragment syntax.

createWebCGMRect() → {webCGMRect}

Creates a webCGMRect object outside of the document.
Returns:
A webCGMRect object, initialized such that all values are set to 0 NVDC units.

Type: webCGMRect


downLoadCanvas2PNG()

Captures the image of the Web Canvas object then writes to the downloads directory as a PNG file.

getAppStructureById(apsId) → {webCGMNodeList}

Returns the Application Structure whose ID is given by apsId. If no such Application Structure exists, returns null. Returns null if apsId corresponds to an APS of type 'grnode'. Behavior is not defined if more than one element has this ID. Only WebCGM Application Structures may be retrieved using getAppStructureById, it does not retrieve foreign namespace elements (application-specific metadata elements).
Parameters:
Name Type Description
apsId string A unique id value for an Application Structure.
Returns:
A webCGMNodeList object containing all the matching Application Structure webCGMNodes.

Type: webCGMNodeList


getAppStructuresByName(name) → {webCGMNodeList}

Returns the list of Application Structures whose names are given by apsName in the order in which they are encountered in a depth-first-order traversal of the webCGMPicture tree. If no such Application Structures exists, returns null. Only webCGM Application Structures may be retrieved using getAppStructuresByName, it does not retrieve foreign namespace elements (application-specific metadata elements).
Parameters:
Name Type Description
name string A non-unique name value for an Application Structure.
Returns:
A webCGMNodeList object containing all the matching Application Structure webCGMNodes.

Type: webCGMNodeList


getAttributeNS(namespaceIRI, localName) → {string}

Returns the node attribute value by local name and namespace IRI.
Parameters:
Name Type Description
namespaceIRI string The namespace IRI of the attribute to retrieve.
localName string The local name of the attribute to retrieve.
Returns:
The webCGMAttr value as a string, or the empty string if that attribute does not have a specified value.

Type: string


getAttributes() → {webCGMNodeList}

Returns a webCGMNodeList that contains all attributes of this picture node. If there are no attributes, this returns null.
Returns:
attributes

Type: webCGMNodeList


getChildNodes() → {string}

Returns a webCGMNodeList that contains all children of this node. If there are no children, this returns null.
Returns:
childNodes

Type: string


getFirstChild() → {webCGMNode}

Returns The first child of this node. If there is no such node, this returns null.
Returns:
lastChild

Type: webCGMNode


getHeight() → {float}

Retrieves the webCGMPicture height in millimeters. Please refer to Coordinate Values section for more information.
Returns:
height

Type: float


getLastChild() → {webCGMNode}

Returns The last child of this node. If there is no such node, this returns null.
Returns:
lastChild

Type: webCGMNode


getLocalName() → {string}

Returns the local part of the qualified name of this node (e.g., foo:elementName, returns "elementName"). This returns empty string if the webCGMNode is not of type XML_METADATA_NODE or ATTR_NODE.
Returns:
localName

Type: string


getMapping() → {int}

Get current mapping
Returns:
mapping

Type: int


getNamespaceIRI() → {string}

Returns The namespace IRI of this node. For example, on the element foo:someElement, returns the IRI of the (xmlns) namespace declaration that associates the prefix foo with the namespace. This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is the namespace IRI given at creation time. This returns empty string if the webCGMNode is not of type XML_METADATA_NODE or ATTR_NODE.
Returns:
namespaceIRI

Type: string


getNextSibling() → {webCGMNode}

Returns the node immediately following this node. If there is no such node, this returns null.
Returns:
nextSibling

Type: webCGMNode


getNodeName() → {string}

Returns the name of this node, depending on its type; see table
Returns:
nodeName

Type: string


getNodeType() → {int}

Returns a code representing the type of the underlying object.
Returns:
types {string}

Type: int


getNodeValue() → {string}

Returns the value of this node, depending on its type; see table
Returns:
nodeValue

Type: string


getOrientation() → {int}

Gets a value denoting orientation of the picture:
  0- no rotation
  1- 90 degree counter-clockwise rotation
  2- 180 degree rotation
  3- 90 degree clockwise rotation.
Returns:
orientation

Type: int


getOwnerPicture() → {webCGMNode}

Returns the webCGMPicture object associated with this node. When the node is a webCGMPicture node, this returns null
Returns:
ownerPicture

Type: webCGMNode


getParentNode() → {webCGMNode}

Returns The parent (immediate ancestor node of a node) of this node. All nodes, except webCGMPicture and webCGMAttr, may have a parent.
Returns:
parentNode

Type: webCGMNode


getPictid() → {string}

Retrieves the webCGMPicture id, which is the id parameter in the BEGIN PICTURE element in the CGM document.
Returns:
pictid

Type: string


getPrefix() → {string}

Returns the namespace prefix of this node (e.g., foo:elementName, returns "foo"). This returns empty string if the webCGMNode is not of type XML_METADATA_NODE or ATTR_NODE.
Returns:
prefix

Type: string


getPreviousSibling() → {webCGMNode}

Returns the node immediately preceding this node. If there is no such node, this returns null.
Returns:
previousSibling

Type: webCGMNode


getStyleProperty(style) → {string}

Retrieves a style property by name on the given Picture. Please refer to the Style Properties Table for more detailed information on retrievable and modifiable Style Properties.
Parameters:
Name Type Description
style string The name of the style property to retrieve.
Returns:
the Style Property value as a string, or the empty string if that Style Property has not been explicitly set on the picture by a setStyleProperty call (or equivalent XCF). For Style Properties that may be set in different modes e.g. NVDC or percentage, the return value shall be in the mode in which it was set. For example, if stroke-weight were most recently set to a percentage value by a setStyleProperty call, then getStyleProperty shall return a percentage value. (See the inheritance model for further related discussion). The value may be a Delimited String.

Type: string


getView() → {webCGMRect}

Gets a view to the specified rectangle expressed in NVDC units.
Returns:
viewRect The view rectangle in NVDC.

Type: webCGMRect


getWidth() → {float}

Retrieves the webCGMPicture width in millimeters. Please refer to Coordinate Values section for more information.
Returns:
width

Type: float


getZoomFactor() → {float}

Get zoom scale factor
Returns:
zoomFactor

Type: float


getZoomPanMode() → {int}

Get zoom pan mode mode
Returns:
mode

Type: int


hasAttributes() → {boolean}

Returns whether this picture node has any attributes. (For more information, see the attributes attribute.)
Returns:
true if this node has any attributes, false otherwise.

Type: boolean


hasChildNodes() → {boolean}

Returns whether this node has any children.
Returns:
true if this node has any children, false otherwise.

Type: boolean


highlight(nodelist, type)

Highlights a collection of Application Structures (APSs). webCGM also allows for highlighting of APSs using the IRI fragment syntax. The exact method of highlighting is viewer dependent. The highlight method provides a way for webCGM script writers to highlight APSs in the same way a IRI fragment would. It also allows for highlighting of entire layers. Highlighting is not defined for webCGMPicture nodes or XML Metadata nodes. APS of type 'grnode' are not valid in the node list, and shall cause no change to the viewed image or theDOM tree. See the 'visibility' APS Attribute for discussion of its effect on execution of the highlight method.
Parameters:
Name Type Description
nodelist webCGMNodeList A webCGMNodeList of APP_STRUCTURE_NODEs to highlight.
type string Denotes a behavior identical to the corresponding highlighting object behavior keywordsof the fragment syntax. Values: { add | new }.

printCanvas()

Does an image capture of the canvas object assocated with this webCGMPicture and then calls the window.print() method to print it.
This method can be overidden with Module['printCanvas'] = myPrintCanvas; where myPrintCanvas is your cusomt print function which can decorate the image with a watermark or footer for example before calling the print method. See the "Basic File Viewer" sample app for actual sample code.

reloadPicture()

Notifies the user agent to immediately redraw the entire webCGMPicture. The user agent will reload the webCGMPicture while preserving the current user agent's zoom and pan level. The reloading of the webCGMPicture also discards any existing companion information that may have been loaded into memory via the applyCompanionFile method.

setFindText(substring)

Sets the findText string. An empty string resets the findText.
Parameters:
Name Type Description
substring string to match against

setHighlightStyle()

Sets the highlighting style for future highlighted APSs in the picture.

setMapping(mapping)

Set mapping of picture extent to canvas window, this centers the picture in the window and initializes zoom factor scaleToFit = 0, scaleToWidth = 1, scaleToHeight =2 , scaleTo100 = 3
Parameters:
Name Type Description
mapping int

setOrientation(orientation)

Sets the orientation of the picture:
  0- no rotation
  1- 90 degree counter-clockwise rotation
  2- 180 degree rotation
  3- 90 degree clockwise rotation.
Orientation can also be defined in the HTML5 canvas object via the attribute "orient", for example
<canvas class="WebCGMDocument" ... orient="1">
Parameters:
Name Type Description
orientation int

setPictureVisibility(visiblity)

Sets the visibility on or off for the whole picture. Note that for the purposes of the inheritance model, the Picture node behaves like an Application Structure, and the visibility as set by this method behaves like the 'visibility' APS Attribute.
Parameters:
Name Type Description
visiblity string Value for the visibility of the picture, {on | off}.

setStyleProperty(style, property)

Set a style property at the picture level by name. Refer to WebCGM 2.1 specication for details on Picture Style Property Names
Parameters:
Name Type Description
style string The name of the style property to modify.
property string The new value for the given style. Note that "inherit" is a valid value for every Style Property, and per the inheritance model, it has the effect of restoring the style property to its initial (load time) value (as determined by the inheritance model).

setView(viewRect) → {boolean}

Sets a view to the specified rectangle expressed in NVDC units. The webCGM viewer shall fit the NVDC rectanglespecified by the 'viewRect' parameter into the viewer�s display rectangle and center it, while maintaining theaspect ratio of the 'viewRect' rectangle.
Parameters:
Name Type Description
viewRect webCGMRect The view rectangle in NVDC.
Returns:
true if new view was set; false if rectangle was invalid and the view could not be set.

Type: boolean


setZoomPanMode(mode)

Set mouse to interactive zoom or pan mode, zoom mode = 1, pan mode = 2
Parameters:
Name Type Description
mode int

toDataURL() → {dataURI}

Returns a data URI of this node/WebCGMPicture (without markups). This is 'data:image/png,base64' encoding.
Returns:
Data:image encoded as png in base64.

Type: dataURI


zoom(zoomFactor)

Set zoom scale factor. the view will remain centered.
Parameters:
Name Type Description
zoomFactor float