【问题标题】:CustomLineBorderDecorator Continous Line between columnsCustomLine Border Decorator 列之间的连续线
【发布时间】:2018-11-12 18:29:52
【问题描述】:

我目前的任务是使用 nattable 在特定列之间绘制连续线。我已经使用 CustomLineBorderDecorator 在每个单元格上绘制了线条。问题是每行之间有一条细的灰线 这条灰线在每个单元生成的边界帽的奇异部分之间可见。 我需要从标题到表格底部的连续线。我如何到那里?

【问题讨论】:

    标签: nattable


    【解决方案1】:

    如果你想在网格线上绘制,你需要实现一个IOverlayPainterICellPainterCustomLineBorderDecorator 一样,只会在单元格内绘制。

    一个简单的版本可能如下所示:

    natTable.addOverlayPainter(new IOverlayPainter() {
    
        @Override
        public void paintOverlay(GC gc, ILayer layer) {
            Color beforeColor = gc.getForeground();
            gc.setForeground(GUIHelper.COLOR_RED);
            int gridBorderX = natTable.getStartXOfColumnPosition(4) - 1;
            gc.drawLine(gridBorderX, 0, gridBorderX, layer.getHeight() - 1);
            gc.setForeground(beforeColor);
        }
    });
    

    但该版本例如不考虑滚动。

    SNAPSHOT 构建包含HideIndicatorOverlayPainter,它会根据标题区域内的标签进行更多检查以呈现此类行。但是您可以调整它以找到基于标签呈现的位置。

    【讨论】:

      猜你喜欢
      • 2021-08-04
      • 1970-01-01
      • 1970-01-01
      • 2012-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      • 1970-01-01
      相关资源
      最近更新 更多