Supercharge Your Innovation With Domain-Expert AI Agents!

Layout processing method and device for tree-shaped Canvas

A canvas and layout technology, applied in the computer field, can solve the problems of low rendering efficiency of canvas and unstable vertical coordinates.

Active Publication Date: 2020-05-05
SUNING CLOUD COMPUTING CO LTD
View PDF3 Cites 4 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0003] In the layout process of the traditional tree-like Canvas canvas, the coordinates of the root node are usually set according to the center point of the canvas, and each time a new child node is added, the coordinates of the child nodes are set according to the coordinates (x, y) of the parent node. Take the layout as an example, the vertical coordinates of the parent node are not fixed, each time a new child node is added to the parent node, the vertical coordinates of the parent node will be set according to the cumulative height of all the child nodes of the parent node, then the parent node's The change must also cause a higher-level position change, and so on. It can be seen that this method of rendering first, then adjusting, and then rendering results in lower canvas rendering efficiency

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Layout processing method and device for tree-shaped Canvas
  • Layout processing method and device for tree-shaped Canvas
  • Layout processing method and device for tree-shaped Canvas

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0064] Embodiments of the present invention provide a layout processing method of a tree-like Canvas canvas, which can be applied to canvas components, such as figure 1 As shown, the method may include the steps of:

[0065] Step S11, acquiring the layout parameters of the Canvas and the tree structure data of the Canvas.

[0066] Among them, the layout parameter is used to indicate the layout direction of the Canvas canvas, and the layout parameter can be preset by the user before calling the canvas component, for example, setting the layout parameter to perform left and right layout on the DOM (Document Object Model, Document Object Model) object in the Canvas canvas Or layout up and down.

[0067] Wherein, the tree structure data can be data in JSON format or data in other formats, and the tree structure data includes node data with a parent-child relationship.

[0068] Specifically, the implementation process of step S11 may include:

[0069] Obtain the canvas configura...

Embodiment 2

[0102] Embodiments of the present invention provide a layout processing method of a tree-like Canvas canvas, which can be applied to canvas components, such as Figure 4 As shown, the method may include the steps of:

[0103] Step S41, acquiring the layout parameters of the Canvas and the tree structure data of the Canvas.

[0104] Specifically, for this process, reference may be made to step S11 in the first embodiment above, which will not be repeated here.

[0105] Step S42, creating virtual DOM objects for nodes at all levels in the tree structure data, and calculating the width and height of each virtual DOM object, and recording them as the virtual width and virtual height of nodes at all levels.

[0106] Specifically, for this process, reference may be made to step S12 in the first embodiment above, which will not be repeated here.

[0107] Step S43, if the layout parameter indicates the upper and lower layout of the Canvas, then traverse the nodes at all levels from ...

Embodiment 3

[0119] An embodiment of the present invention provides a layout processing device for a tree-like Canvas, such as Figure 5 As shown, the device may include:

[0120] Data acquisition module 51, for obtaining the layout parameter of Canvas canvas and the tree structure data of Canvas canvas;

[0121] Object creation module 52, is used for creating virtual DOM object respectively to all levels of nodes in the tree structure data, and calculates the width and the height of each virtual DOM object, is recorded as the virtual width and the virtual height of all levels of nodes;

[0122] The recursive calculation module 53 is used to traverse the nodes at all levels from the root node if the layout parameter indicates that the Canvas canvas is arranged left and right, and when adding a level of child nodes, reverse recursive calculation is performed according to the virtual height of the child nodes of the level The new virtual height of the previous parent node until the new virt...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a layout processing method and device for tree-shaped Canvas, and belongs to the technical field of computers. The method comprises the steps of obtaining layout parameters andtree structure data of a Canvas; respectively creating a virtual DOM object for each level of node in the tree structure data, calculating the width and the height of each virtual DOM object, and recording the width and the height as the virtual width and the virtual height of each level of node; if the layout parameters indicate that the Canvas are arranged left and right, traversing from the root node, and performing reverse recursion according to the virtual height of the child node of the stage to calculate the new virtual height of the father node of the previous stage every time the child node of the stage is added until the new virtual height of the root node is calculated in a recursion manner; according to the virtual width and the new virtual height of each level of node, obtaining first position information of each level of node, and respectively creating a real DOM object for each level of node; and rendering the real DOM object corresponding to each level of node to the Canvas according to the first position information of each level of node. The canvas rendering efficiency can be improved.

Description

technical field [0001] The present invention relates to the field of computer technology, in particular to a method and device for processing the layout of a tree-like Canvas. Background technique [0002] At present, common chart libraries are usually drawn based on HTML5 Canvas (canvas). Canvas is an important new element in HTML5, which is specially used to draw images. Placing a Canvas element on a web page is equivalent to placing a " Canvas” in which images can be drawn. More specifically, text (ie text information), lines (such as straight lines, curves or arcs, etc.), rectangles, circles, etc. can be drawn on the canvas. [0003] In the layout process of the traditional tree-like Canvas canvas, the coordinates of the root node are usually set according to the center point of the canvas, and each time a new child node is added, the coordinates of the child nodes are set according to the coordinates (x, y) of the parent node. Take the layout as an example, the vertic...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): G06F8/38
CPCG06F8/38
Inventor 程小敏杨成颖孙迁
Owner SUNING CLOUD COMPUTING CO LTD
Features
  • R&D
  • Intellectual Property
  • Life Sciences
  • Materials
  • Tech Scout
Why Patsnap Eureka
  • Unparalleled Data Quality
  • Higher Quality Content
  • 60% Fewer Hallucinations
Social media
Patsnap Eureka Blog
Learn More