Class: Surface

Surface(client, oOptsopt)

new Surface(client, oOptsopt)

The ExSurface/JS lets you organize your objects to a surface. You can use the tool to generate organigrams, diagrams, graphs, flowcharts and so on. The ExSurface/JS is a HTML standalone-component, written in JavaScript, that uses no third-party libraries.

Every option of the Surface.Options type has associated a property of the control. For instance, the option:

allowActions {string}, customizes the actions the user can perform once the user clicks or touches the control
is associated with the property:
AllowActions {string}, customizes the actions the user can perform once the user clicks or touches the control
which means that the following statements are equivalent:
oSurface.Options = {allowActions: "scroll"}
oSurface.SetOptions({allowActions: "scroll"})
oSurface.AllowActions = "scroll"
oSurface.SetAllowActions("scroll")
where oSurface is an object of Surface type
Parameters:
Name Type Attributes Description
client any The client parameter indicates the control's client area as:
  • array of [x,y,width,height] type that specifies the control's client area
  • string, that specifies the identifier of the canvas within the document, so the canvas's client area becomes the control's client area
  • HTMLCanvasElement, that specifies the identifier of the canvas within the document, so the canvas's client area becomes the control's client area
oOpts object <optional>
An object of Surface.Options type that defines different options to display the control
Requires:
  • module:exontrol.commmon.min.js

Requires

  • module:exontrol.commmon.min.js

Classes

ElementOptions
LinkOptions
Options

Members

(static, readonly) CoordEnum :number

The CoordEnum type defines the type of coordinates the elements of the surface supports. The CoordEnum type supports the following values:
Type:
  • number
Properties:
Name Type Description
exDefCoord number The positive coordinates are shown right-down to origin of the surface.
exCartesian number The elements show in Cartesian coordinates. The positive coordinates are shown right-up to origin of the surface.
exAllowPositiveOnly number Only the positive panel of the surface is shown. The exAllowPositiveOnly flag can be combined with exDefCoord or exCartesian value. For instance, the exCartesian + exAllowPositiveOnly indicates that surface displays only the positive coordinates in Cartesian system.
Since:
  • 1.3

(static, readonly) LinkControlPointEnum :number

The LinkControlPointEnum type specifies the link's control points. The LinkControlPointEnum type supports the following values:
Type:
  • number
Properties:
Name Type Description
exNoControlPoint number The link displays no control points
exStartControlPoint number The link shows control point that changes the link's StartPos property (the exStartControlPoint point is marked with black squares)
exEndControlPoint number The link shows control point that changes the link's EndPos property (the exEndControlPoint point is marked with black squares)
exControlPoint number Defines the corners of the link's path. You can remove a exControlPoint points by dragging to another, so intermediate exControlPoint points are removed. You can move all control points of the link at once, if SHIFT key is pressed (the exControlPoint points are marked black circles)
exMiddleControlPoint number Defines the link's middle control points that are displayed between two exControlPoint points, to let the use add new exControlPoint points, to redefine the link's path (The exMiddleControlPoint points are marked with gray circles)
exOrthoArrange number Specifies that the lines of the link are orthogonal arranged when the user drags and drops the middle or control-points of the path (excludes the start/end control-points)

(static, readonly) SingleSelEnum :number

The Surface.SingleSelEnum type defines flags the singleSel/SetSingleSel/GetSingleSel method uses.
Type:
  • number
Properties:
Name Type Description
exDisableSel number The exDisableSel value specifies that the control's selection is disabled.
exEnableSel number The exEnableSel flag specifies that the control's selection is enabled (multiple-selection, unless the exSingleSel is set ).
exSingleSel number The exSingleSel flag specifies that the user can select a element only.
exToggleSel number The exToggleSel flag specifies that the element's selection state is toggled once the user clicks a element.
exDisableCtrlSel number The exDisableCtrlSel flag disables toggling the element's selection state when user clicks a element, while CTRL modifier key is pressed.
exDisableShiftSel number The exDisableShiftSel flag disables selecting elements using the SHIFT key.
exDisableDrag number The exDisableDrag flag disables selecting elements by drag.

(static) type :string

The type field defines the full-name of the object (the constructor.name does not give the same name for minimized forms)
Type:
  • string
Since:
  • 1.8

(static) version :string

The version field defines the version of the control
Type:
  • string

CanRedo

The CanRedo() method indicates whether the control can perform a Redo operation.
Since:
  • 2.0
Example
false {boolean}, no Redo operation is permitted
  true {boolean}, a Redo operation is available

CanUndo

The CanUndo() method indicates whether the control can perform an Undo operation.
Since:
  • 2.0
Example
false {boolean}, no Undo operation is permitted
  true {boolean}, an Undo operation is available

EndBlockUndoRedo

The EndBlockUndoRedo() method ends recording the Undo/Redo operations as a block. You can use the StartBlockUndoRedo / EndBlockUndoRedo methods to group multiple Undo/Redo operations into a single-block. The AllowUndoRedo property enables or disables the Undo/Redo feature
Since:
  • 2.0
Example
oControl.StartBlockUndoRedo()
   ...
 oControl.EndBlockUndoRedo()

GetAllowUndoRedo

The GetAllowUndoRedo() method specifies whether the Undo/Redo feature is enabled or disabled. To undo an action you need to press Ctrl+Z, while for to redo something you've undone, press Ctrl+Y.
Since:
  • 2.0
Example
false {boolean}, the Undo/Redo feature is disabled (by default)
  true {boolean}, the Undo/Redo feature is enabled.

GetUndoRedoQueueLength

The GetUndoRedoQueueLength() method gets the maximum number of Undo/Redo actions that may be stored to the control's Undo/Redo queue.
Since:
  • 2.0
Example
-1 {number}, the Undo/Redo queue is limitless
  1 {number}, the Undo/Redo queue limits the number of actions to store to 1 (one action or one block of actions)

Listeners :exontrol.Lts

The Listeners field defines the events of the control, as an object of exontrol.Lts type. The exontrol.Lts type supports forEach(callback, thisArg) method that helps you to enumerate the events the control supports. The Events section lists the events the component supports.
Type:
  • exontrol.Lts
Example
The following sample shows how you can get all events the component currently supports:

oSurface.Listeners.forEach(function(name)
{
 console.log(name);
});

The following sample displays the element being clicked:

oSurface.Listeners.Add("onclick", function (oEvent)
{
 console.log(oEvent);
});

where oSurface is an object of Surface type

oSV :SV

Holds the control's surface view as an object of SV type.
Type:

Redo

The Redo() method redoes the last action that was undone (reverses the Undo method). The Undo and Redo features let you remove or repeat single or multiple UI actions, but all actions must be undone or redone in the order you did or undid them – you can't skip actions.
Since:
  • 2.0
Example
Redo(), redoes the last action that was undone

SetAllowUndoRedo

The SetAllowUndoRedo() method enables or disables the Undo/Redo feature (by default the Undo/Redo feature is disabled). The Undo and Redo features let you remove or repeat single or multiple actions, but all actions must be undone or redone in the order you did or undid them – you can't skip actions. For example, if you added three elements and then decide you want to undo the first change you made, you must undo all three changes. To undo an action you need to press Ctrl+Z, while for to redo something you've undone, press Ctrl+Y
Since:
  • 2.0
Example
false {boolean}, the Undo/Redo feature is disabled (by default)
  true {boolean}, enables the Undo/Redo feature.

SetUndoRedoQueueLength

The SetUndoRedoQueueLength() method limits the Undo/Redo queue.
Since:
  • 2.0
Example
-1 {number}, the Undo/Redo queue is limitless
  1 {number}, the Undo/Redo queue limits the number of actions to store to 1 (one action or one block of actions)

Shortcuts :exontrol.Sts

The Shortcuts field defines the shortcuts of the control, as an object of exontrol.Sts type. In order to provide keyboard support for the component, the owner <canvas> element must include the tabIndex attribute, as <canvas ... tabIndex="0">. You can associated a function or a callback to any shortcut.
Type:
  • exontrol.Sts
Example
The following sample removes the selection (calls the RemoveSelection() method) once the user presses the Delete key:

oSurface.Shortcuts.Add( "Delete", oSurface.RemoveSelection, oSurface );

where oSurface is an object of Surface type

StartBlockUndoRedo

The StartBlockUndoRedo() method records all next Undo/Redo operations into a block until the EndBlockUndoRedo method is called. You can use the StartBlockUndoRedo / EndBlockUndoRedo methods to group multiple Undo/Redo operations into a single-block. The AllowUndoRedo property enables or disables the Undo/Redo feature.
Since:
  • 2.0
Example
oControl.StartBlockUndoRedo()
   ...
 oControl.EndBlockUndoRedo()

Undo

The Undo() method undoes the last action or a sequence of actions. For instance, if an element has been moved, Undo means moves back the element to its position before move. The Undo and Redo features let you remove or repeat single or multiple UI actions, but all actions must be undone or redone in the order you did or undid them – you can't skip actions.
Since:
  • 2.0
Example
Undo(), undoes the last control operation

Methods

BeginUpdate()

The BeginUpdate() method suspends the control's render until the EndUpdate() method is called. It maintains performance, while multiple changes occurs within the control. You can use the Update() method to perform multiple changes at once.

BlockUndoRedo(callback, thisArg)

The BlockUndoRedo() method records the Undo/Redo operations as a block. The BlockUndoRedo() method calls StartBlockUndoRedo / EndBlockUndoRedo methods.
Parameters:
Name Type Description
callback callback Specifies a function of callback() type
thisArg any Indicates the value of "this" keyword during the callback, or the control itself if missing

Element(id) → {Element}

The Element() method gets the element giving its index, identifier/key or reference
Parameters:
Name Type Description
id any The id parameter could be any of the following:
  • id {number}, indicates a numeric value that defines the index of the element to request
  • id {string}, specifies a string expression that defines the identifier/key/plain-caption of the element to request
  • id {Element}, specifies the object reference to the element to request for
Since:
  • 1.1
Returns:
Returns null if the element is not found, or an object of Element type, if the elements collection contains the giving id.
Type
Element

EndUpdate()

The EndUpdate() method resumes the control's render, after it is suspended by the BeginUpdate() method.

GetLayout(oOptsopt) → {string}

The GetLayout() method saves the UI layout of the object to an encoded string. The layout can be restored using the SetLayout() method. Currently, the control's Layout property serializes the following:
  • layout of windows (size, dock, parent)
  • selected elements
  • expand/collapse elements
  • control's zoom
Parameters:
Name Type Attributes Description
oOpts object <optional>
An object of {iMask,eMask,base64,equal,eol} type that defines options to serialize the properties of the container as explained bellow:
  • iMask {string}, specifies the mask (can include ? or * wild-characters) of properties to save
  • eMask {string}, specifies the mask (can include ? or * wild-characters) of properties to exclude from save
  • base64 {boolean}, Encodes the result to BASE 64
  • equal {string}, Indicates the separator between the name and the value. If missing, the = character is used
  • eol {string}, A character that separates the properties. By default it is "\n"
Since:
  • 1.8
Returns:
Returns a string that encodes the current UI layout for the entire object
Type
string
Example
The following statements are equivalents:

 oSurface.GetLayout(), gets the control's layout
 oSurface.Layout, gets the control's layout

where oSurface is an object of Surface type

GetStatistics() → {string}

The GetStatistics() method gives statistics data of objects being hold by the control
Returns:
Returns statistics data of objects being hold by the control such as:
Size: 588x412
Zoom: 100%
Element: 16/21
Link: 10/10
Sel: 0
Type
string

GroupUndoRedoActions(countopt)

The GroupUndoRedoActions() method groups the next to current Undo/Redo actions into a single block
Parameters:
Name Type Attributes Description
count number <optional>
Indicates the number of actions to group (if missing all actions are grouped)
Since:
  • 2.0
Example
GroupUndoRedoActions(), groups all Undo/Redo operations into a block
The Link() method gets the link giving its index, identifier/key or reference
Parameters:
Name Type Description
id any The id parameter could be any of the following:
  • id {number}, indicates a numeric value that defines the index of the link to request
  • id {string}, specifies a string expression that defines the identifier/key/plain-caption of the link to request
  • id {Link}, specifies the object reference to the link to request for
Since:
  • 1.1
Returns:
Returns null if the link is not found, or an object of Link type, if the links collection contains the giving id.
Type
Link

RedoListAction(actionopt, countopt) → {string}

The RedoListAction() method gets the Redo actions that can be performed.
Parameters:
Name Type Attributes Description
action string <optional>
Specifies null(to list all Redo actions) or the mask-pattern to match the action to list. Space sparates multiple mask-pattern. The mask-pattern supports wild characters as explained:
  • * (Any), masks any combination of characters
  • ? (Alphabetic), masks a letter such as [a-z] or [A-Z]
  • # (Digit), masks a digit character, [0-9]
  • [...] (Alternative), masks any characters that are contained in the [] brackets. For instance, the [abcA-C] mask
count number <optional>
Indicates the number of Redo actions to list (if missing all Redo actions are listed)
Since:
  • 2.0
Returns:
Returns the list of Redo actions that can be performed
Type
string
Example
RedoListAction(), lists all Redo actions that can be executed
  RedoListAction("*Element"), lists all "*Element" Redo actions that can be executed, such as AddElement, RemoveElement, UpdateElement or MoveElement
  RedoListAction("AddElement"), lists first "AddElement" Redo actions that can be executed

RedoRemoveAction(actionopt, countopt)

The RedoRemoveAction() method removes the first actions from the Redo queue
Parameters:
Name Type Attributes Description
action string <optional>
Specifies null(to remove all Redo actions) or the mask-pattern to match the action to remove. Space sparates multiple mask-pattern. The mask-pattern supports wild characters as explained:
  • * (Any), masks any combination of characters
  • ? (Alphabetic), masks a letter such as [a-z] or [A-Z]
  • # (Digit), masks a digit character, [0-9]
  • [...] (Alternative), masks any characters that are contained in the [] brackets. For instance, the [abcA-C] mask
count number <optional>
Indicates the number of actions to remove (if missing all actions are removed) from the Redo queue
Since:
  • 2.0
Example
RedoRemoveAction(), removes all actions from the Redo queue
  RedoRemoveAction("*Element"), removes all "*Element" actions, such as AddElement, RemoveElement, UpdateElement or MoveElement, from the Redo queue
  RedoRemoveAction("AddElement"), removes the first "AddElement" Redo action from the Redo queue

SetLayout(layout, oOptsopt)

The SetLayout() method restores the UI layout of the object from an encoded string, previously returned by the GetLayout() method. Currently, the control's Layout property serializes the following:
  • layout of windows (size, dock, parent)
  • selected elements
  • expand/collapse elements
  • control's zoom
Parameters:
Name Type Attributes Description
layout string A string expression that defines the UI layout to apply
oOpts object <optional>
An object of {iMask,eMask,base64,equal,eol} type that defines options to serialize the UI layout as explained bellow:
  • iMask {string}, specifies the mask (can include ? or * wild-characters) of properties to load
  • eMask {string}, specifies the mask (can include ? or * wild-characters) of properties to exclude from load
  • base64 {boolean}, Decodes the layout from BASE 64
  • equal {string}, Indicates the separator between the name and the value. If missing, the = character is used
  • eol {string}, A sequence of characters that can separate the properties. By default, any of \n, \r or ; separates the properties
Since:
  • 1.8

UndoListAction(actionopt, countopt) → {string}

The UndoListAction() method gets the Undo actions that can be performed.
Parameters:
Name Type Attributes Description
action string <optional>
Specifies null(to list all Undo actions) or the mask-pattern to match the action to list. Space sparates multiple mask-pattern. The mask-pattern supports wild characters as explained:
  • * (Any), masks any combination of characters
  • ? (Alphabetic), masks a letter such as [a-z] or [A-Z]
  • # (Digit), masks a digit character, [0-9]
  • [...] (Alternative), masks any characters that are contained in the [] brackets. For instance, the [abcA-C] mask
count number <optional>
Indicates the number of Undo actions to list (if missing all Undo actions are listed)
Since:
  • 2.0
Returns:
Returns the list of Undo actions that can be performed
Type
string
Example
UndoListAction(), lists all Undo actions that can be executed
  UndoListAction("*Element"), lists all "*Element" Undo actions that can be executed, such as AddElement, RemoveElement, UpdateElement or MoveElement.
  UndoListAction("AddElement",1), lists first "AddElement" Undo actions that can be executed

UndoRemoveAction(actionopt, countopt)

The UndoRemoveAction() method removes the last actions from the Undo queue
Parameters:
Name Type Attributes Description
action string <optional>
Specifies null(to remove all Undo actions) or the mask-pattern to match the action to remove. Space sparates multiple mask-pattern. The mask-pattern supports wild characters as explained:
  • * (Any), masks any combination of characters
  • ? (Alphabetic), masks a letter such as [a-z] or [A-Z]
  • # (Digit), masks a digit character, [0-9]
  • [...] (Alternative), masks any characters that are contained in the [] brackets. For instance, the [abcA-C] mask
count number <optional>
Indicates the number of actions to remove (if missing all actions are removed) from the Undo queue
Since:
  • 2.0
Example
UndoRemoveAction(), removes all actions from the Undo queue
  UndoRemoveAction("*Element"), removes all "*Element" actions, such as AddElement, RemoveElement, UpdateElement or MoveElement, from the Undo queue
  UndoRemoveAction("AddElement"), removes the first "AddElement" Undo action from the Undo queue

Update(callback, thisArgopt)

The Update() method locks the control's paint during the callback, and invalidates the control once the method ends.
Parameters:
Name Type Attributes Description
callback callback Indicates a callback to perform changes within the control
thisArg any <optional>
Specifies the value of "this" keyword during the callback. If missing/empty/undefined the thisArg points to the control itself, as an object of Surface type