Browse Source

sonar问题修复

persist/11.0
Maksim 5 years ago
parent
commit
7d541ad364
  1. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java
  2. 3
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaUI.java
  3. 4
      designer-base/src/main/java/com/fr/design/gui/toast/Toast.java
  4. 16
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  5. 2
      designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java
  6. 4
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
  7. 4
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java

8
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<MAXIMUM_SIZE) {

3
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaUI.java

@ -463,9 +463,10 @@ public class RTextAreaUI extends BasicTextAreaUI {
if (textArea.getFadeCurrentLineHighlight()) {
Graphics2D g2d = (Graphics2D)g;
Color bg = textArea.getBackground();
float visibleWidth = (float)(visibleRect.x + visibleRect.width);
GradientPaint paint = new GradientPaint(
visibleRect.x,0, highlight,
visibleRect.x+visibleRect.width,0,
visibleWidth,0,
bg==null ? Color.WHITE : bg);
g2d.setPaint(paint);
g2d.fillRect(visibleRect.x,textArea.currentCaretY,

4
designer-base/src/main/java/com/fr/design/gui/toast/Toast.java

@ -42,7 +42,7 @@ public class Toast extends JFrame {
//int x = (int) (owner.getLocation().getX() + (owner.getWidth() / 2));
int x = (int) (owner.getLocation().getX() + owner.getWidth() - textWidth);
int y = (int) (owner.getLocation().getY() + owner.getHeight() / 2);
int y = (int) (owner.getLocation().getY() + (double)owner.getHeight() / 2);
setLocation(new Point(x, y));
@ -110,7 +110,7 @@ public class Toast extends JFrame {
try {
Toast toastFrame = new Toast(owner, toastText);
toastFrame.fadeIn();
Thread.sleep(durationSec * 1000);
Thread.sleep((long)durationSec * 1000);
toastFrame.fadeOut();
} catch (Exception ex) {
ex.printStackTrace();

16
designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

@ -558,15 +558,15 @@ public class FRGUIPaneFactory {
*/
public static int caculateWidth(int width) {
int w = 0;
float m = (width + WIDTH_OFFSET_M) / WIDTH_PARA_F;
float n = (width + WIDTH_OFFSET_N) / WIDTH_PARA_F;
float i = Math.abs((((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m);
float j = Math.abs((((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n);
float x = i > 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;
}

2
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"),

4
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));
}
}

4
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() {

Loading…
Cancel
Save