gpt4 book ai didi

java - 如何为 Nebula NatTable 中的非装饰项配置缩进

转载 作者:行者123 更新时间:2023-12-02 09:50:01 24 4
gpt4 key购买 nike

我正在尝试设置 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 is the intended layour and B is what I am currently getting.

最佳答案

要实现此目的,您需要将叶子图像传递给 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$

提供的叶子图像实际上是用作间隔符的空图像。使用此功能,扩展节点的子节点也将获得额外的间距。但这是为了区分扩展节点的子节点和没有子节点的节点所必需的。

关于java - 如何为 Nebula NatTable 中的非装饰项配置缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56385012/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com