Browse Source

Pull request #9530: REPORT-75752 表格辅助线的功能从frm扩展到dashboard

Merge in DESIGN/design from ~WEI/design:release/11.0 to release/11.0

* commit 'db53e128aa55149959a1ea0e077e173519d79930':
  REPORT-75752 兼容下旧插件
  REPORT-75752 表格辅助线的功能从frm扩展到dashboard
release/11.0
wei 2 years ago
parent
commit
d4d10419bc
  1. 6
      designer-base/src/main/java/com/fr/design/mainframe/JDashboard.java
  2. 11
      designer-base/src/main/java/com/fr/design/utils/ColorUtils.java
  3. 29
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  4. 25
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java
  5. 16
      designer-realize/src/main/java/com/fr/grid/GridUI.java

6
designer-base/src/main/java/com/fr/design/mainframe/JDashboard.java

@ -1,5 +1,9 @@
package com.fr.design.mainframe;
import com.fr.report.worksheet.FormElementCase;
import java.awt.Rectangle;
/**
* @author Starryi
* @version 1.0
@ -7,4 +11,6 @@ package com.fr.design.mainframe;
*/
public interface JDashboard {
void switchToDashBoardEditor();
Rectangle getElementCaseRectangle(FormElementCase elementCase);
}

11
designer-base/src/main/java/com/fr/design/utils/ColorUtils.java

@ -27,4 +27,15 @@ public class ColorUtils {
}
}
}
public static boolean isDarkColor(Color color) {
if(color == null) {
return false;
}
int red = color.getRed();
int green = color.getGreen();
int blue = color.getBlue();
int greyLevel = (int)(red * 0.299 + green * 0.587 + blue * 0.114);
return greyLevel < 192;
}
}

29
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -41,6 +41,7 @@ import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fit.FormFitAttrAction;
import com.fr.design.fit.common.FormDesignerUtil;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.fun.PropertyItemPaneProvider;
import com.fr.design.gui.frpane.HyperlinkGroupPane;
@ -109,12 +110,7 @@ import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
@ -1307,4 +1303,25 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
public XLayoutContainer getRootComponent() {
return this.formDesign.getRootComponent();
}
@Override
public Rectangle getElementCaseRectangle(FormElementCase elementCase) {
final Rectangle rectangle = new Rectangle();
FormDesigner designer = this.getFormDesign();
if (designer == null) {
return rectangle;
}
XElementCase xElementCase = FormDesignerUtil.getXelementCase(designer.getRootComponent(), elementCase);
if (xElementCase != null) {
rectangle.setBounds(xElementCase.getBounds());
//减去内边距的宽和高
Insets insets = xElementCase.getInsets();
rectangle.width -= insets.left + insets.right;
rectangle.height -= insets.top + insets.bottom;
}
return rectangle;
}
}

25
designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java

@ -72,28 +72,17 @@ public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase
}
private Rectangle getBoundsLineRect(TemplateElementCase elementCase) {
final Rectangle rectangle = new Rectangle();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (!(template instanceof JForm)) {
return rectangle;
if (!(template instanceof JDashboard)) {
return new Rectangle();
}
FormDesigner designer = ((JForm) template).getFormDesign();
if (designer == null) {
return rectangle;
try {
return ((JDashboard)template).getElementCaseRectangle((FormElementCase)elementCase);
} catch (Throwable e) {
// 兼容旧插件
return new Rectangle();
}
XElementCase xElementCase = FormDesignerUtil.getXelementCase(designer.getRootComponent(), (FormElementCase) elementCase);
if (xElementCase != null) {
rectangle.setBounds(xElementCase.getBounds());
//减去内边距的宽和高
Insets insets = xElementCase.getInsets();
rectangle.width -= insets.left + insets.right;
rectangle.height -= insets.top + insets.bottom;
}
return rectangle;
}

16
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -18,6 +18,7 @@ import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.utils.ColorUtils;
import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
@ -1196,13 +1197,13 @@ public class GridUI extends ComponentUI {
}
//绘制吸附辅助线
paintAdsorbLines(g2d, grid);
paintAdsorbLines(g2d, grid, elementCase);
grid.ajustEditorComponentBounds(); // refresh size
}
//绘制吸附辅助线
private void paintAdsorbLines(Graphics2D g2d, Grid grid) {
private void paintAdsorbLines(Graphics2D g2d, Grid grid, TemplateElementCase elementcase) {
int verticalValue = grid.getVerticalValue();
int horizontalValue = grid.getHorizontalValue();
if (grid.getAdsorbWidth() <= 0 || grid.getAdsorbHeight() <= 0) {
@ -1212,13 +1213,18 @@ public class GridUI extends ComponentUI {
- columnWidthList.getRangeValue(0, horizontalValue).toPixI(resolution));
int height = (int) (grid.getAdsorbHeight() * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution())
- rowHeightList.getRangeValue(0, verticalValue).toPixI(resolution));
drawBoundsLine(g2d, width, height);
drawBoundsLine(g2d, width, height, elementcase);
}
private void drawBoundsLine(Graphics2D g2d, int width, int height) {
private void drawBoundsLine(Graphics2D g2d, int width, int height, TemplateElementCase elementcase) {
Paint oldPaint = g2d.getPaint();
Stroke oldStroke = g2d.getStroke();
g2d.setPaint(Color.black);
Color backgroundColor = AdjustWorkBookDefaultStyleUtils.adjustBack(Color.WHITE);
if(ColorUtils.isDarkColor(backgroundColor)) {
g2d.setPaint(Color.white);
} else {
g2d.setPaint(Color.black);
}
g2d.setStroke(GraphDrawHelper.getStroke(Constants.LINE_DASH_DOT));
g2d.drawLine(0, height, width, height);
g2d.drawLine(width, 0, width, height);

Loading…
Cancel
Save