绘制家谱图 [英] Drawing a family Tree Diagram

查看:287
本文介绍了绘制家谱图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试画一棵家谱.我会尝试说出这个概念
这是主数据表

Hi, im trying to draw a family tree. i will try to tell the concept
heres the main data table

|ID  | Name | ....| Spouse ID| Mother | Father |
________________________________________________
|p01 | Jhon | ....| p02      |        |        |
________________________________________________
|p02 | Mary | ....| P01      |        |        |
________________________________________________
|p03 |rachel| ....|          |  ps02  |  ps01  |
________________________________________________
|p04 | paul | ....|  p06     |  ps02  |  ps01
________________________________________________
|p05 |jenny | ....|          |  ps02  |  ps01  |
________________________________________________
|p06 |sarah | ....| P04      |  ps02  |  ps01  |
________________________________________________



我希望我的最终结果像



and i want my end result to be like

     jhon ----- Mary
             |
             |
  ---------------------------------------
 |               |                      |
Rachel           Paul --- Sarah         Jenny
                       |



得到图像?

因此,我在此处尝试使用的逻辑是,首先绘制一个文本为"jhon"的框,然后再绘制一个名称为"Mary"的框,然后将两个框之间用一条线连接起来,然后继续执行....



get the image?

so the logic im trying to use here is that first draw a box which has the text "jhon" then another box with the name "Mary" then connect the two boxes with a line in between and continue such....

Dim x As Integer = 30
        Dim y As Integer = 30
        Dim wid As Integer = 165
        Dim hgt As Integer = 30
        Dim cus As String = Nothing
        e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias

        For i = 0 To Me.FamilyDataSet1.Persons.Rows.Count - 1
            e.Graphics.DrawRectangle(Pens.Black, x, y, wid, hgt)
            Dim big_font As New Font("Comic Sans MS", 20, FontStyle.Bold, GraphicsUnit.Pixel)
            e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit
            e.Graphics.DrawString(FamilyDataSet1.Persons.Rows(i).Item(1), big_font, Brushes.Black, x, y)
            If cus = Nothing Then
                Continue For
            ElseIf cus = FamilyDataSet1.Persons.Rows(i).Item(8) Then
                x += 60
                Continue For
            End If
            cus = FamilyDataSet1.Persons.Rows(i).Item(8)
        Next



Familydataset1是使用的数据集
人员是数据表
``item(1)和item(8)分别指姓名feild和配偶id feild

我要在这里做的是在绘制方框后检查谁是jhon的配偶,然后通过增加jhons矩形的x坐标来绘制jhons配偶"mary"的框
我被困在那里,而不是有点纠结,事实上我从一开始就被困住了,请帮助我.
提前tanqsss :)

继承人更详细的树
[



Familydataset1 is the dataset used
Persons is the data table
''item(1) and item(8) refers to Name feild and the spouse id feild respectively

what i am trying to do here is after drawing the box check who is the spouse of jhon then draw the box for jhons spouse "mary" by increasing the x cordinate of the jhons rectangle
im stuck from there, rather its all a bit tangled and infact im stuck from the begining itself, please help me.
tanqsss in advance :)

heres a more detailed tree
[^]

推荐答案

我实际上是在几年前作为我父亲的项目,但我没有来源了.基本上,您要做的是:
关键是将解决方案分解为可管理的较小部分.

1)确定如何在树上绘制单个节点并构建该对象.
2)确定如何将不同的节点彼此连接并构建该对象.
3)根据节点之间的关系来决定如何将节点放置在图像上.
4)绘制图像.
I actually did this years ago as a project for my father, but I don''t have the source anymore. Basically what you have to do is this:
The key is to break down the solution into smaller bits that are manageable.

1) Decide how to draw a single node on the tree and build that object.
2) Decide how different nodes can be attached to each other and build that object.
3) Decide how the nodes are to be placed on the image based on their relationships.
4) Draw the image.


我建​​议您对数据库的结构有所不同.我建议您使用嵌套集模型 [此处 [ ^ ])中找到它.

另外,如果您真的想在台式机上尝试此操作,并且不想与Web一起使用,我建议您看一下 ^ ],GUI和exec概念得到了很好的解释.
I would recommend you take a different look at how your database is structured. I would recommend you go with Nested Set Model[^] structure. In combination with a PostreSQL DB (which supports recursive queries) it can be a very powerful solution.

I''ve implemented this once (actually it was BS degree, but it was a web app) using JavaEE, MySQL (had no idea about Postgres at the time) and JIT (Javascript library for trees / graphs / etc, operating on JSON-based data. You can find it here[^]).

Also, if you really want to try this with desktop and don''t wanna go along with web, I''d recommend you take a look at the family tree WPF showcase app[^], the GUI and exec concepts are explained pretty well.


这篇关于绘制家谱图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆