HT
is a one-stop solution based on the HTML5 standard enterprise application graphical user interface (GUI), which includes a rich graphical user interface (GUI) development class library for generic components, topologies, and 3D rendering engines, providing a fully based on HTML5
vector graphics editors, topology editors and 3D scene editors, and many other visual design tools, as well as a complete class library development manuals, tool manuals, and the HTML5
technology for large-scale team development of customer depth training manuals.
Ease to use, lightweight, high-performance and cross-platform four principles are our never-ending pursuits.
<script src="ht.js"></script>
The HT
core development class library has only one ht.js
JavaScript
(hereinafter referred to briefly as JS
) file, calling ht.Default.getVersion()
can get the current version number.
We will ensure that all versions are downward compatibility, which means that when upgrading a product, you only need to update the ht.js
file, which can be upgraded without any code modification.
The core ht.js
class library contains the data model, generic components such as tree table, 2D topology components, vector and 3D rendering engines and other core functional components, while HT
provides many extensions, such as dialog box, menu, and form, to meet other requirements of the class library or component for users to choose from.
Unrestricted, any text editor available.
Any browser that supports the HTML5
standard. Years ago, Chrome
, Firefox
, Safari
and Opera
versions have all supported HTML5
, iOS
and Android
browsers have also supported HTML5
, IE
needs IE9
and above versions , if you are using HT for Web 3D is supported by IE11
and above, and it is recommended to use the latest version of the browser as much as possible.
If the project environment must use an old IE browser such as IE6
, IE7
and IE8
, or by using HT for Web 3D, and the onsite environment cannot be upgraded to IE11
, you can consider installing Google Chrome Frame plug-in, embedded in the following Tag
code fragment, the page will use Chrome
to render.
<meta http-equiv="X-UA-Compatible" content="chrome=1">
Pay attention to the following points while using the Google Chrome Frame
:
Google Chrome
does not support opening a page from local file
, and must deploy the page to the Web
server to openGoogle Chrome Frame
does not support 64-bit browsers: Currently, 64-bit versions of IE are not supported. It's worth pointing out that 32-bit IE is the default on 64-bit Windows 7.Google Chrome Frame
does not support iframe
: At this point ChromeFrame only supports the meta tag detection on top level URLs.The solution with embedded OBJECT
element, bypassing Google Chrome Frame
does not support iframe
<OBJECT ID="ChromeFrame" WIDTH=500 HEIGHT=500 CODEBASE="http://www.google.com"
CLASSID="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A">
<PARAM NAME="src" VALUE="http://www.google.com">
<embed ID="ChromeFrameplug-in" WIDTH=500 HEIGHT=500 NAME="ChromeFrame"
SRC="http://www.google.com" TYPE="application/chromeframe">
</embed>
</OBJECT>
Google Chrome Frame
has stopped supporting and updating in January 2014
, and Google Chrome Frame
is now developing to 31
, which has met the canvas capabilities of HT
2D
and 3D
, so HT
customers can use Google Chrome Frame
solves the problem of compatible IE
old versions. Other questions refer to Google Chrome Frame's
Developer Guide and Troubleshooting
Part of the old version of the Android
terminal system, there are bugs
that not erased clean and have a residual shadow for the canvas
support, the following is a section workaround
code:
ht.Default.viewListener = function (view, kind){
var canvas = view._canvas;
if(canvas && kind === 'beginValidate'){
canvas.width = 0;
canvas.height = 0;
canvas.style.width = 0;
canvas.style.height = 0;
}
};
HT
based on the JavaScript
language, the development tools are weaker in spelling and error cues because of the flexibility of the JavaScript
dynamic language, so HT
provides shorthand naming methods for some commonly used functions, memorizing the following common function abbreviations can improve coding efficiency.
Several letters of the HT
abbreviation have the following meanings:
m
: monitor
、model
um
: unmonitor
f
: fire
The list of HT
shorthand functions is as follows:
GraphView#addinteractorListener
= GraphView#mi
GraphView#removeinteractorListener
= GraphView#umi
GraphView#fireinteractorEvent
= GraphView#fi
Graph3dView#addinteractorListener
= Graph3dView#mi
Graph3dView#removeinteractorListener
= Graph3dView#umi
Graph3dView#fireinteractorEvent
= Graph3dView#fi
SelectionModel#addSelectionChangeListener
= SelectionModel#ms
SelectionModel#removeSelectionChangeListener
= SelectionModel#ums
SelectionModel#getFirstData
= SelectionModel#fd
SelectionModel#getLastData
= SelectionModel#ld
SelectionModel#contains
= SelectionModel#co
SelectionModel#setSelection
= SelectionModel#ss
SelectionModel#appendSelection
= SelectionModel#as
SelectionModel#selectAll
= SelectionModel#sa
SelectionModel#removeSelection
= SelectionModel#rs
SelectionModel#clearSelection
= SelectionModel#cs
DataModel#getSelectionModel
= DataModel#sm
DataModel#addDataModelChangeListener
= DataModel#mm
DataModel#removeDataModelChangeListener
= DataModel#umm
DataModel#addDataPropertyChangeListener
= DataModel#md
DataModel#removeDataPropertyChangeListener
= DataModel#umd
DataModel#addHierarchyChangeListener
= DataModel#mh
DataModel#removeHierarchyChangeListener
= DataModel#umh
firePropertyChange
= fp
addPropertyChangeListener
= mp
removePropertyChangeListener
= ump
getPosition
= p
setPosition
= p
getTranslateX
= tx
setTranslateX
= tx
getTranslateY
= ty
setTranslateY
= ty
getStyle
= s
setStyle
= s
getAttr
= a
setAttr
= a
invalidate
= iv
invalidateModel
= ivm
getSelectionModel
= sm
getLogicalPoint
= lp
Toolbar#setValue
= v
Toolbar#getValue
= v
FormPane#setValue
= v
FormPane#getValue
= v
The following is some common shorthand examples:
graphView.getDataModel().getSelectionModel().setSelection(data)
= graphView.dm().sm().ss(data)
graphView.getDataModel().getSelectionModel().addSelectionChangeListener(func)
= graphView.dm().sm().ms(func)
dataModel.getSelectionModel().getLastData().setAttr('age', 35)
= dataModel.sm().ld.a('age', 35)
Refer to DataModel Manual
HT
follows the conventional object-oriented language design style, with Camel-Case for classes and packages, class names beginning with uppercase, and packet names beginning with lowercase. The entire framework occupies only the global variable HT
, which means that the development of the regular front-end page will take up the window.ht
, if ht.js
runs in the webwork environment will occupy the self.ht
variable, if ht.js
runs in node.js
environment will occupy the module.exports.ht
variable.
HT
overall frame hierarchy is very "flat", ht.*
includes models and system-related classes, ht.widget.*
contains generic component-related classes, ht.graph.*
contains 2D graphics component-related classes, ht.graph3d.*
contains the class of the 3D graphics component-related classes, considering js
language and HTML5
application particularity, as far as possible to reduce the hierarchy of class package, short package function naming is the characteristics of the API design in HT framework, which can reduce the user learning index, reduce the coding workload, contribute to minify the overall development kit.
The JavaScript
language does not provide rigorous language-level support for object-oriented classes, for which the HT
designs a package system for users to choose from, refer to Serialization Manual
HT
provides ht.List
array class that encapsulates an Array
array and provides a more easily remember and use function interface:
new ht.List(array/list/object)
Constructor can input array
and ht.List
array, or you can add a single object
elementsize()
Returns the total number of the array elementsisEmpty()
Determines whether an array is empty or notadd(item, index)
Adds elements, index
specifies the insert position and the NULL representative to insert into the lastaddAll(array)
Adds all elements in array
, support Array
and ht.List
typeget(index)
Returns index
position of elementslice(start, end)
Returns the new ht.List
object array from start
to end
, if end
is NULL, represents to the last elementremove(item)
Deletes the specified element and returns the index in which the element is locatedremoveAt(index)
Deletes the element of the index, and returns the deleted element objectset(index, item)
Inserts an element at the specified index locationclear()
Clears all elements of the arraycontains(item)
Determines whether an element is in an arrayindexOf(item)
Returns the index in the array, if it does not exist then return -1
each(func, scope)
Sequence iterates through all the elements, specifying functions to invoke scope
fieldsreverseEach(func, scope)
To iterate through all elements, you can specify the function to invoke scope
fieldtoArray(matchFunc, scope)
Returns all new array
arrays of matching elements according to matchfunc
, which can be specified by the function to invoke scope
fieldtoList(matchFunc, scope)
Returns the new ht.List
array of all matching elements according to matchFunc
, you can specify a function to invoke scope
fieldsort(sortFunc)
Rearrange array element positions according to sortFunc
comparison logicreverse()
The order of the array elements is reversedHT
provides event notification manager ht.Notifier
class, you can add listener functions, remove listener functions, and distribute events to all listener functions:
add(listener, scope)
Adds listener function for scope
parameter optionalremove(listener, scope)
Deletes listener function, scope
field parameter have to be consistent with the parameters of add
contains(listener, scope)
Determines whether the specified listener function is included, the scope
field parameter have to be consistent with the parameters of add
fire(event)
Distributes events to all listening functionsht.Default
defines the default values for all components and a series of tool class functions, refer to Style Manual
ht.Style
object defines the default style
attribute value with ht.Data
type, refer to Style Manual
ht.Color
object defines all the default colors for the HT
system, refer to Style Manual
ht.JSONSerializer
serialization class that provides serialization and deserialization of the JSON
format for DataModel
data model, refer to Serialization Manual
ht.Data
(referred to briefly as Data
, the following is a description of how to omit package header ht.
) is described as the most basic data type, the user can store business information in the Data
object properties, the current HT
provides Node
, Edge
, Tab
, Column
, these types have different display effects in different view components: Data
on the TreeView
tree component represents a tree node; the Data
on the TableView
table component represents a row of records, and the column represents the properties of the Data
object; Graphview
Node
on the graphics component represents a graphical element; Defining a page sign TabView
uses the Tab
type to store the page signing information; When defining a table column, TableView
uses column
to store column information.
Refer to DataModel Manual
ht.Node
type is the base class of the GraphView
and Graph3dView
rendering data nodes, inheriting from the Data
class.
The following is Node
of the GraphView
topological map related function properties, and Graph3dView
related function properties refer to 3D Manual.
In addition to displaying pictures, Node
can display a variety of predefined graphics, refer to Shape Section.
getPosition()
and setPosition({x:100, y:200})
Gets and sets the central point coordinates of datasgetImage()
and setImage(image)
Gets and sets the picture information, in the GraphView
topology picture in general with position
as the center drawinggetWidth()
and setWidth(width)
Gets and sets the width of the data, if not set to image
corresponding picture widthgetHeight()
and setHeight(height)
Gets and sets the height of the data, if not set to image
corresponding picture heightgetSize()
and setSize(10, 20 | {width:10, height:20})
Gets and sets the data's width and height size informationgetRect()
and setRect(x,y,width,height | {x:10,y:20,width:30,height:40})
Gets and sets the data rectangular areagetRotation()
and setRotation(Math.PI/2)
Gets and sets the rotation angle of the data, rotate clockwise around the center pointgetAttaches()
Gets the ht.List
type array that absorbs all of its nodes.getEdges()
Gets all edges to the node model associated with ht.List
type arraygetSourceEdges()
Gets all the edge ht.List
type array that starts at the node on all modelsgetTargetEdges()
Gets all the edge ht.List
type array that ends at the node on all models getAgentEdges()
Gets the edge ht.List
type array on the current node graph that is associated with the agentgetSourceAgentEdges()
Gets all graphics on which the agent starts from the node of the edge ht.List
type arraygetTargetAgentEdges()
Gets all graphics on which the agent ends from the node of the edge ht.List
type arrayhasAgentEdges()
Determines whether the current node has an agent edge on the graph, returns true
, if no return false
getHost()
and setHost(host)
Gets and sets the adsorption host object, when the node is adsorbed on the host data, when the host moves or rotates, it drives all the adsorbents.onHostChanged(oldHost, newHost)
Callbacks the function when the adsorbed host object changes and can be overloaded for subsequent processinghandleHostPropertyChange(event)
Callbacks the function when the adsorbed host object changes and can be overloaded for subsequent processingisHostOn(node)
Determines whether the data is adsorbed onto the specified data object or notisLoopedHostOn(node)
Determines whether a ring adsorption is formed with the specified data, such as A
adsorption B
, B
adsorption C
, C
adsorption back A
, then A
, B
and C
datas are mutually annular adsorption
In the above example, the air11
data was created to adsorb the air13
data, air11
changed the size, air13
set the rotation:
ht.Default.setImage('mac', 'res/mac-air.png');
air11 = new ht.Node();
air11.setName('11-inch MacBook Air');
air11.setImage('mac');
air11.setSize(80, 43);
air11.setPosition(100, 70);
dataModel.add(air11);
air13 = new ht.Node();
air13.setName('13-inch MacBook Air');
air13.setImage('res/mac-air.png');
air13.setPosition(260, 70);
air13.setRotation(Math.PI/2);
dataModel.add(air13);
air11.setHost(air13);
The code sets GraphView
to editable, allowing only air11
to edit the size, air13
can only rotate, which is implemented by setting Filter
graphView.setEditable(true);
graphView.setRectEditableFunc(function (data){
return data === air11;
});
graphView.setRotationEditableFunc(function (data){
return data === air13;
});
ht.Edge
type is used to connect the source and target two Node
nodes, and the two nodes can have multiple Edge
, and also allow the source and target to be the same node.
The agent
of the line refers to the node in the current graph where the true agent connects the edge, and when the node is in the closed Group
, the Group
connects the internal nodes of the agent.
More style attributes of Edge
refer to Edge Style.
getSource()
and setSource(node)
Gets and sets the source nodegetTarget()
and setTarget(node)
Gets and sets the target nodeisLooped()
Determines whether the source and target of the edge are the same node getSourceAgent()
Gets the source node of a edge on a graphgetTargetAgent()
Gets the target node of a edge on a graphgetEdgeGroup()
Gets ht.EdgeGroup
type object with multiple edges between the source and target nodestoggle()
Realizes the switch the multiple lines between the current source and target node and affect the style
attribute of edge.expanded
isEdgeGroupHidden()
Determines whether the current edge is hidden in the edge group or notgetEdgeGroupSize()
Returns the number of edges for the edge group where the current edge is locatedgetEdgeGroupIndex()
Returns the index of the edge group where the current edge is locatedisEdgeGroupAgent()
Determines whether the current edge is an agent of the edge group or notCan insert into the source
and target
node objects in the constructor by new ht.Edge(source, target)
, it can also build the Edge
object and then set separately, the example overloads the graphView.getLabel
function, customized the text label of the data, and when the multiple edges in the same group are merged, the agent text in the edge can show the edge group information:
var edge = new ht.Edge();
edge.setSource(source);
edge.setTarget(target);
dataModel.add(edge);
edge = new ht.Edge(source, target);
edge.toggle();
dataModel.add(edge);
edge = new ht.Edge(source, source);
dataModel.add(edge);
graphView.getLabel = function (data){
if(data instanceof ht.Edge){
if(data.isEdgeGroupAgent()){
return data.getEdgeGroupSize() + ' become 1';
}
}
return data.getName();
};
ht.Group
type is used as a parent container to contain child datas, which can be expanded and merged by double-clicking on the GraphView
topology, and when merged, the hidden descendant data node is automatically set, and the merged Group
connects the agent if there is a child node connected to the outside. The movement of the Group
will drive the child's nodes to follow, and the child's position and size changes will also affect the Group's
expanded graphics and position
. Refer to Group Style Properties.
isExpanded()
and setExpanded(true/false)
The expanded merge state of an object toggle()
Can toggle the expanded merge statestyle
ingroup
property determines whether it can be contained by Group
and defaults to true
In the example, the Group
object is created, and the Group
position is automatically affected by the location of the child nodes that are subsequently added, instead of being assigned a position on the group.setExpanded(true)
. Adding children through addChild
or setParent
is optional:
var group = new ht.Group();
group.setName('Double click on me');
group.setExpanded(true);
dataModel.add(group);
var node1 = new ht.Node();
node1.setName('Node1');
node1.setPosition(80, 80);
group.addChild(node1);
dataModel.add(node1);
var node2 = new ht.Node();
node2.setName('Node2');
node2.setPosition(180, 80);
node2.setParent(group);
dataModel.add(node2);
Constructs a style
of the ingroup
attribute to false
, the data will be free from the group
, the group
move and it will follow, but the node position or size change will not affect the Group
object:
var node4 = new ht.Node();
node4.setName('The Special One');
node4.setStyle('ingroup', false);
node4.setPosition(290, 100);
group.addChild(node4);
dataModel.add(node4);
The following code constructs a label
label that does not affect the Group's
child data, which overloads the Graphview.getBoundsForGroup
function for this function, and only returns its node3. getRect()
size for the node3
data, other datas continue to maintain the logic of the original function, which first caches the default function var oldfunc = Graphview.getBoundsForGroup
, and then called by oldFunc.call(this, child)
in the overloaded function, which use the HT
common overload technique, such the method can be overloaded without defining a new class and can invoke the original function logic as needed:
var node3 = new ht.Node();
node3.setPosition(130, 140);
node3.s({
'label.font': 'bold 21px arial',
'label.color': 'white',
'label.offset.y': 8,
'label.background': '#E74C3C'
});
node3.setName('HT for Web');
node3.setParent(group);
dataModel.add(node3);
var oldFunc = graphView.getBoundsForGroup;
graphView.getBoundsForGroup = function (child){
if(child === node3){
return node3.getRect();
}
return oldFunc.call(this, child);
};
Refer to Shape Manual
Refer to Shape Manual
ht.Grid
type is generally used as a container for grid layout of the subordinate nodes (attachNode.setHost(grid)
), and the subordinate nodes can be Grid
types, to achieve nested layouts.
setStyle('grid.row.count', 1)
Sets number of rowssetStyle('grid.column.count', 1)
Sets number of columnsetStyle('grid.row.percents', [0.1, 0.2, 0.3, 0.4])
Sets the height per line percentage, and the default is null
represents an equalizationsetStyle('grid.column.percents', [0.1, 0.2, 0.3, 0.4])
Sets the height per column percentage, and the default is null
represents an equalizationsetStyle('grid.border', 1)
Sets the thickness of the four edges of the container, if the uneven thickness of the quadrilateral can be controlled by the following four parameterssetStyle('grid.border.left', 0)
Sets the thickness of the left edge of the containersetStyle('grid.border.right', 0)
Sets the thickness of the right edge of the containersetStyle('grid.border.top', 0)
Sets the thickness of the top edge of the containersetStyle('grid.border.bottom', 0)
Sets the thickness of the bottom edge of the containersetStyle('grid.gap', 1)
Sets the gap between cells in a containersetStyle('grid.background', '#E5BB77')
Sets the background between cells in a containersetStyle('grid.depth', 1)
Sets the depth of the four edges of the container, 0
represents a flat effect, a positive value representing a raised effect, and a negative value represents a sunken effect.setStyle('grid.cell.depth', -1)
Sets the depth of the four edges of a cell, 0
represents a flat effect, a positive value representing a raised effect, and a negative value represents a sunken effect.setStyle('grid.cell.border.color', '#868686')
Sets the cell border color that is effective when the grid.cell.depth
value is 0
setStyle('grid.block', 'undefined')
Sets whether to display a block border or not, the default is undefined
represents does not draw, v
represents to draw column block, h
represents to draw row blocksetStyle('grid.block.padding', 3)
Sets block border padding between cell contentssetStyle('grid.block.width', 1)
Sets block border drawing width setStyle('grid.block.color', '#868686')
Sets block border drawing colorNode
type of the satellite node, you can set the following attach
related parameters: setStyle('attach.row.index', 0)
Sets the location of the cell row where the node is locatedsetStyle('attach.column.index', 0)
Sets the location of the cell column where the node is locatedsetStyle('attach.row.span', 1)
Sets the number of node rows acrosssetStyle('attach.column.span', 1)
Sets the number of node column acrosssetStyle('attach.padding', 0)
Sets the distance between four edges and cells, positive values are out of cells, and negative values are less than cellssetStyle('attach.padding.left', 0)
Sets the distance between left edges and cells, positive values are out of cells, and negative values are less than cellssetStyle('attach.padding.right', 0)
Sets the distance between right edges and cells, positive values are out of cells, and negative values are less than cellssetStyle('attach.padding.top', 0)
Sets the distance between top edges and cells, positive values are out of cells, and negative values are less than cellssetStyle('attach.padding.bottom', 0)
Sets the distance between bottom edges and cells, positive values are out of cells, and negative values are less than cellsht.SubGraph
types have similarities with the Group
type, they will affect the way the child is rendered, different with the Group
type with the child node in the same layer interface display, SubGraph
type to present its children including descendant nodes in the next layer of interface, in GraphView
component is shown as double-clicking SubGraph
data will enter the new interface content, under the new interface content double-click the background can return the SubGraph
interface of the data, SubGraph
can be unlimited layer nesting.
The GraphView
is related to the SubGraph
function as follow:
getCurrentSubGraph()
and setCurrentSubGraph(subGraph)
Gets and sets the current subgraph, the default is empty representation at the top layerupSubGraph()
Enter the upper subgraph of the current subgraphRefer to TabView component Manual
Refer to TableView Component Manual
Refer to PropertyView Components Manual
Refer to DataModel Manual
Refer to DataModel Manual#selectionmodel
The components of the HT
framework refer to visually interactive view controls, the HT
framework is based on HTML5
technology, so the visual part of the HT
component is essentially an HTML
element, most of the HT
components are bound to the DataModel
data model, and the user can drive visual components by manipulating the pure JS
language, to shield the complexity of the HTML
underlying graphics technology.
The aim that HT
encapsulate HTML5
technology is to improve development efficiency and maintainability, but does not mean that users are not allowed to manipulate HTML
native elements, programmers with HTML5
development experience can use a variety of HTML5
technologies to customize the HT
component, in the context of understanding the HT
system mechanism.
All HT
components are at the root of a div component that can be obtained through the component's getView()
function.
The default and custom interaction event listeners are generally added to the div
(getView().addEventListener(type, func, false)
), the render layer is generally provided by canvas.
The user can set the CSS background and other styles to the root div
and canvas
layers, you can also add a new HTML
component to the root div
layer and present it as a sibling component of canvas
.
HT
components are generally set to position
as the absolute
absolute positioning mode, box-sizing
properties are set to border-box
.
Most of the HT
components provide the isDisabled()
and setDisabled(true/false, iconUrl)
functions to make the entire component unusable, typically used to remotely load the data process to temporarily leave the component in an unusable state, iconUrl
in which case the gif
picture path is generally set to represent the being loaded state.
Components in the disabled
state generate a div
that blocks the entire component through ht.Default.disabledBackground
can modify the shaded component background color.
The rendering of HT
components is largely implemented by the inner canvas
component, which provides the appropriate extension function for customization, for example, listView
provides drawRow
for function custom line drawing, GraphView
by vector mechanism to customize data image
on topology rendering, etc., components that are rendered based on canvas
such as ListView, PropertyView, TreeView,
TableView, Treetableview, GraphView, etc., components, provides a brush interface for drawing canvas
at the bottom and topmost levels:
addTopPainter(function (g){})
and removeTopPainter(func)
Adds and removes brushes that are drawn at the top leveladdBottomPainter(function (g){})
and removeBottomPainter(func)
Adds and removes brushed that are drawn at the bottom levelAll components of HT
do not take the HTML
feature of the scroll bar, completely from the HT
component, the scroll bar can be automatically hidden, dynamically appearing when the component is translated or the mouse slides over the boundary, and the default transparent scrollbar cover
is above the content and does not affect the layout of the component interface:
getScrollBarColor()
and setScrollBarColor(color)
Gets and sets the color of the scrollbargetScrollBarSize()
and setScrollBarSize(6)
Gets and sets the width of the scrollbarisAutoHideScrollBar()
and setAutoHideScrollBar(true/false)
Gets and sets whether scrollbar are automatically hidden or not, the default value is true
The HT
component's coordinate origin defaults to the upper left corner, most components have the translation function, the translation visualization effect is the scrolling, divides into the horizontal ordinate translation translateX
attribute, and the vertical coordinate translation translateY
attribute, both default values are 0
.
Some components can only be translated horizontally, such as tabView
and tableHeader
; some components can only be translated vertically, such as ListView
and TreeView
, while GraphView
and TableView
are both horizontal and vertical; can be overloaded adjustTranslateX
and adjustTranslateY
functions to change the translation logic:
setTranslate(x, y, anim)
Sets a new horizontal translation and vertical translation value, anim
represents whether to animate it or not, refer to Animation ManualgetTranslateX()
and setTranslateX(10)
Gets and sets the current horizontal translation value, abbreviated to tx()
and tx(10)
getTranslateY()
and setTranslateY(10)
Gets and sets the current vertical translation value, abbreviated to ty()
and ty(10)
translate(tx, ty)
Increases horizontal and vertical translation values based on current valueadjustTranslateX(value)
This function passed the horizontal translation value that is about to be set, returns the final setting value, and can overload the restricted horizontal translation rangeadjustTranslateY(value)
This function passed the vertical translation value that is about to be set, returns the final setting value, and can overload the restricted horizontal translation rangeThe HT
components are typically embedded in containers such as BorderPane
, SplitView
and TabView
, and the outermost HT
component requires the user to manually add getView()
back to the bottom div
element to the page's DOM
element , it should be noted that when the parent container size changes, if the parent container is BorderPane
and SplitView
and so on these HT
predefined container components, then the HT
container automatically recursively invokes the child component invalidate
function to notify the update. However, if the parent container is native to the HTML
element, then the HT
component is not known whether need to be updated, so the outermost HT
component generally needs to listen for window size change events and invoke the outermost component invalidate
function to update.
In order for the outermost component to fill the window with convenience, HT
all components have a addToDOM
function, its implementation logic is as follows, where iv
is the invalidate's
shorthand:
addToDOM = function (){
var self = this,
view = self.getView(),
style = view.style;
document.body.appendChild(view);
style.left = '0';
style.right = '0';
style.top = '0';
style.bottom = '0';
window.addEventListener('resize', function () { self.iv(); }, false);
}
Changing the HT
system default properties requires that the HT
system only read htConfig
configuration information at initialization time through a global htConfig
variable name, so the attribute must be initialized before introducing the ht.js
package, modifying htConfig
when running the variable does not work again, the sample code is as follows:
<script>
htconfig = {
Color: {
label: '#000',
labelSelect: '#FFF'
},
Default: {
toolTipDelay: 100,
toolTipContinual: true
},
Style: {
'select.color': '#E74C3C',
'select.width': 3
}
};
</script>
<script src="ht.js"></script>
Configurable parameters are grouped into three broad categories, and specific attribute descriptions refer to Style Manual
ht.Color
object propertiesht.Default
object propertiesht.Style
object propertiesImages are an important resource for graphics components, icons on trees, topological datas, and so on can be drawn with images, HT
supports regular picture formats such as PNG
and JPG
, as shown in the Node chapter example, there are two ways to use a image:
air13.setImage(res/mac-air.png)
ht.Default.setImage('mac', 'res/mac-air.png')
, and then sets the registration name to the model air11.setImage('mac')
Directly setting path in development is convenient, without registering images in advance, but when data model serialization the image path will occupy more memory, image path is not conducive to management maintenance in the future, both ways are the correct way to use, according to the project situation selected different ways or mixed use.
If you use the url
path, the HT
interior automatically loads the picture, and automatically updates the corresponding view component after onload
.
The HT
frame of the image was given a broader meaning, HT
provides a custom JSON
format vector description in the HT
standard defined JSON
vector format, can also be used as a image for registration and use, HT
vector are more space-saving than traditional picture format, zoom without distortion, the most powerful thing is that all the graphics parameters of the vector can be dynamically bound to data on the Data
model, as specified in the Vector Manual.
ht.Default.setImage
function has several methods of invocation:
setImage('hightopo', 'www.hightopo.com/logo.png')
Registers by urlsetImage('hightopo', 'data:image/png;base64,iVBORw...Jggg==')
Registers by base64
setImage('www.hightopo.com/logo.png')
Only use url
parameter, picture's name
and url
path are the same in this waysetImage('hightopo', 200, 80, 'www.hightopo.com/logo.png')
Registers by url and specified the image's width and heightsetImage('hightopo', 200, 80, 'data:image/png;base64,iVBORw...Jggg==')
Registers by base64
and specified the image's width and heightsetImage('hightopo', img|canvas)
Registers img
and canvas
can draw html
elementUsing registration img
of the HTML
element, the user needs to ensure that the image resource is loaded, and that the HT
does not listen to its onload
event, so the view component updates are not automatically notified.
ht.Default.getImage(name, color)
can obtain the corresponding picture element, in the picture loading process, this function returns empty, only after onload
can get the corresponding data element, color
is the color parameter, generally is NULL, if has the color value then HT
interior will build a new picture of color
dyed
The HT
also provides several drawing functions for the picture, the image
in the following parameters can be plotted img
or canvas
elements, or vector json
format, because the vector can dynamically bind the data model has the function of dyeing, so the vector can be drawn into the data
view
components and color
dyeing parameters:
ht.Default.drawImage(g, image, x, y, width, height, data, view, color)
Draws the image
in a filled way within the specified rectangle areaht.Default.drawCenterImage(g, image, x, y, data, view, color)
Draws image
in the center of x
and y
ht.Default.drawStretchImage(g, image, stretch, x, y, w, h, data, view, color)
Draws the picture in the rectangular position, the strech
type is as follows:fill
Picture fills the entire rectangular area, if the picture width and height scale and the rectangular inconsistency will cause the picture stretch distortionuniform
The picture always retains the original width and height ratio unchanged and fills the rectangular area as far as possiblecenterUniform
When the rectangular area is larger than the picture size, the picture is drawn in the center position in the original size, and the uniform
is used when the space is not enough.Under the design architecture of the HT
data model driven graphics component, the animation can be understood as the process of gradually changing some attributes from the starting value to the target value, HT
provides for ht.Default.startanim
animation function, whose sample code is as follows:
ht.Default.startAnim({
frames: 12, // Animation frame
interval: 10, // Interval between frames
easing: function (t){ return t * t; }, // Animation easing function, use `ht.Default.animEasing`, by default
finishFunc: function (){ console.log('Done!') }, // The call function after animation finished
action: function (v, t){ // Necessary, properties changed while on animation
node.setPosition( // `node` moves from `p1` to `p2` in this example
p1.x + (p2.x - p1.x) * v,
p1.y + (p2.y - p1.y) * v
);
}
});
ht.Default.startAnim
support frame-based
and time-based
two ways of animation, the above code is frame-based
way, in this way the user by specifying the frames
animation frame number, and interval
animation frame interval parameter controls the animation effect.
The following code is time-based
, in which the user only needs to specify the number of milliseconds the animation cycle of duration
can be, HT
will complete the animation in the specified time period, different from frame-based
way has a definite fixed number of frames, that is how many times action
function been called, the number of time-based
mode frames or action
functions are called depending on the system environment, generally the system configuration is better, the more efficient browsers call the number of frames and the animation process is smoother. Because JS
language can not accurately control the interval
time interval, the use of frame-based
can not accurately control the animation time period, even if the same frames
and interval
parameters in different environments, there may be a big difference in the animation cycle, so HT
defaults to time-based
mode, if the duration
and frames
parameters are not be set, the duration
parameter will be automatically set to ht.Default.animDuration
value.
ht.Default.startAnim({
duration: 500, // Animation-duration, use `ht.Default.animDuration`, by default
action: function (v, t){
...
}
});
The startAnim
function returns an anim
object that can be called anim.stop(true)
to terminate the animation, where the parameter shouldBeFinished
represents a completely outstanding target change, if true
, it will invoke anim.action(anim.easing(1))
. At the same time anim
also has anim.pause()
and anim.resume()
interruptible and continue animation functions, as well as the anim.isRunning()
function to determine whether the animation is in progress.
The action
function's first parameter v
represents the value after the operation of the easing (t)
function, t
represents the progress of the current animation form 0
to 1
, and the general properties vary according to the v
parameter.
The above example shows the animation effect of clicking on a background graphic element to move to a click position, clicking on the data itself to rotate and zoom, ht.Default.startAnim
easing
parameter is used to allow user-defined functions to control animations through mathematical formulas, such as constant-speed changes, first-slow, and then fast-after effects, refer to http://easings.net/, the sample code easing.js defines a series of animation functions to choose from:
var Easing = {
swing: function (t) {
return ( -Math.cos(t * PI) / 2 ) + 0.5;
},
/**
* Begins slowly and accelerates towards end. (quadratic)
*/
easeIn: function (t) {
return t * t;
},
/**
* Begins quickly and decelerates towards end. (quadratic)
*/
easeOut: function (t) {
return ( 2 - t) * t;
},
// ...
}
In the example, the build uses graphView.setinteractors
to remove all the default interactivity, adding listeners through view.addEventListener
, while building the select
element for HTML
to select different easing
effect, add it to the div
component of graphView.getView()
, so you need to do a filter on the select
element in a custom interaction event, where graphview.getLogicalPoint(e)
returns the logical coordinate position based on the interaction event.
In this example, the triggering data rotates around its center by clicking on the data, and the data is then restored to the original size by a large variable, which sets the frames
for 30
frame and interval
for 16
millisecond intervals.
The frame-based
way completes the animation; click on the background area trigger data to move to the specified click position, which completes the animation by setting duration
for 500
cycle time-based
.
var select = document.createElement('select');
select.style.position = 'absolute';
select.style.top = '10px';
select.style.right = '10px';
view.appendChild(select);
for(var name in Easing){
var option = document.createElement('option');
option.innerHTML = name;
if(name === 'easeOut'){
option.setAttribute('selected', 'true');
}
select.appendChild(option);
}
graphView.setinteractors(null);
var type = "ontouchend" in document ? 'touchstart' : 'mousedown';
isAnimating = false;
view.addEventListener(type, function (e){
e.preventDefault();
if(isAnimating || e.target === select || !ht.Default.isLeftButton(e)){
return;
}
isAnimating = true;
var data = graphView.getDataAt(e);
var easing = Easing[select.value];
var finishFunc = function (){
isAnimating = false;
};
if(data === toy){
var size = toy.getSize();
ht.Default.startAnim({
frames: 30,
interval: 16,
easing: easing,
finishFunc: finishFunc,
action: function (v){
toy.setRotation(Math.PI * v);
var r = Math.abs(v - 0.5) * 2;
toy.setSize(size.width * r, size.height * r);
}
});
}else{
var p2 = graphView.getLogicalPoint(e);
var p1 = toy.getPosition();
anim = ht.Default.startAnim({
duration: 500,
easing: easing,
finishFunc: finishFunc,
action: function (v){
toy.setPosition(
p1.x + (p2.x - p1.x) * v,
p1.y + (p2.y - p1.y) * v
);
}
});
}
}, false);
The example modifies the style background color of the underlying div
component, while adding the top and bottom brushes, drawing Click anywhere you want ...
text information, by moving the data can be found that topPainter
drawn content is rendered above the data, bottomPainter
drawn content is rendered under the data.
view.style.background = '#FCFCFC';
graphView.addTopPainter(function (g){
ht.Default.drawText(g, 'click anywhere you want ..', '24px Arial', 'lightgray', 50, 100, 0, 0, 'left');
});
graphView.addBottomPainter(function (g){
ht.Default.drawText(g, 'click anywhere you want ..', '24px Arial', 'lightblue', 200, 180, 0, 0, 'left');
});
Functions of many components of HT
are also animated, such as setTranslate(x, y, anim)
, zoomIn(anim)
, rotate(leftRight, upDown, anim)
, and so on, with anim
parameter options, there are two types of arguments that can be passed in:
boolean
type of true
and false
, true
means the animation is started, and the default animation effect is used, false
means that the animation is not startedJSON
object structure that takes the type parameter to represent the start animation, while the JSON
structure attributes with ht.Default.startAnim
type can be descendants of duration
, frames
, interval
, easing
and finishFunc
and other animation control parameters.Except through
ht.Default.startAnim
to invoke startup animation,DataModel
also has functions to start scheduling tasks, which can be extended to flow, flicker, size changes and other animation effects, as detailed in the Dispatch Manual, for more robust descriptive animation controls refer to Animation plug-in.
Refer to Property Component Manual and PropertyPane plug-in
Refer to ListView Component Manual
Refer to TreeView Component Manual
Refer to TableView Component Manual
Refer to TreeTableView Component Manual
Refer to Toolbar Manual
Refer to SplitView Component Manual
Refer to BorderPane Component Manual
Refer to AccordionView Component Manual
Refer to TabView Component Manual
The topological graphics component ht.graph.GraphView
(hereinafter referred to as GraphView
) is the most abundant component in the HT
framework 2D
and its related class libraries are under the ht.graph
package.
GraphView
has basic graphics rendering and editing functions, topology node connection and automatic layout function, power and telecommunications industry predefined objects, with animation rendering and other special effects, so its application is very wide, can be used as a monitoring field of drawing tools and Man-machine interface, can be used as a general graphical editing tools, can be extended into business applications such as workflows and organization charts.
Changing the zoom
attribute value (default to 1
) enables the GraphView
zooming function to view the full picture or detail of the topological graphics component in an enlarged or reduced manner.
The mouse wheel on the peace plate and the double finger pinch
gesture can change the zoom
value in default. Press SPACEBAR to reset zoom
to default 1
(the operation also resets translateX
and translateY
to 0
):
ht.Default.zoomIncrement = 1.3
Calls the zooming stepping of the zoomIn
and zoomOut
functionsht.Default.scrollZoomIncrement = 1.05
Mouse wheel zoom stepht.Default.pinchZoomIncrement = 1.08
Touch screen double finger zoom stepht.Default.zoomMax = 20
Maximum magnificationht.Default.zoomMin = 0.01
Minimum reduction value The following is the GraphView
scaling correlation function in which the point
parameter in the following function represents the center data for zooming, which is typically input the graphView.getLogicalPoint(event)'s
return value, that is the center of the current mouse click, when this parameter is empty, it is zooming in the center of the currently visible rectangular area.
zoomIn(anim, point)
Zoom inzoomOut(anim, point)
Zoom out zoomReset(anim, point)
Sets the scale value to 1
scrollZoomIn(point)
Calls when the wheel is enlargedscrollZoomOut(point)
Calls when the wheel is shrink pinchZoomIn(point)
The touch-screen double finger is magnified when calledpinchZoomOut(point)
Calls when touch double finger shrinksgetZoom()
and setZoom(value, anim, point)
Gets and sets the value of scaling, the final setting will invoke adjustZoom
for controladjustZoom(value)
Input the zoom value that is about to be modified, return the scaling value of the final run setting, and can be overloaded for customizationThe adjustZoom
function defaults to the following, for ht.Default
configured maximum and minimum values are limited:
adjustZoom = function (value){
if(value < ht.Default.zoomMin){
return ht.Default.zoomMin;
}
if(value > ht.Default.zoomMax){
return ht.Default.zoomMax;
}
return value;
};
GraphView
has some internal interactor for basic selection, single double click, zoom, panning, and editing in default, here are the internal interactors:
interactor
interactor class, provides basis functions, such as distributed interactive events, listening function add and remove, encapsulate drag and drop operation, automatic pan scrolling functionDefaultinteractor
To achieve the Group
, Edge
and SubGraph
the double-click response, hand grab picture panning, mouse wheel zooming, keyboard response and other functions in defaultSelectinteractor
Enables the data to be single and box-selected. Drag background is panning in default, and press Ctrl
to make a box selection (Command
key in Mac
)Moveinteractor
To achieve the move function of the selected dataEditinteractor
To achieve the size change and angle rotation of datas, as well as the Shape
and Edge
type of the multiple-point editing of datasTouchinteractor
To achieve touch
interaction on mobile devicesScrollbarinteractor
To achieve scroll bar display and interactive functionThese interactions can be combined with GraphView#setinteractors(list)
, and the user can also extend their own interactivity based on interactor
, the following code is the implementation of Graphview#setEditable(false/true)
, the GraphView
constructor called setEditable(false)
, so by default only the basic operation function does not have the editing function, and the edit function can be achieved by calling setEditable(true)
.
setEditable: function (editable) {
var self = this;
if (editable) {
self.setinteractors([
new ScrollBarinteractor(self),
new Selectinteractor(self),
new Editinteractor(self),
new Moveinteractor(self),
new Defaultinteractor(self),
new Touchinteractor(self)
]);
} else {
self.setinteractors([
new ScrollBarinteractor(self),
new Selectinteractor(self),
new Moveinteractor(self),
new Defaultinteractor(self),
new Touchinteractor(self, {editable: false})
]);
}
},
Touchinteractor
the second parameter of the class can be passed into the JSON
object control function to open and close, the default is open
selectable
Allowed to be selectedmovable
Allowed to movepannable
Allowed to translatepinchable
Allowed to scaleeditable
Allowed to editThe internal interactor
sends events in the interactive process, which can be monitored by GraphView#addinteractorListener
, referred to briefly as mi
graphView.addinteractorListener(function (e) {
if(e.kind === 'clickData'){
console.log(e.data + 'clicked');
}
else if(e.kind === 'doubleClickData'){
console.log(e.data + 'double clicked');
}
else if(e.kind === 'clickBackground'){
console.log('clicked background');
}
else if(e.kind === 'doubleClickBackground'){
console.log('double clicked');
}
else if(e.kind === 'beginRectSelect'){
console.log('start to select the rect');
}
else if(e.kind === 'betweenRectSelect'){
console.log('selecting the rect');
}
else if(e.kind === 'endRectSelect'){
console.log('stop to select the rect');
}
else if(e.kind === 'beginMove'){
console.log('start to move the data');
}
else if(e.kind === 'betweenMove'){
console.log('moving the data');
}
else if(e.kind === 'endMove'){
console.log('stop to move the data');
}
else if(e.kind === 'beginPan'){
console.log('start to pinch pan');
}
else if(e.kind === 'betweenPan'){
console.log('pinching pan');
}
else if(e.kind === 'endPan'){
console.log('stop to pinch pan');
}
else if(e.kind === 'beginEditRect'){
console.log('start to edit the data size and position');
}
else if(e.kind === 'betweenEditRect'){
console.log('editing the data size and position');
}
else if(e.kind === 'endEditRect'){
console.log('stop to edit the data size and position');
}
else if(e.kind === 'beginEditPoint'){
console.log('start to edit the points of multi-sided Shape or multi-point Edge');
}
else if(e.kind === 'betweenEditPoint'){
console.log('editing the points of multi-sided Shape or multi-point Edge');
}
else if(e.kind === 'endEditPoint'){
console.log('stop to edit the points of multi-sided Shape or multi-point Edge');
}
else if(e.kind === 'beginEditRotation'){
console.log('start to rotate the data');
}
else if(e.kind === 'betweenEditRotation'){
console.log('rotating the data');
}
else if(e.kind === 'endEditRotation'){
console.log('stop to rotate the data');
}
else if(e.kind === 'moveLeft'){
console.log('leftarrow move the data 1 pixel to the left');
}
else if(e.kind === 'moveRight'){
console.log('rightarrow move the data 1 pixel to the right ');
}
else if(e.kind === 'moveUp'){
console.log('uparrow move the data up 1 pixel');
}
else if(e.kind === 'moveDown'){
console.log('down-arrow move the data down 1 pixel');
}
else if(e.kind === 'toggleNote'){
console.log('toggle note to expand and merge');
}
else if(e.kind === 'toggleNote2'){
console.log('toggle note2 to expand and merge');
}
});
There is also a logical coordinate point (LogicalPoint
) concept about interaction, the translated and scaled components have getLogicalPoint
function in general, according to the interactive event to return the corresponding coordinate point information, simple understanding of logical coordinates point is same as user set model
coordinates, and the actual display at the screen point of coordinates, need to be through zoom
and translate
conversion, in the GraphView
to change the zoom
and translate
process, the data model of the data has not changed, that is, the logical coordinate value is unchanged, only the rendering effect of the view component changes, the logical coordinate information of all datas in DataModel
, such as position
, points
, width
and height
, remains unchanged, so when customizing the interaction event processing, it is necessary to call the following interactive screen coordinates and logical coordinate conversion functions:
getLogicalPoint(event)
Input interaction event
parameter, return corresponding logical coordinate point, referred to briefly as lp
getDataAt(pointorevent, filter)
Input logical coordinate point or interactive event
event parameter, returns the data under the current point, filter
can be filteredgetSelectedDataAt(pointOrEvent)
Input the logical coordinate point or interaction event
parameter, which returns the selected data under the current point.getDatasInRect(rect, intersects, selectable)
Gets the datas within the logical coordinate region.rect
Represents the logical coordinate area.intersects
Specifies whether to intersect or include select or not, true
means intersect select, false
means include select.selectable
Specifies whether the data is required to be selected or not, for the NULL represents does not require, whether selectable is judging by GraphView.isSelectable
functionmoveSelection(xOffset, yOffset)
Move the selected data horizontally xOffset
, move yOffset
vertically Graphview
has a series of on*
type callback functions that can be overloaded for subsequent processing or change the default implementation logic:
onDataClicked(data, event)
Called when the data is clickedonDataDoubleClicked(data, event)
Called when the data is double clickedonEdgeDoubleClicked(edge, event)
Called when the edge is double clicked, default to call edge.toggle()
onGroupDoubleClicked(group, event)
Called when the group is double clicked, default to call group.toggle()
onSubGraphDoubleClicked(subGraph, event)
Called when the subgraph is double clicked, default to call graphView.setCurrentSubGraph(subGraph)
into the subgraphonBackgroundClicked(event)
Called when the background is clickedonBackgroundDoubleClicked(event)
Called when the background is double clicked, default to call upSubGraph()
into the upper subgraphonCurrentSubGraphChanged(event)
Called when the current subgraph is changed, default to call reset()
to recovery the default zoom and the default translate valueonAutoLayoutEnded()
Called when the autolayout animation is finishedonMoveEnded()
Called when moving the position of data is finishedonPanEnded()
Called when grabbing translate topological graph is finishedonRectSelectEnded()
Called when the frame selection is finishedonTranslateEnded()
Called when translating animation is finishedonZoomEnded()
Called when zooming topological graph is finishedonPinchEnded()
Called when touchscreen pinching is finishedonSelectionChanged()
Called when the selection is changed, the selected data will show in the visible scale in the topological graphIn addition to calling the GraphView
encapsulated functions, users can also add native HTML
component listener events, such as the Node chapter example, through graphView.getView().addEventListener
to add listening to the bottom of the div
, the following code has a few points to note:
ht.Default.isTouchable? ' Touchend ': ' MouseUp '
judgment for the desktop and touchscreen terminals to do a comprehensive event type considerationsGraphview.getDataAt(e)
ht.Default.isDoubleClick(e)
judge click and double-click event distinctionIn the aforementioned HT
package of onDataClicked
and on**Clicked
events, are triggered in mousedown
and touchstart
, if needed to listen in mouseup
and touchend
after letting go of the event, you can listen to the HTML
raw events application is more in the case of click on the data to open the dialog box, if in the HT
package of the on*clicked
event processing directly invoke pop-up dialog, such operations, will affect the HT
subsequent interactive event processing , so interactive events affect the function of the interface, you can choose to listen in mouseup
and touchend
inside, in some cases even need to call ht.Default.callLater(function (){})
is handled in the following ways:
var eventType = ht.Default.isTouchable ? 'touchend' : 'mouseup';
graphView.getView().addEventListener(eventType, function (e){
var data = graphView.getDataAt(e);
if(data && ht.Default.isDoubleClick(e)){
alert(data.getName() + ' is double clicked.');
}
});
The following example customized to create Node
, Edge
and Shape
interactors:
Filtering mechanism through the whole HT
framework, and the use of filtering mechanism is particularly concentrated in GraphView
, the rational use of these filters can flexibly control whether the data visible, movable, editable, etc.
isMovable: function (data) {
if(data instanceof ht.Edge){
return false;
}
return this._movableFunc ? this._movableFunc(data) : true;
},
The above code is a simplified version of the GraphView.isMovable(data)
function, which is called by the moveinteractor
class to determine whether the data movable, this._movableFunc
property is set by GraphView.setMovableFunc(func)
, by the code is known Edge
is not allowed to drag by default, and then determine whether the movableFunc
function property is set, if the logic is set then whether the function movable is determined by this, finally returns true
.
So there are two ways to customize whether movable logic:
GraphView.setMovableFunc(func)
function property.GraphView.isMovable(data)
, in this way customers need to consider the original isMovable
implementation logic.The following list is a common filter function:
GraphView.isVisible(data)
GraphView.setVisibleFunc(func)
GraphView.isSelectable(data)
Returns GraphView.getSelectionModel().isSelectable(data)
in defaultGraphView.getSelectionModel().setFilterFunc(func)
GraphView.setSelectableFunc(func)
Internal called GraphView.getSelectionModel().setFilterFunc(func)
GraphView.isEditable(data)
GraphView.setEditableFunc(func)
GraphView.isRectEditable(data)
GraphView.setRectEditableFunc(func)
GraphView.isRotationEditable(data)
GraphView.setRotationEditableFunc(func)
GraphView.isAnchorEditable(data)
GraphView.setAnchorEditableFunc(func)
GraphView.isPointEditable(data)
GraphView.setPointEditableFunc(func)
Many users who have just started using HT
are puzzled by the filter set on the view component rather than the data model. If you control the filter on the model, all components that share the same model can only have the same filtering logic, and the HT
design idea enables different components to have different filtering logic.
In addition to setting filters on the view components, the GraphView
internal filtering mechanism also refers to the following style
attributes, which can change the control effect of the following style
on a single data:
2d.visible
: The default value is true
, control data is visible on GraphView
2d.selectable
: The default value is true
, control data is selectable on GraphView
2d.movable
: The default value is true
, control data is movable on GraphView
2d.editable
: The default value is true
, control data is editable on GraphView
2d.move.mode
: The default value is NULL, to control data move range, can be set to the following parameters:xy
: Can move in xy
plane x
: Moves only along the x
-axis y
: Moves only along the y
-axis Similarly, there are similar control parameters for Graph3dView
:
3d.visible
: The default value is true
, controls whether data is visible on Graph3dView
3d.selectable
: The default value is true
, controls whether data is selectable on Graph3dView
3d.movable
: The default value is true
, controls whether data is movable on Graph3dView
3d.editable
: The default value is true
, controls whether data is editable on Graph3dView
3d.move.mode
: The default value is null, controls data movement range, can be set as the following parameters:xyz
: Can move in 3d spacexy
: Moves only in xy
plane xz
: Moves only in xz
planeyz
: Moves only in yz
planex
: Moves only in x
-axis y
: Moves only in y
-axis z
: Moves only in z
-axis HT
Data
can be classified into three types of properties:
get/set
or is/set
type, such as getName()
, setName('ht')
and isExpaned()
, for common property operationsattr
type, gets and sets by getAttr(name)
and setAttr(key, value)
, this type is HT
reserved for users to store business datastyle
type, operate by getStyle(name)
and setStyle(name, value)
, the data style on GraphView
is controlled by this type propertyThe following code is the implementation of the style
related function in HT
, the default data _stylemap
is NULL, query the value will refer to ht.Style
global default value:
getStyleMap: function (){
return this._styleMap;
},
getStyle: function (name, checkDefault) {
if (checkDefault === undefined) {
checkDefault = true;
}
var value = this._styleMap ? this._styleMap[name] : undefined;
if (value === undefined && checkDefault) {
return ht.Style[name];
} else {
return value;
}
},
setStyle: function (name, newValue) {
if (!this._styleMap) {
this._styleMap = {};
}
var oldValue = this._styleMap[name];
if(newValue === undefined){
delete this._styleMap[name];
}else{
this._styleMap[name] = newValue;
}
if (this.fp('s:' + name, oldValue, newValue)) {
this.onStyleChanged(name, oldValue, newValue);
}
},
The following is the description of partial style
attribute, and more attributes are described in subsequent chapters:
image.stretch
Draws the drawing type of the image, the default value is fill
, can be set to uniform
or centerUniform
, refer to Imageingroup
Determines whether the data is included within the expanded Group
or not and the default value is true
opacity
Used to control the opacity of the entire data and the value range is 0~1
body.color
Setting this color will change the rendering of the center of the data, and can be customized by overloading the GraphView.getBodyColor(data)
function: image
of the Node
, it will automatically be drawn to the body.color
after the image is dyedshape
, if the background is to be filled, shape.background
is replaced by body.color
shape
, if no background is required, shape.border.color
is replaced by body.color
edge
connection type, edge.color
will be replaced by body.color
The GraphView
data is selected by default to display a selected border, and the effect of the selected border can be controlled by the select.*
related properties on the style.
select.color
The color of selected borderselect.width
The width of selected border, the default value is 1, if the value is 0
represents there were no borderselect.padding
The gap between selected border and Node.getRect()
, the default value is 2
, can be negative value, this attribute is meaningless in ht.Shape
and ht.Edge
select.type
The shape of selected border, the default value is rect
, refer to Shape Manual, and set to shadow
to appear as a shadow effectshadow.offset.x
Shadow horizontal offset, the default value is 3
shadow.offset.y
Shadow vertical offset, the default value is 3
shadow.blur
Shadow blur level, the default value is 6
The boder
style draws a border effect at the edge of the data, which is used for alarms or prompts, and can be customized by overloading the GraphView.getBorderColor(data)
.
border.color
The color of border, the default value is null for not drawingborder.width
The width of border, the default value is 2
border.padding
The gap between border and Node.getRect()
, the default value is 2
, can be set as negative value, this attribute is meaningless of ht.Shape
and ht.Edge
, etc.border.type
The shape of border, the default value is rect
, refer to Shape ManualThe Node
data on GraphView
, in addition to being displayed as a picture set by image
property, can also be set to vector for various polygonal types built into the HT
frame.
To be displayed in vector format can be achieved by setting the style
property of the Node
type data, the related style
property name is described as follows:
shape
String type, determines the shape of shape
, the default value is NULL, represents drawing by image
, the support type is as follows:rect
Rectanglecircle
Circleoval
OvalroundRect
Round rectanglestar
Startriangle
Trianglehexagon
Hexagonpentagon
Pentagondiamond
DiamondrightTriangle
Right Triangleparallelogram
Parallelogramtrapezoid
Trapezoidpolygon
Polygonarc
Arcshape.border.width
The width of border, the default value is 0
represents for not drawing the bordershape.border.color
The color of bordershape.border.cap
The type of border cap, selectable parameters are butt|round|square
shape.border.join
Border when two lines intersect create a type of cornor, optional parameters are bevel|round|miter
shape.border.pattern
The type of dashed line, Array
type, such as [5, 5]
shape.depth
Only make an effect in type rect
, the positive value means bulge, the negative value means depress, the default value is 0
shape.background
The fulfill color of background, null
means do not fulfill the backgroundshape.gradient
The gradient type:shape.background
to fulfill the background'linear.southwest', 'linear.southeast', 'linear.northwest', 'linear.northeast',
'linear.north', 'linear.south', 'linear.west', 'linear.east',
'radial.center', 'radial.southwest', 'radial.southeast', 'radial.northwest', 'radial.northeast',
'radial.north', 'radial.south', 'radial.west', 'radial.east',
'spread.horizontal', 'spread.vertical', 'spread.diagonal', 'spread.antidiagonal',
'spread.north', 'spread.south', 'spread.west', 'spread.east'
shape.gradient.color
The gradient color of background shape.repeat.image
Fulfill the image in repeat background, take notice the image in there do not support vectorshape.dash
Whether display dashed line or not, the default value is false
shape.dash.pattern
The type of the dashed line, the default value is [16, 16]
shape.dash.offset
The offset of the dashed line, the default value is 0
shape.dash.color
The color of the dashed lineshape.dash.width
The width of the dashed line, the default value is NULL means set its value is the same as shape.border.width's
shape.dash.3d
Whether display the 3d
effect of dashed line, the default value is false
shape.dash.3d.color
The 3d
effect colors of dashed line, default to white for null, the middle part of the line is the color when the 3d
effect is renderedshape.dash.3d.accuracy
Dashed 3d
effect precision, the lower the value 3d
progressive effect the better but affect performance, general situation without modificationshape.corner.radius
This parameter specifies the fillet radius of the roundrect
type, which is automatically adjusted by default and can set positive valuesshape.polygon.side
The side of polygon, the parameter specified the side of polygon
, the default value is 6
shape.arc.from
The begin of the arc, the default value is Math.PI
shape.arc.to
The end of the arc, the default value is 2*Math.PI
shape.arc.close
Whether the arc closed or not, the default value is true
shape.arc.oval
Whether the arc is oval or not, the default value is false
Refer to Position Manual
GraphView
datas can add text descriptions, such as the data setName(' Hello ht ')
, the Hello HT
text appears below the data.
The chapter position
Example text message is not set by setName
, but by setStyle(' label ', ' Hello HT ');
GraphView.getLabel
function decides the final display of label:
getLabel: function (data) {
var label = data.getStyle('label');
return label === undefined ? data.getName() : label;
},
Through the above code, style
on the label
property priority is higher than name
attribute, can overload GraphView.getLabel
function to change the text acquisition logic.
*View.getLabel
is designed to run through all of the HT
components in a similar way to ListView
, TreeView
, TabView
, etc., what is the different is that the default implementation logic for other components is to return the data.toLabel()
value, which is the default implementation of Data#toLabel()
.
toLabel: function (){
return this._displayName || this._name;
}
The above code shows that the displayName
attribute has a higher precedence than name
and style
attributes are generally used only GraphView
components, and other components do not consider label
attributes on style, when tree
and When Graphview
share the same DataModel
data model, you need to display different text on Tree
and GraphView
, in which case you can set the label
attribute on style
, or set the displayName
property can achieve a different effect, or directly overload the component's getLabel
function custom logic.
In addition to provide the label.*
properties, HT
also provide the label2.*
property to meet the need for an data to display double label, the label2
and label
attribute meaning is one-to-one correspondence:
label
Label, is NULL in defaultlabel.font
The font of label, such as: 10px sans-serif
label.color
The color of label, can be customized by GraphView.getLabelColor(data)
label.background
The background color of label, is empty in default, can be customized by GraphView.getLabelBackground(data)
label.opacity
The opacity of label, the value range from 0 to 1label.position
The position of label, reference positionlabel.offset.x
The horizontal offset of label means horizontal offset along the edge direction for Edge
label.offset.y
The vertical offset of label means horizontal offset along the edge direction for Edge
label.rotation
The rotation of label, such as setStyle('label.rotation', Math.PI/2)
label.max
The default value is NULL means do not limit the max width, if it is opposite value, then the text max display width will not beyond this valuelabel.align
The align of label, can be set to left
, center
or right
label.position.fixed
The default value is false
, it make an effect in the label of Edge
while it set as true
, to keep label in upper position or lower position of edge directionlabel.scale
The scale of label, the default value is 1
, refer to Position Manualnote
generally as the annotation of the data, there are hints and warnings, in the form of bubbles, can also be reduced to merge into a small callout.
The note
parameter controlled by the style
of the note.*
related property, and Label, in order to meet the requirements of an data double annotation, provides a note2.*
second callout parameter:
note
The content of note, can be customized by GraphView.getNote(data)
note.expanded
Whether to expanded the note or not, the default value is true
, set to false
to merge indent small calloutsnote.font
The font of note, such as: 10px sans-serif
note.color
The color of notenote.background
The background of note, can be customized by GraphView.getNoteBackground(data)
note.border.width
The width of note's border, the default value is 1
note.border.color
The note's border colornote.opacity
The opacity of note, the value range from 0
to 1
note.position
The position of note, reference positionnote.offset.x
The horizontal offset of notenote.offset.y
The vertical offset of notenote.max
The default value is NULL means do not limit the max width, if it is positive value, then the label's max display width should not beyond this valuenote.align
The align of note, can be set as left
, center
or right
note.toggleable
The default value is true
means it allowed double click to expand and merge, if it's false
, then it won't response double clicknote.scale
The scale of note, the default value is 1
, refer to Position icon
and note
are similar, show around the data, there are hints and warnings of the role, the different is the notes
shows the text, and icon
shows the picture or
Vector.
addStyleIcon(name, icons)
Adds a set of icon
, name
parameter to specify the name of this set icon
, icons
parameter describes icon
contentremoveStyleIcon(name)
Removes icons
corresponding to name
parameterAbove is ht.Data
provides the operation icon
function, the two methods actually modify the style
of the icons
attribute, the user can also set and get icons
through setStyle('icons', icons)
and getStyle('icons')
.
addStyleIcon
method the second parameter icons
is a JSON
format object whose properties are as follows:
names
An array that contains multiple strings, each corresponding to a picture or vectorvisible
Whether the group picture is displayedfor3d
Components that represent this group of pictures for Graph3dView
display and are not displayed in the GraphView
componentposition
Specified the position of icons
, refer to PositionoffsetX
The icons
position on the position
basis, the horizontal offset offsetX
offsetY
The icons
position on the position
basis, the vertical offset offsetY
direction
The preferred value is west
, east
, north
, south
, which specifies the direction of icons
keepOrien
When the line direction changes, icons
automatically adjusts the direction to maintain the best reading effect(such as text), and this property is true
to prevent automatic direction adjustmentgap
Specified the gap of icon
rotation
Specified the rotation of icon
rotationFixed
This parameter allows the icon to rotate regardless of the Edge
connection angle, only according to rotation
, the default value is false
width
Specified each icon's widthheight
Specified each icon's heightopacity
The range of value from 0
to 1
stretch
Icon drawing stretch mode, the default value is fill
, can be set as uniform
and centerUniform
positionFixed
The default value is false
, if it's true
, it has an effect on type of Edge
, keep the icon in the upper position or lower positionedge.addStyleIcon("flags", {
position: 17,
direction: 'east',
offsetX: -26,
gap: 10,
names: ['China', 'Spain', 'USA']
});
edge.addStyleIcon("arrow1", {
position: 2,
width: 50,
height: 25,
keepOrien: true,
names: ['arrow']
});
edge.addStyleIcon("arrow2", {
position: 4,
width: 50,
height: 25,
positionFixed: true,
names: ['arrow']
});
In the above example, the Edge
object is set by the addStyleIcon
way, with a row of three flag icons of [' China ', ' Spain ', ' USA ']
, and two arrow
vector icons, which can be replaced by the following code:
edge.setStyle('icons', {
flags: {
position: 17,
direction: 'east',
offsetX: -26,
gap: 10,
names: ['China', 'Spain', 'USA']
},
arrow1: {
position: 2,
width: 50,
height: 25,
keepOrien: true,
names: ['arrow']
},
arrow2: {
position: 4,
width: 50,
height: 25,
positionFixed: true,
names: ['arrow']
}
});
In the example node1
node1.setStyle("icons", ...)
registers a three-vector orb, by overloading graphView.onDataClicked
and combining graphView.getIconInfoAt
functions to get clicked on the specific icon
icons to change the line arrow color
graphView.onDataClicked = function (data, e) {
if(data === node1){
var info = this.getIconInfoAt(e, data);
if(info){
edge.a('arrow.color', info.name.comps[0].background);
node1.a('select.index', info.index);
}
}
};
Group type datas can be set to the following styles:
group.type
The default is NULL, the top section title
text title while group expanded, the lower part is divided into rectangular fill, also can be set to oval
and rect
and other shapes, optional values refer to Shape, the label
is no longer displayed as title
when set to non-empty type and is displayed and controlled using the normal label
style attributegroup.image
The default value is NULL, rendering picture effects for displaying group expansiongroup.image.stretch
Group expand picture stretch mode, the default value is fill
, it can also be uniform
or centerUniform
group.repeat.image
Fill the repeat image to the background, notice that the image in there does not supported vectorgroup.position
The position of group, the default value is 17
means in the centergroup.toggleable
Decided whether allow double click to switch the group to expand or merge or not, the default is true
group.padding
The padding between the four boundary and the child data after expand the group, the default value is 8
group.padding.left
The padding between the left boundary and the child data after expand the group, the default value is 0
group.padding.right
The padding between the right boundary and the child data after expand the group, the default value is 0
group.padding.top
The padding between the top boundary and the child data after expand the group, the default value is 0
group.padding.bottom
The padding between the bottom boundary and the child data after expand the group, the default value is 0
group.title.font
The title's
font after expand the group, only works while group.type
is emptygroup.title.color
The color of title
after expand the group, only works while group.type
is emptygroup.title.background
The background of title
after expand the group, only works while group.type
is emptygroup.title.align
The align of title
after the group expand, the default value is left
, and can be set as center
or right
group.depth
The depth of border after expand the group, 0
means plane effect, the positive value means the convex effect, the negative value means the dent effect, the default value is 1
group.background
The background after expand the group group.gradient
The gradient after expand the group, selectable value refer to Shapegroup.gradient.color
The gradient color after expand the groupgroup.border.color
The border color after expand the groupgroup.border.width
The border width after expand the groupgroup.border.pattern
The border pattern is dash after expand the group, type Array
, such as [5, 5]
group.border.cap
The border cap style after expand the group, selectable value butt|round|square
group.border.join
Group expanded border creates a corner type when two lines intersect, optional parameters are bevel|round|miter
edge.type
the type of string, decided the style of edge: undefined
The default value, represents the connection into a straight line, many times automatically into groups, from the ring to draw a circlepoints
type will be determined by the edge.points
property to draw a polyline or curveedge.points
The default value is NULL, can be set as type ht.List
or Array
{x:10, y:20}
edge.segments
Describe the type of ht.List
or Array
, should be considered between the start point and the end point, the array element is integer: moveTo
, occupied 1
point, represents the start of a new pathlineTo
, occupied 1
point, represents link the last point to this pointquadraticCurveTo
, occupied 2
points, the first point is the control point of the carve line, the second point is the end of the carve linebezierCurveTo
, occupied 3
points, the first and the second are the control points of the curve line, and the last point is the end of the curve lineclosePath
, do not occupied any point, represents this path drawing is done, and close the shape to the begin pointedge.color
The color of the lineedge.width
The width of the line, the default value is 2
edge.offset
The distance between the top of the edge and the center of the data, the default value is 20
edge.group
The line group can be classified by this attribute, to achieve the independence expand effect, the default value is 0
edge.gap
The gap between the group line, the default value is 12
edge.toggleable
Decided whether double click can switch expand and merge or not, the default value is true
edge.center
Decided whether the edge come together to the center or not, the default value is false
edge.pattern
Display dashed edge style, type Array
, such as [5, 5]
edge.expanded
Judging the status is expand or merge, only can be read on common, can call Edge.toggle()
Synchronous changing other line parameteredge.cap
The style of the edge's cap, selectable parameter butt | round | square
edge.join
The type of the corner while two lines join together, selectable parameter bevel|round|miter
edge.source.position
The default value is 17
, the begin point is the related position of the begin dataedge.source.offset.x
The default value is 0
, the horizontal offset of the begin pointedge.source.offset.y
The default value is 0
, the vertical offset of the begin pointedge.target.position
The default value is 17
, the end point is the related position of the end dataedge.target.offset.x
The default value is 0
, the horizontal offset of the end pointedge.target.offset.y
The default value is 0
, the vertical offset of the end point edge.dash
Whether display the dash line or not, the default value is false
edge.dash.pattern
The type of dash line, the default value is [16, 16]
edge.dash.offset
The offset of the dash line, the default value is 0
edge.dash.color
The color of the dash line edge.dash.width
The width of the dash line, the default value is empty means use the value of the edge.width
edge.dash.3d
Whether to display the dash line's 3d
effect, the default value is false
edge.dash.3d.color
The color of the dash line's 3d
effect, if it's empty and the default value is white, the edge's middle part is this coloredge.dash.3d.accuracy
The accuracy of the 3d
dash line, the value is more small the 3d
gradient effect is more good but influence the performance, it do not need to change in commonFor the line of the
edge.type
ispoints
, whileedge.center
isfalse
, and theedge.offset
is0
, the begin of the line and the end of the line will cut by the relative node's rectangle boundary.
Object-Oriented JavaScript
The development of HTML5
applications, especially enterprise applications, JavaScript
almost occupies the bulk of the code, so the need to master the JS
syntax, internal classes and functions, and other object-oriented language different class inheritance patterns, as well as DOM
basic operations, this book is a good choice for this knowledge.
Pro JavaScript Design Patterns
Design patterns have been widely used in a variety of software development, but many familiar design patterns, with the implementation of the JS language and Java
and C#
and other traditional object language implementation of the way there are many differences, resulting in many beginners often don't know how to do, or the design of the model is not the best JS
practice, the book on the interface, single class, inheritance, factories and other modes of the JS
language can be selected to achieve the way.
CSS3: The Missing Manual
HT products provide a wealth of enterprise application components, to make a routine case only with JS is enough, but the more beautiful interface effect can not be separated from the CSS
technology to grasp and use of HT product depth customization expansion is often inseparable from the CSS
technology. The book's 12th edition on the rave, the third version of the HTML5
has been revised, deleted previously for the old version of the IE
browser chapters, added to the CSS3
new features of the chapter space, is a classic reading that worth front-end programmers to read.
Responsive Web Design with HTML5 and CSS3 Responsive Web Design(RWD)
is a new area of front-end technology, the first originator of the concept of "responsive Web designs" is Responsive Web Designer responsive-web-design).
A good page not only in the PC
browser, but also need to consider the user's use of mobile phones or tablets to browse the rendering effect, so programmers and designers need to consider the different screen size and other complex situations, to maintain the desktop mouse and mobile device gesture operation has a better user experience, this book has played a role, can let you understand the current common RWD
design skills, began to focus on this aspect of technology and use.
We recommend reading books to system learning a technology, but it takes months or even years to write an excellent classic book, and it is highly recommended that three weekly subscriptions for front-end technology be developed for the latest technical information in order to keep abreast of the front-line programmers, and just look at the three weekly emails, and will not miss the interesting events that are taking place on earth's front-end development field: