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 controlis associated with the property:
AllowActions {string}, customizes the actions the user can perform once the user clicks or touches the controlwhich means that the following statements are equivalent:
oSurface.Options = {allowActions: "scroll"}where oSurface is an object of Surface type
oSurface.SetOptions({allowActions: "scroll"})
oSurface.AllowActions = "scroll"
oSurface.SetAllowActions("scroll")
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
client |
any | The client parameter indicates the control's client area as:
|
|
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
Members
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
CanRedo
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
CanUndo
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()
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.
GetAllowUndoRedo
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)
GetUndoRedoQueueLength
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
Listeners
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
Redo
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.
SetAllowUndoRedo
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)
SetUndoRedoQueueLength
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
Shortcuts
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()
StartBlockUndoRedo
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
Undo
oSV :SV
Holds the control's surface view as an object of SV type.
Type:
(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 | value | Type | Description |
---|---|---|---|
exDefCoord |
0 |
number | The positive coordinates are shown right-down to origin of the surface. |
exCartesian |
1 |
number | The elements show in Cartesian coordinates. The positive coordinates are shown right-up to origin of the surface. |
exAllowPositiveOnly |
16 |
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 | value | Type | Description |
---|---|---|---|
exNoControlPoint |
0 |
number | The link displays no control points |
exStartControlPoint |
1 |
number | The link shows control point that changes the link's StartPos property (the exStartControlPoint point is marked with black squares) |
exEndControlPoint |
2 |
number | The link shows control point that changes the link's EndPos property (the exEndControlPoint point is marked with black squares) |
exControlPoint |
4 |
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 |
8 |
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 |
16 |
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) |
exAllowChangeFrom |
32 |
number | Allows the user to adjust the link's from element by dragging and dropping the start control point (requires the exStartControlPoint flag) |
exAllowChangeTo |
64 |
number | Indicates that the user can adjust the link's to element by dragging and dropping the end control point (requires the exEndControlPoint flag) |
(static, readonly) SingleSelEnum :number
The Surface.SingleSelEnum type defines flags the singleSel/SetSingleSel/GetSingleSel method uses.
Type:
- number
Properties:
Name | value | Type | Description |
---|---|---|---|
exDisableSel |
0 |
number | The exDisableSel value specifies that the control's selection is disabled. |
exEnableSel |
1 |
number | The exEnableSel flag specifies that the control's selection is enabled (multiple-selection, unless the exSingleSel is set ). |
exSingleSel |
2 |
number | The exSingleSel flag specifies that the user can select a element only. |
exToggleSel |
4 |
number | The exToggleSel flag specifies that the element's selection state is toggled once the user clicks a element. |
exDisableCtrlSel |
8 |
number | The exDisableCtrlSel flag disables toggling the element's selection state when user clicks a element, while CTRL modifier key is pressed. |
exDisableShiftSel |
16 |
number | The exDisableShiftSel flag disables selecting elements using the SHIFT key. |
exDisableDrag |
32 |
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).
The Surface.type member always returns "Surface"
Type:
- string
- Since:
- 1.8
(static) version :string
The version field defines the version of the control.
The current version is 3.3
Type:
- string
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:
|
- 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:
|
- 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
GetLayout
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
GroupUndoRedoActions
Link(id) → {Link}
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:
|
- 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:
|
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
RedoListAction
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:
|
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
RedoRemoveAction
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:
|
- 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:
|
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
UndoListAction
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:
|
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
UndoRemoveAction
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 |
feE(callback, thisArgopt)
The feE/forEachElement() method invokes the callback for each element of the control (enumerates the elements, as they were added)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
callback | A function of callback(oElement) type that's called for every element, where oElement is:
|
|
thisArg |
any |
<optional> |
Indicates 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. |
- Since:
- 3.5
Example
Below is a sample showing the captions for all elements:
oSurface.feE(function(oElement)
{
console.log(oElement.Caption)
})
feE
feEU(callback, thisArgopt) → {any}
The feEU/forEachElementUntil() method invokes the callback for each element of the control, until the callback returns a truly value (enumerates the elements, as they were added)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
callback | A function of callback(oElement) {any} type that's called for every element, where oElement is
|
|
thisArg |
any |
<optional> |
Indicates the value of "this" keyword during the callback. If missing/empty/undefined the thisArg points to the control itself, as an object of Tree type. |
- Since:
- 3.5
Returns:
Returns the last-value of the callback
- Type
- any
Example
The following sample displays the caption of the first non-movable element:
console.log(oSurface.feEU(function(oElement)
{
return !oElement.isMovable() && oElement.Caption || "";
}))
feEU
feL(callback, thisArgopt)
The feL/forEachLink() method invokes the callback for each link of the control (enumerates the links, as they were added)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
callback | A function of callback(oLink) type that's called for every link, where oLink is:
|
|
thisArg |
any |
<optional> |
Indicates 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. |
- Since:
- 3.5
Example
Below is a sample showing the all links (from, to):
oSurface.feL(function(oLink)
{
console.log(oLink.From, "->", oLink.To)
})
feL
feLU(callback, thisArgopt) → {any}
The feLU/forEachLinkUntil() method invokes the callback for each link of the control, until the callback returns a truly value (enumerates the links, as they were added)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
callback | A function of callback(oLink) {any} type that's called for every link, where oLink is
|
|
thisArg |
any |
<optional> |
Indicates the value of "this" keyword during the callback. If missing/empty/undefined the thisArg points to the control itself, as an object of Tree type. |
- Since:
- 3.5
Returns:
Returns the last-value of the callback
- Type
- any
Example
The following sample displays the first hidden link:
console.log(oSurface.feLU(function(oLink)
{
return !oLink.isVisible() && (oLink.From + "->" + oLink.To) || "";
}))
feLU