Browse Source

REPORT-65170【主题边框】悬浮元素的预览图,右下的边框线看不到

【问题原因】
换个方式实现主题单元格内边框样式的预览效果,之前使用setClip(null)的
问题较大,会将边框绘制到父组件的其他区域

【改动思路】
根据预览时Cell的位置计算边框的位置,使得边框可以在Cell区域内完整展示
出来,而不至于被裁剪
bugfix/11.0
Starryi 3 years ago
parent
commit
906eddd571
  1. 8
      designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java
  2. 39
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  3. 2
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

8
designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java

@ -15,6 +15,7 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
@ -46,7 +47,7 @@ public class CellRectangleStylePreviewPane extends JPanel {
for (int r = 0; r < ROW_COUNT; r++) {
for (int c = 0; c < COLUMN_COUNT; c++) {
CellStylePreviewPane pane = new CellStylePreviewPane(false, false);
CellStylePreviewPane pane = new CellStylePreviewPane(c, r, COLUMN_COUNT, ROW_COUNT, false, false);
TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r);
int flags = CellBorderSourceFlag.INVALID_BORDER_SOURCE;
if (supportInnerBorder) {
@ -136,6 +137,11 @@ public class CellRectangleStylePreviewPane extends JPanel {
super.paint(g);
}
@Override
public Rectangle getBounds() {
return super.getBounds();
}
private void paintTransparentBackground(Graphics2D g2d, Style style) {
float alpha = computeTransparentBackgroundAlpha(style);

39
designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

@ -18,7 +18,9 @@ import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.util.List;
@ -36,10 +38,19 @@ public class CellStylePreviewPane extends JPanel {
private String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
private final int column;
private final int row;
private final int columnSpan;
private final int rowSpan;
private final boolean autoClearCanvas;
private final boolean paintingMosaic;
public CellStylePreviewPane(boolean autoClearCanvas, boolean paintingMosaic) {
public CellStylePreviewPane(int column, int row, int columnSpan, int rowSpan, boolean autoClearCanvas, boolean paintingMosaic) {
this.column = column;
this.row = row;
this.columnSpan = columnSpan;
this.rowSpan = rowSpan;
this.autoClearCanvas = autoClearCanvas;
this.paintingMosaic = paintingMosaic;
transparentBackgroundWidth = transparentBackgroundImage.getWidth(null);
@ -133,8 +144,30 @@ public class CellStylePreviewPane extends JPanel {
Style.paintContent(g2d, paintText, style, width, height, resolution);
g2d.setClip(null);
Style.paintBorder(g2d, style, width, height);
paintCellBorder(g2d, style);
}
protected void paintCellBorder(Graphics2D g2d, Style style) {
float adjustLeft = 0;
float adjustTop = 0;
float adjustRight = 0;
float adjustBottom = 0;
if (column == 0) {
adjustLeft = GraphHelper.getLineStyleSize(style.getBorderLeft()) / 2.0F;
}
if (row == 0) {
adjustTop = GraphHelper.getLineStyleSize(style.getBorderTop()) / 2.0F;
}
if (column == columnSpan - 1) {
adjustRight = -GraphHelper.getLineStyleSize(style.getBorderRight()) / 2.0F;
}
if (row == rowSpan - 1) {
adjustBottom = -GraphHelper.getLineStyleSize(style.getBorderBottom()) / 2.0F;
}
g2d.translate(adjustLeft, adjustTop);
Style.paintBorder(g2d, style, getWidth() - adjustLeft + adjustRight, getHeight() - adjustTop + adjustBottom);
g2d.translate(-adjustLeft, -adjustTop);
}
@Override

2
designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

@ -79,7 +79,7 @@ public class ReportStylePane extends BasicPane {
setLayout(FRGUIPaneFactory.createBorderLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
previewArea = new CellStylePreviewPane(true, true);
previewArea = new CellStylePreviewPane(0, 0, 1,1, true, true);
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomFloatStyleSettingPane();

Loading…
Cancel
Save