DOT中标签的下划线(graphviz)

时间:2017-11-29 11:21:49

标签: html graphviz class-diagram dot

我想用DOT创建我的类图,因此我需要强调静态方法。

目前我的来源是:

digraph G {                                                                
    fontname = "Bitstream Vera Sans"                                       
    fontsize = 8                                                           

    node [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
        shape = "record"                                                   
    ]                                                                      

    edge [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
    ]                                                                      

    subgraph packagemodel {                                                

        Class [                                                            
            label = "{Classname|\l\                                        
                + attribute|\l\                                            
                + staticfunction}"                                         
        ]                                                                  
    }                                                                      
}

但我没有找到如何将标签的一部分加下划线。你知道可以吗?

提前致谢!

更新:

我现在改为:

digraph G {                                                                
    fontname = "Bitstream Vera Sans"                                       
    fontsize = 8                                                           

    node [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
        shape = "record"                                                   
    ]                                                                      

    edge [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
    ]                                                                      

    subgraph packagemodel {                                                

        Class [
            label =
            <<table border="0" cellspacing="0" cellborder="1">             
            <tr>                                                       
                <td>Sudoku3DFactory</td>                               
            </tr>                                                      
            <tr>                                                       
                <td>attribute</td>                                              
            </tr>                                                      
            <tr>                                                       
                <td><u>+ staticfunction</u></td>  
            </tr>                                                      
            </table>>
        ]
    }
}

但仍未加下划线。

1 个答案:

答案 0 :(得分:2)

您需要从shape = record更改为shape = plain。在某些系统上,这种形状不可用,例如,我的,这有助于:

digraph G {                                                                
    fontname = "Bitstream Vera Sans"                                       
    fontsize = 8                                                           

    node [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
        shape = none width=0 height=0 margin=0   // this _is_ plain                               
    ]                                                                      

    edge [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
    ]                                                                      

    subgraph packagemodel {                                                

        Class [
            label =
            <<table border="0" cellspacing="0" cellborder="1">             
            <tr>                                                       
                <td>Sudoku3DFactory</td>                               
            </tr>                                                      
            <tr>                                                       
                <td>attribute</td>                                              
            </tr>                                                      
            <tr>                                                       
                <td><u>+ staticfunction</u></td>  
            </tr>                                                      
            </table>>
        ]
    }
}

这会产生

enter image description here

包括下划线。