Coordinate-based dish recording type genealogy generation method
Automating the processing of genealogy data through coordinate-based methods, the problem of insufficient automation and personalization needs of genealogy generation in the existing technology is solved, and efficient and accurate genealogy display and data integration are achieved.
Patent Information
- Application Number
- CN202411398802.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2024-12-31
AI Technical Summary
The existing electronic genealogy technology is low in automation when processing disc tree-type genealogy, and users can manually enter information and find it difficult to meet personalized needs, lack flexibility, and it is difficult to effectively integrate and display complex information.
The coordinate-based method is adopted to obtain family tree data through the graph database, establish a page coordinate system, and automatically calculate and locate the coordinates of each area, dividing lines and segmenting areas to realize automated processing and personalized display.
It improves the efficiency and accuracy of genealogy generation, provides user-defined flexibility, can better integrate and display complex information, meet the specific needs of different families, and enhances the personalization of genealogy and the accuracy of data.
Smart Images

Figure CN119226573A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of document image processing and visualization, and specifically is a coordinate-based disc-type family tree generation method. Background Art
[0002] As an important document that records family members and their blood relationships, family trees have always been important materials for studying family history, social history and culture. With the development of information technology, the electronicization and digitization of family trees has gradually become a trend, so as to facilitate better preservation, query and research. At present, the electronicization technology of family trees mainly includes various forms such as family tree diagrams, family tree fan diagrams, family tree matrix methods, family tree line diagrams, family tree background tree diagrams and family tree force guide diagrams. These technologies meet the visualization needs of family trees to a certain extent. However, the existing electronicization technology of family trees has some shortcomings when processing disc-type family trees. First, most of the existing tools require users to manually input information and adjust the layout. This process is not only cumbersome but also prone to errors. Secondly, the degree of automation is low, and there is a lack of family tree generation tools that can quickly respond to user needs. In addition, the existing technology often adopts a fixed format, which is difficult to adapt to the specific needs of different families and has poor flexibility. The disc-type family tree contains rich information about people, such as birth date, official position, etc., but the existing technology has difficulties in integrating and displaying this complex information. At the same time, it is difficult to meet the personalized needs of users for font size, page layout, etc., and it is relatively difficult to update and maintain the family tree. Therefore, although the electronic technology of family tree has made certain progress, there is still much room for improvement in automation, personalization and information processing. Summary of the invention
[0003] The present invention aims to address the deficiencies of the above-mentioned prior art and proposes a coordinate-based disc-style genealogy generation method, in order to automatically process complex genealogy data, improve the efficiency and accuracy of disc-style genealogy production, and provide user-defined flexibility to meet the specific needs of different families for the disc-style genealogy display format.
[0004] In order to achieve the above-mentioned purpose, the present invention adopts the following technical scheme:
[0005] The coordinate-based disc-type genealogy generation method of the present invention is characterized in that the genealogy obtained from the graph database is generated on a plurality of pages, a border is set on the page, and left and right vertical lines for dividing the genealogy name and the character information are respectively set in the middle position of the border, which are denoted as and , and and The area between is recorded as the middle area. and The outer areas are respectively recorded as the left area and the right area; at the upper position within the frame and at and The left and right upper horizontal lines for separating the character relationship and the character name are respectively set in the outer left and right areas, which are denoted as and , and the upper borders are and The area between is recorded as the character relationship area; and The left and right lower horizontal lines are set below to separate the character name and character profile, denoted as and ,Will and Respectively and The area between is recorded as the character name area; and The area between the lower border and the lower border is recorded as a character profile area, and a plurality of profile dividing lines are set in the character profile area, so as to divide the character profile area into a plurality of columns. The disc-recorded family tree generation method comprises the following steps:
[0006] Step 1: Generate page parameters, including: setting the number of columns on the page to cols, the upper limit of the number of words in the character relationship area to , the font size in the character relationship area is , The upper limit of the number of characters in the character name area is , The font size of the name in the character name area is , The maximum number of characters in each column of the character profile area is 、Introduction font size is , the width of each column in the character profile area , border height and width :
[0007] Step 2: Take any vertex of the page as the origin, and the two edges connected to the origin as the x-axis and y-axis respectively, so as to establish a page coordinate system, and let the coordinate of the lower left corner vertex of the frame in the page coordinate system be ( , ), the coordinates of the upper right corner of the border are marked as ( , ); Calculate the border coordinates on the page, including: left vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate , left vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate , right vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate , right vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate , upper left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate , upper right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate , lower left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right endpoint ordinate , lower right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right endpoint ordinate 、Right dividing line of the i-th character profile The horizontal coordinate of the upper endpoint is , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is , the left dividing line of the i-th character profile Upper endpoint horizontal coordinate , the ordinate of the upper endpoint ; Lower endpoint horizontal coordinate , the lower endpoint ordinate ;
[0008] Step 3: Calculate the coordinates of the character information:
[0009] Step 3.1. Read all character nodes from the graph database layer by layer to get the total number of character nodes n; record the jth character node as p j ={r j ,na j ,b j}, where r j Indicates p j relationship, na j Indicates p j Name, b j Indicates p jIntroduction; Let len(r j ) represents r j Number of Chinese characters, len(na j ) means na j Number of characters in the word, len(b j ) means b j Chinese characters;
[0010] Step 3.2: Number each column in the character profile area from right to left, and let the coordinate of the upper right corner of the i-th column on page t be ( , ),initialization( , )=( , );
[0011] Step 3.3, initialize j=1;
[0012] Step 3.4, initialize t=1;
[0013] Step 3.5, initialize i=1;
[0014] Step 3.6: Initialize k r =1,k na =1, =1;
[0015] Step 3.7: When k r = 1, using formula (16) to get r j The horizontal coordinate of the first word in the tth page, column i and the vertical coordinate ;
[0016] (16)
[0017] When k=2,3,…,len(r j ), using formula (17) we get and :
[0018] (17)
[0019] Step 3.8: When k na = 1, using formula (18) to get na j The horizontal coordinate of the first word in the tth page, column i and the vertical coordinate ;
[0020] (18)
[0021] When k=2,3,…,len(naj ), using formula (19) we can get na j k na The horizontal coordinate of the word in the i-th column of page t and the vertical coordinate ;
[0022] (19)
[0023] Step 3.9: Use formula (20) to get b j Middle The horizontal coordinate of the word in the i-th column of page t and the vertical coordinate ;
[0024] (20)
[0025] Step 3.10, judgment =0, if true, it means that the maximum number of characters in the character profile area column has been reached, and the column change operation in step 3.11 is executed; otherwise, step 3.14 is executed; where, Indicates remainder;
[0026] Step 3.11, assign i+1 to i, and judge i≤cols. If it is true, execute step 3.13; otherwise, it means that the maximum number of columns of the page is reached, and execute the page change operation of step 3.12;
[0027] Step 3.12: Assign t+1 to t, set i=1, and use formula (21) to obtain the horizontal coordinate of the first column of page t: and the vertical coordinate Then, execute step 3.14;
[0028] (twenty one)
[0029] Step 3.13: Use formula (22) to get the horizontal coordinate of the i-th column on page t and the vertical coordinate back Execute step 3.14;
[0030] (twenty two)
[0031] Step 3.14: +1 assigned to After that, judge ≤len(b j ), if it is established, execute step 3.9; otherwise, it means that b is completed j Generate in the character profile area and execute step 3.15;
[0032] Step 3.15: After assigning j+1 to j, determine whether j≤n. If so, execute step 3.6; otherwise, it means that all the characters in the family tree have been generated and the process ends.
[0033] The coordinate-based disc-type family tree generation method described in the present invention is also characterized in that in step 1, the width of each column in the character profile area is obtained by using formula (1): ;
[0034] (1)
[0035] In formula (1), Indicates the font size in the character relationship area The coefficient of Indicates the column width in the character profile area The amount of adjustment;
[0036] The height of the frame is obtained using formula (2): ;
[0037] (2)
[0038] Using formula (3) to get the width of the border ;
[0039] (3)
[0040] In formula (3), The coefficient representing the number of columns cols on the page. Indicates the amount to adjust the page margins.
[0041] Furthermore, the step 2 comprises:
[0042] Step 2.1: Use formula (4) to get the left vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate ;
[0043] (4)
[0044] In formula (4), Set the column width in the profile area The coefficient of
[0045] Step 2.2: Use formula (5) to get the left vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate ;
[0046] (5)
[0047] Step 2.3: Use formula (6) to get the right vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate ;
[0048] (6)
[0049] Step 2.4: Use formula (7) to get the right vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate :
[0050] (7)
[0051] Step 2.5: Use formula (8) to get the upper left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate :
[0052]
[0053] In formula (8), Indicates the adjustment amount of the upper limit of the word count;
[0054] Step 2.6: Use formula (9) to get the upper right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate :
[0055]
[0056] Step 2.7: Use formula (10) to get the lower left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate :
[0057]
[0058] Step 2.8: Use formula (11) to get the lower right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right endpoint ordinate :
[0059]
[0060] Step 2.9: and Divide the character profile area into the character profile left area and the character profile right area, and calculate the total number of dividing lines in the character profile area on either side , so that the dividing line in the left area of the character profile is recorded as { , ,…, ,… }, and the dividing line in the right area of the character profile is recorded as { , ,…, ,… },in, represents the i-th left dividing line, represents the i-th right dividing line;
[0061] Step 2.10: When i=1, use formula (12) to get the first character profile right dividing line The horizontal coordinate of the upper endpoint is , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is ;
[0062] (12)
[0063] When i=2,3,…,m, use formula (13) to get the right dividing line of the i-th character profile The horizontal coordinate of the upper endpoint is , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is ;
[0064] (13)
[0065] Step 2.11, when i=1, use formula (14) to get the first character profile left dividing line The horizontal coordinate of the upper endpoint , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is ;
[0066] (14)
[0067] When i=2,3,…,m, use formula (15) to get the left dividing line of the i-th character profile Upper endpoint horizontal coordinate , the ordinate of the upper endpoint ; Lower endpoint horizontal coordinate , the lower endpoint ordinate ;
[0068] (15).
[0069] The electronic device of the present invention includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the disc-type family tree generation method, and the processor is configured to execute the program stored in the memory.
[0070] The present invention provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program, which is characterized in that when the computer program is executed by a processor, the steps of the disc-type family tree generation method are executed.
[0071] Compared with the prior art, the present invention has the following beneficial effects:
[0072] 1. The present invention adopts an automated coordinate calculation method to automatically process family tree data through a computer program, thereby overcoming the tedious and time-consuming problem of manually drawing family trees in the prior art. This method not only reduces human errors, but also greatly improves the efficiency of family tree generation, allowing users to obtain high-quality family tree diagrams in a short time;
[0073] 2. The present invention allows users to customize parameters such as font size, page layout, column width, etc. according to their needs and preferences, solving the problem of fixed format and lack of personalized options in the prior art. This flexibility makes the display of the family tree more in line with the user's aesthetic and practical needs, and enhances the personalized display of the family tree;
[0074] 3. The present invention can effectively integrate complex family information, such as birthdays, official positions, achievements, etc., solving the problem that existing technologies are difficult to process and display such information. This integration capability makes the family tree content richer and more complete, providing users with a more detailed family history record;
[0075] 4. Through precise coordinate positioning and automated data processing, the present invention ensures accurate display of relationships and information in the family tree, and improves the accuracy and reliability of the family tree data. This accuracy is crucial for the research and recording of family history, ensuring the value of the family tree as historical data. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1It is a flow chart of a coordinate-based disc-type family tree generation method of the present invention;
[0077] Figure 2 This is a schematic diagram of the output results of a coordinate-based disc-type family tree generation method of the present invention. DETAILED DESCRIPTION
[0078] In this embodiment, a coordinate-based disc-type family tree generation method is provided, such as Figure 1 As shown in FIG. 1 , the family tree obtained from the graph database is generated on several pages, a border is set on the page, and left and right vertical lines for dividing the family tree name and character information are set in the middle of the border, respectively, which are denoted as and , and and The area between is recorded as the middle area. and The outer areas are recorded as the left area and the right area respectively; at the upper position within the border and at and The left and right upper horizontal lines for separating the character relationship and the character name are respectively set in the outer left and right areas, which are denoted as and , and the upper borders are and The area between is recorded as the character relationship area; and The left and right lower horizontal lines are set below to separate the character name and character profile, denoted as and ,Will and Respectively and The area between is recorded as the character name area; and The area between the upper and lower borders is recorded as a character profile area. A plurality of profile dividing lines are set in the character profile area, so as to divide the character profile area into a plurality of columns. The disc-recorded family tree generation method comprises the following steps:
[0079] Step 1. Generate page parameters:
[0080] Step 1.1, set the number of columns on the page to cols, and the upper limit of the number of words in the character relationship area to , the font size in the character relationship area is , The upper limit of the number of characters in the character name area is , The font size of the name in the character name area is , The maximum number of characters in each column of the character profile area is 、Introduction font size is ;
[0081] Step 1.2: Use formula (1) to get the width of each column in the character profile area , that is, the width of the column is the maximum font size of the character relationship area, character name area, and character profile area plus the adjustment amount;
[0082] (1)
[0083] In formula (1), Indicates the font size in the character relationship area The coefficient of Indicates the column width in the character profile area The amount of adjustment;
[0084] Step 1.3: Use formula (2) to get the height of the border , that is, the border height is the maximum value of the font sizes of the character relationship area, the character name area, and the character profile area multiplied by the upper limit of the number of characters in the character relationship area, the upper limit of the number of characters in the name area, and the sum of the upper limit of the number of characters in each column of the character profile area;
[0085] (2)
[0086] Step 1.4: Use formula (3) to get the width of the border , that is, the border width is the number of columns multiplied by the coefficient multiplied by the column width plus the adjustment amount;
[0087] (3)
[0088] In formula (3), The coefficient representing the number of columns cols on the page. Indicates the amount of adjustment of the page margins;
[0089] Step 2: Calculate the border coordinates on the page:
[0090] Step 2.1, take any vertex of the page as the origin, and the two edges connected to the origin as the x-axis and y-axis respectively, so as to establish the page coordinate system, and let the coordinate of the lower left corner vertex of the border in the page coordinate system be ( , ), the coordinates of the upper right corner of the border are marked as ( , );
[0091] Step 2.2: Use formula (4) to get the left vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate , that is, the horizontal coordinate of the upper endpoint is the border width divided by 2 minus the column width multiplied by the coefficient, and the vertical coordinate is the vertical coordinate of the upper right corner vertex;
[0092] (4)
[0093] In formula (4), Set the column width in the profile area The coefficient of
[0094] Step 2.3: Use formula (5) to get the left vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate , that is, the horizontal coordinate of the lower endpoint is the border width divided by 2 minus the column width multiplied by the coefficient, and the vertical coordinate is the vertical coordinate of the lower left corner;
[0095] (5)
[0096] Step 2.4: Use formula (6) to get the right vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate , that is, the horizontal coordinate of the upper endpoint is the page width divided by 2 plus the column width multiplier, and the vertical coordinate is the vertical coordinate of the upper right corner;
[0097] (6)
[0098] Step 2.5: Use formula (7) to get the right vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate , that is, the horizontal coordinate of the lower endpoint is the page width divided by 2 plus the column width multiplier, and the vertical coordinate is the vertical coordinate of the lower left corner:
[0099] (7)
[0100] This ensures that the area between the two vertical lines is in the middle of the border. Because it is necessary to separate the character relationship area from the character name area and the character name area from the character profile area, but the middle part is divided by two vertical lines, so four horizontal lines are needed.
[0101] Step 2.6: Use formula (8) to get the upper left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate , that is, the horizontal coordinate of the left endpoint is the horizontal coordinate of the lower left corner, the horizontal coordinate of the right endpoint is the page width divided by 2 minus the column width multiplied by the coefficient, and the vertical coordinate is the vertical coordinate of the upper right vertex minus the relative font size multiplied by the number of relative words plus the adjustment amount;
[0102]
[0103] In formula (8), Indicates the adjustment amount of the upper limit of the word count;
[0104] Step 2.7: Use formula (9) to get the upper right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate :
[0105]
[0106] Step 2.8: Use formula (10) to get the lower left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate That is, the horizontal coordinate of the left endpoint is the horizontal coordinate of the lower left corner, the horizontal coordinate of the right endpoint is the page width divided by 2 minus the column width multiplied by the coefficient, and the vertical coordinate is the vertical coordinate of the upper right vertex minus the relationship font size multiplied by the number of relationship characters plus the adjustment amount, and then minus the name font size multiplied by the number of name characters plus the adjustment amount:
[0107]
[0108] Step 2.9: Use formula (11) to get the lower right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right endpoint ordinate :
[0109]
[0110] Step 2.10: and Divide the character profile area into the character profile left area and the character profile right area, and calculate the total number of dividing lines in the character profile area on either side , so that the dividing line in the left area of the character profile is recorded as { , ,…, ,… }, and the dividing line in the right area of the character profile is recorded as { , ,…, ,… },in, represents the i-th left dividing line, represents the i-th right dividing line;
[0111] Step 2.11, when i=1, use formula (12) to get the first character profile right dividing line The horizontal coordinate of the upper endpoint is , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is That is, the upper endpoint's horizontal coordinate is the page width divided by 2 plus the column width multiplied by the coefficient, the vertical coordinate is the vertical coordinate of the upper right corner vertex minus the relationship font size multiplied by the number of relationship characters plus the adjustment amount, and then minus the name font size multiplied by the number of name characters plus the adjustment amount, the lower endpoint's horizontal coordinate is the page width divided by 2 plus the column width multiplied by the coefficient, and the vertical coordinate is the vertical coordinate of the lower left corner vertex;
[0112] (12)
[0113] When i=2,3,…,m, use formula (13) to get the right dividing line of the i-th character profile The horizontal coordinate of the upper endpoint is , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is , that is, the horizontal coordinates of the upper and lower endpoints are added with the column width, and the vertical coordinate remains unchanged;
[0114] (13)
[0115] Step 2.12: When i=1, use formula (14) to get the first character profile left dividing line The horizontal coordinate of the upper endpoint , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is , that is, the horizontal coordinate of the upper endpoint is the page width divided by 2 minus the column width multiplied by the coefficient, the vertical coordinate is the vertical coordinate of the upper right corner vertex minus the relationship font size multiplied by the number of relationship characters plus the coefficient, and then minus the name font size multiplied by the number of names plus the coefficient, the horizontal coordinate of the lower vertex is the page width divided by 2 minus the column width multiplied by the coefficient, and the vertical coordinate is the vertical coordinate of the lower left corner vertex;
[0116] (14)
[0117] When i=2,3,…,m, use formula (15) to get the left dividing line of the i-th character profile Upper endpoint horizontal coordinate , the ordinate of the upper endpoint ; Lower endpoint horizontal coordinate , the lower endpoint ordinate , that is, the horizontal coordinates of the upper and lower endpoints are subtracted from the column width, and the vertical coordinate remains unchanged;
[0118] (15)
[0119] Step 3: Calculate the coordinates of the character information:
[0120] Step 3.1. Read all character nodes from the graph database by layer to obtain the total number of character nodes n;
[0121] The jth character node is recorded as p j ={r j ,na j ,b j}, where r j Indicates p j relationship, na j Indicates p j Name, b j Indicates p j Introduction; Let len(r j ) represents r j Number of Chinese characters, len(na j ) means na j Number of characters in the word, len(b j ) means b j Chinese characters;
[0122] Step 3.2: Number each column in the character profile area from right to left, and let the coordinate of the upper right corner of the i-th column on page t be ( , ),initialization( , )=( , );
[0123] Step 3.3, initialize j=1;
[0124] Step 3.4, initialize t=1;
[0125] Step 3.5, initialize i=1;
[0126] Step 3.6: Initialize k r =1,k na =1, =1;
[0127] Step 3.7: When k r = 1, using formula (16) to get r j The horizontal coordinate of the first word in the tth page, column i and the vertical coordinate , that is, the horizontal coordinate is the horizontal coordinate of the upper right corner of the column minus the column width divided by 2 plus the relationship font size divided by 2, and the vertical coordinate is the vertical coordinate of the upper right corner of the column. This ensures that each character in the character relationship is centered in the column;
[0128] (16)
[0129] When k=2,3,…,len(r j ) Using formula (17), we can get and , that is, the vertical coordinate moves downward by the font size of a character relationship area;
[0130] (17)
[0131] Step 3.8: When k na = 1, using formula (18) to get na j The horizontal coordinate of the first word in the tth page, column i and the vertical coordinate , that is, the horizontal coordinate is the horizontal coordinate of the upper right corner of the column minus the column width divided by 2 plus the name font size divided by 2, and the vertical coordinate is the vertical coordinate of the upper right corner of the column minus the number of related words plus the adjustment amount multiplied by the font size of the related area. This ensures that the character name is generated in the character name area and each character is centered in the column;
[0132] (18)
[0133] When k=2,3,…,len(na j ), using formula (19) we can get na j k na The horizontal coordinate of the word in the i-th column of page t and the vertical coordinate , that is, the vertical coordinate moves downward by the font size of the character name area;
[0134] (19)
[0135] Step 3.9: Use formula (20) to get b j Middle The horizontal coordinate of the word in the i-th column of page t and the vertical coordinate That is, if it is the first character in the column, the horizontal coordinate is the horizontal coordinate of the upper right corner of the column minus the column width divided by 2 plus the font size of the introduction divided by 2, and the vertical coordinate is the vertical coordinate of the upper right corner of the column minus the number of related characters plus the adjustment amount multiplied by the font size of the relationship area plus the number of name characters plus the adjustment amount multiplied by the font size of the name area. This ensures that the character introduction is generated in the character introduction area and each character is centered in the column; otherwise, the vertical coordinate moves downward by the distance of the font size of the character introduction area;
[0136] (20)
[0137] Step 3.10, judgment ==0, if true, it means that the maximum number of characters in the character profile area column has been reached and a column change is required, then execute step 3.11; otherwise, execute step 3.14;
[0138] Step 3.11, assign i+1 to i, and judge i≤cols. If it is true, execute step 3.13; otherwise, it means that the maximum number of columns of the page is reached and the page needs to be changed, so execute step 3.12;
[0139] Step 3.12: Assign t+1 to t, set i=1, and use formula (21) to obtain the horizontal coordinate of the first column of page t: , and the ordinate , then proceed to step 3.14;
[0140] (twenty one)
[0141] Step 3.13: Use formula (22) to get the horizontal coordinate of the i-th column on page t , and the ordinate Then proceed to step 3.14;
[0142] (twenty two)
[0143] Step 3.14: +1 assigned to After that, judge ≤len(b j ), if it is established, execute step 3.9; otherwise, it means that b is completed j For the generation in the character profile area, execute step 3.15;
[0144] Step 3.15, after assigning j+1 to j, judge j≤n. If it is true, execute step 3.6; otherwise, it means that all characters have been generated and the process ends; finally, according to the calculated coordinates, use tools such as reportlab library to save them to PDF page by page. The result is as follows Figure 2 shown.
[0145] In this embodiment, an electronic device includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the above method, and the processor is configured to execute the program stored in the memory.
[0146] In this embodiment, a computer-readable storage medium stores a computer program on the computer-readable storage medium, and the computer program executes the steps of the above method when executed by a processor.
Claims
1. A coordinate-based disc-type family tree generation method, characterized in that: The family tree obtained from the graph database is generated on several pages, a border is set on the page, and left and right vertical lines for dividing the family tree name and character information are set in the middle of the border, respectively, denoted as and , and and The area between is recorded as the middle area. and The outer areas are respectively recorded as the left area and the right area; at the upper position within the frame and at and The left and right upper horizontal lines for separating the character relationship and the character name are respectively set in the outer left and right areas, which are denoted as and , and the upper borders are and The area between is recorded as the character relationship area; and The left and right lower horizontal lines are set below to separate the character name and character profile, denoted as and ,Will and Respectively and The area between is recorded as the character name area; and The area between the lower border and the lower border is recorded as a character profile area, and a plurality of profile dividing lines are set in the character profile area, so as to divide the character profile area into a plurality of columns. The disc-recorded family tree generation method comprises the following steps: Step 1: Generate page parameters, including: setting the number of columns on the page to cols, the upper limit of the number of words in the character relationship area to , the font size in the character relationship area is , The upper limit of the number of characters in the character name area is , The font size of the name in the character name area is , The maximum number of characters in each column of the character profile area is 、Introduction font size is , the width of each column in the character profile area , border height and width : Step 2: Take any vertex of the page as the origin, and the two edges connected to the origin as the x-axis and y-axis respectively, so as to establish a page coordinate system, and let the coordinate of the lower left corner vertex of the frame in the page coordinate system be ( , ), the coordinates of the upper right corner of the border are marked as ( , ); Calculate the border coordinates on the page, including: left vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate , left vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate , right vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate , right vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate , upper left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate , upper right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate , lower left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right endpoint ordinate , lower right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right endpoint ordinate , the right dividing line of the i-th character profile The horizontal coordinate of the upper endpoint is , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is , the left dividing line of the i-th character profile Upper endpoint horizontal coordinate , the ordinate of the upper endpoint ; Lower endpoint horizontal coordinate , the lower endpoint ordinate ; Step 3: Calculate the coordinates of the character information: Step 3.
1. Read all character nodes from the graph database layer by layer to get the total number of character nodes n; record the jth character node as p j ={r j ,na j ,b j }, where r j Indicates p j relationship, na j Indicates p j Name, b j Indicates p j Introduction; Let len(r j ) represents r j Number of Chinese characters, len(na j ) means na j Number of characters in the word, len(b j ) means b j Chinese characters; Step 3.2: Number each column in the character profile area from right to left, and let the coordinate of the upper right corner of the i-th column on page t be ( , ),initialization( , )=( , ); Step 3.3, initialize j=1; Step 3.4, initialize t=1; Step 3.5, initialize i=1; Step 3.6: Initialize k r =1,k na =1, =1; Step 3.7: When k r = 1, using formula (16) to get r j The horizontal coordinate of the first word in the tth page, column i and the vertical coordinate ; (16) When k=2,3,…,len(r j ), using formula (17) we get and : (17) Step 3.8: When k na = 1, using formula (18) to get na j The horizontal coordinate of the first word in the tth page, column i and the vertical coordinate ; (18) When k=2,3,…,len(na j ), using formula (19) we can get na j k na The horizontal coordinate of the word in the i-th column of page t and the vertical coordinate ; (19) Step 3.9: Use formula (20) to get b j Middle The horizontal coordinate of the word in the i-th column of page t and the vertical coordinate ; (20) Step 3.10, judgment =0, if true, it means that the maximum number of characters in the character profile area column has been reached, and the column change operation in step 3.11 is executed; otherwise, step 3.14 is executed; where, Indicates remainder; Step 3.11, assign i+1 to i, and judge i≤cols. If it is true, execute step 3.13; otherwise, it means that the maximum number of columns of the page is reached, and execute the page change operation of step 3.12; Step 3.12: Assign t+1 to t, set i=1, and use formula (21) to obtain the horizontal coordinate of the first column of page t: and the vertical coordinate Then, execute step 3.14; (21) Step 3.13: Use formula (22) to get the horizontal coordinate of the i-th column on page t and the vertical coordinate back Execute step 3.14; (22) Step 3.14: +1 assigned to After that, judge ≤len(b j ), if it is established, execute step 3.9; otherwise, it means that b is completed j Generate in the character profile area and execute step 3.15; Step 3.15: After assigning j+1 to j, determine whether j≤n. If so, execute step 3.6; otherwise, it means that all the characters in the family tree have been generated and the process ends.
2. A coordinate-based disc-type family tree generation method according to claim 1, characterized in that: In step 1, formula (1) is used to obtain the width of each column in the character profile area. ; (1) In formula (1), Indicates the font size in the character relationship area The coefficient of Indicates the column width in the character profile area The amount of adjustment; The height of the frame is obtained using formula (2): ; (2) Using formula (3) to get the width of the border ; (3) In formula (3), The coefficient representing the number of columns cols on the page. Indicates the amount to adjust the page margins.
3. A coordinate-based disc-type family tree generation method according to claim 2, characterized in that: The step 2 comprises: Step 2.1: Use formula (4) to get the left vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate ; (4) In formula (4), Set the column width in the profile area The coefficient of Step 2.2: Use formula (5) to get the left vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate ; (5) Step 2.3: Use formula (6) to get the right vertical line The horizontal coordinate of the upper endpoint , the upper endpoint ordinate ; (6) Step 2.4: Use formula (7) to get the right vertical line The horizontal coordinate of the lower endpoint , the lower endpoint ordinate : (7) Step 2.5: Use formula (8) to get the upper left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate : (8) In formula (8), Indicates the adjustment amount of the upper limit of the word count; Step 2.6: Use formula (9) to get the upper right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate : (9) Step 2.7: Use formula (10) to get the lower left horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right vertex ordinate : (10) Step 2.8: Use formula (11) to get the lower right horizontal line The horizontal coordinate of the left endpoint , right endpoint horizontal coordinate , left endpoint ordinate , right endpoint ordinate : (11) Step 2.9: and Divide the profile area into the left profile area and the right profile area, and calculate the total number of dividing lines in the profile area on either side , so that the dividing line in the left area of the character profile is recorded as { , ,…, ,… }, and the dividing line in the right area of the character profile is recorded as { , ,…, ,… },in, represents the i-th left dividing line, represents the i-th right dividing line; Step 2.10: When i=1, use formula (12) to get the first character profile right dividing line The horizontal coordinate of the upper endpoint is , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is ; (12) When i=2,3,…,m, use formula (13) to get the right dividing line of the i-th character profile The horizontal coordinate of the upper endpoint is , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is ; (13) Step 2.11, when i=1, use formula (14) to get the first character profile left dividing line The horizontal coordinate of the upper endpoint , the ordinate of the upper endpoint is , the horizontal coordinate of the lower endpoint is , the ordinate of the lower endpoint is ; (14) When i=2,3,…,m, use formula (15) to get the left dividing line of the i-th character profile Upper endpoint horizontal coordinate , the ordinate of the upper endpoint ; Lower endpoint horizontal coordinate , the lower endpoint ordinate ; (15)。 4. An electronic device, comprising a memory and a processor, characterized in that: The memory is used to store a program that supports the processor to execute the disc-type family tree generation method described in any one of claims 1-3, and the processor is configured to execute the program stored in the memory.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the disc-type family tree generation method described in any one of claims 1-3 are executed.