From 9fa7771d6e2e33c32d02477a783305fc206488c7 Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 3 Aug 2020 14:17:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9=EF=BC=9A?= =?UTF-8?q?=201.FRGUIPanelFactory=E4=B8=AD=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E7=A7=8D=E5=9E=82=E7=9B=B4=E5=B8=83=E5=B1=80=EF=BC=8C?= =?UTF-8?q?=E6=B0=B4=E5=B9=B3=E5=B1=85=E5=B7=A6=EF=BC=8C=E7=AB=96=E7=9B=B4?= =?UTF-8?q?=E9=A1=B6=E5=AF=B9=E9=BD=90=EF=BC=8C=E7=94=A8=E4=BB=A5=E6=BB=A1?= =?UTF-8?q?=E8=B6=B3bug=E6=8F=90=E5=87=BA=E8=80=85=E7=9A=84=E9=9C=80?= =?UTF-8?q?=E6=B1=82=202.=E5=AF=B9VerticalFlowLayout=E4=B8=AD=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=B3=A8=E9=87=8A=E9=94=99=E8=AF=AF(=E5=8E=9F?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E6=B3=A8=E9=87=8A=E4=B8=AD=E6=98=AF=E5=B7=A6?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=E5=B1=85=E4=B8=AD=E5=AF=B9=E9=BD=90=E5=92=8C?= =?UTF-8?q?=E5=8F=B3=E5=AF=B9=E9=BD=90=EF=BC=8C=E5=91=BD=E5=90=8D=E5=8D=B4?= =?UTF-8?q?=E4=B8=BAtop=EF=BC=8Ccenter=E5=92=8Cbottom=EF=BC=8C=E7=BB=8F?= =?UTF-8?q?=E8=BF=87=E8=B0=83=E8=AF=95=E5=8F=91=E7=8E=B0=E8=BF=99=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=E5=8F=98=E9=87=8F=E5=AE=9E=E5=88=99=E4=BB=A3=E8=A1=A8?= =?UTF-8?q?=E4=BA=86=E7=AB=96=E7=9B=B4=E6=96=B9=E5=90=91=E4=B8=8A=E7=9A=84?= =?UTF-8?q?=E9=A1=B6=E5=AF=B9=E9=BD=90=EF=BC=8C=E5=B1=85=E4=B8=AD=E5=AF=B9?= =?UTF-8?q?=E9=BD=90=E5=92=8C=E5=BA=95=E5=AF=B9=E9=BD=90)=E5=92=8C?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E9=94=99=E8=AF=AF(dealWith=E5=86=99=E6=88=90?= =?UTF-8?q?=E4=BA=86dialWith)=E8=BF=9B=E8=A1=8C=E4=BA=86=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=203.=E4=B8=BAVerticalFlowLayout=E4=B8=AD=E9=87=8D=E5=86=99?= =?UTF-8?q?=E7=9A=84=E5=87=A0=E4=B8=AA=E6=96=B9=E6=B3=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86@Override=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/PreferencePane.java | 6 +--- .../fr/design/layout/FRGUIPaneFactory.java | 18 +++++++++- .../fr/design/layout/VerticalFlowLayout.java | 33 +++++++++++-------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 57d9bbcb9..0ccb5d3e7 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -256,7 +256,7 @@ public class PreferencePane extends BasicPane { } private void createVcsSettingPane(JPanel generalPane) { - JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); + JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); generalPane.add(vcsPane); remindVcsLabel = new UILabel(i18nText("Fine-Design_Vcs_Remind")); remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); @@ -449,10 +449,6 @@ public class PreferencePane extends BasicPane { JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors")); generalPane.add(colorSettingPane); - new UILabel(i18nText("Fine-Design_Basic_Preference_Grid_Line_Color")); - - new UILabel(i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color")); - gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); gridLineColorTBButton.setEnabled(this.isEnabled()); diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index 80efde739..f63d8f576 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -168,6 +168,22 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建一个带标题边框面板,垂直居左布局,组件顶对齐 + * + * @param string 边框标题 + * @return JPanel对象 + */ + public static JPanel createTopVerticalTitledBorderPane(String string) { + JPanel jp = new JPanel(); + UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(string); + jp.setBorder(explainBorder); + VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP); + layout.setAlignLeft(true); + jp.setLayout(layout); + return jp; + } + /** * 创建一个带标题边框面板并且居中显示 * @@ -584,4 +600,4 @@ public class FRGUIPaneFactory { return h; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/layout/VerticalFlowLayout.java b/designer-base/src/main/java/com/fr/design/layout/VerticalFlowLayout.java index 5d5131ff4..c857c7301 100644 --- a/designer-base/src/main/java/com/fr/design/layout/VerticalFlowLayout.java +++ b/designer-base/src/main/java/com/fr/design/layout/VerticalFlowLayout.java @@ -16,20 +16,17 @@ import java.awt.LayoutManager; public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { /** - * This value indicates that each row of components - * should be left-justified. + * 竖直方向上将子组件设置为顶对齐方式 */ public static final int TOP = 0; /** - * This value indicates that each row of components - * should be centered. + * 竖直方向上将子组件设置为居中对齐方式 */ public static final int CENTER = 1; /** - * This value indicates that each row of components - * should be right-justified. + * 竖直方向上将子组件设置为底对齐方式 */ public static final int BOTTOM = 2; @@ -71,7 +68,9 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { */ int newAlign; // This is the one we actually use - // 当列宽不一致时,是否需要左对齐(默认居中对齐) + /** + * 当列宽不一致时,是否需要将水平方向设置成左对齐(默认水平方向为居中对齐) + */ boolean isAlignLeft = false; /** @@ -220,6 +219,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { * @param name the name of the component * @param comp the component to be added */ + @Override public void addLayoutComponent(String name, Component comp) { } @@ -230,6 +230,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { * @param comp the component to remove * @see java.awt.Container#removeAll */ + @Override public void removeLayoutComponent(Component comp) { } @@ -244,6 +245,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { * @see #minimumLayoutSize * @see java.awt.Container#getPreferredSize */ + @Override public Dimension preferredLayoutSize(Container target) { synchronized (target.getTreeLock()) { Dimension dim = new Dimension(0, 0); @@ -255,7 +257,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { if (m.isVisible()) { Dimension d = m.getPreferredSize(); - firstVisibleComponent = dialWithDim4PreferredLayoutSize(dim, d, firstVisibleComponent); + firstVisibleComponent = dealWithDim4PreferredLayoutSize(dim, d, firstVisibleComponent); } } Insets insets = target.getInsets(); @@ -265,7 +267,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { } } - protected boolean dialWithDim4PreferredLayoutSize(Dimension dim, Dimension d, boolean firstVisibleComponent) { + protected boolean dealWithDim4PreferredLayoutSize(Dimension dim, Dimension d, boolean firstVisibleComponent) { dim.width = Math.max(dim.width, d.width); if (firstVisibleComponent) { firstVisibleComponent = false; @@ -289,6 +291,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { * @see java.awt.Container * @see java.awt.Container#doLayout */ + @Override public Dimension minimumLayoutSize(Container target) { synchronized (target.getTreeLock()) { Dimension dim = new Dimension(0, 0); @@ -300,7 +303,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { if (m.isVisible()) { Dimension d = m.getMinimumSize(); - firstVisibleComponent = dialWithDim4MinimumLayoutSize(dim, d, i, firstVisibleComponent); + firstVisibleComponent = dealWithDim4MinimumLayoutSize(dim, d, i, firstVisibleComponent); } } Insets insets = target.getInsets(); @@ -310,7 +313,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { } } - protected boolean dialWithDim4MinimumLayoutSize(Dimension dim, Dimension d, int i, boolean firstVisibleComponent) { + protected boolean dealWithDim4MinimumLayoutSize(Dimension dim, Dimension d, int i, boolean firstVisibleComponent) { dim.width = Math.max(dim.width, d.width); if (i > 0) { dim.height += vgap; @@ -370,6 +373,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { * @see java.awt.Container * @see java.awt.Container#doLayout */ + @Override public void layoutContainer(Container target) { synchronized (target.getTreeLock()) { Insets insets = target.getInsets(); @@ -410,7 +414,9 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { protected int[] dealWithDim4LayoutContainer(Container target, Insets insets, Dimension d, int x, int y, int roww, int start, int maxlen, int i, boolean ltr) { if ((y == 0) || ((y + d.height) <= maxlen)) { - if (y > 0) y += vgap; + if (y > 0) { + y += vgap; + } y += d.height; roww = Math.max(roww, d.width); } else { @@ -449,6 +455,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { * * @return a string representation of this layout */ + @Override public String toString() { String str = ""; switch (this.newAlign) { @@ -465,4 +472,4 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + str + "]"; } -} \ No newline at end of file +}