A canvas automatic layout method, system, device and storage medium
By automatically judging and adjusting the control overlap problem in the canvas interface, the problem of control layout management defects and difficulty in automatic adjustment in the existing technology is solved, and efficient configuration debugging and implementation is achieved.
Patent Information
- Application Number
- CN202111646369.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2041-12-29
AI Technical Summary
In the prior art, the canvas interface that is developed through controls has layout management defects, resulting in incomplete display of control stacking and control bit number names, and cannot be automatically adjusted, requiring manual optimization, resulting in inefficient configuration debugging and implementation.
By obtaining the position information of the control, determining the control area, traversing the control area to determine whether it overlaps. If it overlaps, perform a preset offset operation to ensure that the control does not overlap, and calculate the scaling ratio to achieve equal scale scaling and accurate position adjustment.
Automatic adjustment of the canvas interface layout is realized, configuration debugging and implementation efficiency is improved, the need for manual adjustment is avoided, and adjustment accuracy is improved.
Smart Images

Figure CN114265585B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of interface layout optimization, and in particular to a canvas automatic layout method, system, device and storage medium. Background Art
[0002] Controls are visual components that encapsulate data and methods and are used to develop applications. However, due to layout management defects in the existing canvas interface for program development using controls, the converted interface has problems such as control stacking and incomplete display of control bit names. In addition, the existing technology cannot automatically adjust the above problems, and the layout of the canvas interface needs to be further optimized manually, resulting in low efficiency in configuration debugging and implementation. Summary of the invention
[0003] The purpose of the embodiments of the present invention is to provide a canvas automatic layout method, system, device and storage medium to achieve the invention purpose of automatically adjusting the canvas interface layout and improving configuration debugging and implementation efficiency. The specific technical solution is as follows:
[0004] A canvas automatic layout method, the method comprising:
[0005] The position information of a first number of controls is obtained, and a control area of each of the controls is determined according to the position information.
[0006] Traverse the control area of each of the controls, and determine one by one whether the untraversed controls overlap with the minimum valid area. If so, perform offset operations on the untraversed controls that overlap with the minimum valid area one by one according to a preset offset method, so that each of the untraversed controls does not overlap with the minimum valid area, wherein the minimum valid area is the minimum rectangular area jointly occupied by the control being traversed and the traversed controls.
[0007] After traversing the first number of controls, the initial spacing value between each control and the adjacent controls in the final valid area is obtained, wherein the final valid area is the minimum valid area jointly occupied by the first number of controls.
[0008] The scaling ratio of scaling the final effective area to the canvas display area is calculated.
[0009] An initial area of the initial control in the canvas display area is determined according to the position information of the initial control and the zoom ratio, wherein the initial control is the first control to be traversed.
[0010] The positions of the other controls in the canvas display area are determined according to the initial area, the initial spacing value, the zoom ratio and the position information of the other traversed controls, wherein the other controls are controls other than the initial controls among the first number of traversed controls.
[0011] Optionally, after the traversal of the first number of controls is completed, obtaining an initial spacing value between each control and an adjacent control in the final valid area includes:
[0012] The coordinates of the positioning points of each of the controls are extracted from the position information of each of the controls in the final valid area.
[0013] The adjacent controls of each control are determined according to the traversal order in the traversal process.
[0014] The coordinates of the positioning point of each of the controls are subtracted from the coordinates of the positioning point of each of the corresponding adjacent controls to obtain the initial spacing value between each of the controls and the adjacent controls corresponding to the control.
[0015] Optionally, determining the initial area of the initial control in the canvas display area according to the position information of the initial control and the zoom ratio includes:
[0016] The positioning point coordinates and size information are obtained from the position information of the initial control.
[0017] The anchor point coordinates of the initial control are replaced with the coordinate system origin coordinates of the canvas display area.
[0018] The size information of the initial control is divided by the zoom ratio to obtain the size information of the initial control in the canvas display area.
[0019] The initial area of the initial control in the canvas display area is determined according to the coordinates of the anchor point passing through the initial control and the size information of the initial control in the canvas display area.
[0020] Optionally, determining the position of the other controls in the canvas display area according to the initial area, the initial spacing value, the zoom ratio, and the position information of the traversed other controls includes:
[0021] The initial spacing value is divided by the zoom ratio to obtain a final spacing value in the canvas display area.
[0022] According to the positioning point coordinates of the initial area, the final spacing value and the traversal order, the final positioning point coordinates of each of the other controls are obtained in sequence.
[0023] According to the position information of the other controls, the size information of each of the other controls is acquired, and the size information of each of the other controls is divided by the zoom ratio to obtain the final size information of each of the other controls in the canvas display area.
[0024] The positions of the other controls in the canvas display area are determined according to the final positioning point coordinates and the final size information.
[0025] Optionally, the step of determining whether the untraversed controls overlap with the minimum valid area one by one includes:
[0026] Using a preset overlap judgment algorithm, determine one by one whether the position information of the untraversed control meets the preset overlap condition with the minimum effective area. If yes, determine that the untraversed control overlaps with the minimum effective area. Otherwise, determine that the untraversed control does not overlap with the minimum effective area, wherein the preset overlap condition is: the horizontal coordinate of the first positioning point of the predicted overlapping area is not greater than the horizontal coordinate of the second positioning point of the predicted overlapping area, and the vertical coordinate of the first positioning point is not greater than the vertical coordinate of the second positioning point, the horizontal coordinate of the first positioning point is the maximum value of the horizontal coordinate of the positioning point of the minimum effective area and the horizontal coordinate of the positioning point of the untraversed control, the vertical coordinate of the first positioning point is the maximum value of the vertical coordinate of the positioning point of the minimum effective area and the vertical coordinate of the positioning point of the untraversed control, the horizontal coordinate of the second positioning point is the minimum value of the horizontal coordinate of the size point of the minimum effective area and the size point of the untraversed control, and the vertical coordinate of the second positioning point is the minimum value of the horizontal coordinate of the size point of the minimum effective area and the size point of the untraversed control.
[0027] Optionally, the calculating a scaling ratio of scaling the final valid area to the canvas display area includes:
[0028] The first size information of the canvas display area is obtained, wherein the first size information includes: horizontal size information of the canvas display area and vertical size information of the canvas display area.
[0029] Acquire second size information of the final valid area, wherein the second size information includes: transverse size information of the final valid area and longitudinal size information of the final valid area.
[0030] The horizontal size information of the final effective area is divided by the horizontal size information of the canvas display area to obtain a horizontal zoom ratio.
[0031] The vertical size information of the final effective area is divided by the vertical size information of the canvas display area to obtain a vertical zoom ratio.
[0032] A canvas automatic layout system, the system comprising:
[0033] An information acquisition module, used to acquire position information of a first number of controls, and determine a control area of each of the controls according to the position information;
[0034] A position adjustment module, used for traversing the control area of each of the controls, determining one by one whether the untraversed controls overlap with the minimum effective area, and if so, performing an offset operation on the untraversed controls overlapping with the minimum effective area one by one according to a preset offset method, so that each of the untraversed controls does not overlap with the minimum effective area, wherein the minimum effective area is the minimum rectangular area jointly occupied by the control being traversed and the traversed controls;
[0035] A spacing acquisition module, used for acquiring an initial spacing value between each control and an adjacent control in a final valid area after traversing the first number of controls, wherein the final valid area is the minimum valid area jointly occupied by the first number of controls;
[0036] A zoom ratio acquisition module, used for calculating the zoom ratio of scaling the final effective area to the canvas display area;
[0037] A reference positioning module, used to determine an initial area of the initial control in the canvas display area according to the position information of the initial control and the zoom ratio, wherein the initial control is the first control traversed;
[0038] A position determination module is used to determine the positions of the other controls in the canvas display area according to the initial area, the initial spacing value, the zoom ratio and the position information of the other traversed controls, wherein the other controls are controls other than the initial controls among the first number of traversed controls.
[0039] Optionally, the spacing acquisition module is configured as follows:
[0040] The coordinates of the positioning points of each of the controls are extracted from the position information of each of the controls in the final valid area.
[0041] The adjacent controls of each control are determined according to the traversal order in the traversal process.
[0042] The coordinates of the positioning point of each of the controls are subtracted from the coordinates of the positioning point of each of the corresponding adjacent controls to obtain the initial spacing value between each of the controls and the adjacent controls corresponding to the control.
[0043] Optionally, the reference positioning module is configured as:
[0044] The positioning point coordinates and size information are obtained from the position information of the initial control.
[0045] The anchor point coordinates of the initial control are replaced with the coordinate system origin coordinates of the canvas display area.
[0046] The size information of the initial control is divided by the zoom ratio to obtain the size information of the initial control in the canvas display area.
[0047] The initial area of the initial control in the canvas display area is determined according to the coordinates of the anchor point passing through the initial control and the size information of the initial control in the canvas display area.
[0048] Optionally, the location determination module is configured to:
[0049] The initial spacing value is divided by the zoom ratio to obtain a final spacing value in the canvas display area.
[0050] According to the positioning point coordinates of the initial area, the final spacing value and the traversal order, the final positioning point coordinates of each of the other controls are obtained in sequence.
[0051] According to the position information of the other controls, the size information of each of the other controls is acquired, and the size information of each of the other controls is divided by the zoom ratio to obtain the final size information of each of the other controls in the canvas display area.
[0052] The positions of the other controls in the canvas display area are determined according to the final positioning point coordinates and the final size information.
[0053] Optionally, the position adjustment module is configured as follows:
[0054] Using a preset overlap judgment algorithm, determine one by one whether the position information of the untraversed control meets the preset overlap condition with the minimum effective area. If yes, determine that the untraversed control overlaps with the minimum effective area. Otherwise, determine that the untraversed control does not overlap with the minimum effective area, wherein the preset overlap condition is: the horizontal coordinate of the first positioning point of the predicted overlapping area is not greater than the horizontal coordinate of the second positioning point of the predicted overlapping area, and the vertical coordinate of the first positioning point is not greater than the vertical coordinate of the second positioning point, the horizontal coordinate of the first positioning point is the maximum value of the horizontal coordinate of the positioning point of the minimum effective area and the horizontal coordinate of the positioning point of the untraversed control, the vertical coordinate of the first positioning point is the maximum value of the vertical coordinate of the positioning point of the minimum effective area and the vertical coordinate of the positioning point of the untraversed control, the horizontal coordinate of the second positioning point is the minimum value of the horizontal coordinate of the size point of the minimum effective area and the size point of the untraversed control, and the vertical coordinate of the second positioning point is the minimum value of the horizontal coordinate of the size point of the minimum effective area and the size point of the untraversed control.
[0055] Optionally, the scaling ratio acquisition module is configured as follows:
[0056] The first size information of the canvas display area is obtained, wherein the first size information includes: horizontal size information of the canvas display area and vertical size information of the canvas display area.
[0057] Acquire second size information of the final valid area, wherein the second size information includes: transverse size information of the final valid area and longitudinal size information of the final valid area.
[0058] The horizontal size information of the final effective area is divided by the horizontal size information of the canvas display area to obtain a horizontal zoom ratio.
[0059] The vertical size information of the final effective area is divided by the vertical size information of the canvas display area to obtain a vertical zoom ratio.
[0060] A canvas automatic layout device, the device comprising:
[0061] processor;
[0062] A memory for storing instructions executable by the processor.
[0063] The processor is configured to execute the instructions to implement any of the above-mentioned canvas automatic layout methods.
[0064] A computer storage medium. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the device is enabled to execute any one of the above-mentioned methods for automatic layout of canvas.
[0065] The embodiment of the present invention provides a canvas automatic layout method, system, device and storage medium. By presetting whether the control overlaps with the minimum effective area, and using a preset offset method to offset the overlapping control, the present invention realizes automatic adjustment of the control position compared to the prior art that requires manual adjustment of the overlapping control. And by recording the order of traversing the controls, the adjacent controls of each control can be determined, and a reference can be provided for the subsequent adjustment of the control position, so that the present invention improves the accuracy of the subsequent adjustment of the control position. At the same time, the present invention can realize proportional scaling of the controls in the final effective area by calculating the scaling ratio, and accurately adjust the position of the control scaled to the canvas display area according to the initial spacing value and the scaling ratio. Finally, according to the initial area, the initial spacing value, the scaling ratio and the position information of other controls traversed, the automatic adjustment of the control position in the canvas display area is realized. It can be seen that compared with the prior art, the present invention needs to manually adjust the control position manually, so as to realize the invention purpose of automatically adjusting the layout of the canvas interface, thereby improving the configuration debugging and implementation efficiency.
[0066] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0068] Figure 1 A flowchart of a canvas automatic layout method provided by an embodiment of the present invention;
[0069] Figure 2 A schematic diagram of location information provided for an optional embodiment of the present invention;
[0070] Figure 3 A schematic diagram of performing an offset operation on overlapping controls provided in accordance with a specific embodiment of the present invention;
[0071] Figure 4 A schematic diagram of automatic layout of a canvas provided for another specific embodiment of the present invention;
[0072] Figure 5 A block diagram of a canvas automatic layout system provided for an optional embodiment of the present invention;
[0073] Figure 6 A block diagram of a canvas automatic layout device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0074] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0075] The embodiment of the present invention provides a canvas automatic layout method, such as Figure 1 As shown, the method includes:
[0076] S101. Obtain position information of a first number of controls, and determine a control area of each control according to the position information.
[0077] It should be noted that the canvas automatic layout method provided by the embodiment of the present invention can be applied to fields such as web design and industrial control system design. There are no excessive restrictions on specific application scenarios, so as to achieve the purpose and technical effects of the present invention. In order to facilitate the explanation of the technical solution of the present invention, the following embodiments all use the function block diagram (FBD) as the application scenario.
[0078] Optionally, in an optional embodiment of the present invention, the above-mentioned control may be a function block (Function Block) or a reference label encapsulating a program or data in the above-mentioned FBD program.
[0079] Optional, in Figure 2 In another optional embodiment of the present invention shown, the above-mentioned position information may include the coordinates of the positioning point 201 and the coordinates of the size point 202 of each control. Through the positioning point 201 and the size point 202, the position and control area of a control can be uniquely determined in the canvas. The above-mentioned position information can be obtained by reading the control parameters in the imported file. Among them, the type of the imported file can be a comma-separated value file (Comma-Separated Values, CSV) or an extensible markup language file (eXtensible Markup Language, XML).
[0080] S102, traverse the control area of each control, and determine whether the untraversed controls overlap with the minimum valid area one by one. If so, perform offset operations on the untraversed controls that overlap with the minimum valid area one by one according to a preset offset method, so that each untraversed control does not overlap with the minimum valid area, wherein the minimum valid area is the minimum rectangular area jointly occupied by the control being traversed and the traversed controls.
[0081] Optionally, in an optional embodiment of the present invention, the preset offset method can be an algorithm for controlling a non-traversed control to make a horizontal or vertical displacement when it is determined that the non-traversed control overlaps with the minimum effective area. The distance of the horizontal or vertical displacement can be set according to the size information of the control or the size information of the canvas, and there are no excessive restrictions. The size information of the control includes but is not limited to the text width of the function block name, the text width of the function block bit number name, the maximum value of the hard-coded width of the control text, etc. The present invention realizes automatic adjustment of the control position by determining whether the control overlaps with the minimum effective area and performing an offset operation on the overlapping control using a preset offset method.
[0082] Optionally, in another optional embodiment of the present invention, the above traversal process can record the order of traversing the controls. By recording the order of traversing the controls, the adjacent controls of each control can be determined, and a reference can be provided for subsequent adjustment of the control position, so that the present invention improves the accuracy of subsequent adjustment of the control position.
[0083] S103. After traversing the first number of controls, obtain the initial spacing value between each control and the adjacent controls in the final valid area, wherein the final valid area is the minimum valid area jointly occupied by the first number of controls.
[0084] Optionally, in an optional embodiment of the present invention, the above method of obtaining the initial spacing value can be: in the order of the above traversal, starting from the first control traversed, the horizontal and vertical coordinates of the positioning points of each control and the adjacent control are subtracted correspondingly to obtain the initial spacing values between each control and the adjacent control in the horizontal and vertical directions.
[0085] S104: Calculate a scaling ratio for scaling the final effective area to the canvas display area.
[0086] Optionally, in an optional embodiment of the present invention, since the canvas size in the above-mentioned final effective area is inconsistent with the canvas size of the canvas display area, the prior art will have a phenomenon of chaotic distribution and overlap of controls after converting the final effective area to the canvas display area. Therefore, the present invention can achieve proportional scaling of controls in the final effective area by calculating the scaling ratio, and accurately adjust the position of controls scaled to the canvas display area according to the initial spacing value and the scaling ratio.
[0087] S105. Determine an initial area of the initial control in the canvas display area according to the position information and the zoom ratio of the initial control, wherein the initial control is the first control to be traversed.
[0088] Optionally, in an optional embodiment of the present invention, the initial area of the initial control in the canvas display area is used as a reference, and the coordinates of the positioning points of each control in the canvas display area are determined according to the above-mentioned initial spacing value, zoom ratio and traversal order.
[0089] S106. Determine the positions of other controls in the canvas display area according to the initial area, the initial spacing value, the zoom ratio, and the position information of other traversed controls, wherein the other controls are controls other than the initial control in the first number of traversed controls.
[0090] The present invention determines whether the control overlaps with the minimum effective area by preset, and uses the preset offset method to offset the overlapping control, so that the present invention realizes automatic adjustment of the control position compared with the prior art that requires manual adjustment of the overlapping control. And by recording the order of traversing the controls, the adjacent controls of each control can be determined, and a reference can be provided for the subsequent adjustment of the control position, so that the present invention improves the accuracy of the subsequent adjustment of the control position. At the same time, the present invention can realize the proportional scaling of the controls in the final effective area by calculating the scaling ratio, and accurately adjust the position of the controls scaled to the canvas display area according to the initial spacing value and the scaling ratio. Finally, according to the initial area, the initial spacing value, the scaling ratio and the position information of other controls traversed, the automatic adjustment of the control position in the canvas display area is realized. It can be seen that compared with the prior art, the present invention needs to have a manual adjustment method for the control position, so as to realize the automatic adjustment of the canvas interface layout, thereby improving the invention purpose of configuration debugging and implementation efficiency.
[0091] Optionally, after traversing the first number of controls, obtaining the initial spacing value between each control and the adjacent controls in the final valid area includes:
[0092] From the position information of each control in the final valid area, extract the anchor point coordinates of each control.
[0093] Determine the adjacent controls of each control according to the traversal order during the traversal process.
[0094] The coordinates of the anchor point of each control are subtracted from the coordinates of the anchor point of each corresponding adjacent control to obtain the initial spacing value between each control and the adjacent control corresponding to the control.
[0095] Optionally, determining an initial area of the initial control in the canvas display area according to the position information and the zoom ratio of the initial control includes:
[0096] Get the anchor point coordinates and size information from the initial control's position information.
[0097] Replace the initial control's anchor point coordinates with the coordinate system origin coordinates of the canvas display area.
[0098] The size information of the initial control is divided by the zoom ratio to obtain the size information of the initial control in the canvas display area.
[0099] The initial area of the initial control in the canvas display area is determined according to the coordinates of the anchor point passing through the initial control and the size information of the initial control in the canvas display area.
[0100] Optionally, the positions of other controls in the canvas display area are determined according to the initial area, initial spacing value, zoom ratio, and position information of other traversed controls, including:
[0101] Divide the initial spacing value by the zoom ratio to get the final spacing value in the canvas display area.
[0102] According to the anchor point coordinates of the initial area, the final spacing value and the traversal order, the final anchor point coordinates of each other control are obtained in turn.
[0103] According to the position information of other controls, the size information of each other control is obtained, and the size information of each other control is divided by the zoom ratio to obtain the final size information of each other control in the canvas display area.
[0104] The positions of other controls in the canvas display area are determined based on the final anchor point coordinates and final size information.
[0105] Optionally, determine whether the untraversed controls overlap with the minimum valid area one by one, including:
[0106] Using a preset overlap judgment algorithm, determine one by one whether the position information of the untraversed control meets the preset overlap condition with the minimum effective area. If yes, determine that the untraversed control overlaps with the minimum effective area. Otherwise, determine that the untraversed control does not overlap with the minimum effective area, wherein the preset overlap condition is: the horizontal coordinate of the first positioning point of the predicted overlapping area is not greater than the horizontal coordinate of the second positioning point of the predicted overlapping area, and the vertical coordinate of the first positioning point is not greater than the vertical coordinate of the second positioning point, the horizontal coordinate of the first positioning point is the maximum value of the horizontal coordinate of the positioning point of the minimum effective area and the horizontal coordinate of the positioning point of the untraversed control, the vertical coordinate of the first positioning point is the maximum value of the vertical coordinate of the positioning point of the minimum effective area and the vertical coordinate of the positioning point of the untraversed control, the horizontal coordinate of the second positioning point is the minimum value of the horizontal coordinate of the size point of the minimum effective area and the size point of the untraversed control, and the vertical coordinate of the second positioning point is the minimum value of the horizontal coordinate of the size point of the minimum effective area and the size point of the untraversed control.
[0107] Optional, please combine Figure 3 A specific embodiment of the present invention shown in a, b and c of Figure 1 The step S102 shown is understood as follows:
[0108] There are currently three square controls, located as follows Figure 3 As shown in a. The coordinates of the positioning point of control A are minA(0, 0), the coordinates of the size point are maxA(2, -2), and the control area is rectA(minA, maxA). This rectA is the minimum valid area. The coordinates of the positioning point of control B are minB(1, -1), the coordinates of the size point are maxB(3, -3), and the control area is rectB(minB, maxB). The coordinates of the positioning point of control C are minC(4, -3), the coordinates of the size point are maxC(6, -5), and the control area is rectC(minC, maxC).
[0109] Now traverse the area of each control in the order from control A to control B, and then from control B to control C.
[0110] Assuming the overlapping area is D, the area of the overlapping area D is rectD(minD, maxD). Figure 3From a, we can know that minD.x=1, minD.y=0, maxD.x=2, maxD.y=2. Among them, minD.x is the horizontal coordinate of the coordinates of the positioning point of the overlapping area D. minD.y is the vertical coordinate of the coordinates of the positioning point of the overlapping area D. maxD.x is the vertical coordinate of the coordinates of the size point of the overlapping area D. maxD.y is the vertical coordinate of the coordinates of the size point of the overlapping area D. When minD.x is not greater than maxD.x, and minD.y is not greater than maxD.y, it can be seen from the above preset overlapping algorithm that control A and control B overlap.
[0111] Now that it is known that controls A and B overlap, according to the preset offset method, an offset operation is performed on control B: control B is moved horizontally 2 units to the right and vertically 1 unit downward. And based on control A and control B after the offset operation, a new minimum effective area b1 is determined. At this time, the positions of the above three controls are as follows Figure 3 As shown in b.
[0112] Depend on Figure 3 From b, we can see that control A and control B do not overlap, control A and control C do not overlap, and control B and control C overlap. Since control A and control B have been traversed, the above offset operation is now performed on control C, and the following is obtained: Figure 3 The control position shown in c is as follows: Figure 3 The control position shown in c determines the final effective area b2.
[0113] Optional, please combine Figure 3 b. Figure 4 A and Figure 4 Another specific embodiment of the present invention shown in b, for example Figure 1 Step S106 is shown to understand:
[0114] Due to space limitations, the scaling ratio is set to 0.5 in this embodiment. Figure 3 After the control A in b is scaled, the initial area of the initial control in the canvas display area is determined as follows Figure 4 As shown in a. At this time, the positioning point coordinates of control A are (0, 0), and the size point coordinates are (4, -4). Figure 3 From b, we can see that the initial horizontal spacing between control A and control B is 3, and the initial vertical spacing is 2. The initial horizontal spacing between control B and control C is 3, and the initial vertical spacing is 2.
[0115] Then the initial horizontal spacing value is set at the zoom ratio, and the final horizontal spacing value is 6, and the final vertical spacing value is 4. Then the final positioning point coordinates of control B in the canvas display area are calculated to be (6, -4), and the final positioning point coordinates of control C in the canvas display area are calculated to be (12, -8). Then, according to the size information of control B, the size information of control C and the zoom ratio, the final size information of control B and control C in the canvas display area is obtained. After scaling, both control B and control C are square controls with a side length of 4.
[0116] According to the above final positioning point coordinates and final size information, we can obtain Figure 4 The canvas layout shown in b.
[0117] Optionally, calculate the scaling ratio of the final valid area to the canvas display area, including:
[0118] First size information of the canvas display area is obtained, wherein the first size information includes: horizontal size information of the canvas display area and vertical size information of the canvas display area.
[0119] The second size information of the final effective area is obtained, wherein the second size information includes: the horizontal size information of the final effective area and the vertical size information of the final effective area.
[0120] The horizontal size information of the final effective area is divided by the horizontal size information of the canvas display area to obtain the horizontal zoom ratio.
[0121] The vertical size information of the final effective area is divided by the vertical size information of the canvas display area to obtain the vertical scaling ratio.
[0122] Corresponding to the above-mentioned canvas automatic layout method embodiment, the present invention also provides a canvas automatic layout system, such as Figure 5 As shown, the system includes:
[0123] The information acquisition module 501 is used to acquire position information of a first number of controls, and determine a control area of each control according to the position information.
[0124] The position adjustment module 502 is used to traverse the control area of each control, and determine whether the untraversed controls overlap with the minimum valid area one by one. If so, according to a preset offset method, an offset operation is performed one by one on the untraversed controls overlapping with the minimum valid area, so that each untraversed control does not overlap with the minimum valid area, wherein the minimum valid area is the minimum rectangular area jointly occupied by the control being traversed and the traversed controls.
[0125] The spacing acquisition module 503 is used to obtain the initial spacing value between each control and the adjacent control in the final valid area after traversing the first number of controls, wherein the final valid area is the minimum valid area jointly occupied by the first number of controls.
[0126] The zoom ratio acquisition module 504 is used to calculate the zoom ratio for zooming the final effective area to the canvas display area.
[0127] The reference positioning module 505 is used to determine the initial area of the initial control in the canvas display area according to the position information and the zoom ratio of the initial control, wherein the initial control is the first control to be traversed.
[0128] The position determination module 506 is used to determine the positions of other controls in the canvas display area according to the initial area, initial spacing value, zoom ratio and position information of other traversed controls, wherein other controls are controls other than the initial control in the first number of traversed controls.
[0129] Optionally, the spacing acquisition module 503 is configured to:
[0130] Extract the coordinates of the positioning point of each control from the position information of each control in the final valid area;
[0131] Determine the adjacent controls of each control according to the traversal order during the traversal process.
[0132] The coordinates of the anchor point of each control are subtracted from the coordinates of the anchor point of each corresponding adjacent control to obtain the initial spacing value between each control and the adjacent control corresponding to the control.
[0133] Optionally, the reference positioning module 505 is configured to:
[0134] Get the anchor point coordinates and size information from the initial control's position information.
[0135] Replace the initial control's anchor point coordinates with the coordinate system origin coordinates of the canvas display area.
[0136] The size information of the initial control is divided by the zoom ratio to obtain the size information of the initial control in the canvas display area.
[0137] The initial area of the initial control in the canvas display area is determined according to the coordinates of the anchor point passing through the initial control and the size information of the initial control in the canvas display area.
[0138] Optionally, the location determination module 506 is configured to:
[0139] Divide the initial spacing value by the zoom ratio to get the final spacing value in the canvas display area.
[0140] According to the anchor point coordinates of the initial area, the final spacing value and the traversal order, the final anchor point coordinates of each other control are obtained in turn.
[0141] According to the position information of other controls, the size information of each other control is obtained, and the size information of each other control is divided by the zoom ratio to obtain the final size information of each other control in the canvas display area.
[0142] The positions of other controls in the canvas display area are determined based on the final anchor point coordinates and final size information.
[0143] Optionally, the position adjustment module 502 is configured to:
[0144] Using a preset overlap judgment algorithm, determine one by one whether the position information of the untraversed controls meets the preset overlap condition with the minimum effective area. If so, determine that the untraversed controls overlap with the minimum effective area; otherwise, determine that the untraversed controls do not overlap with the minimum effective area, wherein the preset overlap condition is: the horizontal coordinate of the first positioning point of the predicted overlapping area is not greater than the horizontal coordinate of the second positioning point of the predicted overlapping area, and the vertical coordinate of the first positioning point is not greater than the vertical coordinate of the second positioning point, the horizontal coordinate of the first positioning point is the maximum value between the horizontal coordinate of the positioning point of the minimum effective area and the horizontal coordinate of the positioning point of the untraversed controls, the vertical coordinate of the first positioning point is the maximum value between the vertical coordinate of the positioning point of the minimum effective area and the vertical coordinate of the positioning point of the untraversed controls, the horizontal coordinate of the second positioning point is the minimum value between the horizontal coordinate of the size point of the minimum effective area and the size point of the untraversed controls, and the vertical coordinate of the second positioning point is the minimum value between the horizontal coordinate of the size point of the minimum effective area and the size point of the untraversed controls.
[0145] Optionally, the zoom ratio acquisition module 504 is configured to:
[0146] First size information of the canvas display area is obtained, wherein the first size information includes: horizontal size information of the canvas display area and vertical size information of the canvas display area.
[0147] The second size information of the final effective area is obtained, wherein the second size information includes: the horizontal size information of the final effective area and the vertical size information of the final effective area.
[0148] The horizontal size information of the final effective area is divided by the horizontal size information of the canvas display area to obtain the horizontal zoom ratio.
[0149] The vertical size information of the final effective area is divided by the vertical size information of the canvas display area to obtain the vertical scaling ratio.
[0150] The embodiment of the present invention provides a canvas automatic layout device, such as Figure 6 As shown, the device comprises:
[0151] Processor 601;
[0152] The memory 602 is used to store instructions executable by the processor 601 .
[0153] The processor 601 is configured to execute instructions to implement any of the above-mentioned canvas automatic layout methods.
[0154] An embodiment of the present invention provides a computer storage medium. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the device can execute any of the above-mentioned canvas automatic layout methods.
[0155] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
[0156] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0157] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0158] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. It should also be noted that the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0159] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0160] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A canvas automatic layout method, characterized in that: The method comprises: Acquire position information of a first number of controls, and determine a control area of each of the controls according to the position information; Traversing the control area of each of the controls, determining one by one whether the untraversed controls overlap with the minimum valid area, and if so, performing an offset operation on the untraversed controls overlapping with the minimum valid area according to a preset offset method, so that each of the untraversed controls does not overlap with the minimum valid area, wherein the minimum valid area is the minimum rectangular area jointly occupied by the control being traversed and the traversed controls; wherein after performing the offset operation, updating the minimum valid area; After traversing the first number of controls, obtaining an initial spacing value between each control and an adjacent control in a final valid area, wherein the final valid area is the minimum valid area jointly occupied by the first number of controls; Calculate a scaling ratio for scaling the final valid area to the canvas display area; Determine an initial area of the initial control in the canvas display area according to the position information of the initial control and the zoom ratio, wherein the initial control is the first control to be traversed; The positions of the other controls in the canvas display area are determined according to the initial area, the initial spacing value, the zoom ratio and the position information of the other traversed controls, wherein the other controls are controls other than the initial controls among the first number of traversed controls.
2. The method according to claim 1, characterized in that After the traversal of the first number of controls is completed, obtaining the initial spacing value between each control and the adjacent controls in the final valid area includes: Extracting the coordinates of the positioning point of each control from the position information of each control in the final valid area; Determine the adjacent controls of each control according to the traversal order in the traversal process; The coordinates of the positioning point of each of the controls are subtracted from the coordinates of the positioning point of each of the corresponding adjacent controls to obtain the initial spacing value between each of the controls and the adjacent controls corresponding to the control.
3. The method according to claim 2, characterized in that The determining, according to the position information of the initial control and the zoom ratio, an initial area of the initial control in the canvas display area includes: Acquire the positioning point coordinates and size information from the position information of the initial control; Replacing the positioning point coordinates of the initial control with the coordinate system origin coordinates of the canvas display area; Performing a division operation on the size information of the initial control and the zoom ratio to obtain the size information of the initial control in the canvas display area; The initial area of the initial control in the canvas display area is determined according to the coordinates of the anchor point passing through the initial control and the size information of the initial control in the canvas display area.
4. The method according to claim 3, characterized in that The determining the position of the other controls in the canvas display area according to the initial area, the initial spacing value, the zoom ratio and the position information of the traversed other controls includes: Performing a division operation on the initial spacing value and the zoom ratio to obtain a final spacing value in the canvas display area; According to the positioning point coordinates of the initial area, the final spacing value and the traversal order, the final positioning point coordinates of each of the other controls are obtained in sequence; According to the position information of the other controls, the size information of each of the other controls is acquired, and the size information of each of the other controls is divided by the zoom ratio to obtain the final size information of each of the other controls in the canvas display area; The positions of the other controls in the canvas display area are determined according to the final positioning point coordinates and the final size information.
5. The method according to claim 1, characterized in that The step of determining whether the untraversed controls overlap with the minimum valid area one by one includes: Using a preset overlap judgment algorithm, determine one by one whether the position information of the untraversed control meets the preset overlap condition with the minimum valid area. If yes, determine that the untraversed control overlaps with the minimum valid area; otherwise, determine that the untraversed control does not overlap with the minimum valid area, wherein the preset overlap condition is: the horizontal coordinate of the first positioning point of the predicted overlapping area is not greater than the horizontal coordinate of the second positioning point of the predicted overlapping area, and the vertical coordinate of the first positioning point is not greater than the vertical coordinate of the second positioning point, the horizontal coordinate of the first positioning point is the maximum value of the horizontal coordinate of the positioning point of the minimum valid area and the horizontal coordinate of the positioning point of the untraversed control, the vertical coordinate of the first positioning point is the maximum value of the vertical coordinate of the positioning point of the minimum valid area and the vertical coordinate of the positioning point of the untraversed control, the horizontal coordinate of the second positioning point is the minimum value of the horizontal coordinate of the size point of the minimum valid area and the size point of the untraversed control, and the vertical coordinate of the second positioning point is the minimum value of the horizontal coordinate of the size point of the minimum valid area and the size point of the untraversed control.
6. The method according to claim 1, characterized in that The calculation of scaling the final effective area to the scaling ratio of the canvas display area includes: Acquire first size information of the canvas display area, wherein the first size information includes: horizontal size information of the canvas display area and vertical size information of the canvas display area; Acquire second size information of the final valid area, wherein the second size information includes: transverse size information of the final valid area and longitudinal size information of the final valid area; Performing a division operation on the horizontal size information of the final effective area and the horizontal size information of the canvas display area to obtain a horizontal zoom ratio; The vertical size information of the final effective area is divided by the vertical size information of the canvas display area to obtain a vertical zoom ratio.
7. A canvas automatic layout system, characterized in that: The system comprises: An information acquisition module, used to acquire position information of a first number of controls, and determine a control area of each of the controls according to the position information; A position adjustment module, used for traversing the control area of each of the controls, determining one by one whether the untraversed controls overlap with the minimum effective area, and if so, performing an offset operation on the untraversed controls overlapping with the minimum effective area one by one according to a preset offset method, so that each of the untraversed controls does not overlap with the minimum effective area, wherein the minimum effective area is the minimum rectangular area jointly occupied by the control being traversed and the traversed controls; wherein after performing the offset operation, the minimum effective area is updated; A spacing acquisition module, used for acquiring an initial spacing value between each control and an adjacent control in a final valid area after traversing the first number of controls, wherein the final valid area is the minimum valid area jointly occupied by the first number of controls; A zoom ratio acquisition module, used for calculating the zoom ratio of scaling the final effective area to the canvas display area; A reference positioning module, used to determine an initial area of the initial control in the canvas display area according to the position information of the initial control and the zoom ratio, wherein the initial control is the first control traversed; A position determination module is used to determine the positions of the other controls in the canvas display area according to the initial area, the initial spacing value, the zoom ratio and the position information of the other traversed controls, wherein the other controls are controls other than the initial controls among the first number of traversed controls.
8. The system according to claim 7, characterized in that The zoom ratio acquisition module is configured as follows: Acquire first size information of the canvas display area, wherein the first size information includes: horizontal size information of the canvas display area and vertical size information of the canvas display area; Acquire second size information of the final valid area, wherein the second size information includes: transverse size information of the final valid area and longitudinal size information of the final valid area; Performing a division operation on the horizontal size information of the final effective area and the horizontal size information of the canvas display area to obtain a horizontal zoom ratio; The vertical size information of the final effective area is divided by the vertical size information of the canvas display area to obtain a vertical zoom ratio.
9. A canvas automatic layout device, characterized in that: The device comprises: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the canvas automatic layout method as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the device is enabled to execute the canvas automatic layout method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Control display method and display equipment
CN111182345A
Screen display method and device, terminal equipment and storage medium
CN111986601A