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