From b36f0f8bfe387b604d8a09f874dbee9a37d3a627 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Thu, 12 Sep 2019 09:22:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=EF=BC=8Csonar?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/layout/TableLayout.java | 13 ++++++------- .../mainframe/vcs/ui/FileVersionCellEditor.java | 3 ++- .../mainframe/vcs/ui/FileVersionCellRender.java | 3 ++- .../style/background/gradient/GradientBar.java | 3 ++- .../java/com/fr/design/utils/gui/GUICoreUtils.java | 9 +++++---- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/layout/TableLayout.java b/designer-base/src/main/java/com/fr/design/layout/TableLayout.java index 961d3e23e..f8134be1f 100644 --- a/designer-base/src/main/java/com/fr/design/layout/TableLayout.java +++ b/designer-base/src/main/java/com/fr/design/layout/TableLayout.java @@ -322,7 +322,6 @@ public class TableLayout implements LayoutManager2, Serializable { this row/column. */ public static final double MINIMUM = -3.0; - public static final double EPSILON = 0.0000001; //****************************************************************************** //** Constructors *** @@ -1808,8 +1807,8 @@ public class TableLayout implements LayoutManager2, Serializable { for (counter = entry.cr1[z]; counter <= entry.cr2[z]; counter++) if (crSpec[z][counter] >= 1.0) scalableSize -= crSpec[z][counter]; - else if (Math.abs(crSpec[z][counter] - PREFERRED) < EPSILON || - Math.abs(crSpec[z][counter] - MINIMUM) < EPSILON) { + else if (AssistUtils.equals(crSpec[z][counter], PREFERRED) || + AssistUtils.equals(crSpec[z][counter], MINIMUM)) { scalableSize -= crPrefMin[counter]; } @@ -1825,13 +1824,13 @@ public class TableLayout implements LayoutManager2, Serializable { // Add scaled size to relativeWidth relativeSize += crSpec[z][counter]; // Cr is fill - else if (Math.abs(crSpec[z][counter] - FILL) < EPSILON && Math.abs(fillSizeRatio - 0.0) >= EPSILON) + else if (AssistUtils.equals(crSpec[z][counter], FILL) && !AssistUtils.equals(fillSizeRatio, 0.0)) // Add fill size to relativeWidth relativeSize += fillSizeRatio; } // Determine the total scaled size as estimated by this component - if (Math.abs(relativeSize - 0) < EPSILON) + if (AssistUtils.equals(relativeSize, 0)) temp = 0; else temp = (int) (scalableSize / relativeSize + 0.5); @@ -1852,8 +1851,8 @@ public class TableLayout implements LayoutManager2, Serializable { if (crSpec[z][counter] >= 1.0) totalSize += (int) (crSpec[z][counter] + 0.5); // Is the current cr a preferred/minimum size - else if (Math.abs(crSpec[z][counter] - PREFERRED) < EPSILON|| - Math.abs(crSpec[z][counter] - MINIMUM) < EPSILON) { + else if (AssistUtils.equals(crSpec[z][counter], PREFERRED) || + AssistUtils.equals(crSpec[z][counter], MINIMUM)) { // Add preferred/minimum width totalSize += crPrefMin[counter]; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java index 125d4bc4e..bf5b8ba45 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java @@ -10,6 +10,7 @@ import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.report.entity.VcsEntity; +import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; @@ -67,7 +68,7 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe } double height = editor.getPreferredSize().getHeight(); - if (table.getRowHeight(row) != height) { + if (!AssistUtils.equals(table.getRowHeight(row), height)) { table.setRowHeight(row, (int) height + VcsHelper.OFFSET); } return editor; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java index 40fa02c1f..d97e1efb1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.vcs.ui; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.report.entity.VcsEntity; +import com.fr.stable.AssistUtils; import javax.swing.JPanel; import javax.swing.JTable; @@ -34,7 +35,7 @@ public class FileVersionCellRender implements TableCellRenderer { editor.setBackground(isSelected ? TABLE_SELECT_BACKGROUND : TREE_BACKGROUND); double height = editor.getPreferredSize().getHeight(); - if (table.getRowHeight(row) != height) { + if (!AssistUtils.equals(table.getRowHeight(row), height)) { table.setRowHeight(row, (int) height + VcsHelper.OFFSET); } return editor; diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index 2ce1a0bc3..b197a3d39 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -29,6 +29,7 @@ import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.style.color.ColorSelectDetailPane; import com.fr.design.style.color.ColorSelectDialog; import com.fr.design.style.color.ColorSelectable; +import com.fr.stable.AssistUtils; /** * TODO:面板缩放的功能没有考虑(就是尾值过大,导致超过界面显示的情况),原来的那个实现完全是个BUG。要缩放的情况也比较少,就干脆以后弄吧 @@ -217,7 +218,7 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl * @return 同上 */ public boolean isOriginalPlace() { - return startLabel.getValue() == min && endLabel.getValue() == max; + return AssistUtils.equals(startLabel.getValue(), min) && AssistUtils.equals(endLabel.getValue(), max); } /** diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index c8c0561c9..c30637509 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -31,6 +31,7 @@ import com.fr.design.style.color.ColorFactory; import com.fr.design.style.color.ColorSelectBox; import com.fr.design.style.color.ColorSelectable; import com.fr.general.FRFont; +import com.fr.stable.AssistUtils; import com.fr.stable.Constants; import com.fr.stable.OperatingSystem; import com.fr.stable.StringUtils; @@ -890,10 +891,10 @@ public final class GUICoreUtils { * @return 同上 */ public static boolean isTheSameRect(Rectangle oneRect, Rectangle otherRect) { - return oneRect.getX() == otherRect.getX() - && oneRect.getY() == otherRect.getY() - && oneRect.getWidth() == otherRect.getWidth() - && oneRect.getHeight() == otherRect.getHeight(); + return AssistUtils.equals(oneRect.getX(), otherRect.getX()) + && AssistUtils.equals(oneRect.getY(), otherRect.getY()) + && AssistUtils.equals(oneRect.getWidth(), otherRect.getWidth()) + && AssistUtils.equals(oneRect.getHeight(), otherRect.getHeight()); } /**