From 7d541ad364afe53aaa285ff855be40f0588adcf3 Mon Sep 17 00:00:00 2001 From: Maksim Date: Thu, 10 Oct 2019 15:00:57 +0800 Subject: [PATCH] =?UTF-8?q?sonar=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 --- .../syntax/ui/rtextarea/RTextAreaEditorKit.java | 8 ++++---- .../gui/syntax/ui/rtextarea/RTextAreaUI.java | 3 ++- .../main/java/com/fr/design/gui/toast/Toast.java | 4 ++-- .../com/fr/design/layout/FRGUIPaneFactory.java | 16 ++++++++-------- .../com/fr/design/layout/TableLayoutHelper.java | 2 +- .../PatternBackgroundQuickPane.java | 4 ++-- .../TextureBackgroundQuickPane.java | 4 ++-- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java index 277064c2f9..de97867fbb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java @@ -741,10 +741,10 @@ public class RTextAreaEditorKit extends DefaultEditorKit { public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { Font font = textArea.getFont(); float oldSize = font.getSize2D(); - float newSize = oldSize - decreaseAmount; + double newSize = (double)oldSize - (double)decreaseAmount; if (newSize>=MINIMUM_SIZE) { // Shrink by decreaseAmount. - font = font.deriveFont(newSize); + font = font.deriveFont((float)newSize); textArea.setFont(font); } else if (oldSize>MINIMUM_SIZE) { @@ -1329,10 +1329,10 @@ public class RTextAreaEditorKit extends DefaultEditorKit { public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { Font font = textArea.getFont(); float oldSize = font.getSize2D(); - float newSize = oldSize + increaseAmount; + double newSize = (double)oldSize + (double)increaseAmount; if (newSize<=MAXIMUM_SIZE) { // Grow by increaseAmount. - font = font.deriveFont(newSize); + font = font.deriveFont((float)newSize); textArea.setFont(font); } else if (oldSize j ? i : j; + double m = (double)(width + WIDTH_OFFSET_M) / (double)WIDTH_PARA_F; + double n = (double)(width + WIDTH_OFFSET_N ) / (double)WIDTH_PARA_F; + double i = Math.abs(((double) ((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m); + double j = Math.abs(((double) ((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n); + double x = i > j ? i : j; if (AssistUtils.equals(x, i)) { - w = Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M; + w = (int) (Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M); } else if (AssistUtils.equals(x, j)) { - w = Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N; + w = (int) (Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N); } return w; } @@ -579,7 +579,7 @@ public class FRGUIPaneFactory { */ public static int caculateHeight(int height) { int h = 0; - float x = (height + HEIGHT_OFFSET) / HEIGHT_PARA; + double x = (double)(height + HEIGHT_OFFSET) / HEIGHT_PARA; h = ((int) x + 1) * HEIGHT_PARA; return h; } diff --git a/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java b/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java index b26e057ef5..1be77c8492 100644 --- a/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java +++ b/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java @@ -372,7 +372,7 @@ public class TableLayoutHelper { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; JPanel jp1 = TableLayoutHelper.createTableLayoutPane(createTestComponents("jp1"), TableLayoutHelper.FILL_NONE); - JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp2"), TableLayoutHelper.FILL_LASTCOL_AND_ROW, 2 * TEN, 2 * TEN); + JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp2"), TableLayoutHelper.FILL_LASTCOL_AND_ROW, (double)2 * TEN, (double)2 * TEN); JPanel jp3 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp3"), new double[]{f, p, f, p}, new double[]{f, f}, 4, 4); JPanel jp4 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp4"), diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java index 5e69d9f829..9da1344dcd 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java @@ -164,11 +164,11 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane { Graphics2D g2d = (Graphics2D) g; Dimension d = getSize(); - this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, (double)d.width - 1, (double)d.height - 1)); if (this.pIndex == patternIndex) {// it's selected. g2d.setPaint(UIConstants.LINE_COLOR); - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, (double)d.width - 1, (double)d.height - 1)); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java index 773498502a..0d94bf3bce 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java @@ -101,7 +101,7 @@ public class TextureBackgroundQuickPane extends BackgroundQuickPane { Dimension d = getSize(); g2d.setPaint(this.buttonTexturePaint); - GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, (double) d.width - 1, (double)d.height - 1)); if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's // selected. @@ -109,7 +109,7 @@ public class TextureBackgroundQuickPane extends BackgroundQuickPane { } else { g2d.setPaint(null); } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, (double)d.width - 1, (double) d.height - 1)); } public Dimension getPreferredSize() {