WO2023097990A1 - Element layout method and related device - Google Patents

Element layout method and related device Download PDF

Info

Publication number
WO2023097990A1
WO2023097990A1 PCT/CN2022/093727 CN2022093727W WO2023097990A1 WO 2023097990 A1 WO2023097990 A1 WO 2023097990A1 CN 2022093727 W CN2022093727 W CN 2022093727W WO 2023097990 A1 WO2023097990 A1 WO 2023097990A1
Authority
WO
WIPO (PCT)
Prior art keywords
elements
canvas
constraints
layout
size
Prior art date
Application number
PCT/CN2022/093727
Other languages
French (fr)
Chinese (zh)
Inventor
赵刚华
刘坤
Original Assignee
华为云计算技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Publication of WO2023097990A1 publication Critical patent/WO2023097990A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image

Definitions

  • the present application relates to the field of computer technology, and in particular to an element layout method, a system, a computer cluster, a computer-readable storage medium, and a computer program product.
  • an element refers to a component that expresses a certain meaning.
  • an element can include different types of components such as text and graphics.
  • the industry provides methods for automatically laying out elements based on templates and dynamic programming.
  • This method provides a variety of layout templates, and when the user inputs elements, the corresponding layout templates can be automatically matched based on dynamic programming, so as to realize element layout.
  • the above method is mainly suitable for text-type elements.
  • the format of elements such as charts is more free, and it is difficult to match the layout template, which leads to poor layout effects based on templates and dynamic programming.
  • This application provides an element layout method, which transforms the element layout problem into a linear programming problem, and uses an iterative optimization method to determine the recommended position and size of elements for a set of input elements, thereby realizing intelligent element layout . Since there is no need to match with a fixed layout template, it solves the problem that it is not suitable for elements such as charts, resulting in poor layout effects.
  • the present application also provides an element layout system, a computer cluster, a computer-readable storage medium, and a computer program product corresponding to the above method.
  • the present application provides an element layout method. This method can be performed by the element layout system.
  • the element layout system may be a software system, and the computer cluster executes the element layout method by running the program code of the software system.
  • the element layout system may also be a hardware system for element layout.
  • the element layout system may receive multiple elements input by the user, determine the initial size and initial position of the multiple elements on the canvas, and then use the initial size and initial position of the multiple elements on the canvas as a starting point, combine the The size and design constraints of the canvas, iteratively optimize the size and position of the multiple elements on the canvas, and obtain the recommended size and position of the multiple elements on the canvas, thereby realizing intelligent elements layout.
  • the element layout system transforms the element layout problem into a linear programming problem, and uses an iterative optimization method to solve the recommended position and recommended size of each element for a set of input elements (usually multiple elements), so that Each element does not overlap other elements and does not overflow the canvas. Because it does not match with a fixed layout template, it solves the problem in the related art that it is not suitable for elements of types such as charts and the layout effect is not good, and has high usability. Moreover, the method realizes driving based on user intent by setting necessary layout attributes such as the position of the upper, lower, left, and right edges of the element, and performing iterative optimization based on the initial size and initial position of the element input by the user. , which improves interactivity and reduces the workload of designers.
  • this method uses a fixed-size canvas instead of a pixel-discretized canvas, so that continuous decision variables can be used instead of a large number of discrete decision variables, and iterative optimization can be performed in the continuous space provided by continuous decision variables, which can greatly reduce the amount of calculation.
  • the algorithm complexity shortens the time of intelligent layout and improves the efficiency of intelligent layout.
  • the element layout system iteratively optimizes the sizes and positions of the multiple elements on the canvas to obtain multiple candidate layouts.
  • Each candidate layout of the plurality of candidate layouts includes a size and position of the plurality of elements on the canvas. Then the element layout system sorts multiple candidate layouts to obtain layout results.
  • the layout result is a top-ranked candidate layout among the multiple candidate layouts, for example, the layout result may be the first-ranked candidate layout among the multiple candidate layouts.
  • the element layout system sorts a plurality of candidate layouts, and determines the layout result from the plurality of candidate results according to the sorting result, which further improves the layout effect and meets business requirements.
  • the element layout system may be based on the balance of the size of each of the multiple elements, the balance of the images presented by the multiple elements on the canvas, and the alignment of the multiple elements At least one of the multiple candidate layouts is sorted. In this way, the layout effect can be sorted from at least one of the dimensions of the balance of the size of the element, the balance of the picture presented by the element on the canvas, and the alignment of the elements, so as to determine the balance of the size of the element, the balance of the element on the canvas The balance of the presented picture and/or the alignment of elements meet the required layout results.
  • the balance of the images presented by the multiple elements on the canvas is represented by a sum of importance scores of each element.
  • the importance score is determined according to the area of the element and the distance from the element to the center point of the canvas. In this way, the elements with higher importance can be laid out according to the weight, so that the elements with higher importance are in the visual focus and meet business needs.
  • the design constraints may include not only the built-in basic constraints of the system, but also user-defined constraints.
  • the element layout system can also receive user-defined constraints and combine them to iteratively optimize the size and position of elements. This enables smart element layout based on user intent.
  • the basic constraints include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and filling constraints.
  • the self-defined constraints include any one or more of locking constraints, aspect ratio constraints, and alignment preference constraints.
  • Alignment constraints are specifically used to ensure the alignment of elements. Grid constraints are used to ensure a reasonable division of the canvas area and prevent elements from overlapping. Size constraints are used to ensure that the size (ie size) of elements is reasonable to meet the readability of elements such as charts by the human eye.
  • the boundary constraint is used to ensure that the input elements fill the canvas, and the filling constraint is used to ensure that the interior of the layout is full, so as to avoid the internal vacancy of the layout and make the overall space lose the sense of continuity, which in turn affects the aesthetics of the layout to a certain extent.
  • Lock constraints are used to lock the size and position of one or more elements.
  • Aspect ratio constraints are used to constrain the scaling ratio of one or more elements.
  • Alignment preference constraints are used to constrain one or more elements to be top, left, right, or bottom.
  • the final layout result can have a better layout effect and meet business needs.
  • the elements include one or more of graphics, text or decorations.
  • the decoration may refer to, for example, a graph, a title of a text, a background, and the like.
  • the element layout system can implement intelligent element layout for different types of elements such as charts, texts, and decorations, and has high usability.
  • the element layout system can present a design interface to the user, the design interface carries a visual component, and the user can trigger a drag operation on the visual component, and the element layout system responds to the above operation of the user, receiving Multiple elements corresponding to visual components.
  • the element layout system can set trigger conditions for smart element layout.
  • the trigger condition can be set such that the user triggers the smart layout control, or the user's vision of the last input element is greater than the preset time. Based on this, when the user triggers the smart layout control or the time since the user last entered an element is greater than the preset time, the trigger condition of the smart element layout is met, and the element layout system can use the initial size and initial size of the multiple elements on the canvas The position is used as a starting point, and the size and position of the multiple elements on the canvas are iteratively optimized in combination with the size of the canvas and design constraints.
  • the method sets the triggering condition of the smart element layout, and automatically triggers the smart element layout when the triggering condition of the smart element layout is satisfied, further reduces user operations, improves the efficiency of the element layout, and improves user experience.
  • the present application provides an element layout system.
  • the system includes:
  • An interactive module for receiving multiple elements input by the user
  • a determining module configured to determine the initial size and initial position of the plurality of elements on the canvas
  • An optimization module configured to iteratively optimize the size and position of the multiple elements on the canvas, taking the initial size and initial position of the multiple elements on the canvas as a starting point, in combination with the size of the canvas and design constraints, A layout result is obtained, where the layout result includes recommended sizes and recommended positions of the plurality of elements on the canvas.
  • the optimization module is specifically used to:
  • each of the multiple candidate layouts includes the size and position of the multiple elements on the canvas ;
  • the optimization module is specifically used to:
  • the plurality of candidate layouts Sort According to at least one of the degree of balance of the size of each of the plurality of elements, the degree of balance of the images presented by the plurality of elements on the canvas, and the degree of alignment of the plurality of elements, the plurality of candidate layouts Sort.
  • the balance degree of the picture presented by the multiple elements on the canvas is characterized by the sum of the importance scores of each element, and the importance score is based on the area of the element and the distance between the element and the Determine the distance from the center point of the canvas.
  • the interaction module is also used to:
  • the design constraints include basic constraints and the custom constraints.
  • the basic constraints include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and fill constraints
  • the custom constraints include locking constraints, aspect ratio constraints, Any one or more of the alignment preference constraints.
  • the elements include one or more of graphics, text or decorations.
  • the interaction module is specifically used to:
  • a plurality of elements corresponding to the visualization component are received in response to a user's drag operation on the visualization component.
  • the optimization module is specifically used to:
  • the present application provides a computer cluster.
  • the computer cluster includes at least one computer, and the at least one computer includes at least one processor and at least one memory.
  • the at least one processor and the at least one memory communicate with each other.
  • the at least one processor is configured to execute instructions stored in the at least one memory, so that the computer cluster executes the element layout method in the first aspect or any implementation manner of the first aspect.
  • the present application provides a computer-readable storage medium. Instructions are stored in the computer-readable storage medium, and the instructions instruct a cluster of computers to execute the element layout method described in the first aspect or any implementation manner of the first aspect.
  • the present application provides a computer program product containing instructions. When it is run on a computer cluster, the computer cluster executes the element layout method described in the first aspect or any implementation manner of the first aspect. .
  • FIG. 1A to FIG. 1D are application scene diagrams of the element layout method provided by the embodiment of the present application.
  • FIG. 2 is a system architecture diagram of an element layout method provided by an embodiment of the present application.
  • FIG. 3 is a flow chart of an element layout method provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of an element layout method provided by an embodiment of the present application.
  • 6A to 6C are schematic diagrams of scoring different layouts provided by the embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a computer cluster provided by an embodiment of the present application.
  • first and second in the embodiments of the present application are used for description purposes only, and cannot be interpreted as indicating or implying relative importance or implicitly indicating the quantity of indicated technical features. Thus, a feature defined as “first” and “second” may explicitly or implicitly include one or more of these features.
  • Element layout refers to setting the size and position of elements on the screen (such as the canvas of the screen application).
  • the size of the screen or canvas is usually fixed, and the size and position of elements are adjustable.
  • the process of element layout is usually a process of continuously adjusting the size and position of elements on the screen or canvas to optimize the presentation effect.
  • an element is a component that expresses a certain meaning.
  • the elements may be of various types, for example, the elements may include different types such as text, graphics, and decorations.
  • the text can include text or title (the title of the text or the title of the chart), etc.
  • the chart can include bar charts, line charts, pie charts or patterns
  • the decoration can include shapes, symbols or backgrounds used to highlight or beautify text and charts .
  • Automated element layout is possible based on templates and dynamic programming.
  • the element layout application can provide multiple layout templates.
  • the element layout application can automatically match the layout templates that match the multiple elements based on dynamic programming, and provide the user with the layout templates that match the multiple elements.
  • the above method is mainly suitable for text-type elements.
  • the format of elements such as charts is more free, and it is difficult to match the layout template, which leads to poor layout effects based on templates and dynamic programming.
  • the embodiment of the present application provides an element layout method.
  • This method can be performed by the element layout system.
  • the element layout system may be a software system, and the computer cluster executes the element layout method by running the program code of the software system.
  • the element layout system may also be a hardware system for element layout.
  • the embodiment of the present application uses an element layout system as a software system for illustration.
  • the element layout problem can be defined as: for a set of elements (such as rectangular elements) that need to be placed on a fixed-size canvas with a specified width and height, find a feasible solution so that all elements do not overlap and do not overflow the canvas.
  • This method can transform the element layout problem into a linear programming problem.
  • the linear programming problem is: for a set of input elements (usually multiple elements), solve the recommended position and recommended size of each element, so that each element does not overlap with other elements and does not overflow the canvas.
  • the element layout system can receive multiple elements input by the user, determine the initial size and initial position of the multiple elements on the canvas, and then use the initial size and initial position of the multiple elements on the canvas as a starting point, combine The size and design constraints of the canvas, iteratively optimize the size and position of the multiple elements on the canvas, and obtain the recommended size and recommended position of the multiple elements on the canvas, thereby realizing intelligent Element layout.
  • the method uses an iterative optimization method to determine the recommended size and recommended position instead of matching with a fixed layout template, it solves the problem in the related art that the elements of the chart and other types are not applicable and the layout effect is not good. high availability. Moreover, the method realizes driving based on user intent by setting necessary layout attributes such as the position of the upper, lower, left, and right edges of the element, and performing iterative optimization based on the initial size and initial position of the element input by the user. , which improves interactivity and reduces the workload of designers.
  • this method uses a fixed-size canvas instead of a pixel-discretized canvas, so that continuous decision variables can be used instead of a large number of discrete decision variables, and iterative optimization can be performed in the continuous space provided by continuous decision variables, which can greatly reduce the amount of calculation.
  • the algorithm complexity shortens the time of intelligent layout and improves the efficiency of intelligent layout.
  • the element layout method in the embodiment of the present application can be adapted to various scenarios.
  • this element layout method can be applied to security situational awareness scenarios.
  • the element layout system can rank histograms of access areas, access area maps, line graphs of access trends, histograms of attack area rankings, and line graphs of attack trends.
  • attack type ranking list and other elements are intelligently arranged to realize comprehensive security situation awareness from micro to macro, and provide decision-making basis for security incident handling.
  • this element layout method can be applied to trade analysis scenarios.
  • the element layout system can analyze the sales statistics, the global quantity distribution of goods exports, the global sales ranking table, the sales situation table, and the global port distribution. Smart layout of map and other elements to realize global economic and trade analysis.
  • the element layout method can also be used in business management scenarios. By accessing the business data of the enterprise, it is possible to present the production situation, product quality and/or product sales of the enterprise, and provide a visual basis for decision-making for enterprise managers.
  • the element layout method can be used to analyze the cockpit sales situation, see Figure 1C
  • the element layout system can rank column charts for premium regions, popular insurance policies, annual premium column charts and line charts, and compare new and old customers Graphs, real-time transaction tables, annual cumulative total premiums and other elements are intelligently laid out to analyze cockpit sales.
  • the element layout method can be used to analyze the sales of real estate projects.
  • the element layout system can analyze the annual plan chart, sales amount statistical column chart, sales return trend chart, and operating income column chart.
  • Graphs, investment and profitability column charts, inventory line charts, project value indicator charts, inventory indicator column charts, and conventional project indicator charts are intelligently laid out to realize the analysis of real estate project sales.
  • the above element layout method can be specifically provided to users in the form of data visualization service (data lake visualization, DLV).
  • DLV data lake visualization
  • the DLV may be a cloud service.
  • DLV can provide a one-stop data visualization platform, such as the above-mentioned element layout system, which can adapt to various data sources on or off the cloud, and provide a variety of two-dimensional (2dimension, 2D) or three-dimensional (3dimension, 3D) visualization components, users can drag and drop the above visualization components to freely layout, so as to realize efficient customization of screen display content.
  • the terminal 10 and the terminal 30 are respectively connected to the cloud environment 20 .
  • the terminal 10 is a user terminal used to design the presentation content of the terminal 30, such as a desktop computer, a notebook computer, a tablet computer, etc.
  • the terminal 30 is a device used for presentation content, and is usually equipped with a large screen.
  • the cloud environment 20 indicates a central computing cluster owned by a cloud service provider for providing computing, storage, and communication resources.
  • the central computing cluster is a computer cluster formed by one or more central computing devices (such as a central server).
  • the element layout system 200 can be deployed on one or more computers in the cloud environment 20 . As shown in Figure 2, the element layout system 200 includes multiple modules such as an interaction module 202, a determination module 204, and an optimization module 206. Different computers on environment 20.
  • the terminal 10 is deployed with a client (not shown in FIG. 2 ).
  • the client can be a general client with element layout functions, such as a browser, or a dedicated client dedicated to element layout.
  • the client can be connected to the element layout system 200 to load the interaction logic of the interaction module 202 in the element layout system 200, so that the client can present the design interface to the user.
  • the design interface may be a graphical user interface (graphical user interface, GUI). Users can interact through the above-mentioned design interface to realize element layout.
  • the design interface carries visual components, which can include different types such as column charts, trend graphs, maps, and statistical tables. Users can trigger drag and drop operations on the visual components through the design interface, and the client responds to the above operations , and report the corresponding event to the element layout system 200 .
  • the interaction module 202 of the element layout system 200 can receive the above events, so as to obtain a plurality of elements corresponding to the visual components. Among them, multiple elements are determined based on the components dragged by the user and the connected data sources. Then the determination module 204 of the element layout system 200 determines the initial size and initial position of the multiple elements on the canvas, and the optimization module 206 of the element layout system 200 takes the initial size and initial position of the multiple elements on the canvas as a starting point, combined with the The size and design constraints of the canvas, performing iterative optimization on the size and position of the plurality of elements on the canvas, to obtain the recommended size and position of the plurality of elements on the canvas.
  • the interaction module 202 of the element layout system 200 can also return the recommended size and recommended position of multiple elements on the canvas to the client.
  • the element layout system 200 can send the elements and their recommended size and recommended position to the terminal 30, and the terminal 30 places multiple elements, thereby achieving intelligent element layout.
  • FIG. 2 is a schematic deployment manner of the element layout system 200 in the embodiment of the present application.
  • the element layout system 200 may also be deployed in an edge environment.
  • the edge environment indicates an edge computing cluster that is geographically close to the terminal (that is, the end-side device) and is used to provide computing, storage, and communication resources.
  • An edge computing cluster is a computer cluster formed by one or more edge computing devices (such as edge servers).
  • the element layout system 200 can also be deployed in a terminal, such as the terminal 10 . The user can directly control the terminal 30 to demonstrate content through the terminal 10 .
  • the element layout system 200 can be connected to a plurality of terminals 10 and a plurality of terminals 30, and each user can select a terminal 30 for displaying content from a plurality of terminals 30 through a respective terminal 10, and the element layout system 200 can, according to the selection of the user, Send the layout result to the corresponding terminal 30, so that different users can be provided with intelligent layout services.
  • the method includes:
  • the element layout system 200 receives a plurality of elements input by the user.
  • the element layout system 200 can provide a wealth of visual components, such as visual components of chart types such as column charts, line charts, maps, and data tables, or visual components of text types such as title boxes, and visual components of decorative types such as backgrounds.
  • the user can input multiple elements based on the above-mentioned visual components provided by the element layout system 200 .
  • the element layout system 200 can present a design interface to the user, the design interface carries at least one visual component, and then the element layout system 200 receives multiple elements corresponding to the visual component in response to the user's drag operation on the visual component .
  • the element layout system 200 can obtain corresponding elements according to the visual component of the chart type and the data source connected thereto.
  • the element layout system 200 can obtain corresponding elements according to the text-type visual component and the text content input by the user.
  • the element layout system 200 can obtain title-type elements according to the title box dragged by the user and the text content entered by the user.
  • the element layout system 200 can obtain corresponding elements according to the decoration-type visual component.
  • the element layout system 200 may also receive multiple elements input by the user through the element adding control. Wherein, the above-mentioned multiple elements may be added one by one by the user, or may be added by the user in batches.
  • the user can set the size and position of the element to be added through the element adding control. When the element is a rectangular element, the size and position of the element can be determined by the positions of the top, bottom, left, and right edges of the element.
  • the positions of the top, bottom, left, and right edges can be determined by the top margin (the distance from the top edge of the element to the top edge of the canvas), the bottom margin (the distance from the bottom edge of the element to the bottom edge of the canvas) ), left margin (the distance from the left edge of the element to the left edge of the canvas), and right margin (the distance from the right edge of the element to the right edge of the canvas).
  • the user can also set the type of element to be added through the element adding control.
  • the element adding control can be a chart, text or decoration.
  • charts can be further divided into column charts, line charts, maps and other types.
  • Text can be further divided into types such as heading or body text.
  • S304 The element layout system 200 receives user-defined constraints input by the user.
  • the element layout system 200 converts the element layout problem into a linear programming problem. Therefore, the element layout system 200 can formulate design constraints, so as to perform linear programming based on the design constraints.
  • design constraints are usually mathematical constraints.
  • the design constraints may include basic constraints (also referred to as model internal constraints) formulated according to design criteria such as design criteria related to large screens, and may also include user-defined constraints input by the user.
  • custom constraints can be configured according to user needs.
  • the element layout system 200 can provide various custom constraints, and then receive one or more custom constraints selected by the user.
  • the basic constraints may include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and filling constraints.
  • the custom constraints may include any one or more of locking constraints, aspect ratio constraints, and alignment preference constraints. The above-mentioned basic constraints and custom constraints are described in detail below.
  • Alignment constraints are used to ensure alignment of elements. Alignment constraints divide multiple elements input by the user into several alignment groups, such as upper, lower, left, and right alignment groups. Among them, elements aligned in a certain direction belong to an alignment group, and a line in which elements in an alignment group are aligned is called an alignment line.
  • Alignment constraints are used to divide all elements input by the user into several alignment groups such as top, bottom, left, and right, and each edge of an element (such as top edge, bottom edge, left edge or the right edge) respectively correspond to one and only one alignment group.
  • e is used to represent the element, Used to represent collections of elements, Represents any element in a collection of elements.
  • ⁇ , ⁇ , ⁇ , and ⁇ denote the left edge, right edge, upper edge, and lower edge, respectively, Indicates the alignment group corresponding to the left edge of element e, Indicates the alignment group corresponding to the right edge of element e, Indicates the alignment group corresponding to the top edge of element e, Indicates the alignment group corresponding to the bottom edge of element e.
  • this application also provides a specific example. See Figure 4A, the second element of the first row is aligned with the first element of the first row, the third element of the first row, and the second element of the first row is aligned with the third element of the first row Bottom alignment.
  • the second element in the first row is also left-aligned and right-aligned with the first element in the second row.
  • the four dotted lines shown in Figure 4A are alignment lines corresponding to the above-mentioned alignment group.
  • Grid constraints are used to ensure a reasonable division of the canvas area and prevent elements from overlapping.
  • Common design guidelines include visual balance.
  • a classic example of visual balance is symmetrical balance.
  • Symmetrical balance is a common way to organize elements in a stable and regular layout.
  • Grid constraints place elements in place based on symmetrical balance, preventing elements from overlapping.
  • the canvas area can be divided into grids including several rows and several columns, and the number of alignment lines can be calculated as a benchmark amount of alignment constraints. Then divide the design by vertically or horizontally dividing the area containing the elements, formulate a segmentation strategy based on pixel coordinates, and adopt a simple layered design style to make the elements visually balanced.
  • align count 4*grid count +2*(grid addCol +grid addRest ) (5)
  • grid addRest N el -grid count *grid count -grid addCol *grid count (8)
  • N el represents the number of elements
  • grid count represents the number of grid line rows
  • grid addCol represents the number of column extensions
  • grid addRest represents the number of remaining elements after column expansion
  • align count represents the number of alignment lines.
  • the root operation is performed first, and then the result of the root operation can be rounded down to determine that the above elements can be arranged in 3 rows, and then expand based on the remaining 5 elements (as shown in the dotted line box in the figure).
  • the number of alignment lines can be determined for each layout. The larger the number of alignment lines, the more balanced the element layout.
  • Size constraints are used to ensure that the size (ie dimensions) of an element is reasonable. Considering that the human eye has certain requirements for the readability of the chart, elements should not be too small during the layout process. In addition, in terms of the overall aesthetics of the content displayed on the screen, enlarged charts can affect the overall harmony of the screen and create a sense of clutter. Therefore, elements should also be avoided from being overly enlarged during the layout process. For this reason, the zoom range of the element can be constrained to ensure that the element is at a reasonable size.
  • the zoom range of the element can be between 2/3 of the initial width (ie ) and the width of the canvas (ie width ca ), and the height is between 2/3 of the initial height (ie ) and the height of the canvas (height ca ).
  • the initial size of the element is equal to the size of the dark gray area in Figure 4C, and the minimum width and height of the element can be reduced to 2/3 of the width and height of the dark gray area, that is, the smallest element can be as shown in the figure
  • the width and height of the element can be scaled to the maximum width and height of the canvas, that is, the maximum size of the element can be shown in the black area in the figure.
  • Bound constraints are used to ensure that the layout fills the canvas. Jagged outlines, unbalanced outlines, or any non-convex arrangement can affect aesthetics. Therefore, you can set the overall outline caused by element layout to be close to the outer outline of a rectangle, so that the layout result occupies the entire screen and ensures that the elements fill the canvas.
  • constraints can be made through the upper and lower limits of the alignment group.
  • the boundary constraint makes the element with the smallest coordinate value in the left and upper alignment groups of all elements be at the left and upper boundaries of the canvas, as shown in formulas (13) and (14), the element with the largest coordinate value in the right and lower alignment groups is at The right and bottom boundaries of the canvas, as shown in equations (15) (16). details as follows:
  • padding represents the margin.
  • padding X can represent the set margin along the X axis
  • padding Y can represent the set margin along the Y axis.
  • Set margins Characterizes the distance from the left edge of the element with the smallest coordinate value (such as the Y-axis coordinate value) in the left-aligned group to the sitting edge of the canvas, Indicates the distance from the upper edge of the element with the smallest coordinate value (such as the X-axis coordinate value) in the upper alignment group to the upper edge of the canvas.
  • Characterizes the distance from the element with the largest coordinate value (such as the Y-axis coordinate value) in the right-aligned group to the right edge and the left edge of the canvas Indicates the distance from the element with the largest coordinate value (such as the X-axis coordinate value) in the lower alignment group to the upper edge of the canvas.
  • two elements in the first row form an upper alignment group
  • two elements in the second row form a lower alignment group
  • two elements in the first column form a left alignment group
  • two elements in the second column form a right alignment group Group.
  • the element with the smallest coordinate value in the top alignment group and the left alignment group is, for example, the first element in the first row, which can be arranged at a distance of padding X and padding Y from the left and top edges of the canvas
  • the element with the largest coordinate value in the bottom alignment group and the right alignment group is, for example, the second element in the second row, which can be arranged at a distance of width canvas -paddingX and height canvas -paddingY from the left and top edges of the canvas.
  • Padding constraints are used to ensure that the interior of the layout is filled.
  • the internal vacancy of the layout can make the overall space lose the sense of continuity, which in turn affects the aesthetics of the layout to a certain extent. For this reason, you can set the spacing between each element to not exceed the set spacing, so that the interior of the layout result is filled.
  • the closer the spacing between elements is the closer the total area of the elements is to the area of the canvas. Therefore, it is also possible to scale the elements so that the total area of the elements approaches the area of the canvas.
  • the element when scaling an element, the element may be scaled according to the ratio of the area of the element to the area of the canvas.
  • the scaling ratio of the area is equal to the scaling ratio of the width multiplied by the scaling ratio of the height
  • the root operation can be performed on the ratio of the area of the element to the area of the canvas, and then the width and height of the element can be scaled according to the result of the root operation, such as the formula As shown in (17) and (18):
  • width canvas represents the width of the canvas
  • height canvas represents the height of the canvas
  • area canvas represents the area of the canvas
  • area e represents the area of the element
  • Indicates the maximum width of the element Indicates the maximum value of the element's height.
  • the filling constraint when the total area of the scaled elements is close to the area of the canvas, it can be determined that the filling constraint is satisfied.
  • whether the total area of the scaled elements is close to the area of the canvas can be measured by the area ratio.
  • the ratio of the total area of the scaled elements to the area of the canvas is greater than or equal to a preset ratio, then it may be determined that the total area of the scaled elements is close to the area of the canvas.
  • the preset ratio can be set according to experience values, for example, it can be set to 99%.
  • aspects ratio constraints are used to constrain the scaling ratio of one or more elements. That is, when scaling elements, scale one or more elements while maintaining the specified aspect ratio (ratio).
  • the aspect ratio may be determined according to the initial height and initial width of the element, for example, may be a ratio of the initial height to the initial width.
  • the height of the scaled element when scaling an element, can be determined according to the scaled width and aspect ratio:
  • width ' represents the width after scaling
  • height ' represents the height after scaling
  • Alignment preference constraints are used to constrain one or more elements to be top, left, right, or bottom.
  • the element that needs to be on top can be placed on top of other elements, as shown in FIG. 4G .
  • the target element can be set above other elements, such as formula (20), or the target element is on the right of other elements, such as formula (21), or the target element is on the left of other elements, such as formula ( 22), or the target element is under other elements, such as formula (23):
  • e1 represents the target element
  • e2 represents other elements other than the target element.
  • a target element is an element that the user intends to be top, right, left, or bottom.
  • Lock constraints are used to lock the size and position of one or more elements. That is to say, it is stipulated that the size and position of one or more elements are consistent with the size and position of the above-mentioned elements.
  • a lock field can be added, which is a Boolean variable that can take a value of true or false. When the value is true, the size and position of the corresponding element can be locked.
  • L lock indicates the position of the left boundary of the locked element, which can be expressed specifically by the distance from the left boundary to the Y axis
  • B lock indicates the position of the lower boundary of the locked element, which can be expressed specifically by the distance from the lower boundary to the X axis
  • X lock and Y lock respectively represent the coordinates of the lower left vertex of the locked element
  • Width lock respectively indicates the minimum, maximum and initial value of the width of the locked element
  • the height lock indicates the minimum, maximum, and initial values of the height of the locked element, respectively.
  • constraints (1) to (5) are basic constraints
  • constraints (6) to (8) are self-defined constraints.
  • the element layout system 200 may not perform S304, and use basic constraints to perform linear programming, so as to implement element layout.
  • the element layout system 200 determines the initial size and initial position of the multiple elements on the canvas.
  • the element layout system 200 can determine the initial size of each element by determining the distance from the reference point or side of each of the multiple elements to the edge of the canvas and initial position.
  • the element layout system 200 can determine the distance from the top and bottom edges of each element to the top edge of the canvas (denoted as the X axis), and the distance from the left and right edges of each element to the left edge of the canvas (denoted as the Y axis). axis) distance. Then, the element layout system 200 can determine the height of the element according to the difference between the upper and lower edges of the element and the upper edge of the canvas, and determine the width of the element according to the difference between the left and right edges of the element and the left edge of the canvas. , so you can get the initial size of multiple elements in the canvas.
  • the element layout system 200 can determine the ordinate of the center point of the element according to the average distance between the upper and lower edges of the element and the upper edge of the canvas, and determine the element according to the average distance between the left and right edges of the element and the left edge of the canvas.
  • the abscissa of the center point of the element, the initial position of the element can be determined based on the abscissa and ordinate of the center point of the element.
  • the element layout system 200 can directly determine multiple The element's initial size and position on the canvas.
  • the element layout system 200 takes the initial size and position of multiple elements on the canvas as a starting point, combines the size of the canvas and design constraints, iteratively optimizes the size and position of the multiple elements on the canvas, and obtains multiple Candidate layout.
  • the layout of an element can be characterized by the size and position of the element, and the element layout system 200 determines an appropriate size and position through an iterative optimization algorithm to realize the element layout.
  • the element layout system 200 can start from the initial size and initial position of multiple elements on the canvas, combine the size of the canvas and design constraints, such as basic constraints and user-defined constraints (if any), and use an optimizer to Iteratively optimizing the size and position of the multiple elements on the canvas, so as to obtain multiple candidate layouts.
  • the element layout system 200 can be implemented using the above-mentioned Gurobi optimizer or CBC optimizer Iterative optimization to meet different business needs.
  • the element layout system 200 may also obtain the type of each element, such as chart, text, decoration and other types.
  • iterative optimization may also be performed in combination with element types.
  • the element layout system 200 can group elements based on element types, bind elements belonging to the same group, and then perform iterative optimization in units of bound element groups.
  • the element layout system 200 can bind a chart type element with a text type element (for example, the title of a chart), and then treat the bound element groups as one element for iterative optimization.
  • the element layout system 200 uses a generative model, such as the core mixed-integer linear programming (MILP) generative model, to generate candidate layouts during the layout generation phase.
  • MILP mixed-integer linear programming
  • the size of the generative model usually depends on the number of elements.
  • the number of decision variables and constraints in the generative model is independent of the canvas and other factors.
  • the core MILP formulation (not shown in Figure 5) and objective function are defined in the generative model.
  • the core MILP formulas are used to generate an appropriate layout grid skeleton to ensure that elements are within allowed position and size constraints, do not overlap each other, and do not overflow the canvas.
  • the generation model defines the origin of the coordinate system as the upper left corner of the canvas, the positive direction of the X-axis is horizontally to the right, and the positive direction of the Y-axis is vertically downward.
  • Continuous decision variables Le, Re, Te, and Be are defined in the generative model to indicate the position of the left, right, upper, and lower edges of a single element e, through which the appropriate element size can be ensured and element overflow can be prevented.
  • Design constraints such as alignment constraints and padding constraints can be used as the objective function of the generative model (also called additional constraints) to optimize the layout grid skeleton and generate candidate layouts with aesthetic effects such as alignment.
  • the element layout system 200 sorts the multiple candidate layouts to obtain a layout result.
  • the element layout system 200 can sort multiple candidate layouts from different dimensions, so as to select a candidate layout with better performance as the layout result.
  • the element layout system 200 may, according to at least one of the size balance of each of the multiple elements, the balance of the picture presented by the multiple elements on the canvas, and the alignment of the multiple elements, Ranking the plurality of candidate layouts.
  • the element layout system 200 may score the balance of the size of each of the multiple elements, the balance of the picture presented by the multiple elements on the canvas, and the alignment of the multiple elements, The plurality of candidate layouts are ranked according to the corresponding scores.
  • the element layout system 200 adopts a sorting model to evaluate the size quality Q s (the balance degree of the size), the balance quality Q b (the balance degree of the picture presented by multiple elements on the canvas), and the alignment quality Q a (the balance degree of the multiple elements Alignment degree) is scored to obtain the size balance score Score size , balance score (importance score Score importance ) and alignment score Score align .
  • the element layout system 200 can calculate the total score for each candidate layout as follows:
  • the element layout system 200 can sort multiple candidate layouts based on the above total score to obtain a layout result.
  • the layout result may be the top candidate layout among the plurality of candidate layouts, for example, it may be the candidate layout whose total score is ranked top3.
  • the layout result may be a candidate layout sorted as top1, such as candidate layout 1.
  • the layout result includes recommended sizes and recommended positions of elements on the canvas.
  • the recommended size and recommended position may be the size and position of elements in the above-mentioned top-ranked candidate layouts.
  • the Score size can be determined based on the sum of the normalized width and normalized height of each element. Please refer to the formula (31) for the specific calculation method:
  • width e and height e are used to represent the width and height of element e
  • width ca and height ca are used to represent the width and height of the canvas.
  • N el is used to characterize the number of elements.
  • the element size difference in the left layout is greater than the element size difference in the right layout, and the size balance score corresponding to the left layout is lower than the size balance score corresponding to the right layout.
  • the higher the size balance score the more balanced the size of each element in the layout.
  • the alignment score Score alig can be determined according to the top, bottom, left, and right alignments between every two elements. If two elements are aligned, then Take 1, similarly, if the two elements are bottom-aligned, left-aligned, and right-aligned, then Take 1.
  • the alignment score Score ali of a candidate layout can be referred to the following formula:
  • the number of element alignments in the left layout is smaller than that of the right layout, and correspondingly, the alignment score of the left layout is smaller than that of the right layout.
  • the importance score Score importance may be determined according to the area of the element and the distance from the element to the center point of the canvas. For example, the importance score for a candidate layout may be determined based on the area of each element and the distance of each element from the center point of the canvas. Please refer to the formula (33) for the specific calculation method:
  • important_weight e represents the importance coefficient of the element
  • area e represents the area of the element
  • x e represents the x coordinate of the element
  • y e represents the y coordinate of the element
  • width e and height e represent the width and height of the element respectively
  • width canvas indicates the width and height of the canvas respectively.
  • the importance score of the element in the third column and the first row in the layout on the left in FIG. 6C is smaller than the importance score of the element in the second column in the layout on the right.
  • sorting may also be performed based on the weighted average of the three scores or one or two of the three scores, and the layout result is determined according to the sorting result.
  • the above S308 to S310 are the element layout system 200 in the embodiment of the present application, starting from the initial size and initial position of the multiple elements on the canvas, combining the size of the canvas and design constraints, Iteratively optimizes the size and position of each element on the canvas to obtain a layout result.
  • the element layout system 200 may not perform operations such as sorting.
  • the element layout system 200 can generate a candidate layout and use the candidate layout as a layout result.
  • the element layout system 200 can set various trigger conditions to trigger the process of iterative optimization and layout generation.
  • the element layout system 200 may provide an intelligent layout control, and the trigger condition may include that the user triggers the above-mentioned intelligent layout control.
  • the element layout system 200 is set with a pre-review time, and the trigger condition may include that the time since the user last entered an element is greater than the preset time. That is to say, the element layout system 200 may start from the initial size and initial position of the multiple elements on the canvas when the user triggers the smart layout control, or when the time since the user last entered an element is greater than the preset time, in combination with the The size and design constraints of the canvas, iteratively optimize the size and position of the multiple elements on the canvas.
  • the embodiment of the present application provides an element layout method.
  • the method adopts an iterative optimization method to determine the recommended size and recommended position, rather than matching with a fixed layout template, thus solving the problems in related technologies that are not suitable for elements such as charts and poor layout effects, and has high usability .
  • multiple candidate layouts can be generated and sorted based on the size balance score, alignment score and/or importance score to obtain the layout result, which can realize the intelligent layout driven by user intent .
  • one chart also called the main chart
  • the rest of the visual charts can be used to assist the main chart to complete the narration of the data fact. In this way, it can be obtained Better presentation effect.
  • the embodiments of the present application also design relevant verification experiments to verify the demonstration effect. Taking into account the age, gender, culture, professional background and other factors of different personnel, 20 people were selected for the test in this verification experiment. Among them, the 20 people who conducted the test were specifically 15 visualization professionals and 5 technical experts.
  • the verification experiment uses the T-test test method to analyze the test data.
  • T-test is a statistical test method widely used to compare the means of two groups of samples. It uses the T distribution theory to infer the probability of the difference, so as to determine whether the difference between the two means is significant. It is mainly used for normal distribution with small sample size (eg n ⁇ 30) and unknown population standard deviation ⁇ .
  • the element layout method of the embodiment of the present application uses the element layout method of the embodiment of the present application and other element layout methods (such as element layout methods based on templates and dynamic programming) to generate different layouts, assuming layout 1 and layout 2. Then, 20 testers can score the above layout 1 and layout 2 respectively. For Layout 1 and Layout 2, T-test is used to determine whether the difference between the mean scores of 20 testers is significant.
  • T-test results show that the demonstration effect of the element layout method adopted in the embodiment of the present application is significantly better than that of the element layout method based on templates and dynamic programming (confidence degree >99%).
  • the overall effect of the layout generated by the element layout method in the embodiment of the present application is better, the size of the elements is reasonable, and the canvas is better filled.
  • the system 200 includes:
  • An interaction module 202 configured to receive multiple elements input by the user
  • a determining module 204 configured to determine the initial size and initial position of the plurality of elements on the canvas
  • An optimization module 206 configured to iteratively optimize the size and position of the multiple elements on the canvas, taking the initial size and initial position of the multiple elements on the canvas as a starting point, in combination with the size of the canvas and design constraints , obtaining a layout result, where the layout result includes recommended sizes and recommended positions of the plurality of elements on the canvas.
  • the optimization module 206 is specifically configured to:
  • each of the multiple candidate layouts includes the size and position of the multiple elements on the canvas ;
  • the optimization module 206 is specifically configured to:
  • the plurality of candidate layouts Sort According to at least one of the degree of balance of the size of each of the plurality of elements, the degree of balance of the images presented by the plurality of elements on the canvas, and the degree of alignment of the plurality of elements, the plurality of candidate layouts Sort.
  • the balance degree of the picture presented by the multiple elements on the canvas is characterized by the sum of the importance scores of each element, and the importance score is based on the area of the element and the distance between the element and the Determine the distance from the center point of the canvas.
  • the interaction module 202 is also configured to:
  • the design constraints include basic constraints and the custom constraints.
  • the basic constraints include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and fill constraints
  • the custom constraints include locking constraints, aspect ratio constraints, Any one or more of the alignment preference constraints.
  • the elements include one or more of graphics, text or decorations.
  • the interaction module 202 is specifically configured to:
  • a plurality of elements corresponding to the visualization component are received in response to a user's drag operation on the visualization component.
  • the optimization module 206 is specifically configured to:
  • the element layout system 200 may correspond to the implementation of the method described in the embodiment of the present application, and the above-mentioned and other operations and/or functions of the various modules/units of the element layout system 200 are respectively in order to realize the implementation shown in FIG. 2
  • the corresponding flow of each method in the example is not repeated here.
  • the embodiment of the present application also provides a computer cluster.
  • the computer cluster includes at least one computer, and any computer in the at least one computer may be from a cloud environment or an edge environment, or may be a terminal device.
  • the computer cluster is specifically used to implement the functions of the element layout system 200 in the embodiment shown in FIG. 2 .
  • FIG. 7 provides a schematic structural diagram of a computer cluster.
  • the computer cluster 70 includes multiple computers 700 , and the computers 700 include a bus 701 , a processor 702 , a communication interface 703 and a memory 704 .
  • the processor 702 , the memory 704 and the communication interface 703 communicate through the bus 701 .
  • the bus 701 may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus or an extended industry standard architecture (extended industry standard architecture, EISA) bus, etc.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one thick line is used in FIG. 7 , but it does not mean that there is only one bus or one type of bus.
  • the processor 702 may be a central processing unit (central processing unit, CPU), a graphics processing unit (graphics processing unit, GPU), a microprocessor (micro processor, MP) or a digital signal processor (digital signal processor, DSP) etc. Any one or more of them.
  • CPU central processing unit
  • GPU graphics processing unit
  • MP microprocessor
  • DSP digital signal processor
  • the communication interface 703 is used for communicating with the outside.
  • the communication interface 703 is used to receive multiple elements input by the user, output layout results, and so on.
  • the memory 704 may include a volatile memory (volatile memory), such as a random access memory (random access memory, RAM).
  • volatile memory such as a random access memory (random access memory, RAM).
  • Memory 704 can also include non-volatile memory (non-volatile memory), such as read-only memory (read-only memory, ROM), flash memory, hard disk drive (hard disk drive, HDD) or solid state drive (solid state drive) , SSD).
  • Computer-readable instructions are stored in the memory 704 , and the processor 702 executes the computer-readable instructions, so that the computer cluster 70 executes the aforementioned element layout method (or implements the aforementioned element layout system 200 functions).
  • the determination module 204 and the optimization module 206 are realized by software
  • software or program codes required to execute the functions of the modules in FIG. 2 may be stored in at least one memory 704 in the computer cluster 70 .
  • At least one processor 702 executes the program code stored in the memory 704, so that the computer cluster 70 executes the aforementioned element layout method.
  • the embodiment of the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be any available medium that can be stored by a computer cluster or a data storage device such as a data center including one or more available media.
  • the available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state hard disk), etc.
  • the computer-readable storage medium includes instructions, and the instructions instruct a cluster of computers to execute the above element layout method.
  • the embodiment of the present application also provides a computer program product.
  • the computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on the computer cluster, the processes or functions according to the embodiments of the present application are generated in whole or in part.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, from a website, computing device, or data center via Wired (eg, coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.) transmission to another website site, computing device, or data center.
  • Wired eg, coaxial cable, fiber optic, digital subscriber line (DSL)
  • wireless eg, infrared, wireless, microwave, etc.

Abstract

The present application provides an element layout method, comprising: receiving a plurality of elements inputted by a user, determining initial sizes and initial locations of the plurality of elements in a canvas, and starting from the initial sizes and initial locations of the plurality of elements in the canvas in combination with the size of the canvas and design constraints, iteratively optimizing the sizes and locations of the plurality of elements in the canvas to obtain a layout result, the layout result comprising recommended sizes and recommended locations of the plurality of elements in the canvas. In the method, an element layout problem is transformed into a linear programming problem, and for a set of inputted elements, recommended locations and recommended sizes of elements are determined by using an iterative optimization approach, such that an intelligent element layout is achieved. The method is also applicable to elements of types such as charts, achieves a good layout effect in the layout of elements such as charts, and therefore is highly available.

Description

元素布局方法以及相关设备Element layout method and related equipment
本申请要求于2021年11月30日提交中国国家知识产权局、申请号为202111447457.3、发明名称为“元素布局方法以及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202111447457.3 and the title of the invention "element layout method and related equipment" filed with the State Intellectual Property Office of China on November 30, 2021, the entire contents of which are incorporated by reference in this application middle.
技术领域technical field
本申请涉及计算机技术领域,尤其涉及一种元素布局方法、系统以及计算机集群、计算机可读存储介质、计算机程序产品。The present application relates to the field of computer technology, and in particular to an element layout method, a system, a computer cluster, a computer-readable storage medium, and a computer program product.
背景技术Background technique
在日常工作或生活中,常常需要通过屏幕,例如是大尺寸屏幕(也可以简称为大屏)进行内容演示,以提高沟通效率。其中,屏幕演示的内容通常由元素提供。元素是指表达一定含义的组件,例如元素可以包括文本、图表等不同类型的组件。In daily work or life, it is often necessary to perform content demonstration through a screen, for example, a large-size screen (also referred to as a large screen for short), so as to improve communication efficiency. Among them, the content of the screen presentation is usually provided by the element. An element refers to a component that expresses a certain meaning. For example, an element can include different types of components such as text and graphics.
随着用户对元素的添加与修改,屏幕中元素的布局需要随之发生相应的改变。也即在可视化屏幕的整个设计过程中,需要不断地调整元素的布局。元素组合方式的多样性,以及布局目标的复杂性,如各元素之间相互对齐、元素填充等给屏幕中元素的布局带来了巨大的挑战。As users add and modify elements, the layout of elements on the screen needs to change accordingly. That is to say, in the whole design process of the visual screen, it is necessary to constantly adjust the layout of the elements. The diversity of element combinations and the complexity of layout goals, such as mutual alignment between elements and element filling, have brought great challenges to the layout of elements on the screen.
业界提供了基于模板和动态编程自动进行元素布局的方法。该方法提供了多种布局模板,当用户输入元素时,可以基于动态编程自动匹配相应的布局模板,从而实现元素布局。然而,上述方法主要适用于文本类型的元素,图表等类型的元素的格式更加自由,难以匹配布局模板,进而导致基于模板和动态编程的布局效果不佳。The industry provides methods for automatically laying out elements based on templates and dynamic programming. This method provides a variety of layout templates, and when the user inputs elements, the corresponding layout templates can be automatically matched based on dynamic programming, so as to realize element layout. However, the above method is mainly suitable for text-type elements. The format of elements such as charts is more free, and it is difficult to match the layout template, which leads to poor layout effects based on templates and dynamic programming.
发明内容Contents of the invention
本申请提供了一种元素布局方法,该方法将元素布局问题转化为线性规划问题,针对输入的一组元素,采用迭代优化的方式确定元素的推荐位置和推荐尺寸,从而实现智能化的元素布局。由于不需与固定的布局模板进行匹配,解决了对图表等类型的元素不适用,导致布局效果不佳的问题。本申请还提供了上述方法对应的元素布局系统、计算机集群、计算机可读存储介质以及计算机程序产品。This application provides an element layout method, which transforms the element layout problem into a linear programming problem, and uses an iterative optimization method to determine the recommended position and size of elements for a set of input elements, thereby realizing intelligent element layout . Since there is no need to match with a fixed layout template, it solves the problem that it is not suitable for elements such as charts, resulting in poor layout effects. The present application also provides an element layout system, a computer cluster, a computer-readable storage medium, and a computer program product corresponding to the above method.
第一方面,本申请提供了一种元素布局方法。该方法可以由元素布局系统执行。在一些实施例中,该元素布局系统可以是软件系统,计算机集群通过运行该软件系统的程序代码,以执行元素布局方法。在另一些实施例中,该元素布局系统也可以是用于元素布局的硬件系统。In a first aspect, the present application provides an element layout method. This method can be performed by the element layout system. In some embodiments, the element layout system may be a software system, and the computer cluster executes the element layout method by running the program code of the software system. In some other embodiments, the element layout system may also be a hardware system for element layout.
具体地,元素布局系统可以接收用户输入的多个元素,确定所述多个元素在画布的初始尺寸和初始位置,然后以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得所述多个元素在所述画布的推荐尺寸和推荐位置,由此实现智能化的元素布局。Specifically, the element layout system may receive multiple elements input by the user, determine the initial size and initial position of the multiple elements on the canvas, and then use the initial size and initial position of the multiple elements on the canvas as a starting point, combine the The size and design constraints of the canvas, iteratively optimize the size and position of the multiple elements on the canvas, and obtain the recommended size and position of the multiple elements on the canvas, thereby realizing intelligent elements layout.
在该方法中,元素布局系统通过将元素布局问题转换为线性规划问题,针对输入的一 组元素(通常是多个元素),采用迭代优化的方式求解每个元素的推荐位置和推荐尺寸,使得每个元素不与其他元素重叠,并且不溢出画布。由于不与固定的布局模板进行匹配,因而解决了相关技术中对于图表等类型的元素不适用,布局效果不佳的问题,具有较高可用性。而且,该方法通过设置必要的布局属性如元素的上、下、左、右边缘的位置等,并以用户输入元素的初始尺寸、初始位置等为起点进行迭代优化,实现了基于用户意图进行驱动,提升了交互性,减少了设计者的工作量。此外,该方法采用固定尺寸画布代替像素离散化的画布,由此可以实现采用连续决策变量代替大量的离散决策变量,在连续决策变量所提供的连续空间进行迭代优化,可以大幅降低计算量,降低算法复杂度,缩短智能布局的时间,提高智能布局的效率。In this method, the element layout system transforms the element layout problem into a linear programming problem, and uses an iterative optimization method to solve the recommended position and recommended size of each element for a set of input elements (usually multiple elements), so that Each element does not overlap other elements and does not overflow the canvas. Because it does not match with a fixed layout template, it solves the problem in the related art that it is not suitable for elements of types such as charts and the layout effect is not good, and has high usability. Moreover, the method realizes driving based on user intent by setting necessary layout attributes such as the position of the upper, lower, left, and right edges of the element, and performing iterative optimization based on the initial size and initial position of the element input by the user. , which improves interactivity and reduces the workload of designers. In addition, this method uses a fixed-size canvas instead of a pixel-discretized canvas, so that continuous decision variables can be used instead of a large number of discrete decision variables, and iterative optimization can be performed in the continuous space provided by continuous decision variables, which can greatly reduce the amount of calculation. The algorithm complexity shortens the time of intelligent layout and improves the efficiency of intelligent layout.
在一些可能的实现方式中,元素布局系统对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得多个候选布局。所述多个候选布局中的每个候选布局包括所述多个元素在所述画布的尺寸和位置。然后元素布局系统对多个候选布局进行排序,获得布局结果。该布局结果为所述多个候选布局中排序靠前的候选布局,例如布局结果可以是多个候选布局中排名第一的候选布局。In some possible implementation manners, the element layout system iteratively optimizes the sizes and positions of the multiple elements on the canvas to obtain multiple candidate layouts. Each candidate layout of the plurality of candidate layouts includes a size and position of the plurality of elements on the canvas. Then the element layout system sorts multiple candidate layouts to obtain layout results. The layout result is a top-ranked candidate layout among the multiple candidate layouts, for example, the layout result may be the first-ranked candidate layout among the multiple candidate layouts.
该方法中,元素布局系统通过对多个候选布局进行排序,根据排序结果从多个候选结果中确定布局结果,如此进一步提升了布局效果,满足了业务需求。In this method, the element layout system sorts a plurality of candidate layouts, and determines the layout result from the plurality of candidate results according to the sorting result, which further improves the layout effect and meets business requirements.
在一些可能的实现方式中,元素布局系统可以根据所述多个元素中每个元素的尺寸的均衡度、所述多个元素在画布呈现的画面的均衡度以及所述多个元素的对齐程度中的至少一个,对所述多个候选布局进行排序。如此,可以从元素的尺寸的均衡度、元素在画布呈现的画面的均衡度以及元素的对齐程度等维度中的至少一个维度对布局效果进行排序,从而确定元素的尺寸的均衡度、元素在画布呈现的画面的均衡度和/或元素的对齐程度满足要求的布局结果。In some possible implementations, the element layout system may be based on the balance of the size of each of the multiple elements, the balance of the images presented by the multiple elements on the canvas, and the alignment of the multiple elements At least one of the multiple candidate layouts is sorted. In this way, the layout effect can be sorted from at least one of the dimensions of the balance of the size of the element, the balance of the picture presented by the element on the canvas, and the alignment of the elements, so as to determine the balance of the size of the element, the balance of the element on the canvas The balance of the presented picture and/or the alignment of elements meet the required layout results.
在一些可能的实现方式中,所述多个元素在画布呈现的画面的均衡度通过每个元素的重要性分数之和表征。其中,所述重要性分数根据所述元素的面积以及所述元素到所述画布的中心点的距离确定。如此可以实现对具有较高重要性的元素按照权重进行布局,使得较高重要性的元素处于视觉焦点,满足业务需求。In some possible implementation manners, the balance of the images presented by the multiple elements on the canvas is represented by a sum of importance scores of each element. Wherein, the importance score is determined according to the area of the element and the distance from the element to the center point of the canvas. In this way, the elements with higher importance can be laid out according to the weight, so that the elements with higher importance are in the visual focus and meet business needs.
在一些可能的实现方式中,设计约束不仅可以包括系统内置的基础约束,还可以包括自定义约束。元素布局系统除了基于系统内置的基础约束,对元素的尺寸和位置进行迭代优化,还可以接收用户输入的自定义约束,并结合该自定义约束,对元素的尺寸和位置进行迭代优化。如此可以实现基于用户意图的智能元素布局。In some possible implementation manners, the design constraints may include not only the built-in basic constraints of the system, but also user-defined constraints. In addition to iteratively optimizing the size and position of elements based on the built-in basic constraints of the system, the element layout system can also receive user-defined constraints and combine them to iteratively optimize the size and position of elements. This enables smart element layout based on user intent.
在一些可能的实现方式中,所述基础约束包括对齐约束、网格约束、大小约束、边界约束和填充约束中的任意一种或多种。所述自定义约束包括锁定约束、纵横比约束、对齐偏好约束中的任意一种或多种。In some possible implementation manners, the basic constraints include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and filling constraints. The self-defined constraints include any one or more of locking constraints, aspect ratio constraints, and alignment preference constraints.
对齐约束具体用于保证元素对齐,网格约束用于保证画布区域的合理划分,防止元素重叠,大小约束用于保证元素的大小(即尺寸)合理,以满足人眼对于图表等元素的可读性的要求,边界约束用于保证输入的元素充满画布,填充约束用于保证布局内部充满,避免布局内部空缺使得整体的空间失去连续感,进而在一定程度上影响布局的美观度。Alignment constraints are specifically used to ensure the alignment of elements. Grid constraints are used to ensure a reasonable division of the canvas area and prevent elements from overlapping. Size constraints are used to ensure that the size (ie size) of elements is reasonable to meet the readability of elements such as charts by the human eye. The boundary constraint is used to ensure that the input elements fill the canvas, and the filling constraint is used to ensure that the interior of the layout is full, so as to avoid the internal vacancy of the layout and make the overall space lose the sense of continuity, which in turn affects the aesthetics of the layout to a certain extent.
锁定约束用于对一个或多个元素进行尺寸和位置的锁定。综横比约束用于对一个或多 个元素的缩放比进行约束。对齐偏好约束用于对一个或多个元素进行置顶、置左、置右或者置下约束。Lock constraints are used to lock the size and position of one or more elements. Aspect ratio constraints are used to constrain the scaling ratio of one or more elements. Alignment preference constraints are used to constrain one or more elements to be top, left, right, or bottom.
通过在上述约束下,对元素的尺寸和位置进行迭代优化,可以使得最终的布局结果具有较好的布局效果,能够满足业务需求。By iteratively optimizing the size and position of elements under the above constraints, the final layout result can have a better layout effect and meet business needs.
在一些可能的实现方式中,所述元素包括图表、文本或装饰中的一种或多种。其中,装饰例如可以是指图表、文本的标题、背景等。在该方法中,元素布局系统可以实现对图表、文本、装饰等不同类型的元素进行智能元素布局,具有较高可用性。In some possible implementations, the elements include one or more of graphics, text or decorations. Wherein, the decoration may refer to, for example, a graph, a title of a text, a background, and the like. In this method, the element layout system can implement intelligent element layout for different types of elements such as charts, texts, and decorations, and has high usability.
在一些可能的实现方式中,元素布局系统可以向用户呈现设计界面,该设计界面承载有可视化组件,用户可以触发对所述可视化组件的拖拽操作,元素布局系统响应于用户的上述操作,接收与可视化组件对应的多个元素。In some possible implementations, the element layout system can present a design interface to the user, the design interface carries a visual component, and the user can trigger a drag operation on the visual component, and the element layout system responds to the above operation of the user, receiving Multiple elements corresponding to visual components.
通过上述可视化组件,简化用户操作,提高元素布局的效率。而且,通过将可视化组件拖拽至设计界面,可以保障元素布局过程的透明度,便于用户手动调整元素的布局,满足用户精细化的布局要求。Through the above visual components, user operations are simplified and the efficiency of element layout is improved. Moreover, by dragging and dropping visual components to the design interface, the transparency of the element layout process can be guaranteed, and it is convenient for users to manually adjust the layout of elements to meet users' refined layout requirements.
在一些可能的实现方式中,元素布局系统可以设置智能元素布局的触发条件。例如触发条件可以设置为用户触发智能布局控件,或者是距离用户上次输入元素的视觉大于预设时间。基于此,当用户触发智能布局控件或者距离用户上次输入元素的时间大于预设时间时,智能元素布局的触发条件被满足,元素布局系统可以以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化。In some possible implementations, the element layout system can set trigger conditions for smart element layout. For example, the trigger condition can be set such that the user triggers the smart layout control, or the user's vision of the last input element is greater than the preset time. Based on this, when the user triggers the smart layout control or the time since the user last entered an element is greater than the preset time, the trigger condition of the smart element layout is met, and the element layout system can use the initial size and initial size of the multiple elements on the canvas The position is used as a starting point, and the size and position of the multiple elements on the canvas are iteratively optimized in combination with the size of the canvas and design constraints.
该方法通过设置智能元素布局的触发条件,并在智能元素布局的触发条件被满足时,自动触发智能元素布局,进一步减少了用户操作,提高了元素布局的效率,提升了用户体验。The method sets the triggering condition of the smart element layout, and automatically triggers the smart element layout when the triggering condition of the smart element layout is satisfied, further reduces user operations, improves the efficiency of the element layout, and improves user experience.
第二方面,本申请提供了一种元素布局系统。所述系统包括:In a second aspect, the present application provides an element layout system. The system includes:
交互模块,用于接收用户输入的多个元素;An interactive module for receiving multiple elements input by the user;
确定模块,用于确定所述多个元素在画布的初始尺寸和初始位置;A determining module, configured to determine the initial size and initial position of the plurality of elements on the canvas;
优化模块,用于以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得布局结果,所述布局结果包括所述多个元素在所述画布的推荐尺寸和推荐位置。An optimization module, configured to iteratively optimize the size and position of the multiple elements on the canvas, taking the initial size and initial position of the multiple elements on the canvas as a starting point, in combination with the size of the canvas and design constraints, A layout result is obtained, where the layout result includes recommended sizes and recommended positions of the plurality of elements on the canvas.
在一些可能的实现方式中,所述优化模块具体用于:In some possible implementation manners, the optimization module is specifically used to:
对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得多个候选布局,所述多个候选布局中的每个候选布局包括所述多个元素在所述画布的尺寸和位置;Iteratively optimizing the size and position of the multiple elements on the canvas to obtain multiple candidate layouts, each of the multiple candidate layouts includes the size and position of the multiple elements on the canvas ;
对所述多个候选布局进行排序,获得布局结果,所述布局结果为所述多个候选布局中排序靠前的候选布局。Sorting the multiple candidate layouts to obtain a layout result, where the layout result is a top-ranked candidate layout among the multiple candidate layouts.
在一些可能的实现方式中,所述优化模块具体用于:In some possible implementation manners, the optimization module is specifically used to:
根据所述多个元素中每个元素的尺寸的均衡度、所述多个元素在画布呈现的画面的均衡度以及所述多个元素的对齐程度中的至少一个,对所述多个候选布局进行排序。According to at least one of the degree of balance of the size of each of the plurality of elements, the degree of balance of the images presented by the plurality of elements on the canvas, and the degree of alignment of the plurality of elements, the plurality of candidate layouts Sort.
在一些可能的实现方式中,所述多个元素在画布呈现的画面的均衡度通过每个元素的重要性分数之和表征,所述重要性分数根据所述元素的面积以及所述元素到所述画布的中 心点的距离确定。In some possible implementation manners, the balance degree of the picture presented by the multiple elements on the canvas is characterized by the sum of the importance scores of each element, and the importance score is based on the area of the element and the distance between the element and the Determine the distance from the center point of the canvas.
在一些可能的实现方式中,所述交互模块还用于:In some possible implementations, the interaction module is also used to:
接收用户输入的自定义约束;Receive custom constraints entered by the user;
所述设计约束包括基础约束和所述自定义约束。The design constraints include basic constraints and the custom constraints.
在一些可能的实现方式中,所述基础约束包括对齐约束、网格约束、大小约束、边界约束和填充约束中的任意一种或多种,所述自定义约束包括锁定约束、纵横比约束、对齐偏好约束中的任意一种或多种。In some possible implementations, the basic constraints include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and fill constraints, and the custom constraints include locking constraints, aspect ratio constraints, Any one or more of the alignment preference constraints.
在一些可能的实现方式中,所述元素包括图表、文本或装饰中的一种或多种。In some possible implementations, the elements include one or more of graphics, text or decorations.
在一些可能的实现方式中,所述交互模块具体用于:In some possible implementation manners, the interaction module is specifically used to:
向用户呈现设计界面,所述设计界面承载有可视化组件;presenting a design interface to a user, the design interface carrying a visual component;
响应于用户对所述可视化组件的拖拽操作,接收与所述可视化组件对应的多个元素。A plurality of elements corresponding to the visualization component are received in response to a user's drag operation on the visualization component.
在一些可能的实现方式中,所述优化模块具体用于:In some possible implementation manners, the optimization module is specifically used to:
当用户触发智能布局控件或者距离用户上次输入元素的时间大于预设时间时,以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化。When the user triggers the smart layout control or the time since the user last entered an element is greater than the preset time, starting from the initial size and initial position of the multiple elements on the canvas, combined with the size of the canvas and design constraints, the Iteratively optimizing the size and position of the plurality of elements on the canvas.
第三方面,本申请提供一种计算机集群。该计算机集群包括至少一台计算机,至少一台计算机包括至少一个处理器和至少一个存储器。所述至少一个处理器、所述至少一个存储器进行相互的通信。所述至少一个处理器用于执行所述至少一个存储器中存储的指令,以使得计算机集群执行如第一方面或第一方面的任一种实现方式中的元素布局方法。In a third aspect, the present application provides a computer cluster. The computer cluster includes at least one computer, and the at least one computer includes at least one processor and at least one memory. The at least one processor and the at least one memory communicate with each other. The at least one processor is configured to execute instructions stored in the at least one memory, so that the computer cluster executes the element layout method in the first aspect or any implementation manner of the first aspect.
第四方面,本申请提供一种计算机可读存储介质。所述计算机可读存储介质中存储有指令,所述指令指示计算机集群执行上述第一方面或第一方面的任一种实现方式所述的元素布局方法。In a fourth aspect, the present application provides a computer-readable storage medium. Instructions are stored in the computer-readable storage medium, and the instructions instruct a cluster of computers to execute the element layout method described in the first aspect or any implementation manner of the first aspect.
第五方面,本申请提供了一种包含指令的计算机程序产品,当其在计算机集群上运行时,使得计算机集群执行上述第一方面或第一方面的任一种实现方式所述的元素布局方法。In the fifth aspect, the present application provides a computer program product containing instructions. When it is run on a computer cluster, the computer cluster executes the element layout method described in the first aspect or any implementation manner of the first aspect. .
本申请在上述各方面提供的实现方式的基础上,还可以进行进一步组合以提供更多实现方式。On the basis of the implementation manners provided in the foregoing aspects, the present application may further be combined to provide more implementation manners.
附图说明Description of drawings
为了更清楚地说明本申请实施例的技术方法,下面将对实施例中所需使用的附图作以简单地介绍。In order to more clearly illustrate the technical methods of the embodiments of the present application, the following will briefly introduce the drawings required in the embodiments.
图1A至图1D为本申请实施例提供的元素布局方法的应用场景图;FIG. 1A to FIG. 1D are application scene diagrams of the element layout method provided by the embodiment of the present application;
图2为本申请实施例提供的一种元素布局方法的系统架构图;FIG. 2 is a system architecture diagram of an element layout method provided by an embodiment of the present application;
图3为本申请实施例提供的一种元素布局方法的流程图;FIG. 3 is a flow chart of an element layout method provided by an embodiment of the present application;
图4A至图4H为本申请实施例提供的设计约束的示意图;4A to 4H are schematic diagrams of the design constraints provided by the embodiments of the present application;
图5为本申请实施例提供的一种元素布局方法的原理图;FIG. 5 is a schematic diagram of an element layout method provided by an embodiment of the present application;
图6A至图6C为本申请实施例提供的一种不同布局打分的示意图;6A to 6C are schematic diagrams of scoring different layouts provided by the embodiment of the present application;
图7为本申请实施例提供的一种计算机集群的结构示意图。FIG. 7 is a schematic structural diagram of a computer cluster provided by an embodiment of the present application.
具体实施方式Detailed ways
本申请实施例中的术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。The terms "first" and "second" in the embodiments of the present application are used for description purposes only, and cannot be interpreted as indicating or implying relative importance or implicitly indicating the quantity of indicated technical features. Thus, a feature defined as "first" and "second" may explicitly or implicitly include one or more of these features.
首先对本申请实施例中所涉及到的一些技术术语进行介绍。First, some technical terms involved in the embodiments of the present application are introduced.
元素布局是指设置元素在屏幕(例如是屏幕应用的画布)的尺寸和位置。其中,屏幕或者画布的尺寸通常是固定的,元素的尺寸和位置是可调整的。基于此,元素布局的过程通常是不断调整元素在屏幕或画布的尺寸和位置,以优化演示效果的过程。Element layout refers to setting the size and position of elements on the screen (such as the canvas of the screen application). Among them, the size of the screen or canvas is usually fixed, and the size and position of elements are adjustable. Based on this, the process of element layout is usually a process of continuously adjusting the size and position of elements on the screen or canvas to optimize the presentation effect.
元素是指表达一定含义的组件。其中,元素可以多种类型,例如元素可以包括文本、图表、装饰等不同类型。其中,文本可以包括正文或标题(正文的标题或者图表的标题)等,图表可以包括柱状图、折线图、饼图或者图案,装饰可以包括用于突出或美化文本、图表的形状、符号或者背景。An element is a component that expresses a certain meaning. Wherein, the elements may be of various types, for example, the elements may include different types such as text, graphics, and decorations. Among them, the text can include text or title (the title of the text or the title of the chart), etc., the chart can include bar charts, line charts, pie charts or patterns, and the decoration can include shapes, symbols or backgrounds used to highlight or beautify text and charts .
基于模板和动态编程可以实现自动化的元素布局。具体地,元素布局应用可以提供多种布局模板,当用户输入多个元素时,元素布局应用可以基于动态编程自动匹配与多个元素适配的布局模板,并向用户提供与多个元素匹配的布局模板,以供用户选择,从而实现元素布局。然而,上述方法主要适用于文本类型的元素,图表等类型的元素的格式更加自由,难以匹配布局模板,进而导致基于模板和动态编程的布局效果不佳。Automated element layout is possible based on templates and dynamic programming. Specifically, the element layout application can provide multiple layout templates. When the user inputs multiple elements, the element layout application can automatically match the layout templates that match the multiple elements based on dynamic programming, and provide the user with the layout templates that match the multiple elements. Layout templates for the user to select to implement element layout. However, the above method is mainly suitable for text-type elements. The format of elements such as charts is more free, and it is difficult to match the layout template, which leads to poor layout effects based on templates and dynamic programming.
有鉴于此,本申请实施例提供了一种元素布局方法。该方法可以由元素布局系统执行。在一些实施例中,该元素布局系统可以是软件系统,计算机集群通过运行该软件系统的程序代码,以执行元素布局方法。在另一些实施例中,该元素布局系统也可以是用于元素布局的硬件系统。本申请实施例以元素布局系统为软件系统进行示例说明。In view of this, the embodiment of the present application provides an element layout method. This method can be performed by the element layout system. In some embodiments, the element layout system may be a software system, and the computer cluster executes the element layout method by running the program code of the software system. In some other embodiments, the element layout system may also be a hardware system for element layout. The embodiment of the present application uses an element layout system as a software system for illustration.
其中,元素布局问题可以定义为:对于一组需要放置在具有指定宽度和高度的固定尺寸画布上的元素(例如是矩形元素),找到可行的解决方案,使得所有元素不重叠并且不溢出画布。该方法可以将元素布局问题转换为线性规划问题。该线性规划问题具体为:针对输入的一组元素(通常是多个元素),求解每个元素的推荐位置和推荐尺寸,使得每个元素不与其他元素重叠,并且不溢出画布。Among them, the element layout problem can be defined as: for a set of elements (such as rectangular elements) that need to be placed on a fixed-size canvas with a specified width and height, find a feasible solution so that all elements do not overlap and do not overflow the canvas. This method can transform the element layout problem into a linear programming problem. Specifically, the linear programming problem is: for a set of input elements (usually multiple elements), solve the recommended position and recommended size of each element, so that each element does not overlap with other elements and does not overflow the canvas.
具体实现时,元素布局系统可以接收用户输入的多个元素,确定所述多个元素在画布的初始尺寸和初始位置,然后以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得所述多个元素在所述画布的推荐尺寸和推荐位置,由此实现智能化的元素布局。During specific implementation, the element layout system can receive multiple elements input by the user, determine the initial size and initial position of the multiple elements on the canvas, and then use the initial size and initial position of the multiple elements on the canvas as a starting point, combine The size and design constraints of the canvas, iteratively optimize the size and position of the multiple elements on the canvas, and obtain the recommended size and recommended position of the multiple elements on the canvas, thereby realizing intelligent Element layout.
由于该方法是采用迭代优化的方式确定推荐尺寸和推荐位置,而不是与固定的布局模板进行匹配,因而解决了相关技术中对于图表等类型的元素不适用,布局效果不佳的问题,具有较高可用性。而且,该方法通过设置必要的布局属性如元素的上、下、左、右边缘的位置等,并以用户输入元素的初始尺寸、初始位置等为起点进行迭代优化,实现了基于用户意图进行驱动,提升了交互性,减少了设计者的工作量。此外,该方法采用固定尺寸画布代替像素离散化的画布,由此可以实现采用连续决策变量代替大量的离散决策变量,在连续决策变量所提供的连续空间进行迭代优化,可以大幅降低计算量,降低算法复杂度,缩短智能布局的时间,提高智能布局的效率。Since the method uses an iterative optimization method to determine the recommended size and recommended position instead of matching with a fixed layout template, it solves the problem in the related art that the elements of the chart and other types are not applicable and the layout effect is not good. high availability. Moreover, the method realizes driving based on user intent by setting necessary layout attributes such as the position of the upper, lower, left, and right edges of the element, and performing iterative optimization based on the initial size and initial position of the element input by the user. , which improves interactivity and reduces the workload of designers. In addition, this method uses a fixed-size canvas instead of a pixel-discretized canvas, so that continuous decision variables can be used instead of a large number of discrete decision variables, and iterative optimization can be performed in the continuous space provided by continuous decision variables, which can greatly reduce the amount of calculation. The algorithm complexity shortens the time of intelligent layout and improves the efficiency of intelligent layout.
本申请实施例的元素布局方法可以适应于多种场景。例如,该元素布局方法可以适用于安全态势感知场景,如图1A所示,元素布局系统可以对访问区域排行柱状图、访问区域地图、访问趋势折线图以及攻击区域排行柱状图、攻击趋势折线图、攻击类型排行表等元素进行智能布局,实现从微观到宏观的全面安全态势感知,为安全事件处置提供决策依据。又例如,该元素布局方法可以适用于贸易分析场景,如图1B所示,元素布局系统可以对销售额统计图、货品出口全球数量分布图、全球销售额排名表、销售情况表、全球港口分布地图等元素进行智能布局,实现全球经济贸易分析。The element layout method in the embodiment of the present application can be adapted to various scenarios. For example, this element layout method can be applied to security situational awareness scenarios. As shown in Figure 1A, the element layout system can rank histograms of access areas, access area maps, line graphs of access trends, histograms of attack area rankings, and line graphs of attack trends. , attack type ranking list and other elements are intelligently arranged to realize comprehensive security situation awareness from micro to macro, and provide decision-making basis for security incident handling. For another example, this element layout method can be applied to trade analysis scenarios. As shown in Figure 1B, the element layout system can analyze the sales statistics, the global quantity distribution of goods exports, the global sales ranking table, the sales situation table, and the global port distribution. Smart layout of map and other elements to realize global economic and trade analysis.
在一些可能的实现方式中,该元素布局方法还可以用于企业经营管理场景。通过接入企业经营数据,可以对企业的生产情况、产品质量情况和/或产品的销售情况进行呈现,为企业管理者提供可视化的决策依据。例如,元素布局方法可以用于对驾驶舱销售情况进行分析,参见图1C,元素布局系统可以对保费地区排名柱形图、热门保单柱形图、年度保费柱形图以及折线图、新旧客户对比图、实时交易表、年度累计总保费等元素进行智能布局,从而实现驾驶舱销售情况分析。又例如,元素布局方法可以用于对房产项目销售情况进行分析,如图1D所示,元素布局系统可以对年度计划图、销售金额统计柱形图、销售回款趋势图、营业收入情况柱形图、投资与盈利情况柱形图、库存情况折线图、项目价值指标图、库存指标柱形图、常规项目指标图等元素进行智能布局,从而实现房产项目销售情况分析。In some possible implementations, the element layout method can also be used in business management scenarios. By accessing the business data of the enterprise, it is possible to present the production situation, product quality and/or product sales of the enterprise, and provide a visual basis for decision-making for enterprise managers. For example, the element layout method can be used to analyze the cockpit sales situation, see Figure 1C, the element layout system can rank column charts for premium regions, popular insurance policies, annual premium column charts and line charts, and compare new and old customers Graphs, real-time transaction tables, annual cumulative total premiums and other elements are intelligently laid out to analyze cockpit sales. For another example, the element layout method can be used to analyze the sales of real estate projects. As shown in Figure 1D, the element layout system can analyze the annual plan chart, sales amount statistical column chart, sales return trend chart, and operating income column chart. Graphs, investment and profitability column charts, inventory line charts, project value indicator charts, inventory indicator column charts, and conventional project indicator charts are intelligently laid out to realize the analysis of real estate project sales.
上述元素布局方法具体可以以数据可视化服务(data lake visualization,DLV)的方式提供给用户使用。其中,DLV可以是云服务。DLV可以提供一站式的数据可视化平台,例如是上述元素布局系统,该系统能够适配云上或云下多种数据源,并提供丰富多样的二维(2dimension,2D)或三维(3dimension,3D)可视化组件,用户可以拖拽上述可视化组件进行自由布局,从而实现屏幕展示内容的高效定制。The above element layout method can be specifically provided to users in the form of data visualization service (data lake visualization, DLV). Wherein, the DLV may be a cloud service. DLV can provide a one-stop data visualization platform, such as the above-mentioned element layout system, which can adapt to various data sources on or off the cloud, and provide a variety of two-dimensional (2dimension, 2D) or three-dimensional (3dimension, 3D) visualization components, users can drag and drop the above visualization components to freely layout, so as to realize efficient customization of screen display content.
为了使得本申请的技术方案更加清楚、易于理解,下面结合附图,对本申请实施例的系统架构进行介绍。In order to make the technical solution of the present application clearer and easier to understand, the system architecture of the embodiment of the present application will be introduced below with reference to the accompanying drawings.
参见图2所示的元素布局方法的系统架构图,终端10、终端30分别与云环境20连接。其中,终端10为用于设计终端30演示内容的用户终端,例如可以是台式机、笔记本电脑、平板电脑等,终端30为用于演示内容的设备,通常配置有大屏。云环境20指示云服务提供商拥有的,用于提供计算、存储、通信资源的中心计算集群。中心计算集群是由一个或多个中心计算设备(例如是中心服务器)形成的计算机集群。Referring to the system architecture diagram of the element layout method shown in FIG. 2 , the terminal 10 and the terminal 30 are respectively connected to the cloud environment 20 . Wherein, the terminal 10 is a user terminal used to design the presentation content of the terminal 30, such as a desktop computer, a notebook computer, a tablet computer, etc., and the terminal 30 is a device used for presentation content, and is usually equipped with a large screen. The cloud environment 20 indicates a central computing cluster owned by a cloud service provider for providing computing, storage, and communication resources. The central computing cluster is a computer cluster formed by one or more central computing devices (such as a central server).
元素布局系统200可以部署在云环境20上的一台或多台计算机。如图2所示,元素布局系统200包括交互模块202、确定模块204和优化模块206等多个模块,上述多个模块可以集中部署在云环境20的一个计算机,也可以分布式地部署在云环境20上的不同计算机。The element layout system 200 can be deployed on one or more computers in the cloud environment 20 . As shown in Figure 2, the element layout system 200 includes multiple modules such as an interaction module 202, a determination module 204, and an optimization module 206. Different computers on environment 20.
终端10部署有客户端(图2中未示出)。该客户端可以是具有元素布局功能的通用客户端,例如是浏览器,也可以是专用于元素布局的专用客户端。客户端可以与元素布局系统200连接,以加载元素布局系统200中交互模块202的交互逻辑,如此,客户端可以向用户呈现设计界面。其中,设计界面可以是图形用户界面(graphical user interface,GUI)。 用户可以通过上述设计界面进行交互,以实现元素布局。The terminal 10 is deployed with a client (not shown in FIG. 2 ). The client can be a general client with element layout functions, such as a browser, or a dedicated client dedicated to element layout. The client can be connected to the element layout system 200 to load the interaction logic of the interaction module 202 in the element layout system 200, so that the client can present the design interface to the user. Wherein, the design interface may be a graphical user interface (graphical user interface, GUI). Users can interact through the above-mentioned design interface to realize element layout.
具体地,设计界面承载有可视化组件,该可视化组件可以包括柱形图、趋势图、地图、统计表等不同类型,用户可以通过设计界面触发对可视化组件的拖拽操作,客户端响应于上述操作,将相应的事件上报至元素布局系统200。Specifically, the design interface carries visual components, which can include different types such as column charts, trend graphs, maps, and statistical tables. Users can trigger drag and drop operations on the visual components through the design interface, and the client responds to the above operations , and report the corresponding event to the element layout system 200 .
元素布局系统200的交互模块202可以接收上述事件,从而获得与可视化组件对应的多个元素。其中,多个元素由基于用户拖拽的组件以及接入的数据源确定。然后元素布局系统200的确定模块204确定多个元素在画布的初始尺寸和初始位置,元素布局系统200的优化模块206以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得所述多个元素在所述画布的推荐尺寸和推荐位置。The interaction module 202 of the element layout system 200 can receive the above events, so as to obtain a plurality of elements corresponding to the visual components. Among them, multiple elements are determined based on the components dragged by the user and the connected data sources. Then the determination module 204 of the element layout system 200 determines the initial size and initial position of the multiple elements on the canvas, and the optimization module 206 of the element layout system 200 takes the initial size and initial position of the multiple elements on the canvas as a starting point, combined with the The size and design constraints of the canvas, performing iterative optimization on the size and position of the plurality of elements on the canvas, to obtain the recommended size and position of the plurality of elements on the canvas.
元素布局系统200的交互模块202还可以向客户端返回多个元素在所述画布的推荐尺寸和推荐位置。当用户确认按照推荐尺寸和推荐位置放置所述多个元素时,元素布局系统200可以将元素以及元素的推荐尺寸和推荐位置下发至终端30,终端30按照上述推荐尺寸和推荐位置放置多个元素,由此实现智能化的元素布局。The interaction module 202 of the element layout system 200 can also return the recommended size and recommended position of multiple elements on the canvas to the client. When the user confirms to place the multiple elements according to the recommended size and recommended position, the element layout system 200 can send the elements and their recommended size and recommended position to the terminal 30, and the terminal 30 places multiple elements, thereby achieving intelligent element layout.
需要说明的是,图2是本申请实施例中元素布局系统200的一种示意性部署方式,在本申请实施例其他可能的实现方式中,元素布局系统200也可以部署在边缘环境中。边缘环境指示在地理位置上距离终端(即端侧设备)较近的,用于提供计算、存储、通信资源的边缘计算集群。边缘计算集群是由一个或多个边缘计算设备(例如是边缘服务器)形成的计算机集群。在一些实施例中,元素布局系统200也可以部署在终端中,例如是终端10中。用户可以通过终端10直接控制终端30演示内容。It should be noted that FIG. 2 is a schematic deployment manner of the element layout system 200 in the embodiment of the present application. In other possible implementation manners of the embodiment of the present application, the element layout system 200 may also be deployed in an edge environment. The edge environment indicates an edge computing cluster that is geographically close to the terminal (that is, the end-side device) and is used to provide computing, storage, and communication resources. An edge computing cluster is a computer cluster formed by one or more edge computing devices (such as edge servers). In some embodiments, the element layout system 200 can also be deployed in a terminal, such as the terminal 10 . The user can directly control the terminal 30 to demonstrate content through the terminal 10 .
元素布局系统200可以与多个终端10、多个终端30连接,每个用户可以通过各自的终端10从多个终端30中选择用于演示内容的终端30,元素布局系统200根据用户的选择,将布局结果下发至对应的终端30,如此可以实现为不同用户提供智能布局服务。The element layout system 200 can be connected to a plurality of terminals 10 and a plurality of terminals 30, and each user can select a terminal 30 for displaying content from a plurality of terminals 30 through a respective terminal 10, and the element layout system 200 can, according to the selection of the user, Send the layout result to the corresponding terminal 30, so that different users can be provided with intelligent layout services.
接下来,从元素布局系统200的角度,结合附图对本申请实施例提供的元素布局方法进行详细地介绍。Next, from the perspective of the element layout system 200, the element layout method provided by the embodiment of the present application will be described in detail with reference to the accompanying drawings.
参见图3所示的元素布局方法的流程图,该方法包括:Referring to the flow chart of the element layout method shown in Figure 3, the method includes:
S302:元素布局系统200接收用户输入的多个元素。S302: The element layout system 200 receives a plurality of elements input by the user.
元素布局系统200可以提供丰富的可视化组件,例如是柱形图、折线图、地图、数据表等图表类型的可视化组件,或者是标题框等文本类型的可视化组件,背景等装饰类型的可视化组件,用户可以基于元素布局系统200提供的上述可视化组件输入多个元素。The element layout system 200 can provide a wealth of visual components, such as visual components of chart types such as column charts, line charts, maps, and data tables, or visual components of text types such as title boxes, and visual components of decorative types such as backgrounds. The user can input multiple elements based on the above-mentioned visual components provided by the element layout system 200 .
具体地,元素布局系统200可以向用户呈现设计界面,该设计界面承载有至少一种可视化组件,然后元素布局系统200响应于用户对可视化组件的拖拽操作,接收与可视化组件对应的多个元素。Specifically, the element layout system 200 can present a design interface to the user, the design interface carries at least one visual component, and then the element layout system 200 receives multiple elements corresponding to the visual component in response to the user's drag operation on the visual component .
其中,用户对图表类型的可视化组件执行拖拽操作时,元素布局系统200可以根据该图表类型的可视化组件及其接入的数据源,获得相应的元素。用户对文本类型的可视化组件执行拖拽操作时,元素布局系统200可以根据该文本类型的可视化组件以及用户输入的文本内容,获得相应的元素。例如,用户对标题框执行拖拽操作时,元素布局系统200可 以根据用户拖拽的标题框以及用户输入的文本内容,获得标题类型的元素。用户对装饰类型的可视化组件执行拖拽操作时,元素布局系统200可以根据该装饰类型的可视化组件,获得相应的元素。Wherein, when the user performs a drag operation on the visual component of the chart type, the element layout system 200 can obtain corresponding elements according to the visual component of the chart type and the data source connected thereto. When the user performs a drag operation on a text-type visual component, the element layout system 200 can obtain corresponding elements according to the text-type visual component and the text content input by the user. For example, when the user performs a drag operation on the title box, the element layout system 200 can obtain title-type elements according to the title box dragged by the user and the text content entered by the user. When the user performs a drag operation on the decoration-type visual component, the element layout system 200 can obtain corresponding elements according to the decoration-type visual component.
在一些可能的实现方式中,元素布局系统200也可以接收用户通过元素添加控件输入的多个元素。其中,上述多个元素可以是用户逐个添加,也可以是用户批量添加。用户可以通过元素添加控件设置需要添加的元素的尺寸、位置。元素为矩形元素时,元素的尺寸和位置可以通过元素的上、下、左、右边缘的位置确定。在画布尺寸固定的情况下,上、下、左、右边缘的位置可以通过上边距(元素的上边缘到画布的上边缘的距离)、下边距(元素的下边缘到画布的下边缘的距离)、左边距(元素的左边缘到画布的左边缘的距离)、右边距(元素的右边缘到画布的右边缘的距离)表示。In some possible implementation manners, the element layout system 200 may also receive multiple elements input by the user through the element adding control. Wherein, the above-mentioned multiple elements may be added one by one by the user, or may be added by the user in batches. The user can set the size and position of the element to be added through the element adding control. When the element is a rectangular element, the size and position of the element can be determined by the positions of the top, bottom, left, and right edges of the element. In the case of a fixed canvas size, the positions of the top, bottom, left, and right edges can be determined by the top margin (the distance from the top edge of the element to the top edge of the canvas), the bottom margin (the distance from the bottom edge of the element to the bottom edge of the canvas) ), left margin (the distance from the left edge of the element to the left edge of the canvas), and right margin (the distance from the right edge of the element to the right edge of the canvas).
当元素布局系统200提供多种类型的元素时,用户还可以通过元素添加控件设置需要添加的元素的类型。例如可以是图表、文本或者装饰等类型。其中,图表还可以进一步分为柱形图、折线图、地图等类型。文本可以进一步分为标题或正文等类型。当用户设置添加的元素的类型为图表或文本时,用户还可以通过元素添加控件设置图表接入的数据源或文本对应的文本内容。When the element layout system 200 provides multiple types of elements, the user can also set the type of element to be added through the element adding control. For example, it can be a chart, text or decoration. Among them, charts can be further divided into column charts, line charts, maps and other types. Text can be further divided into types such as heading or body text. When the user sets the type of the added element to chart or text, the user can also set the data source accessed by the chart or the text content corresponding to the text through the element adding control.
S304:元素布局系统200接收用户输入的自定义约束。S304: The element layout system 200 receives user-defined constraints input by the user.
在本实施例中,元素布局系统200将元素布局问题转换为线性规划问题,为此,元素布局系统200可以制定设计约束,以便基于该设计约束进行线性规划。其中,设计约束通常是数学约束。该设计约束可以包括根据设计准则如大屏相关设计准则制定的基础约束(也可以称作模型内部约束),还可以包括用户输入的自定义约束。其中,自定义约束可以根据用户需求选择配置。元素布局系统200可以提供多种自定义约束,然后接收用户选择的一种或多种自定义约束。In this embodiment, the element layout system 200 converts the element layout problem into a linear programming problem. Therefore, the element layout system 200 can formulate design constraints, so as to perform linear programming based on the design constraints. Among them, design constraints are usually mathematical constraints. The design constraints may include basic constraints (also referred to as model internal constraints) formulated according to design criteria such as design criteria related to large screens, and may also include user-defined constraints input by the user. Among them, custom constraints can be configured according to user needs. The element layout system 200 can provide various custom constraints, and then receive one or more custom constraints selected by the user.
其中,基础约束可以包括对齐约束、网格约束、大小约束、边界约束和填充约束中的任意一种或多种。自定义约束可以包括锁定约束、纵横比约束、对齐偏好约束中的任意一种或多种。下面对上述基础约束以及自定义约束进行详细说明。Wherein, the basic constraints may include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and filling constraints. The custom constraints may include any one or more of locking constraints, aspect ratio constraints, and alignment preference constraints. The above-mentioned basic constraints and custom constraints are described in detail below.
(1)对齐约束(1) Alignment constraints
对齐约束用于保证元素对齐。对齐约束将用户输入的多个元素分为若干个对齐组,例如是上、下、左、右等若干个对齐组。其中,在某个方向上对齐的元素属于一个对齐组,一个对齐组中的元素对齐的线称作对齐线。Alignment constraints are used to ensure alignment of elements. Alignment constraints divide multiple elements input by the user into several alignment groups, such as upper, lower, left, and right alignment groups. Among them, elements aligned in a certain direction belong to an alignment group, and a line in which elements in an alignment group are aligned is called an alignment line.
具体参见公式(1)至(4),对齐约束用于将用户输入的所有元素划分为上、下、左、右等若干个对齐组,一个元素的各边缘(如上边缘、下边缘、左边缘或右边缘)分别对应有且只有一个对齐组。Refer to formulas (1) to (4) for details. Alignment constraints are used to divide all elements input by the user into several alignment groups such as top, bottom, left, and right, and each edge of an element (such as top edge, bottom edge, left edge or the right edge) respectively correspond to one and only one alignment group.
Figure PCTCN2022093727-appb-000001
Figure PCTCN2022093727-appb-000001
Figure PCTCN2022093727-appb-000002
Figure PCTCN2022093727-appb-000002
Figure PCTCN2022093727-appb-000003
Figure PCTCN2022093727-appb-000003
Figure PCTCN2022093727-appb-000004
Figure PCTCN2022093727-appb-000004
其中,e用于表示元素,
Figure PCTCN2022093727-appb-000005
用于表示元素集合,
Figure PCTCN2022093727-appb-000006
表示元素集合中的任意元素。α、β、γ和δ分别表示左边缘、右边缘、上边缘和下边缘,
Figure PCTCN2022093727-appb-000007
表示元素e的左边缘对应的对齐组,
Figure PCTCN2022093727-appb-000008
表示元素e的右边缘对应的对齐组,
Figure PCTCN2022093727-appb-000009
表示元素e的上边缘对应的对齐组,
Figure PCTCN2022093727-appb-000010
表示元素e的下边缘对应的对齐组。
Among them, e is used to represent the element,
Figure PCTCN2022093727-appb-000005
Used to represent collections of elements,
Figure PCTCN2022093727-appb-000006
Represents any element in a collection of elements. α, β, γ, and δ denote the left edge, right edge, upper edge, and lower edge, respectively,
Figure PCTCN2022093727-appb-000007
Indicates the alignment group corresponding to the left edge of element e,
Figure PCTCN2022093727-appb-000008
Indicates the alignment group corresponding to the right edge of element e,
Figure PCTCN2022093727-appb-000009
Indicates the alignment group corresponding to the top edge of element e,
Figure PCTCN2022093727-appb-000010
Indicates the alignment group corresponding to the bottom edge of element e.
为了便于理解,本申请还提供了一具体示例。参见图4A,第一行的第二个元素与第一行的第一个元素、第一行的第三个元素上对齐,第一行的第二个元素与第一行的第三个元素下对齐,此外,第一行的第二个元素还与第二行的第一个元素左对齐和右对齐,图4A所示的四条虚线为上述对齐组对应的对齐线。For ease of understanding, this application also provides a specific example. See Figure 4A, the second element of the first row is aligned with the first element of the first row, the third element of the first row, and the second element of the first row is aligned with the third element of the first row Bottom alignment. In addition, the second element in the first row is also left-aligned and right-aligned with the first element in the second row. The four dotted lines shown in Figure 4A are alignment lines corresponding to the above-mentioned alignment group.
(2)网格约束(2) Grid constraints
网格约束用于保证画布区域的合理划分,防止元素重叠。常见的设计准则包括视觉平衡。视觉平衡的一个典型示例是对称平衡。对称平衡是在稳定且常规的布局中组织元素的常用方法。网格约束可以基于对称平衡将元素放置在合适的位置,防止元素重叠。Grid constraints are used to ensure a reasonable division of the canvas area and prevent elements from overlapping. Common design guidelines include visual balance. A classic example of visual balance is symmetrical balance. Symmetrical balance is a common way to organize elements in a stable and regular layout. Grid constraints place elements in place based on symmetrical balance, preventing elements from overlapping.
具体地,根据元素的数量可以将画布区域划分为包括若干行、若干列的网格,并计算对齐线数量,作为对齐线约束的基准量。然后通过垂直或水平分割包含元素的区域来分割设计,基于像素坐标制定分割策略,采用简单的分层设计样式,使得元素视觉平衡。Specifically, according to the number of elements, the canvas area can be divided into grids including several rows and several columns, and the number of alignment lines can be calculated as a benchmark amount of alignment constraints. Then divide the design by vertically or horizontally dividing the area containing the elements, formulate a segmentation strategy based on pixel coordinates, and adopt a simple layered design style to make the elements visually balanced.
其中,对齐线数量的计算可以参照公式(5)至(8):Among them, the calculation of the number of alignment lines can refer to formulas (5) to (8):
align count=4*grid count+2*(grid addCol+grid addRest)                   (5) align count =4*grid count +2*(grid addCol +grid addRest ) (5)
Figure PCTCN2022093727-appb-000011
Figure PCTCN2022093727-appb-000011
Figure PCTCN2022093727-appb-000012
Figure PCTCN2022093727-appb-000012
grid addRest=N el-grid count*grid count-grid addCol*grid count           (8) grid addRest =N el -grid count *grid count -grid addCol *grid count (8)
其中,N el表示元素的数量,grid count表示网格线行数,grid addCol表示列拓展数,grid addRest表示列拓展后剩余元素的数量,align count表示对齐线数量。在计算对齐线数量时,如公式(6)至(8),可以先对元素的数量开根,然后进行向下取整,以确定网格线的行数,对剩余的元素根据行数进行列拓展,接着根据列拓展数确定列拓展后剩余元素的数量。然后,参照上述公式(5),根据网格线数量和列拓展数、列拓展后剩余元素的数量确定对齐线数量。 Among them, N el represents the number of elements, grid count represents the number of grid line rows, grid addCol represents the number of column extensions, grid addRest represents the number of remaining elements after column expansion, and align count represents the number of alignment lines. When calculating the number of alignment lines, such as formulas (6) to (8), the number of elements can be rooted first, and then rounded down to determine the number of rows of grid lines, and the remaining elements are calculated according to the number of rows Column expansion, and then determine the number of remaining elements after column expansion according to the column expansion number. Then, referring to the above formula (5), the number of alignment lines is determined according to the number of grid lines, the number of column extensions, and the number of remaining elements after column expansion.
为了便于理解,本申请还提供了一些具体示例。参见图4B,元素数量为9时,可以按照三行三列进行排列,每个元素可以有上、下、左、右四条对齐线,不同元素可以包括重复的对齐线,排除重复的对齐线,共有4*3=12条对齐线。元素数量为13时,先进行开根运算,然后可以开根运算结果进行向下取整,从而确定上述元素可以排列3行,然后基于剩余的5个元素(如图中虚线框所示)拓展1列,再根据拓展列数,确定拓展列后剩余元素的数量为13-3*3-3*1=1,由此计算出对齐线数量为3*4+2*(1+1)=16。For ease of understanding, this application also provides some specific examples. Referring to Figure 4B, when the number of elements is 9, they can be arranged in three rows and three columns, and each element can have four alignment lines of up, down, left, and right. Different elements can include repeated alignment lines, and exclude repeated alignment lines. There are 4*3=12 alignment lines in total. When the number of elements is 13, the root operation is performed first, and then the result of the root operation can be rounded down to determine that the above elements can be arranged in 3 rows, and then expand based on the remaining 5 elements (as shown in the dotted line box in the figure). 1 column, and then according to the number of expanded columns, determine the number of remaining elements after the expanded column is 13-3*3-3*1=1, and calculate the number of alignment lines as 3*4+2*(1+1)= 16.
对于包括相同数量元素的元素集合,可以有多种布局。针对每一种布局可以确定对齐线数量,对齐线数量越大,则元素布局越均衡。There can be multiple layouts for a collection of elements that includes the same number of elements. The number of alignment lines can be determined for each layout. The larger the number of alignment lines, the more balanced the element layout.
(3)大小约束(3) Size constraints
大小约束用于保证元素的大小(也即尺寸)合理。考虑到人眼对于图表的可读性有一定要求,元素在布局过程中应当避免过于缩小。另外从屏幕展示内容整体的美观度而言,于放大的图表可以影响屏幕整体的和谐性,产生杂乱感,因此,元素在布局过程中也应当避免过于放大。为此,可以对元素的缩放范围进行约束,保证元素处于合理大小。Size constraints are used to ensure that the size (ie dimensions) of an element is reasonable. Considering that the human eye has certain requirements for the readability of the chart, elements should not be too small during the layout process. In addition, in terms of the overall aesthetics of the content displayed on the screen, enlarged charts can affect the overall harmony of the screen and create a sense of clutter. Therefore, elements should also be avoided from being overly enlarged during the layout process. For this reason, the zoom range of the element can be constrained to ensure that the element is at a reasonable size.
参见公式(9)至(12):See equations (9) to (12):
Figure PCTCN2022093727-appb-000013
Figure PCTCN2022093727-appb-000013
Figure PCTCN2022093727-appb-000014
Figure PCTCN2022093727-appb-000014
Figure PCTCN2022093727-appb-000015
Figure PCTCN2022093727-appb-000015
Figure PCTCN2022093727-appb-000016
Figure PCTCN2022093727-appb-000016
其中,
Figure PCTCN2022093727-appb-000017
标识元素的初始宽度,
Figure PCTCN2022093727-appb-000018
表示元素的初始高度,width ca表示画布的宽度,height ca表示画布的高度,也即元素的缩放范围可以是宽度介于初始宽度的2/3(即
Figure PCTCN2022093727-appb-000019
)与画布的宽度(即width ca)之间,高度介于初始高度的2/3(即
Figure PCTCN2022093727-appb-000020
)与画布的高度(height ca)之间。
in,
Figure PCTCN2022093727-appb-000017
identifies the initial width of the element,
Figure PCTCN2022093727-appb-000018
Represents the initial height of the element, width ca represents the width of the canvas, and height ca represents the height of the canvas, that is, the zoom range of the element can be between 2/3 of the initial width (ie
Figure PCTCN2022093727-appb-000019
) and the width of the canvas (ie width ca ), and the height is between 2/3 of the initial height (ie
Figure PCTCN2022093727-appb-000020
) and the height of the canvas (height ca ).
为了便于理解,本申请还提供了一具体示例。如图4C所示,元素的初始大小等于图4C中深灰色区域的大小,该元素的宽和高最小可以缩小至深灰色区域的宽和高的2/3,也即元素最小可以如图中浅灰色区域所示,该元素的宽和高最大可以缩放至画布的宽和高,也即元素最大可以如图中黑色区域所示。For ease of understanding, this application also provides a specific example. As shown in Figure 4C, the initial size of the element is equal to the size of the dark gray area in Figure 4C, and the minimum width and height of the element can be reduced to 2/3 of the width and height of the dark gray area, that is, the smallest element can be as shown in the figure As shown in the light gray area, the width and height of the element can be scaled to the maximum width and height of the canvas, that is, the maximum size of the element can be shown in the black area in the figure.
(4)边界约束(4) Boundary constraints
边界约束用于保证布局充满画布。锯齿状的轮廓、不平衡的轮廓或任何非凸排列可以影响美观度,因此,可以设置元素布局引起的整体轮廓接近矩形的外部轮廓,从而使得布局结果占满整张屏幕,保证元素充满画布。Bound constraints are used to ensure that the layout fills the canvas. Jagged outlines, unbalanced outlines, or any non-convex arrangement can affect aesthetics. Therefore, you can set the overall outline caused by element layout to be close to the outer outline of a rectangle, so that the layout result occupies the entire screen and ensures that the elements fill the canvas.
针对矩形轮廓的上述需求,可以通过对齐组的上下限进行约束。例如,边界约束使所有元素的左、上对齐组中坐标值最小的元素处于画布的左、上边界,如公式(13)(14)所示,右、下对齐组中坐标值最大的元素处于画布的右、下边界,如式(15)(16)所示。具体如下:For the above-mentioned requirements of the rectangular outline, constraints can be made through the upper and lower limits of the alignment group. For example, the boundary constraint makes the element with the smallest coordinate value in the left and upper alignment groups of all elements be at the left and upper boundaries of the canvas, as shown in formulas (13) and (14), the element with the largest coordinate value in the right and lower alignment groups is at The right and bottom boundaries of the canvas, as shown in equations (15) (16). details as follows:
Figure PCTCN2022093727-appb-000021
Figure PCTCN2022093727-appb-000021
Figure PCTCN2022093727-appb-000022
Figure PCTCN2022093727-appb-000022
Figure PCTCN2022093727-appb-000023
Figure PCTCN2022093727-appb-000023
Figure PCTCN2022093727-appb-000024
Figure PCTCN2022093727-appb-000024
其中,padding表示边距。以画布的左上角为坐标系的原点,上边缘为X轴,左边缘为Y轴,则padding X可以表示沿着X轴方向的设定边距,padding Y可以表示沿着Y轴方向的设定边距。
Figure PCTCN2022093727-appb-000025
表征左对齐组中坐标值(如Y轴坐标值)最小的元素的左边缘到画布的坐边缘的距离,
Figure PCTCN2022093727-appb-000026
表征上对齐组中坐标值(如X轴坐标值)最小的元素的上边缘到画布的上边缘的距离。类似地,
Figure PCTCN2022093727-appb-000027
表征右对齐组中坐标值(如Y轴坐标值)最大的元素到右边缘到画布的左边缘的距离,
Figure PCTCN2022093727-appb-000028
表征下对齐组中坐标值(如X轴坐标值)最大的元素到画布的上边缘的距离。
Among them, padding represents the margin. Taking the upper left corner of the canvas as the origin of the coordinate system, the upper edge as the X axis, and the left edge as the Y axis, padding X can represent the set margin along the X axis, and padding Y can represent the set margin along the Y axis. Set margins.
Figure PCTCN2022093727-appb-000025
Characterizes the distance from the left edge of the element with the smallest coordinate value (such as the Y-axis coordinate value) in the left-aligned group to the sitting edge of the canvas,
Figure PCTCN2022093727-appb-000026
Indicates the distance from the upper edge of the element with the smallest coordinate value (such as the X-axis coordinate value) in the upper alignment group to the upper edge of the canvas. Similarly,
Figure PCTCN2022093727-appb-000027
Characterizes the distance from the element with the largest coordinate value (such as the Y-axis coordinate value) in the right-aligned group to the right edge and the left edge of the canvas,
Figure PCTCN2022093727-appb-000028
Indicates the distance from the element with the largest coordinate value (such as the X-axis coordinate value) in the lower alignment group to the upper edge of the canvas.
为了便于理解,本申请还提供了一具体示例。参见图4D,4个元素中第一行两个元素形成上对齐组,第二行两个元素形成下对齐组,第一列两个元素形成左对齐组,第二列两个元素形成右对齐组。在排列上述元素时,上对齐组和左对齐组中坐标值最小的元素例如是第一行第一个元素可以排列在到画布左边缘和上边缘距离为padding X、padding Y的位置,类似地,下对齐组和右对齐组中坐标值最大的元素例如是第二行第二个元素可以排列在到画布左边缘和上边缘距离为width canvas-paddingX、height canvas-paddingY的位置。由此,可以使得所有元素充满画布。 For ease of understanding, this application also provides a specific example. Referring to Figure 4D, among the four elements, two elements in the first row form an upper alignment group, two elements in the second row form a lower alignment group, two elements in the first column form a left alignment group, and two elements in the second column form a right alignment group Group. When arranging the above elements, the element with the smallest coordinate value in the top alignment group and the left alignment group is, for example, the first element in the first row, which can be arranged at a distance of padding X and padding Y from the left and top edges of the canvas, similarly , the element with the largest coordinate value in the bottom alignment group and the right alignment group is, for example, the second element in the second row, which can be arranged at a distance of width canvas -paddingX and height canvas -paddingY from the left and top edges of the canvas. Thus, it is possible to make all elements fill the canvas.
(5)填充约束(5) Filling constraints
填充约束用于保证布局内部充满。除了布局的轮廓形状,布局的内部空缺可以使得整体的空间失去连续感,进而在一定程度上影响布局的美观度。为此,可以设置各个元素之间的间距不可超过设定间距,从而使布局结果内部充满。其中,各个元素之间的间距越近,元素的总面积越接近画布的面积。因此,还可以对元素进行缩放,使得元素的总面积接近画布的面积。Padding constraints are used to ensure that the interior of the layout is filled. In addition to the outline shape of the layout, the internal vacancy of the layout can make the overall space lose the sense of continuity, which in turn affects the aesthetics of the layout to a certain extent. For this reason, you can set the spacing between each element to not exceed the set spacing, so that the interior of the layout result is filled. Wherein, the closer the spacing between elements is, the closer the total area of the elements is to the area of the canvas. Therefore, it is also possible to scale the elements so that the total area of the elements approaches the area of the canvas.
具体地,在对元素进行缩放时,可以根据元素的面积和画布的面积的比例对元素进行缩放。考虑到面积的缩放比例等于宽度的缩放比例乘以高度的缩放比例,可以对元素的面积和画布的面积的比例进行开根运算,然后按照开根运算的结果缩放元素的宽度和高度,如公式(17)和(18)所示:Specifically, when scaling an element, the element may be scaled according to the ratio of the area of the element to the area of the canvas. Considering that the scaling ratio of the area is equal to the scaling ratio of the width multiplied by the scaling ratio of the height, the root operation can be performed on the ratio of the area of the element to the area of the canvas, and then the width and height of the element can be scaled according to the result of the root operation, such as the formula As shown in (17) and (18):
Figure PCTCN2022093727-appb-000029
Figure PCTCN2022093727-appb-000029
Figure PCTCN2022093727-appb-000030
Figure PCTCN2022093727-appb-000030
其中,width canvas表示画布的宽度,height canvas画布的高度,area canvas表示画布的面积,area e表示元素的面积,
Figure PCTCN2022093727-appb-000031
表示元素的宽度的最大值,
Figure PCTCN2022093727-appb-000032
表示元素的高度的最大值。
Among them, width canvas represents the width of the canvas, height canvas represents the height of the canvas, area canvas represents the area of the canvas, area e represents the area of the element,
Figure PCTCN2022093727-appb-000031
Indicates the maximum width of the element,
Figure PCTCN2022093727-appb-000032
Indicates the maximum value of the element's height.
参见图4E,当缩放后的元素的总面积接近画布的面积时,则可以确定满足填充约束。其中,缩放后的元素的总面积是否接近画布的面积可以通过面积比例进行衡量。例如缩放后的元素的总面积和画布的面积的比例大于或等于预设比例,则可以确定缩放后的元素的总面积接近画布的面积。预设比例可以根据经验值设置,例如可以设置为99%。Referring to FIG. 4E , when the total area of the scaled elements is close to the area of the canvas, it can be determined that the filling constraint is satisfied. Wherein, whether the total area of the scaled elements is close to the area of the canvas can be measured by the area ratio. For example, the ratio of the total area of the scaled elements to the area of the canvas is greater than or equal to a preset ratio, then it may be determined that the total area of the scaled elements is close to the area of the canvas. The preset ratio can be set according to experience values, for example, it can be set to 99%.
(6)纵横比约束(6) Aspect ratio constraints
纵横比约束用于对一个或多个元素的缩放比进行约束。也即在对元素进行缩放时,对一个或多个元素保持指定的纵横比(ratio)进行缩放。其中,纵横比可以根据元素的初始高度以及初始宽度确定,例如可以为初始高度和初始宽度的比值。参见图4F,在对元素进行缩放时,元素缩放后的高度可以根据缩放后的宽度以及纵横比确定:Aspect ratio constraints are used to constrain the scaling ratio of one or more elements. That is, when scaling elements, scale one or more elements while maintaining the specified aspect ratio (ratio). Wherein, the aspect ratio may be determined according to the initial height and initial width of the element, for example, may be a ratio of the initial height to the initial width. Referring to Figure 4F, when scaling an element, the height of the scaled element can be determined according to the scaled width and aspect ratio:
height =width *ratio                              (19) height = width *ratio (19)
其中,width 表示缩放后的宽度,height 表示缩放后的高度。 Wherein, width ' represents the width after scaling, and height ' represents the height after scaling.
(7)对齐偏好约束(7) Alignment preference constraints
对齐偏好约束用于对一个或多个元素进行置顶、置左、置右或者置下约束。例如,可以将需要置顶的元素放在其他元素的上方,如图4G所示。为了实现不同的对齐偏好,可以设置目标元素在其他元素之上,如公式(20),或者目标元素在其他元素之右,如公式(21),或者目标元素在其他元素之左,如公式(22),或者目标元素在其他元素之下,如公式(23):Alignment preference constraints are used to constrain one or more elements to be top, left, right, or bottom. For example, the element that needs to be on top can be placed on top of other elements, as shown in FIG. 4G . In order to achieve different alignment preferences, the target element can be set above other elements, such as formula (20), or the target element is on the right of other elements, such as formula (21), or the target element is on the left of other elements, such as formula ( 22), or the target element is under other elements, such as formula (23):
Figure PCTCN2022093727-appb-000033
Figure PCTCN2022093727-appb-000033
Figure PCTCN2022093727-appb-000034
Figure PCTCN2022093727-appb-000034
Figure PCTCN2022093727-appb-000035
Figure PCTCN2022093727-appb-000035
Figure PCTCN2022093727-appb-000036
Figure PCTCN2022093727-appb-000036
其中,e1表示目标元素,e2表示目标元素之外的其他元素。目标元素是指用户意图置顶、置右、置左或置下的元素。
Figure PCTCN2022093727-appb-000037
为布尔逻辑变量。当e1在e2之上时,则
Figure PCTCN2022093727-appb-000038
取值为1,否则,
Figure PCTCN2022093727-appb-000039
取值为0。类似地,
Figure PCTCN2022093727-appb-000040
也是布尔逻辑变量。当e1在e2之右时,则
Figure PCTCN2022093727-appb-000041
取值为1,否则,
Figure PCTCN2022093727-appb-000042
取值为0。当e1在e2之左时,
Figure PCTCN2022093727-appb-000043
取值为1,否则
Figure PCTCN2022093727-appb-000044
取值为0。当e1在e2之下时,则
Figure PCTCN2022093727-appb-000045
取值为1,否则取值为0。
Wherein, e1 represents the target element, and e2 represents other elements other than the target element. A target element is an element that the user intends to be top, right, left, or bottom.
Figure PCTCN2022093727-appb-000037
is a boolean logic variable. When e1 is above e2, then
Figure PCTCN2022093727-appb-000038
The value is 1, otherwise,
Figure PCTCN2022093727-appb-000039
The value is 0. Similarly,
Figure PCTCN2022093727-appb-000040
Also a boolean logic variable. When e1 is to the right of e2, then
Figure PCTCN2022093727-appb-000041
The value is 1, otherwise,
Figure PCTCN2022093727-appb-000042
The value is 0. When e1 is to the left of e2,
Figure PCTCN2022093727-appb-000043
The value is 1, otherwise
Figure PCTCN2022093727-appb-000044
The value is 0. When e1 is below e2, then
Figure PCTCN2022093727-appb-000045
The value is 1, otherwise the value is 0.
(8)锁定约束(8) Lock constraints
锁定约束用于对一个或多个元素进行尺寸和位置的锁定。也即规定一个或多个元素的大小和位置与输入上述元素时的大小和位置保持一致。通常可以在输入元素时,增加lock 字段,该字段为布尔型变量,可以取值为true或false。当取值为true时,则可以将对应元素的大小和位置进行锁定。Lock constraints are used to lock the size and position of one or more elements. That is to say, it is stipulated that the size and position of one or more elements are consistent with the size and position of the above-mentioned elements. Usually, when inputting an element, a lock field can be added, which is a Boolean variable that can take a value of true or false. When the value is true, the size and position of the corresponding element can be locked.
参见图4H,当某个元素被锁定时,则在智能布局过程中,该元素的位置和大小保持不变。也即该元素满足如下公式:Referring to FIG. 4H , when an element is locked, the position and size of the element remain unchanged during the smart layout process. That is, the element satisfies the following formula:
L lock=X lock                                  (24) L lock = X lock (24)
B lock=Y lock                                  (25) B lock = Y lock (25)
Figure PCTCN2022093727-appb-000046
Figure PCTCN2022093727-appb-000046
Figure PCTCN2022093727-appb-000047
Figure PCTCN2022093727-appb-000047
Figure PCTCN2022093727-appb-000048
Figure PCTCN2022093727-appb-000048
Figure PCTCN2022093727-appb-000049
Figure PCTCN2022093727-appb-000049
其中,L lock表示被锁定元素的左边界的位置,具体可以通过左边界到Y轴的距离表示,B lock表示被锁定元素的下边界的位置,具体可以通过下边界到X轴的距离表示,X lock、Y lock分别表示被锁定元素的左下顶点的坐标,
Figure PCTCN2022093727-appb-000050
width lock分别表示被锁定元素的宽的最小值、最大值和初始值,
Figure PCTCN2022093727-appb-000051
height lock分别表示被锁定元素的高的最小值、最大值和初始值。
Among them, L lock indicates the position of the left boundary of the locked element, which can be expressed specifically by the distance from the left boundary to the Y axis, and B lock indicates the position of the lower boundary of the locked element, which can be expressed specifically by the distance from the lower boundary to the X axis, X lock and Y lock respectively represent the coordinates of the lower left vertex of the locked element,
Figure PCTCN2022093727-appb-000050
Width lock respectively indicates the minimum, maximum and initial value of the width of the locked element,
Figure PCTCN2022093727-appb-000051
The height lock indicates the minimum, maximum, and initial values of the height of the locked element, respectively.
上述约束(1)至(5)为基础约束,约束(6)至(8)为自定义约束。在一些实施例中,元素布局系统200也可以不执行S304,采用基础约束进行线性规划,从而实现元素布局。The above constraints (1) to (5) are basic constraints, and constraints (6) to (8) are self-defined constraints. In some embodiments, the element layout system 200 may not perform S304, and use basic constraints to perform linear programming, so as to implement element layout.
S306:元素布局系统200确定多个元素在画布的初始尺寸和初始位置。S306: The element layout system 200 determines the initial size and initial position of the multiple elements on the canvas.
当用户采用拖拽可视化组件的方式,输入多个元素时,元素布局系统200可以通过确定多个元素中的每个元素的参考点或边到画布的边缘的距离,确定每个元素的初始尺寸和初始位置。When the user inputs multiple elements by dragging and dropping visual components, the element layout system 200 can determine the initial size of each element by determining the distance from the reference point or side of each of the multiple elements to the edge of the canvas and initial position.
例如,元素布局系统200可以确定每个元素的上边缘、下边缘到画布的上边缘(记作X轴)的距离,以及每个元素的左边缘、右边缘到画布的左边缘(记作Y轴)的距离。然后,元素布局系统200可以根据元素的上、下边缘到画布的上边缘的距离的差值确定元素的高度,根据元素的左、右边缘到画布的左边缘的距离的差值确定元素的宽度,由此可以获得多个元素在画布的初始尺寸。元素布局系统200可以根据元素的上、下边缘到画布的上边缘的距离的平均值确定元素的中心点的纵坐标,根据元素的左、右边缘到画布的左边缘的距离的平均值确定元素的中心点的横坐标,基于元素的中心点的横纵坐标可以确定元素的初始位置。For example, the element layout system 200 can determine the distance from the top and bottom edges of each element to the top edge of the canvas (denoted as the X axis), and the distance from the left and right edges of each element to the left edge of the canvas (denoted as the Y axis). axis) distance. Then, the element layout system 200 can determine the height of the element according to the difference between the upper and lower edges of the element and the upper edge of the canvas, and determine the width of the element according to the difference between the left and right edges of the element and the left edge of the canvas. , so you can get the initial size of multiple elements in the canvas. The element layout system 200 can determine the ordinate of the center point of the element according to the average distance between the upper and lower edges of the element and the upper edge of the canvas, and determine the element according to the average distance between the left and right edges of the element and the left edge of the canvas. The abscissa of the center point of the element, the initial position of the element can be determined based on the abscissa and ordinate of the center point of the element.
当用户采用元素添加控件的方式输入多个元素时,元素布局系统200可以直接根据用户通过元素添加控件输入的元素的布局属性,如元素的上、下、左、右边缘的位置,确定多个元素在画布的初始尺寸和初始位置。When the user inputs multiple elements by using the element adding control, the element layout system 200 can directly determine multiple The element's initial size and position on the canvas.
S308:元素布局系统200以多个元素在画布的初始尺寸和初始位置为起点,结合画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得多个候选布局。S308: The element layout system 200 takes the initial size and position of multiple elements on the canvas as a starting point, combines the size of the canvas and design constraints, iteratively optimizes the size and position of the multiple elements on the canvas, and obtains multiple Candidate layout.
具体地,元素的布局可以通过元素的尺寸和位置进行表征,元素布局系统200通过迭代优化算法确定合适的尺寸和位置,以实现元素布局。其中,元素布局系统200可以以多个元素在画布的初始尺寸和初始位置为起点,结合画布的尺寸以及设计约束,例如是基础 约束和用户输入的自定义约束(如果存在),采用优化器对所述多个元素在所述画布的尺寸和位置进行迭代优化,从而获得多个候选布局。Specifically, the layout of an element can be characterized by the size and position of the element, and the element layout system 200 determines an appropriate size and position through an iterative optimization algorithm to realize the element layout. Among them, the element layout system 200 can start from the initial size and initial position of multiple elements on the canvas, combine the size of the canvas and design constraints, such as basic constraints and user-defined constraints (if any), and use an optimizer to Iteratively optimizing the size and position of the multiple elements on the canvas, so as to obtain multiple candidate layouts.
考虑到Gurobi优化器在混合整数线性规划、凸或非凸等二次规划问题上性能领先,CBC优化器也具有不俗的优化效果,元素布局系统200可以采用上述Gurobi优化器或CBC优化器进行迭代优化,以满足不同的业务需求。Considering that the Gurobi optimizer has the leading performance in quadratic programming problems such as mixed integer linear programming, convex or non-convex, and the CBC optimizer also has a good optimization effect, the element layout system 200 can be implemented using the above-mentioned Gurobi optimizer or CBC optimizer Iterative optimization to meet different business needs.
在一些可能的实现方式中,元素布局系统200还可以获取各元素的类型,例如是图表、文本、装饰等类型。相应地,元素布局系统200在对多个元素在所述画布的尺寸和位置进行迭代优化时,还可以结合元素的类型进行迭代优化。例如,元素布局系统200可以基于元素的类型对元素进行分组,将属于同一分组的元素绑定,然后按照以绑定后的元素分组为单位进行迭代优化。例如,元素布局系统200可以将一个图表类型的元素与一个文本类型的元素(例如是图表的标题)绑定,然后将绑定后的元素分组视为一个元素进行迭代优化。In some possible implementation manners, the element layout system 200 may also obtain the type of each element, such as chart, text, decoration and other types. Correspondingly, when the element layout system 200 performs iterative optimization on the size and position of multiple elements on the canvas, iterative optimization may also be performed in combination with element types. For example, the element layout system 200 can group elements based on element types, bind elements belonging to the same group, and then perform iterative optimization in units of bound element groups. For example, the element layout system 200 can bind a chart type element with a text type element (for example, the title of a chart), and then treat the bound element groups as one element for iterative optimization.
参见图5所示的智能布局的原理图,元素布局系统200在布局生成阶段,采用生成模型,例如是核心混合整数线性规划(mixed-integer linear programming,MILP)生成模型,生成候选布局。其中,生成模型的大小通常取决于元素的数量。生成模型中的决策变量和约束的数量与画布和其他因素无关。Referring to the schematic diagram of the intelligent layout shown in FIG. 5 , the element layout system 200 uses a generative model, such as the core mixed-integer linear programming (MILP) generative model, to generate candidate layouts during the layout generation phase. Among them, the size of the generative model usually depends on the number of elements. The number of decision variables and constraints in the generative model is independent of the canvas and other factors.
生成模型中定义了核心MILP公式(图5中未示出)和目标函数。核心MILP公式用于生成适当的布局网格骨架,以确保元素在允许的位置和尺寸限制内,元素之间不重叠,且不溢出画布。其中,生成模型定义坐标系原点为画布的左上角,X轴的正方向为水平向右,Y轴的正方向为竖直向下。生成模型中定义连续决策变量Le、Re、Te、Be表示单个元素e的左、右、上、下边缘的位置,通过上述变量可以确保适当的元素大小以及防止元素溢出。对齐约束、填充约束等设计约束可以作为生成模型的目标函数(也称作附加约束),以优化布局网格骨架,生成具有对齐等美学效果的候选布局。The core MILP formulation (not shown in Figure 5) and objective function are defined in the generative model. The core MILP formulas are used to generate an appropriate layout grid skeleton to ensure that elements are within allowed position and size constraints, do not overlap each other, and do not overflow the canvas. Among them, the generation model defines the origin of the coordinate system as the upper left corner of the canvas, the positive direction of the X-axis is horizontally to the right, and the positive direction of the Y-axis is vertically downward. Continuous decision variables Le, Re, Te, and Be are defined in the generative model to indicate the position of the left, right, upper, and lower edges of a single element e, through which the appropriate element size can be ensured and element overflow can be prevented. Design constraints such as alignment constraints and padding constraints can be used as the objective function of the generative model (also called additional constraints) to optimize the layout grid skeleton and generate candidate layouts with aesthetic effects such as alignment.
S310:元素布局系统200对所述多个候选布局进行排序,获得布局结果。S310: The element layout system 200 sorts the multiple candidate layouts to obtain a layout result.
元素布局系统200可以从不同维度对多个候选布局进行排序,以选择性能较好的候选布局,作为布局结果。例如,元素布局系统200可以根据所述多个元素中每个元素的尺寸的均衡度、所述多个元素在画布呈现的画面的均衡度以及所述多个元素的对齐程度中的至少一个,对所述多个候选布局进行排序。The element layout system 200 can sort multiple candidate layouts from different dimensions, so as to select a candidate layout with better performance as the layout result. For example, the element layout system 200 may, according to at least one of the size balance of each of the multiple elements, the balance of the picture presented by the multiple elements on the canvas, and the alignment of the multiple elements, Ranking the plurality of candidate layouts.
在一些可能的实现方式中,元素布局系统200可以对多个元素中每个元素的尺寸的均衡度、多个元素在画布呈现的画面的均衡度以及所述多个元素的对齐程度进行打分,根据相应的分数对所述多个候选布局进行排序。参见图5,元素布局系统200采用排序模型对大小质量Q s(尺寸的均衡度)、平衡质量Q b(多个元素在画布呈现的画面的均衡度)、对齐质量Q a(多个元素的对齐程度)进行打分,得到尺寸均衡分数Score size、平衡分数(重要性分数Score importance)和对齐分数Score align。元素布局系统200可以计算各个候选布局的总分数,如下所示: In some possible implementation manners, the element layout system 200 may score the balance of the size of each of the multiple elements, the balance of the picture presented by the multiple elements on the canvas, and the alignment of the multiple elements, The plurality of candidate layouts are ranked according to the corresponding scores. Referring to FIG. 5 , the element layout system 200 adopts a sorting model to evaluate the size quality Q s (the balance degree of the size), the balance quality Q b (the balance degree of the picture presented by multiple elements on the canvas), and the alignment quality Q a (the balance degree of the multiple elements Alignment degree) is scored to obtain the size balance score Score size , balance score (importance score Score importance ) and alignment score Score align . The element layout system 200 can calculate the total score for each candidate layout as follows:
Score=Score size+Score align+Score importance                     (30) Score=Score size +Score align +Score importance (30)
元素布局系统200可以基于上述总分数对多个候选布局进行排序,获得布局结果。其中,布局结果可以为所述多个候选布局中排序靠前的候选布局,例如可以是总分数排序为top3的候选布局。在图5的示例中,布局结果可以是排序为top1的候选布局,如候选布局 1。该布局结果包括多个元素在所述画布的推荐尺寸和推荐位置。其中,推荐尺寸和推荐位置可以是上述排序靠前的候选布局中元素的尺寸和位置。The element layout system 200 can sort multiple candidate layouts based on the above total score to obtain a layout result. Wherein, the layout result may be the top candidate layout among the plurality of candidate layouts, for example, it may be the candidate layout whose total score is ranked top3. In the example in FIG. 5 , the layout result may be a candidate layout sorted as top1, such as candidate layout 1. The layout result includes recommended sizes and recommended positions of elements on the canvas. Wherein, the recommended size and recommended position may be the size and position of elements in the above-mentioned top-ranked candidate layouts.
接下来,对尺寸均衡分数Score size、对齐分数Score align、重要性分数Score importance的确定方式进行说明。 Next, how to determine the size balance score Score size , the alignment score Score align , and the importance score Score importance will be described.
尺寸均衡分数Score size可以基于各个元素的规格化宽度和规格化高度之和确定。具体计算方式参见公式(31): The Score size can be determined based on the sum of the normalized width and normalized height of each element. Please refer to the formula (31) for the specific calculation method:
Figure PCTCN2022093727-appb-000052
Figure PCTCN2022093727-appb-000052
其中,width e、height e用于表征元素e的宽度和高度,width ca、height ca用于表征画布的宽度和高度。相应地,
Figure PCTCN2022093727-appb-000053
用于表征元素e的规格化宽度和规格化高度。N el用于表征元素的数量。
Among them, width e and height e are used to represent the width and height of element e, and width ca and height ca are used to represent the width and height of the canvas. Correspondingly,
Figure PCTCN2022093727-appb-000053
Used to characterize the normalized width and normalized height of element e. N el is used to characterize the number of elements.
参见图6A所示不同布局的尺寸均衡分数的示意图,左边的布局中元素大小差异大于右边的布局中元素大小差异,左边的布局对应的尺寸均衡分数低于右边的布局对应的尺寸均衡分数。其中,尺寸均衡分数越高,代表布局内各元素的大小越均衡。Referring to the schematic diagram of the size balance scores of different layouts shown in Figure 6A, the element size difference in the left layout is greater than the element size difference in the right layout, and the size balance score corresponding to the left layout is lower than the size balance score corresponding to the right layout. Among them, the higher the size balance score, the more balanced the size of each element in the layout.
对齐分数Score alig可以根据每两个元素间上下左右对齐情况确定。若两元素上对齐,则
Figure PCTCN2022093727-appb-000054
取1,类似地,若两元素下对齐、左对齐、右对齐,则
Figure PCTCN2022093727-appb-000055
Figure PCTCN2022093727-appb-000056
取1。一个候选布局的对齐分数Score ali可以参见如下公式:
The alignment score Score alig can be determined according to the top, bottom, left, and right alignments between every two elements. If two elements are aligned, then
Figure PCTCN2022093727-appb-000054
Take 1, similarly, if the two elements are bottom-aligned, left-aligned, and right-aligned, then
Figure PCTCN2022093727-appb-000055
Figure PCTCN2022093727-appb-000056
Take 1. The alignment score Score ali of a candidate layout can be referred to the following formula:
Figure PCTCN2022093727-appb-000057
Figure PCTCN2022093727-appb-000057
参见图6B所示不同布局的对齐分数的示意图,左边的布局中元素对齐的数量小于右边的布局中元素对齐的数量,相应地,左边的布局的对齐分数小于右边的布局的对齐分数。Referring to the schematic diagram of alignment scores of different layouts shown in FIG. 6B , the number of element alignments in the left layout is smaller than that of the right layout, and correspondingly, the alignment score of the left layout is smaller than that of the right layout.
重要性分数Score importance可以根据所述元素的面积以及所述元素到所述画布的中心点的距离确定。例如,候选布局的重要性分数可以基于每个元素的面积以及每个元素到画布的中心点的距离确定。具体计算方式参见公式(33): The importance score Score importance may be determined according to the area of the element and the distance from the element to the center point of the canvas. For example, the importance score for a candidate layout may be determined based on the area of each element and the distance of each element from the center point of the canvas. Please refer to the formula (33) for the specific calculation method:
Figure PCTCN2022093727-appb-000058
Figure PCTCN2022093727-appb-000058
其中,important_weight e表示元素的重要性系数,area e表示元素的面积,x e表示元素的x坐标,y e表示元素的y坐标,width e、height e分别表示元素的宽、高,width canvas、height canvas分别表示画布的宽、高。 Among them, important_weight e represents the importance coefficient of the element, area e represents the area of the element, x e represents the x coordinate of the element, y e represents the y coordinate of the element, width e and height e represent the width and height of the element respectively, width canvas , height canvas indicates the width and height of the canvas respectively.
参见图6C,一个元素的面积占比越大,距离画布的中心点越近,则该元素的重要性越高,反之,则越低。基于此,图6C中左边的布局中第三列第一行的元素的重要性分数小于右边的布局中第二列的元素的重要性分数。Referring to Figure 6C, the larger the area ratio of an element and the closer it is to the center of the canvas, the higher the importance of the element, and vice versa. Based on this, the importance score of the element in the third column and the first row in the layout on the left in FIG. 6C is smaller than the importance score of the element in the second column in the layout on the right.
上述示例是以元素布局系统200基于三个分数之和数进行排序,然后根据排序结果确定布局结果进行示例说明。在一些可能的实现方式中,也可以基于三个分数的加权平均数或者三个分数中的一个或两个分数进行排序,并根据排序结果确定布局结果。The above example is illustrated by using the element layout system 200 to sort based on the sum of the three scores, and then determine the layout result according to the sorting result. In some possible implementation manners, sorting may also be performed based on the weighted average of the three scores or one or two of the three scores, and the layout result is determined according to the sorting result.
需要说明的是,上述S308至S310为本申请实施例中元素布局系统200以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得布局结果的一种实现方式,在一些可的实现方式中,元素布局系统200也可以不执行排序等操作。例如,元素布局系统200可以生成一个候选布局,并将该候选布局作为布局结果。It should be noted that, the above S308 to S310 are the element layout system 200 in the embodiment of the present application, starting from the initial size and initial position of the multiple elements on the canvas, combining the size of the canvas and design constraints, Iteratively optimizes the size and position of each element on the canvas to obtain a layout result. In some possible implementations, the element layout system 200 may not perform operations such as sorting. For example, the element layout system 200 can generate a candidate layout and use the candidate layout as a layout result.
并且,元素布局系统200可以设置多种触发条件,以触发迭代优化,生成布局的过程。例如,元素布局系统200可以提供智能布局控件,则触发条件可以包括用户触发上述智能 布局控件。又例如,元素布局系统200设置有预审时间,触发条件可以包括距离用户上次输入元素的时间大于预设时间。也即,元素布局系统200可以在用户触发智能布局控件,或者距离用户上次输入元素的时间大于预设时间时,以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化。Moreover, the element layout system 200 can set various trigger conditions to trigger the process of iterative optimization and layout generation. For example, the element layout system 200 may provide an intelligent layout control, and the trigger condition may include that the user triggers the above-mentioned intelligent layout control. For another example, the element layout system 200 is set with a pre-review time, and the trigger condition may include that the time since the user last entered an element is greater than the preset time. That is to say, the element layout system 200 may start from the initial size and initial position of the multiple elements on the canvas when the user triggers the smart layout control, or when the time since the user last entered an element is greater than the preset time, in combination with the The size and design constraints of the canvas, iteratively optimize the size and position of the multiple elements on the canvas.
基于上述内容描述,本申请实施例提供了一种元素布局方法。该方法采用迭代优化的方式确定推荐尺寸和推荐位置,而不是与固定的布局模板进行匹配,因而解决了相关技术中对于图表等类型的元素不适用,布局效果不佳的问题,具有较高可用性。进一步地,在迭代优化时,可以生成多个候选布局,并基于尺寸均衡分数、对齐分数和/或重要性分数对多个候选布局进行排序,获得布局结果,可以实现用户意图驱动的智能化布局。Based on the above content description, the embodiment of the present application provides an element layout method. The method adopts an iterative optimization method to determine the recommended size and recommended position, rather than matching with a fixed layout template, thus solving the problems in related technologies that are not suitable for elements such as charts and poor layout effects, and has high usability . Furthermore, during iterative optimization, multiple candidate layouts can be generated and sorted based on the size balance score, alignment score and/or importance score to obtain the layout result, which can realize the intelligent layout driven by user intent .
在演示数据图表为主的场景中,通过上述方法可以实现以一个图表(也称作主图表)为视觉焦点,以其余的可视化图表辅助主图表完成数据事实(data fact)的讲述,如此可以获得较好的演示效果。In the scenario where the presentation data chart is the main one, one chart (also called the main chart) can be used as the visual focus through the above method, and the rest of the visual charts can be used to assist the main chart to complete the narration of the data fact. In this way, it can be obtained Better presentation effect.
本申请实施例还设计了相关验证实验,以验证演示效果。考虑到不同人员的年龄、性别、文化、专业背景等多方面因素,本验证实验选择20人进行测试。其中,进行测试的20人具体为15名可视化专业人员以及5名技术专家。The embodiments of the present application also design relevant verification experiments to verify the demonstration effect. Taking into account the age, gender, culture, professional background and other factors of different personnel, 20 people were selected for the test in this verification experiment. Among them, the 20 people who conducted the test were specifically 15 visualization professionals and 5 technical experts.
该验证实验采用T-test检验法对测试数据分析。T-test是一种广泛用于比较两组样本均值的统计检验方法,它采用T分布理论来推断差异发生的概率,从而判定两个平均数的差异是否显著。主要用于样本含量较小(例如n<30),总体标准差σ未知的正态分布。The verification experiment uses the T-test test method to analyze the test data. T-test is a statistical test method widely used to compare the means of two groups of samples. It uses the T distribution theory to infer the probability of the difference, so as to determine whether the difference between the two means is significant. It is mainly used for normal distribution with small sample size (eg n<30) and unknown population standard deviation σ.
具体地,给定相同的元素,分别采用本申请实施例的元素布局方法和其他元素布局方法(例如是基于模板和动态编程的元素布局方法)生成不同布局,假设为布局1和布局2。然后,20名测试人员可以对上述布局1和布局2分别打分。对于布局1和布局2,采用T-test判定20名测试人员打分的平均数的差异是否显著。Specifically, given the same element, use the element layout method of the embodiment of the present application and other element layout methods (such as element layout methods based on templates and dynamic programming) to generate different layouts, assuming layout 1 and layout 2. Then, 20 testers can score the above layout 1 and layout 2 respectively. For Layout 1 and Layout 2, T-test is used to determine whether the difference between the mean scores of 20 testers is significant.
T-test结果表明:采用本申请实施例的元素布局方法的演示效果显著优于基于模板和动态编程的元素布局方法的演示结果(置信度>99%)。本申请实施例的元素布局方法生成的布局的整套效果较好,元素大小合理,并且较好地填充画布。T-test results show that the demonstration effect of the element layout method adopted in the embodiment of the present application is significantly better than that of the element layout method based on templates and dynamic programming (confidence degree >99%). The overall effect of the layout generated by the element layout method in the embodiment of the present application is better, the size of the elements is reasonable, and the canvas is better filled.
上文结合图1A至图6C对本申请实施例提供的元素布局方法进行了详细介绍,下面将结合附图对本申请实施例提供的元素布局系统200进行介绍。The element layout method provided by the embodiment of the present application has been described in detail above with reference to FIG. 1A to FIG. 6C , and the element layout system 200 provided by the embodiment of the present application will be introduced below with reference to the accompanying drawings.
参见图2所示的元素布局系统的结构示意图,该系统200包括:Referring to the structural diagram of the element layout system shown in FIG. 2, the system 200 includes:
交互模块202,用于接收用户输入的多个元素;An interaction module 202, configured to receive multiple elements input by the user;
确定模块204,用于确定所述多个元素在画布的初始尺寸和初始位置;A determining module 204, configured to determine the initial size and initial position of the plurality of elements on the canvas;
优化模块206,用于以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得布局结果,所述布局结果包括所述多个元素在所述画布的推荐尺寸和推荐位置。An optimization module 206, configured to iteratively optimize the size and position of the multiple elements on the canvas, taking the initial size and initial position of the multiple elements on the canvas as a starting point, in combination with the size of the canvas and design constraints , obtaining a layout result, where the layout result includes recommended sizes and recommended positions of the plurality of elements on the canvas.
在一些可能的实现方式中,所述优化模块206具体用于:In some possible implementation manners, the optimization module 206 is specifically configured to:
对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得多个候选布局,所述多 个候选布局中的每个候选布局包括所述多个元素在所述画布的尺寸和位置;Iteratively optimizing the size and position of the multiple elements on the canvas to obtain multiple candidate layouts, each of the multiple candidate layouts includes the size and position of the multiple elements on the canvas ;
对所述多个候选布局进行排序,获得布局结果,所述布局结果为所述多个候选布局中排序靠前的候选布局。Sorting the multiple candidate layouts to obtain a layout result, where the layout result is a top-ranked candidate layout among the multiple candidate layouts.
在一些可能的实现方式中,所述优化模块206具体用于:In some possible implementation manners, the optimization module 206 is specifically configured to:
根据所述多个元素中每个元素的尺寸的均衡度、所述多个元素在画布呈现的画面的均衡度以及所述多个元素的对齐程度中的至少一个,对所述多个候选布局进行排序。According to at least one of the degree of balance of the size of each of the plurality of elements, the degree of balance of the images presented by the plurality of elements on the canvas, and the degree of alignment of the plurality of elements, the plurality of candidate layouts Sort.
在一些可能的实现方式中,所述多个元素在画布呈现的画面的均衡度通过每个元素的重要性分数之和表征,所述重要性分数根据所述元素的面积以及所述元素到所述画布的中心点的距离确定。In some possible implementation manners, the balance degree of the picture presented by the multiple elements on the canvas is characterized by the sum of the importance scores of each element, and the importance score is based on the area of the element and the distance between the element and the Determine the distance from the center point of the canvas.
在一些可能的实现方式中,所述交互模块202还用于:In some possible implementations, the interaction module 202 is also configured to:
接收用户输入的自定义约束;Receive custom constraints entered by the user;
所述设计约束包括基础约束和所述自定义约束。The design constraints include basic constraints and the custom constraints.
在一些可能的实现方式中,所述基础约束包括对齐约束、网格约束、大小约束、边界约束和填充约束中的任意一种或多种,所述自定义约束包括锁定约束、纵横比约束、对齐偏好约束中的任意一种或多种。In some possible implementations, the basic constraints include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and fill constraints, and the custom constraints include locking constraints, aspect ratio constraints, Any one or more of the alignment preference constraints.
在一些可能的实现方式中,所述元素包括图表、文本或装饰中的一种或多种。In some possible implementations, the elements include one or more of graphics, text or decorations.
在一些可能的实现方式中,所述交互模块202具体用于:In some possible implementation manners, the interaction module 202 is specifically configured to:
向用户呈现设计界面,所述设计界面承载有可视化组件;presenting a design interface to a user, the design interface carrying a visual component;
响应于用户对所述可视化组件的拖拽操作,接收与所述可视化组件对应的多个元素。A plurality of elements corresponding to the visualization component are received in response to a user's drag operation on the visualization component.
在一些可能的实现方式中,所述优化模块206具体用于:In some possible implementation manners, the optimization module 206 is specifically configured to:
当用户触发智能布局控件或者距离用户上次输入元素的时间大于预设时间时,以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化。When the user triggers the smart layout control or the time since the user last entered an element is greater than the preset time, starting from the initial size and initial position of the multiple elements on the canvas, combined with the size of the canvas and design constraints, the Iteratively optimizing the size and position of the plurality of elements on the canvas.
根据本申请实施例的元素布局系统200可对应于执行本申请实施例中描述的方法,并且元素布局系统200的各个模块/单元的上述和其它操作和/或功能分别为了实现图2所示实施例中的各个方法的相应流程,为了简洁,在此不再赘述。The element layout system 200 according to the embodiment of the present application may correspond to the implementation of the method described in the embodiment of the present application, and the above-mentioned and other operations and/or functions of the various modules/units of the element layout system 200 are respectively in order to realize the implementation shown in FIG. 2 For the sake of brevity, the corresponding flow of each method in the example is not repeated here.
本申请实施例还提供一种计算机集群。该计算机集群包括至少一台计算机,该至少一台计算机中的任一台计算机可以来自云环境或者边缘环境,也可以是终端设备。该计算机集群具体用于实现如图2所示实施例中元素布局系统200的功能。The embodiment of the present application also provides a computer cluster. The computer cluster includes at least one computer, and any computer in the at least one computer may be from a cloud environment or an edge environment, or may be a terminal device. The computer cluster is specifically used to implement the functions of the element layout system 200 in the embodiment shown in FIG. 2 .
图7提供了一种计算机集群的结构示意图,如图7所示,计算机集群70包括多台计算机700,计算机700包括总线701、处理器702、通信接口703和存储器704。处理器702、存储器704和通信接口703之间通过总线701通信。FIG. 7 provides a schematic structural diagram of a computer cluster. As shown in FIG. 7 , the computer cluster 70 includes multiple computers 700 , and the computers 700 include a bus 701 , a processor 702 , a communication interface 703 and a memory 704 . The processor 702 , the memory 704 and the communication interface 703 communicate through the bus 701 .
总线701可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图7中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The bus 701 may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus or an extended industry standard architecture (extended industry standard architecture, EISA) bus, etc. The bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one thick line is used in FIG. 7 , but it does not mean that there is only one bus or one type of bus.
处理器702可以为中央处理器(central processing unit,CPU)、图形处理器(graphics  processing unit,GPU)、微处理器(micro processor,MP)或者数字信号处理器(digital signal processor,DSP)等处理器中的任意一种或多种。The processor 702 may be a central processing unit (central processing unit, CPU), a graphics processing unit (graphics processing unit, GPU), a microprocessor (micro processor, MP) or a digital signal processor (digital signal processor, DSP) etc. Any one or more of them.
通信接口703用于与外部通信。例如,通信接口703用于接收用户输入的多个元素,输出布局结果等等。The communication interface 703 is used for communicating with the outside. For example, the communication interface 703 is used to receive multiple elements input by the user, output layout results, and so on.
存储器704可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。存储器704还可以包括非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器,硬盘驱动器(hard disk drive,HDD)或固态驱动器(solid state drive,SSD)。The memory 704 may include a volatile memory (volatile memory), such as a random access memory (random access memory, RAM). Memory 704 can also include non-volatile memory (non-volatile memory), such as read-only memory (read-only memory, ROM), flash memory, hard disk drive (hard disk drive, HDD) or solid state drive (solid state drive) , SSD).
存储器704中存储有计算机可读指令,处理器702执行该计算机可读指令,以使得计算机集群70执行前述元素布局方法(或实现前述元素布局系统200的功能)。Computer-readable instructions are stored in the memory 704 , and the processor 702 executes the computer-readable instructions, so that the computer cluster 70 executes the aforementioned element layout method (or implements the aforementioned element layout system 200 functions).
具体地,在实现图2所示系统的实施例的情况下,且图2中所描述的元素布局系统200的各模块如交互模块202、确定模块204和优化模块206的功能为通过软件实现的情况下,执行图2中各模块的功能所需的软件或程序代码可以存储在计算机集群70中的至少一个存储器704中。至少一个处理器702执行存储器704中存储的程序代码,以使得计算机集群70执行前述元素布局方法。Specifically, in the case of realizing the embodiment of the system shown in FIG. 2 , and the functions of the various modules of the element layout system 200 described in FIG. 2 such as the interaction module 202, the determination module 204 and the optimization module 206 are realized by software In some cases, software or program codes required to execute the functions of the modules in FIG. 2 may be stored in at least one memory 704 in the computer cluster 70 . At least one processor 702 executes the program code stored in the memory 704, so that the computer cluster 70 executes the aforementioned element layout method.
本申请实施例还提供了一种计算机可读存储介质。所述计算机可读存储介质可以是计算机集群能够存储的任何可用介质或者是包含一个或多个可用介质的数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘)等。该计算机可读存储介质包括指令,所述指令指示计算机集群执行上述元素布局方法。The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that can be stored by a computer cluster or a data storage device such as a data center including one or more available media. The available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state hard disk), etc. The computer-readable storage medium includes instructions, and the instructions instruct a cluster of computers to execute the above element layout method.
本申请实施例还提供了一种计算机程序产品。所述计算机程序产品包括一个或多个计算机指令。在计算机集群上加载和执行所述计算机指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算设备或数据中心进行传输。所述计算机程序产品可以为一个软件安装包,在需要使用前述元素布局方法的任一方法的情况下,可以下载该计算机程序产品并在计算机集群上执行该计算机程序产品。The embodiment of the present application also provides a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on the computer cluster, the processes or functions according to the embodiments of the present application are generated in whole or in part. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, from a website, computing device, or data center via Wired (eg, coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.) transmission to another website site, computing device, or data center. The computer program product may be a software installation package, which may be downloaded and executed on a computer cluster if any of the aforementioned element layout methods needs to be used.
上述各个附图对应的流程或结构的描述各有侧重,某个流程或结构中没有详述的部分,可以参见其他流程或结构的相关描述。The description of the process or structure corresponding to each of the above drawings has its own emphasis. For the part that is not described in detail in a certain process or structure, you can refer to the relevant description of other processes or structures.

Claims (21)

  1. 一种元素布局方法,其特征在于,所述方法包括:An element layout method, characterized in that the method comprises:
    接收用户输入的多个元素;Multiple elements that receive user input;
    确定所述多个元素在画布的初始尺寸和初始位置;determining the initial size and initial position of the plurality of elements on the canvas;
    以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得布局结果,所述布局结果包括所述多个元素在所述画布的推荐尺寸和推荐位置。Taking the initial size and position of the plurality of elements on the canvas as a starting point, combined with the size and design constraints of the canvas, iteratively optimizes the size and position of the plurality of elements on the canvas to obtain a layout result. The layout result includes recommended sizes and recommended positions of the plurality of elements on the canvas.
  2. 根据权利要求1所述的方法,其特征在于,所述对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得布局结果,包括:The method according to claim 1, wherein the iterative optimization of the size and position of the plurality of elements on the canvas to obtain a layout result includes:
    对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得多个候选布局,所述多个候选布局中的每个候选布局包括所述多个元素在所述画布的尺寸和位置;Iteratively optimizing the size and position of the multiple elements on the canvas to obtain multiple candidate layouts, each of the multiple candidate layouts includes the size and position of the multiple elements on the canvas ;
    对所述多个候选布局进行排序,获得布局结果,所述布局结果为所述多个候选布局中排序靠前的候选布局。Sorting the multiple candidate layouts to obtain a layout result, where the layout result is a top-ranked candidate layout among the multiple candidate layouts.
  3. 根据权利要求2所述的方法,其特征在于,所述对所述多个候选布局进行排序,包括:The method according to claim 2, wherein said sorting said plurality of candidate layouts comprises:
    根据所述多个元素中每个元素的尺寸的均衡度、所述多个元素在画布呈现的画面的均衡度以及所述多个元素的对齐程度中的至少一个,对所述多个候选布局进行排序。According to at least one of the degree of balance of the size of each of the plurality of elements, the degree of balance of the images presented by the plurality of elements on the canvas, and the degree of alignment of the plurality of elements, the plurality of candidate layouts Sort.
  4. 根据权利要求3所述的方法,其特征在于,所述多个元素在画布呈现的画面的均衡度通过每个元素的重要性分数之和表征,所述重要性分数根据所述元素的面积以及所述元素到所述画布的中心点的距离确定。The method according to claim 3, wherein the balance degree of the picture presented by the plurality of elements on the canvas is characterized by the sum of the importance scores of each element, and the importance score is based on the area of the elements and The distance from the element to the center point of the canvas is determined.
  5. 根据权利要求1至4任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 4, wherein the method further comprises:
    接收用户输入的自定义约束;Receive custom constraints entered by the user;
    所述设计约束包括基础约束和所述自定义约束。The design constraints include basic constraints and the custom constraints.
  6. 根据权利要求5所述的方法,其特征在于,所述基础约束包括对齐约束、网格约束、大小约束、边界约束和填充约束中的任意一种或多种,所述自定义约束包括锁定约束、纵横比约束、对齐偏好约束中的任意一种或多种。The method according to claim 5, wherein the basic constraints include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and filling constraints, and the custom constraints include locking constraints Any one or more of , aspect ratio constraints, and alignment preference constraints.
  7. 根据权利要求1至6任一项所述的方法,其特征在于,所述元素包括图表、文本或装饰中的一种或多种。The method according to any one of claims 1 to 6, wherein the elements include one or more of diagrams, texts or decorations.
  8. 根据权利要求1至7任一项所述的方法,其特征在于,所述接收用户输入的多个元素,包括:The method according to any one of claims 1 to 7, wherein the multiple elements input by the user include:
    向用户呈现设计界面,所述设计界面承载有可视化组件;presenting a design interface to a user, the design interface carrying a visual component;
    响应于用户对所述可视化组件的拖拽操作,接收与所述可视化组件对应的多个元素。A plurality of elements corresponding to the visualization component are received in response to a user's drag operation on the visualization component.
  9. 根据权利要求1至8任一项所述的方法,其特征在于,所述以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,包括:The method according to any one of claims 1 to 8, characterized in that, starting from the initial size and initial position of the plurality of elements on the canvas, combined with the size of the canvas and design constraints, the Multiple elements are iteratively optimized in size and position on the canvas, including:
    当用户触发智能布局控件或者距离用户上次输入元素的时间大于预设时间时,以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化。When the user triggers the smart layout control or the time since the user last entered an element is greater than the preset time, starting from the initial size and initial position of the multiple elements on the canvas, combined with the size of the canvas and design constraints, the Iteratively optimizing the size and position of the plurality of elements on the canvas.
  10. 一种元素布局系统,其特征在于,所述系统包括:An element layout system, characterized in that the system includes:
    交互模块,用于接收用户输入的多个元素;An interactive module for receiving multiple elements input by the user;
    确定模块,用于确定所述多个元素在画布的初始尺寸和初始位置;A determining module, configured to determine the initial size and initial position of the plurality of elements on the canvas;
    优化模块,用于以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得布局结果,所述布局结果包括所述多个元素在所述画布的推荐尺寸和推荐位置。An optimization module, configured to iteratively optimize the size and position of the multiple elements on the canvas, taking the initial size and initial position of the multiple elements on the canvas as a starting point, in combination with the size of the canvas and design constraints, A layout result is obtained, where the layout result includes recommended sizes and recommended positions of the plurality of elements on the canvas.
  11. 根据权利要求10所述的系统,其特征在于,所述优化模块具体用于:The system according to claim 10, wherein the optimization module is specifically used for:
    对所述多个元素在所述画布的尺寸和位置进行迭代优化,获得多个候选布局,所述多个候选布局中的每个候选布局包括所述多个元素在所述画布的尺寸和位置;Iteratively optimizing the size and position of the multiple elements on the canvas to obtain multiple candidate layouts, each of the multiple candidate layouts includes the size and position of the multiple elements on the canvas ;
    对所述多个候选布局进行排序,获得布局结果,所述布局结果为所述多个候选布局中排序靠前的候选布局。Sorting the multiple candidate layouts to obtain a layout result, where the layout result is a top-ranked candidate layout among the multiple candidate layouts.
  12. 根据权利要求11所述的系统,其特征在于,所述优化模块具体用于:The system according to claim 11, wherein the optimization module is specifically used for:
    根据所述多个元素中每个元素的尺寸的均衡度、所述多个元素在画布呈现的画面的均衡度以及所述多个元素的对齐程度中的至少一个,对所述多个候选布局进行排序。According to at least one of the degree of balance of the size of each of the plurality of elements, the degree of balance of the images presented by the plurality of elements on the canvas, and the degree of alignment of the plurality of elements, the plurality of candidate layouts Sort.
  13. 根据权利要求12所述的系统,其特征在于,所述多个元素在画布呈现的画面的均衡度通过每个元素的重要性分数之和表征,所述重要性分数根据所述元素的面积以及所述元素到所述画布的中心点的距离确定。The system according to claim 12, wherein the balance degree of the picture presented by the plurality of elements on the canvas is represented by the sum of the importance scores of each element, and the importance score is based on the area of the elements and The distance from the element to the center point of the canvas is determined.
  14. 根据权利要求10至13任一项所述的系统,其特征在于,所述交互模块还用于:The system according to any one of claims 10 to 13, wherein the interaction module is also used for:
    接收用户输入的自定义约束;Receive custom constraints entered by the user;
    所述设计约束包括基础约束和所述自定义约束。The design constraints include basic constraints and the custom constraints.
  15. 根据权利要求14所述的系统,其特征在于,所述基础约束包括对齐约束、网格约束、大小约束、边界约束和填充约束中的任意一种或多种,所述自定义约束包括锁定约束、纵横比约束、对齐偏好约束中的任意一种或多种。The system according to claim 14, wherein the basic constraints include any one or more of alignment constraints, grid constraints, size constraints, boundary constraints, and filling constraints, and the custom constraints include locking constraints Any one or more of , aspect ratio constraints, and alignment preference constraints.
  16. 根据权利要求10至15任一项所述的系统,其特征在于,所述元素包括图表、文本或装饰中的一种或多种。The system according to any one of claims 10 to 15, wherein the element comprises one or more of graphics, text or decoration.
  17. 根据权利要求10至16任一项所述的系统,其特征在于,所述交互模块具体用于:The system according to any one of claims 10 to 16, wherein the interaction module is specifically used for:
    向用户呈现设计界面,所述设计界面承载有可视化组件;presenting a design interface to a user, the design interface carrying a visual component;
    响应于用户对所述可视化组件的拖拽操作,接收与所述可视化组件对应的多个元素。A plurality of elements corresponding to the visualization component are received in response to a user's drag operation on the visualization component.
  18. 根据权利要求10至17任一项所述的系统,其特征在于,所述优化模块具体用于:The system according to any one of claims 10 to 17, wherein the optimization module is specifically used for:
    当用户触发智能布局控件或者距离用户上次输入元素的时间大于预设时间时,以所述多个元素在画布的初始尺寸和初始位置为起点,结合所述画布的尺寸以及设计约束,对所述多个元素在所述画布的尺寸和位置进行迭代优化。When the user triggers the smart layout control or the time since the user last entered an element is greater than the preset time, starting from the initial size and initial position of the multiple elements on the canvas, combined with the size of the canvas and design constraints, the Iteratively optimizing the size and position of the plurality of elements on the canvas.
  19. 一种计算机集群,其特征在于,所述计算机集群包括至少一台计算机,所述至少一台计算机包括至少一个处理器和至少一个存储器,所述至少一个存储器中存储有计算机可读指令,所述至少一个处理器执行所述计算机可读指令,使得所述计算机集群执行如权利要求1至9任一项所述的方法。A computer cluster, characterized in that the computer cluster includes at least one computer, the at least one computer includes at least one processor and at least one memory, and computer-readable instructions are stored in the at least one memory, the At least one processor executes the computer-readable instructions, causing the computer cluster to perform the method according to any one of claims 1-9.
  20. 一种计算机可读存储介质,其特征在于,包括计算机可读指令,当所述计算机可读指令在计算机集群上运行时,使得所述计算机集群执行如权利要求1至9任一项所述的 方法。A computer-readable storage medium, characterized in that it includes computer-readable instructions, and when the computer-readable instructions are run on a computer cluster, the computer cluster executes the method described in any one of claims 1 to 9. method.
  21. 一种计算机程序产品,其特征在于,包括计算机可读指令,当所述计算机可读指令在计算机集群上运行时,使得所述计算机集群执行如权利要求1至9任一项所述的方法。A computer program product, characterized by comprising computer-readable instructions, which, when the computer-readable instructions are run on a computer cluster, cause the computer cluster to execute the method according to any one of claims 1 to 9.
PCT/CN2022/093727 2021-11-30 2022-05-19 Element layout method and related device WO2023097990A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111447457.3 2021-11-30
CN202111447457.3A CN116206012A (en) 2021-11-30 2021-11-30 Element layout method and related equipment

Publications (1)

Publication Number Publication Date
WO2023097990A1 true WO2023097990A1 (en) 2023-06-08

Family

ID=86511684

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/093727 WO2023097990A1 (en) 2021-11-30 2022-05-19 Element layout method and related device

Country Status (2)

Country Link
CN (1) CN116206012A (en)
WO (1) WO2023097990A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116663483A (en) * 2023-07-31 2023-08-29 全芯智造技术有限公司 Method, apparatus and medium for chip layout
CN117033844A (en) * 2023-10-07 2023-11-10 之江实验室 Canvas element layout method and device, storage medium and electronic equipment
CN117557682A (en) * 2024-01-09 2024-02-13 腾讯科技(深圳)有限公司 Data processing method, apparatus, product, device, and medium
CN117828701A (en) * 2024-03-05 2024-04-05 中国石油大学(华东) Engineering drawing layout optimization method, system, equipment and medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117076811A (en) * 2023-10-13 2023-11-17 腾讯科技(深圳)有限公司 Webpage export method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050007382A1 (en) * 2003-07-11 2005-01-13 Schowtka Alexander K. Automated image resizing and cropping
CN106056651A (en) * 2016-06-03 2016-10-26 北京金山安全软件有限公司 Picture layout management method and device and electronic equipment
CN107240151A (en) * 2017-07-05 2017-10-10 常州赞云软件科技有限公司 A kind of scene layout based on parent-child constraint preserves and reproducting method
CN108280135A (en) * 2017-12-26 2018-07-13 阿里巴巴集团控股有限公司 Realize the method, apparatus and electronic equipment of data structure visualization
CN112164127A (en) * 2020-09-25 2021-01-01 大方众智创意广告(珠海)有限公司 Picture generation method and device, electronic equipment and readable storage medium
CN113190781A (en) * 2021-05-12 2021-07-30 北京奇艺世纪科技有限公司 Page layout method, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050007382A1 (en) * 2003-07-11 2005-01-13 Schowtka Alexander K. Automated image resizing and cropping
CN106056651A (en) * 2016-06-03 2016-10-26 北京金山安全软件有限公司 Picture layout management method and device and electronic equipment
CN107240151A (en) * 2017-07-05 2017-10-10 常州赞云软件科技有限公司 A kind of scene layout based on parent-child constraint preserves and reproducting method
CN108280135A (en) * 2017-12-26 2018-07-13 阿里巴巴集团控股有限公司 Realize the method, apparatus and electronic equipment of data structure visualization
CN112164127A (en) * 2020-09-25 2021-01-01 大方众智创意广告(珠海)有限公司 Picture generation method and device, electronic equipment and readable storage medium
CN113190781A (en) * 2021-05-12 2021-07-30 北京奇艺世纪科技有限公司 Page layout method, device, equipment and storage medium

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116663483A (en) * 2023-07-31 2023-08-29 全芯智造技术有限公司 Method, apparatus and medium for chip layout
CN116663483B (en) * 2023-07-31 2023-10-20 全芯智造技术有限公司 Method, apparatus and medium for chip layout
CN117033844A (en) * 2023-10-07 2023-11-10 之江实验室 Canvas element layout method and device, storage medium and electronic equipment
CN117033844B (en) * 2023-10-07 2024-01-16 之江实验室 Canvas element layout method and device, storage medium and electronic equipment
CN117557682A (en) * 2024-01-09 2024-02-13 腾讯科技(深圳)有限公司 Data processing method, apparatus, product, device, and medium
CN117557682B (en) * 2024-01-09 2024-04-19 腾讯科技(深圳)有限公司 Data processing method, apparatus, product, device, and medium
CN117828701A (en) * 2024-03-05 2024-04-05 中国石油大学(华东) Engineering drawing layout optimization method, system, equipment and medium

Also Published As

Publication number Publication date
CN116206012A (en) 2023-06-02

Similar Documents

Publication Publication Date Title
WO2023097990A1 (en) Element layout method and related device
Todi et al. Sketchplore: Sketch and explore with a layout optimiser
US8972295B2 (en) Dynamic visual statistical data display and method for limited display device
US8402379B2 (en) Dynamic content layout for a user interface display
US20170032026A1 (en) Interactive visualization of big data sets and models including textual data
US20160117308A1 (en) Responsive data exploration on small screen devices
US11087503B2 (en) Interactive color palette interface for digital painting
US11733850B2 (en) Slide grid snapping and comment anywhere for presentation slides in a cloud collaboration platform
US20120154402A1 (en) Discovering and configuring representations of data via an insight taxonomy
US11734359B2 (en) Handling vague modifiers in natural language commands
US10318629B2 (en) Adaptive content rendering for optimizing page layout
US20110099465A1 (en) Butterfly diagrams enabling multi-dimensional performance analysis
US20210073324A1 (en) Reviewing Document Designs
US11449662B2 (en) Automatic generation of layout variations based on visual flow
CN109213316B (en) Automatic layout engine
US20160132215A1 (en) Alternative People Charting for Organizational Charts
Jena An Approach for Forecast Prediction in Data Analytics Field by Tableau Software.
US20170221237A1 (en) Data visualization system for exploring relational information
US10769162B2 (en) Generating business intelligence analytics data visualizations with genomically defined genetic selection
US20160078015A1 (en) Representation of data records in graphic tables
US20130326433A1 (en) Adaptive design editor for web applications
Agarwal et al. VisWall: Visual data exploration using direct combination on large touch displays
US8326812B2 (en) Data search device, data search method, and recording medium
CN109213981B (en) Demonstration collaboration for various electronic devices
US11829703B2 (en) Parallel object analysis for efficiently generating layouts in digital design documents

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22899810

Country of ref document: EP

Kind code of ref document: A1