Browse Source

REPORT-111995 【UI翻新】西区拖拽面板处理/网格色处理

newui
Levy.Xie-解安森 1 year ago
parent
commit
3b86f775bb
  1. 143
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java
  2. 2
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

143
designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java

@ -1,24 +1,23 @@
package com.fr.design.gui.icontainer; package com.fr.design.gui.icontainer;
import com.fr.base.vcs.DesignerMode; import com.fine.theme.utils.FineUIScale;
import com.fr.design.constants.UIConstants; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.SvgDrawUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.Border;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -26,31 +25,28 @@ import java.awt.event.MouseMotionListener;
public class UIResizableContainer extends JPanel { public class UIResizableContainer extends JPanel {
private static final long serialVersionUID = 1854340560790476907L; private static final long serialVersionUID = 1854340560790476907L;
private static final int MAX_PARA_HEIGHT = 240; private int maxParaHeight = FineUIScale.scale(240);
private int containerWidth = 240; private int containerWidth = FineUIScale.scale(240);
private int preferredWidth = 240; private int preferredWidth = FineUIScale.scale(240);
private int toolPaneY = 300; private int toolPaneY = FineUIScale.scale(300);
private int toolPaneHeight = 10; private int toolPaneHeight = FineUIScale.scale(5);
private int bottomHeight = 30; private int bottomHeight = FineUIScale.scale(30);
private JComponent upPane; private JComponent upPane;
private JComponent downPane; private JComponent downPane;
//放参数面板 //放参数面板
private JComponent parameterPane = new JPanel(); private JComponent parameterPane = new JPanel();
private HorizotalToolPane horizontToolPane; private HorizontalToolPane horizontalToolPane;
private VerticalToolPane verticalToolPane; private VerticalToolPane verticalToolPane;
private int direction; private int direction;
private boolean hasParameterPane; private boolean hasParameterPane;
private static final int MAX_WIDTH = 300; private static final int MAX_WIDTH = FineUIScale.scale(300);
private static final int MIN_WIDTH = 165;
private static final int ARROW_MARGIN = 15; private static final int ARROW_RANGE = FineUIScale.scale(35);
private static final int ARROW_MARGIN_VERTICAL = 7; private static final int ARROW_RANGE_VERTICAL = FineUIScale.scale(25);
private static final int ARROW_RANGE = 35;
private static final int ARROW_RANGE_VERTICAL = 25;
private boolean isLeftRightDragEnabled = true; private boolean isLeftRightDragEnabled = true;
private boolean isDownPaneVisible = true ; private boolean isDownPaneVisible = true ;
@ -95,12 +91,12 @@ public class UIResizableContainer extends JPanel {
this.direction = direction; this.direction = direction;
this.downPane = downPane; this.downPane = downPane;
this.horizontToolPane = new HorizotalToolPane(); this.horizontalToolPane = new HorizontalToolPane();
this.verticalToolPane = new VerticalToolPane(); this.verticalToolPane = new VerticalToolPane();
setLayout(containerLayout); setLayout(containerLayout);
add(upPane); add(upPane);
add(horizontToolPane); add(horizontalToolPane);
add(downPane); add(downPane);
add(verticalToolPane); add(verticalToolPane);
} }
@ -110,10 +106,10 @@ public class UIResizableContainer extends JPanel {
this.upPane = upPane; this.upPane = upPane;
this.direction = direction; this.direction = direction;
this.horizontToolPane = new HorizotalToolPane(); this.horizontalToolPane = new HorizontalToolPane();
setLayout(containerLayout); setLayout(containerLayout);
add(upPane); add(upPane);
add(horizontToolPane); add(horizontalToolPane);
} }
@ -152,7 +148,7 @@ public class UIResizableContainer extends JPanel {
* @param height * @param height
*/ */
public void setParameterHeight(int height) { public void setParameterHeight(int height) {
paraHeight = hasParameterPane? Math.min(height, MAX_PARA_HEIGHT) : 0; paraHeight = hasParameterPane? Math.min(height, maxParaHeight) : 0;
refreshContainer(); refreshContainer();
} }
@ -220,7 +216,7 @@ public class UIResizableContainer extends JPanel {
if (direction == Constants.RIGHT) { if (direction == Constants.RIGHT) {
if(isDownPaneVisible){ if(isDownPaneVisible){
upPane.setBounds(0, 0, containerWidth - toolPaneHeight, toolPaneY); upPane.setBounds(0, 0, containerWidth - toolPaneHeight, toolPaneY);
horizontToolPane.setBounds(0, toolPaneY, containerWidth - toolPaneHeight, toolPaneHeight); horizontalToolPane.setBounds(0, toolPaneY, containerWidth, toolPaneHeight);
downPane.setBounds(0, toolPaneY + toolPaneHeight, containerWidth - toolPaneHeight, parent.getHeight() - toolPaneY - toolPaneHeight - bottomHeight); downPane.setBounds(0, toolPaneY + toolPaneHeight, containerWidth - toolPaneHeight, parent.getHeight() - toolPaneY - toolPaneHeight - bottomHeight);
verticalToolPane.setBounds(containerWidth - toolPaneHeight, 0, toolPaneHeight, getHeight()); verticalToolPane.setBounds(containerWidth - toolPaneHeight, 0, toolPaneHeight, getHeight());
}else{ }else{
@ -232,13 +228,13 @@ public class UIResizableContainer extends JPanel {
if (toolPaneY > getHeight() - toolPaneHeight - getParameterPaneHeight()) { if (toolPaneY > getHeight() - toolPaneHeight - getParameterPaneHeight()) {
toolPaneY = getHeight() - toolPaneHeight - getParameterPaneHeight(); toolPaneY = getHeight() - toolPaneHeight - getParameterPaneHeight();
} }
parameterPane.setBounds(20, 0, 230, getParameterPaneHeight()); parameterPane.setBounds(FineUIScale.scale(20), 0, FineUIScale.scale(230), getParameterPaneHeight());
upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneY); upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneY);
horizontToolPane.setBounds(toolPaneHeight, toolPaneY + getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneHeight); horizontalToolPane.setBounds(toolPaneHeight, toolPaneY + getParameterPaneHeight(), containerWidth, toolPaneHeight);
downPane.setBounds(toolPaneHeight, toolPaneY + toolPaneHeight + getParameterPaneHeight(), containerWidth - toolPaneHeight, parent.getHeight() - toolPaneY - toolPaneHeight - getParameterPaneHeight()); downPane.setBounds(toolPaneHeight, toolPaneY + toolPaneHeight + getParameterPaneHeight(), containerWidth - toolPaneHeight, parent.getHeight() - toolPaneY - toolPaneHeight - getParameterPaneHeight());
verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight()); verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight());
} else { } else {
parameterPane.setBounds(20, 0, 230, getParameterPaneHeight()); parameterPane.setBounds(FineUIScale.scale(20), 0, FineUIScale.scale(230), getParameterPaneHeight());
upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, getHeight() - getParameterPaneHeight()); upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, getHeight() - getParameterPaneHeight());
verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight()); verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight());
} }
@ -251,7 +247,7 @@ public class UIResizableContainer extends JPanel {
parentHeight = parent.getHeight(); parentHeight = parent.getHeight();
} }
if (parentHeight != parent.getHeight() && (parent.getHeight() - toolPaneHeight) >= 0) { if (parentHeight != parent.getHeight() && (parent.getHeight() - toolPaneHeight) >= 0) {
// 调整toolPaneY,保证至少水平的拖拽条horizontToolPane不丢失 // 调整toolPaneY,保证至少水平的拖拽条horizontalToolPane不丢失
toolPaneY = Math.min(toolPaneY, parent.getHeight() - toolPaneHeight); toolPaneY = Math.min(toolPaneY, parent.getHeight() - toolPaneHeight);
parentHeight = parent.getHeight(); parentHeight = parent.getHeight();
} }
@ -267,7 +263,7 @@ public class UIResizableContainer extends JPanel {
* 得到最佳大小 * 得到最佳大小
*/ */
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(containerWidth, 400); return new Dimension(containerWidth, FineUIScale.scale(400));
} }
/** /**
@ -350,24 +346,24 @@ public class UIResizableContainer extends JPanel {
} }
private class HorizotalToolPane extends JPanel { private class HorizontalToolPane extends JPanel {
private int upModel = UIConstants.MODEL_NORMAL;
private int downModel = UIConstants.MODEL_NORMAL;
public HorizotalToolPane() { private Border paneBorder = BorderFactory.createMatteBorder(1, 0, 0, 1, UIManager.getColor("East.border"));
private Border hideBorder = BorderFactory.createMatteBorder(0, 0, 0, 1, UIManager.getColor("East.border"));
private final JPanel toolPane = this;
public HorizontalToolPane() {
super(); super();
this.setBorder(paneBorder);
addMouseMotionListener(new MouseMotionListener() { addMouseMotionListener(new MouseMotionListener() {
@Override @Override
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
if (e.getX() <= ARROW_RANGE) { if (e.getX() <= ARROW_RANGE) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
upModel = UIConstants.MODEL_PRESS;
} else if (e.getX() >= getWidth() - ARROW_RANGE) { } else if (e.getX() >= getWidth() - ARROW_RANGE) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
downModel = UIConstants.MODEL_PRESS;
} else { } else {
resetModel();
setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
} }
repaint(); repaint();
@ -376,8 +372,9 @@ public class UIResizableContainer extends JPanel {
@Override @Override
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y;
toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; toolPaneY = Math.max(toolPaneY, 0);
toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight();
toolPane.setBorder(toolPaneY == 0 ? hideBorder : paneBorder);
refreshContainer(); refreshContainer();
} }
}); });
@ -391,7 +388,6 @@ public class UIResizableContainer extends JPanel {
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
setCursor(Cursor.getDefaultCursor()); setCursor(Cursor.getDefaultCursor());
resetModel();
repaint(); repaint();
} }
@ -409,36 +405,20 @@ public class UIResizableContainer extends JPanel {
}); });
} }
private void resetModel() {
upModel = UIConstants.MODEL_NORMAL;
downModel = UIConstants.MODEL_NORMAL;
}
@Override
public void paint(Graphics g) {
Image upButton = (upModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_UP_NORMAL : UIConstants.DRAG_UP_PRESS);
Image downButton = (downModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_DOWN_NORMAL : UIConstants.DRAG_DOWN_PRESS);
g.setColor(UIManager.getColor("SplitPane.background"));
g.fillRect(0, 0, getWidth(), getHeight());
SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null));
SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, upButton, ARROW_MARGIN, 0, null));
SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null));
}
} }
private class VerticalToolPane extends JPanel { private class VerticalToolPane extends JPanel {
private int model = UIConstants.MODEL_NORMAL;
public VerticalToolPane() { public VerticalToolPane() {
super(); super();
this.setOpaque(false);
this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, UIManager.getColor("East.border")));
addMouseMotionListener(new MouseMotionListener() { addMouseMotionListener(new MouseMotionListener() {
@Override @Override
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
if (e.getY() <= ARROW_RANGE_VERTICAL) { if (e.getY() <= ARROW_RANGE_VERTICAL) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
model = UIConstants.MODEL_PRESS;
} else if (isLeftRightDragEnabled) { } else if (isLeftRightDragEnabled) {
setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
} }
@ -458,10 +438,10 @@ public class UIResizableContainer extends JPanel {
containerWidth = UIResizableContainer.this.getWidth() + (UIResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen()); containerWidth = UIResizableContainer.this.getWidth() + (UIResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen());
} }
containerWidth = containerWidth > MAX_WIDTH ? MAX_WIDTH : containerWidth; containerWidth = Math.min(containerWidth, MAX_WIDTH);
containerWidth = containerWidth < MIN_WIDTH ? MIN_WIDTH : containerWidth; containerWidth = Math.max(containerWidth, toolPaneHeight);
refreshContainer(); refreshContainer();
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize(); DesignerContext.getDesignerFrame().doResize();
} }
@ -480,7 +460,6 @@ public class UIResizableContainer extends JPanel {
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
setCursor(Cursor.getDefaultCursor()); setCursor(Cursor.getDefaultCursor());
model = UIConstants.MODEL_NORMAL;
repaint(); repaint();
} }
@ -494,7 +473,7 @@ public class UIResizableContainer extends JPanel {
containerWidth = toolPaneHeight; containerWidth = toolPaneHeight;
} }
refreshContainer(); refreshContainer();
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize(); DesignerContext.getDesignerFrame().doResize();
} }
} }
@ -502,48 +481,6 @@ public class UIResizableContainer extends JPanel {
}); });
} }
@Override
public void paint(Graphics g) {
Image button;
g.setColor(UIManager.getColor("SplitPane.background"));
g.fillRect(0, 0, toolPaneHeight, getHeight());
if (direction == Constants.RIGHT) {
// g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null);
if (containerWidth == toolPaneHeight) {
if (model == UIConstants.MODEL_NORMAL) {
button = UIConstants.DRAG_RIGHT_NORMAL;
} else {
button = UIConstants.DRAG_RIGHT_PRESS;
}
} else {
if (model == UIConstants.MODEL_NORMAL) {
button = UIConstants.DRAG_LEFT_NORMAL;
} else {
button = UIConstants.DRAG_LEFT_PRESS;
}
}
SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this));
} else {
// g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null);
if (containerWidth == toolPaneHeight) {
if (model == UIConstants.MODEL_NORMAL) {
button = UIConstants.DRAG_LEFT_NORMAL;
} else {
button = UIConstants.DRAG_LEFT_PRESS;
}
} else {
if (model == UIConstants.MODEL_NORMAL) {
button = UIConstants.DRAG_RIGHT_NORMAL;
} else {
button = UIConstants.DRAG_RIGHT_PRESS;
}
}
SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.this));
}
if (isLeftRightDragEnabled) {
g.drawImage(UIConstants.DRAG_DOT_VERTICAL, 2, getHeight() / 2, 5, toolPaneHeight, null);
}
}
} }
/** /**

2
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -3,6 +3,7 @@
*/ */
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.base.Formula; import com.fr.base.Formula;
@ -404,7 +405,6 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor()); grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor());
} }
addExtraCellEditor(grid); addExtraCellEditor(grid);
grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor()); grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor());

Loading…
Cancel
Save