0

我正在尝试设置 NatTable 树的样式,以便非装饰物品的缩进与装饰物品的缩进相匹配。所以没有子项和有子项的项目基本上具有相同的缩进。

我使用以下配置的示例:

public class PerfLogTreeConfiguration extends AbstractRegistryConfiguration {

private static final int fTreeIndent = 10;
private static final int fIconSpacing = 2;

private TreeImagePainter fTreeImagePainter = new TreeImagePainter(false,
        GUIHelper.getImage("right"), //$NON-NLS-1$
        GUIHelper.getImage("right_down"), null); //$NON-NLS-1$

private IndentedTreeImagePainter indentedTreeImagePainter = new IndentedTreeImagePainter(
        fTreeIndent,
        null,
        CellEdgeEnum.LEFT,
        fTreeImagePainter, 
        false,
        fIconSpacing,
        true);
private PaddingDecorator paddingDecorator = new PaddingDecorator(
        indentedTreeImagePainter,
        0,
        5,
        0,
        5, 
        true);
private ICellPainter fTreeStructurePainter = new BackgroundPainter(paddingDecorator);

@Override
public void configureRegistry(IConfigRegistry configRegistry) {
    configRegistry.registerConfigAttribute(TreeConfigAttributes.TREE_STRUCTURE_PAINTER, fTreeStructurePainter,
            DisplayMode.NORMAL);

}

A 是预期的布局,B 是我目前得到的。

4

1 回答 1

1

为此,您需要将叶子图像传递给TreeImagePainter

TreeImagePainter fTreeImagePainter = new TreeImagePainter(false,
        GUIHelper.getImage("right"), //$NON-NLS-1$
        GUIHelper.getImage("right_down"), //$NON-NLS-1$
        GUIHelper.getImage("leaf")); //$NON-NLS-1$

提供的叶子图像实际上是一个用作间隔的空图像。使用它,扩展节点的子节点也将获得额外的间距。但这对于区分扩展节点的子节点和没有子节点的节点是必要的。

于 2019-06-03T05:17:46.563 回答