顶点中的文本未居中

Text in vertex isn't centered

当在值中创建带有文本的顶点时,它会将几个像素放在中间上方。不同的字体大小在不同的高度。文本也小于我输入的字体大小。我怎样才能让文本在单元格中居中?

这是我使用的样式表。

int TFontSize = 15;
mxStylesheet stylesheet = graph.getStylesheet();
Hashtable<String, Object> style = new Hashtable<String, Object>();
style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE);
style.put(mxConstants.STYLE_FILLCOLOR, "white");
style.put(mxConstants.STYLE_STROKECOLOR, "black");
style.put(mxConstants.STYLE_FONTCOLOR, "black");
style.put(mxConstants.STYLE_FONTFAMILY, "Arial");
style.put(mxConstants.STYLE_FONTSIZE, TFontSize);

stylesheet.putCellStyle("teamS", style);

这是创建单元格的代码

for (int j = 0; j < matches.get(i).teams.size(); j++) {
    //gets string of team
    String teamName = matches.get(i).teams.get(j).name;

    //team names get put into multiple lines
    String teamWrapped = WordWrap.from(teamName).maxWidth(cellSize / 5).insertHyphens(true).wrap();

    //location of vertex
    int cellX = (hCellSpace / 2) + (j / rows * (cellSize + hCellSpace));
    int cellY = (titleSize) + ((j % rows) * (cellSize + vCellSpace));

    //style for vertex
    String cellStyle = "teamS;";

    //creates vertex
    Object cell = graph.insertVertex(base, null, teamWrapped, cellX, cellY, cellSize, cellSize, cellStyle);
}

image of vertexes (circle shaped cells)

style.put(mxConstants.STYLE_VERTICAL_ALIGN, "ALIGN_TOP");

然后添加 ";spacingTop=" + (cellSize + 3) 风格