From e2e41ccc472040b959b247d733731dba0e759fd4 Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 10 Sep 2021 18:29:38 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-58252=20=E6=8A=A5=E8=A1=A8=E5=9D=97?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E8=A1=8C=E5=88=97=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=90=8E=E7=9A=84=E5=BC=A5=E8=A1=A5=E6=96=B9?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 表单报表块缩略图中去掉表格行列标志后,需要提供给用户一个仅 通过缩略图确定表格内容区域位置的方案。讨论后的方案为表格缩略 图中不出现内容区域外的网格线,用户从而可以直接通过缩略图网格线 的尺寸和位置来确定内容区域的大小和位置. 【改动思路】 同上 --- .../form/FormElementCaseDesigner.java | 3 ++ .../src/main/java/com/fr/grid/Grid.java | 10 ++++ .../src/main/java/com/fr/grid/GridUI.java | 50 ++++++++++++++----- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index 2dd3dbbb7f..5be6362a4d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -152,10 +152,13 @@ public class FormElementCaseDesigner Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; if (grid != null) { boolean oldTranslucent = grid.isTranslucent(); + boolean oldShowExtraGridLine = grid.isShowExtraGridLine(); // 截缩图图时grid需支持半透明,不能用默认白色填充画布,否则会遮挡组件样式背景 grid.setTranslucent(true); + grid.setShowExtraGridLine(false); grid.paint(g2d); grid.setTranslucent(oldTranslucent); + grid.setShowExtraGridLine(oldShowExtraGridLine); } } catch (Exception e) { diff --git a/designer-realize/src/main/java/com/fr/grid/Grid.java b/designer-realize/src/main/java/com/fr/grid/Grid.java index b55f60bb53..80147f3e57 100644 --- a/designer-realize/src/main/java/com/fr/grid/Grid.java +++ b/designer-realize/src/main/java/com/fr/grid/Grid.java @@ -136,6 +136,8 @@ public class Grid extends BaseGridComponent { // 截取缩略图时需透明(不能用默认白色填充),否则会遮挡组件样式的背景,其余情况的绘制可以用白色等默认颜色填充 private boolean isTranslucent = false; + // 是否绘制单元格内容区之外的网格线 + private boolean showExtraGridLine = true; public Grid(int resolution) { this.resolution = resolution; @@ -1469,4 +1471,12 @@ public class Grid extends BaseGridComponent { public void setTranslucent(boolean translucent) { isTranslucent = translucent; } + + public boolean isShowExtraGridLine() { + return showExtraGridLine; + } + + public void setShowExtraGridLine(boolean showExtraGridLine) { + this.showExtraGridLine = showExtraGridLine; + } } diff --git a/designer-realize/src/main/java/com/fr/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index 10934a7cc4..07044b82c2 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -288,15 +288,25 @@ public class GridUI extends ComponentUI { } } } - GridRange gridRange = GridRange.range(grid.getHorizontalBeginValue(), horizontalEndValue, grid.getVerticalBeginValue(), verticalEndValue) + int xBeginIndex = grid.getHorizontalBeginValue(); + int xEndIndex = horizontalEndValue; + int yBeginIndex = grid.getVerticalBeginValue(); + int yEndIndex = verticalEndValue; + if (!grid.isShowExtraGridLine()) { + xBeginIndex = 0; + xEndIndex = Math.max(0, report.getColumnCount() - 1); + yBeginIndex = 0; + yEndIndex = Math.max(0, report.getRowCount() - 1); + } + GridRange gridRange = GridRange.range(xBeginIndex, xEndIndex, yBeginIndex, yEndIndex) .rangeList(rowHeightList, columnWidthList) .realSize(realWidth, realHeight); - new DrawVerticalLineHelper(gridRange, grid.isShowGridLine(), + new DrawVerticalLineHelper(gridRange, grid.isShowGridLine(), grid.isShowExtraGridLine(), isShowVerticalPaginateLine, paperPaintHeight, paginateLineList, resolution).iterateStart2End(g2d); - new DrawHorizontalLineHelper(gridRange, grid.isShowGridLine(), + new DrawHorizontalLineHelper(gridRange, grid.isShowGridLine(), grid.isShowExtraGridLine(), isShowHorizontalPaginateLine, paperPaintWidth, paginateLineList, resolution).iterateStart2End(g2d); } @@ -320,6 +330,7 @@ public class GridUI extends ComponentUI { protected GridRange gridRange; protected boolean showGridLine; + protected boolean showExtraGridLine; protected boolean showPaginateLine; protected double paperPaintSize; @@ -332,11 +343,12 @@ public class GridUI extends ComponentUI { protected static final double THRESHOLD = 1.0E-4D; - DrawLineHelper(GridRange gridRange, boolean showGridLine, + DrawLineHelper(GridRange gridRange, boolean showGridLine, boolean showExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { this.gridRange = gridRange; this.showGridLine = showGridLine; + this.showExtraGridLine = showExtraGridLine; this.showPaginateLine = showPaginateLine; this.paperPaintSize = paperPaintSize; @@ -353,10 +365,10 @@ public class GridUI extends ComponentUI { private class DrawVerticalLineHelper extends DrawLineHelper { - DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, + DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine, boolean discardExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - super(gridRange, showGridLine, showPaginateLine, + super(gridRange, showGridLine, discardExtraGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); } @@ -372,7 +384,7 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - float rowHeight, paperYAxisSumSize = 0, yAxisSumSize = 0; + float rowHeight, paperYAxisSumSize = 0, maxXAxisSumSize = 0, yAxisSumSize = 0; for (int i = 0; i <= gridRange.yEndIndex; i++) { if (i == 0) { i = gridRange.yBeginIndex; @@ -397,6 +409,9 @@ public class GridUI extends ComponentUI { } xAxisSumSize += columnWidth; } + if (xAxisSumSize > maxXAxisSumSize) { + maxXAxisSumSize = xAxisSumSize; + } } if (showPaginateLine && paperYAxisSumSize - paperPaintSize > THRESHOLD) { paginateLineList.add(getPaginateLine2D((int) yAxisSumSize)); @@ -406,17 +421,21 @@ public class GridUI extends ComponentUI { } // paint 最后一个横线.. if (showGridLine) { - drawLastLine(g2d, (int) yAxisSumSize); + if (showExtraGridLine) { + drawLastLine(g2d, (int) yAxisSumSize); + } else { + GraphHelper.drawLine(g2d, 0, yAxisSumSize, maxXAxisSumSize, yAxisSumSize); + } } } } private class DrawHorizontalLineHelper extends DrawLineHelper { - DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, + DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine, boolean discardExtraGridLine, boolean showPaginateLine, double paperPaintSize, List paginateLineList, int resolution) { - super(gridRange, showGridLine, showPaginateLine, + super(gridRange, showGridLine, discardExtraGridLine, showPaginateLine, paperPaintSize, paginateLineList, resolution); } @@ -432,7 +451,7 @@ public class GridUI extends ComponentUI { @Override protected void iterateStart2End(Graphics2D g2d) { - float columnWidth, paperXAxisSumSize = 0, xAxisSumSize = 0; + float columnWidth, paperXAxisSumSize = 0, maxYAxisSumSize = 0, xAxisSumSize = 0; for (int i = 0; i <= gridRange.xEndIndex; i++) { if (i == 0) { i = gridRange.xBeginIndex; @@ -456,6 +475,9 @@ public class GridUI extends ComponentUI { } yAxisSumSize += rowHeight; } + if (yAxisSumSize > maxYAxisSumSize) { + maxYAxisSumSize = yAxisSumSize; + } } if (showPaginateLine && paperXAxisSumSize - paperPaintSize > THRESHOLD) { paginateLineList.add(getPaginateLine2D((int) xAxisSumSize)); @@ -465,7 +487,11 @@ public class GridUI extends ComponentUI { } // paint 最后一个横线.. if (showGridLine) { - drawLastLine(g2d, (int) xAxisSumSize); + if (showExtraGridLine) { + drawLastLine(g2d, (int) xAxisSumSize); + } else { + GraphHelper.drawLine(g2d, xAxisSumSize, 0, xAxisSumSize, maxYAxisSumSize); + } } } }