ToolsView
The joint.dia.ToolsView
class works as a container for one set of link tools (an array of joint.dia.ToolView
objects). It is responsible for rendering the tools as a group when the tools view is attached to a joint.dia.LinkView.
To create a new tools view object, we call its constructor. Two optional arguments are accepted:
name | string | The name of this tools view. Default is null (no name). |
---|---|---|
tools | Array<dia.ToolView> | An array of tools that should be a part of the tools view. Default is [] (no tools). |
Creating a tools view is the second step in the process of setting up link tools on a link view:
// 1) creating link tools
var verticesTool = new joint.linkTools.Vertices();
var segmentsTool = new joint.linkTools.Segments();
var boundaryTool = new joint.linkTools.Boundary();
// 2) creating a tools view
var toolsView = new joint.dia.ToolsView({
name: 'basic-tools',
tools: [verticesTool, segmentsTool, boundaryTool]
});
// 3) attaching to a link view
var linkView = link.findView(paper);
linkView.addTools(toolsView);
Every link view we want to attach to requires its own tools view object (ToolsView
objects are automatically reassigned to the last link view they are added to). Similarly, every tools view we create requires its own set of tools (ToolView
objects are automatically reassigned to the last toolsView.tools
array they were made part of).
Methodsβ
blurTool()β
toolsView.blurTool(tool)
Stop focusing the specified tool
(of the joint.dia.ToolView
type) within this tools view.
This function reverses the effect of the toolsView.focusTool
function.
blurTools()β
toolsView.blurTools()
Stop focusing any tools within this tools view.
This function reverses the effect of the toolsView.focusTool
function applied to any tool in this tools view.
focusTool()β
toolsView.focusTool(tool)
Focus the specified tool
(of the joint.dia.ToolView
type) within this tools view.
When a tool is focused, all other tools within this tools view are hidden and the tool's opacity is changed according to the tool's focusOpacity
option. Only one tool can be focused at a time; the focus passes to the last tool within this tools view with which the focusTool
function was called.
The effect of this function can be reversed for a single tool
by the toolsView.blurTool
function. All tools can be unfocused by the toolsView.blurTools
function.
getName()β
toolsView.getName()
Return the name of this tools view. If no name was set during the construction of the tools view, null
is returned.
hide()β
toolsView.hide()
Hide all tools within this tools view.
show()β
toolsView.show()
Show all tools within this tools view.
Optionsβ
layerβ
layer - the stacking context of the tools view.
"tools" (default) | Render the tools in front of all the cells. |
null | Render the tools above the cell. It can be hidden by a cell with a higher z index. |
zβ
z - the stacking order (z-index) of the tools view in the given stacking context.