new webCGMDocument()
webCGMDocument constructor
Methods
addEventListener(type, func)
This method allows the registration of event listeners on the webCGMMetafile. If a webCGMEventListener is added to the webCGMMetafile while it is processing an event, it will not be triggered by the current actions. If multiple identical webCGMEventListeners are registeredon the webCGMMetafile with the same parameters the duplicate instances are discarded. They do not cause the webCGMEventListener to be called twice.Note: Although all webCGMEventListeners on the webCGMMetafile are guaranteed to be triggered by any event which is received, no specification is made as to the order in which the webCGMMetafile will receive the event with regards to the other webCGMEventListeners on the webCGMMetafile.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
string | The event type for which the user is registering, (for example: "click", "mouseover"). |
func |
webCGMEventListener | The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs. |
getAppName() → {string}
Returns the name of the viewer application.
Returns:
The name of the viewer application.
Type: string
getAppVersion() → {string}
Returns the version of the viewer application.
Returns:
The version of the viewer application.
Type: string
getFirstPicture() → {webCGMPicture}
Returns the first webCGMPicture element of the webCGM document. Subsequent webCGMPictures can be accessed using the webCGMPicture interface. A webCGM document (version 2.0 and later) contains exactly one webCGMPicture. If no webCGM document is open in the viewer, null is returned.
Returns:
firstPicture
Type: webCGMPicture
getMetafileDescription() → {string}
Returns the Metafile Description of the webCGM document, which is a string consisting of QUOTE-delimited substrings, as defined in the WebCGM PPF.
For example:
"ProfileId:webCGM""ProfileEd:2.1""Source:A software vendor""Date:20040602""ColourClass:monochrome".Also as specified by the webCGM PPF, a valid metafileDescription will always contain the ProfileId: and the ProfileEd:, other information such as Source, ColourClass etc... is optional. If no webCGM document is open in the viewer, an empty string is returned.Returns:
metafileDescription
Type: string
getMetafileID() → {string}
Returns the Metafile Identifier, which is the parameter of the BEGIN METAFILE element in the CGM document. If no webCGM document is open in the viewer, an empty string is returned.
Returns:
metafileID
Type: string
getMetafileVersion() → {int}
Returns the Metafile Version of the webCGM document. If no webCGM document is open in the viewer, the value zero is returned
Returns:
metafileVersion
Type: int
removeEventListener(type, func)
This method allows the removal of event listeners on the webCGMMetafile. If an webCGMEventListeneris removed from the webCGMMetafile while it is processing an event, it will not be triggered by thecurrent actions. webCGMEventListeners can never be invoked after being removed. CallingremoveEventListener with arguments which do not identify any currently registered webCGMEventListeneron the webCGMMetafile has no effect.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
string | Specifies the event type of the webCGMEventListener being removed (for example: "click", "mouseover"). |
func |
webCGMEventListener | The webCGMEventListener to be removed. |
resize()
Forces the viewer application to apply changes to the picture based on new size of the canvas.
setLocalSrc(source)
Sets the local file path of the current document.
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | local file path |
setLocalSrc(source, onload)
Sets the local file path of the current document and specifies an "onload" which is fired after the document is loaded.
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | local file path |
onload |
function | the onload event function |
Fires:
- event:{function} onload
setRedraw(enable)
Disables or enables the redrawing of the metafile. The default value is enableAll. Note when this interface is used and set to enableAll a redraw of the picture automatically will occur. Care should be used when disabling the redrawing function to insure it is set back to enableAll.
Parameters:
| Name | Type | Description |
|---|---|---|
enable |
string | the redraw mode of the metafile, {enableAll | disableAll}. |
setSrc(source)
Sets the IRI of the current document. On setting, the new document pointed to by the IRI is loaded by the user agent. The user agent mustfully parse the fragment identifier (if any) in the IRI and execute the indicated behavior. The "Picture behaviors"" rule does apply to the 'src' attribute � if a IRI fragment contains a picBehavior, the viewer shall ignore the picBehavior. If the CGM resource pointed to by the IRI is currently loaded for the object, the user agent shall not reload the CGM (similar to the specification of a same-CGM IRI for the _replace behavior on a CGM-to-CGM link.) On retrieval, if no webCGM document is open in the viewer, an empty string is returned.The IRI source can also be defined in the HTML5 canvas object via the attribute "src", i.e. <canvas class="WebCGMDocument" ... src="myfile.cgm">
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | IRI |
setSrc(source, onload)
Sets the IRI of the current document and specifies an "onload" which is fired after the document is loaded.
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | IRI |
onload |
function | the onload event function |
Fires:
- event:{function} onload
setToolbar()
Sets the tools that show up on the internal toolbar. A value of zero (0) turns off the internal toolbar. The value passed in is comprised of bitwise OR'd tool values:
fileOpen = 0x0001 fileSave = 0x0002 filePrint = 0x0004 scaleToFit = 0x0008 scaleToWidth = 0x0010 scaleTo100 = 0x0020 zoomMode = 0x0040
zoomIn = 0x0080 zoomOut = 0x0100 rotImage = 0x0200 panMode = 0x0400 showHotspots = 0x0800
findText = 0x1000 refresh = 0x2000 larsonLogo = 0x4000
Predefined values of "off" (0) and "on" (scaleToFit | scaleToWidth | scaleTo100 | zoomMode | zoomIn | zoomOut | rotImage | panMode | showHotspots) are
also allowed.The tools can also be defined in the HTML5 canvas object via the attribute
"toolbar", i.e. <canvas class="WebCGMDocument" ... toolbar="on">
Note: not all tools are available on all platforms.
src() → {string}
Retrieves the current IRI, if no webCGM document is open in the viewer, an empty string is returned
Returns:
source IRI
Type: string