From afdd96c1a36094e1b073695def74b287ffa79e69 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 6 Sep 2019 17:32:16 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-20327=20sonar=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/poly/PolyDesignUI.java | 27 +++++----- .../com/fr/poly/creator/BlockCreator.java | 37 +++++++------ .../java/com/fr/poly/creator/BlockEditor.java | 53 ++++++++++--------- .../com/fr/start/fx/PrismImageLoader2.java | 4 +- .../java/com/fr/start/fx/SplashFxWindow.java | 1 + 5 files changed, 66 insertions(+), 56 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java b/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java index 2bf55e5a0..d12920bfd 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java @@ -47,7 +47,7 @@ import java.util.ArrayList; */ public class PolyDesignUI extends ComponentUI { private static final Color PAGINATE_LINE_COLOR = Color.GRAY; - + private static final double SCROLL_POINT = 50; private static final int SCROLL_DISTANCE = 15; private static final int TEN = 10; @@ -65,11 +65,11 @@ public class PolyDesignUI extends ComponentUI { /** * 从组件中获取设计器, 并赋值 - * + * * @param c 组件对象 - * + * * @date 2015-2-12-下午2:38:05 - * + * */ public void installUI(JComponent c) { designer = ((PolyArea) c).getPolyDesigner(); @@ -137,7 +137,7 @@ public class PolyDesignUI extends ComponentUI { } } } - + private void changeForbiddenWindowVisibility(BlockCreator creator){ Rectangle pixRec = creator.getBounds(); boolean intersected = designer.intersectsAllBlock(creator); @@ -145,12 +145,12 @@ public class PolyDesignUI extends ComponentUI { creator.getEditor().hideForbiddenWindow(); return; } - + int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX()*time - designer.getHorizontalValue()); int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY()*time - designer.getVerticalValue()); creator.getEditor().showForbiddenWindow(x, y); } - + private Rectangle getCreatorPixRectangle(BlockCreator creator, Point location){ int width = creator.getWidth(); int height = creator.getHeight(); @@ -158,21 +158,22 @@ public class PolyDesignUI extends ComponentUI { int resy = location.y - height / 2 + designer.getVerticalValue(); return new Rectangle(resx, resy, width, height); } - + + @SuppressWarnings("squid:S2142") private void scrollWhenCreatorAtCorner(final BlockCreator creator){ Thread scrollThread = new Thread(new Runnable() { - + @Override public void run() { try { Thread.sleep(100); - + int rightCornerX = creator.getX() + creator.getWidth(); int rightCornerY = creator.getY() + creator.getHeight(); JScrollBar horizonBar = designer.getHorizontalScrollBar(); JScrollBar verticalBar = designer.getVerticalScrollBar(); - + int scrollX = designer.getWidth() + horizonBar.getValue(); int scrollY = designer.getHeight() + verticalBar.getValue(); @@ -180,7 +181,7 @@ public class PolyDesignUI extends ComponentUI { if(rightCornerX > scrollX - SCROLL_POINT){ horizonBar.setValue(horizonBar.getValue() + SCROLL_DISTANCE); } - + if(rightCornerY > scrollY - SCROLL_POINT){ verticalBar.setValue(verticalBar.getValue() + SCROLL_DISTANCE); } @@ -200,7 +201,7 @@ public class PolyDesignUI extends ComponentUI { GraphHelper.drawString(g, convertUnit(y), 0, resy); GraphHelper.drawString(g, convertUnit(x), resx, 10); } - + private String convertUnit(int i) { short unit = designer.getRulerLengthUnit(); // int resolution = ScreenResolution.getScreenResolution(); diff --git a/designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java b/designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java index 1d11a783d..5b581f8f1 100644 --- a/designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java +++ b/designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java @@ -54,6 +54,9 @@ public abstract class BlockCreator extends JComponent i @Override public boolean equals(Object o) { + if (o == null) { + return false; + } return ComparatorUtils.equals(o.getClass().getName(), this.getClass().getName()); } }); @@ -81,7 +84,7 @@ public abstract class BlockCreator extends JComponent i //默认大小, 报表块默认3列6行, 图表块默认330*240 public abstract UnitRectangle getDefaultBlockBounds(); - + // 不同的Block有不同的显示器 protected abstract JComponent initMonitor(); @@ -97,9 +100,9 @@ public abstract class BlockCreator extends JComponent i /** * 检测按钮状态 - * + * * @date 2015-2-5-上午11:33:46 - * + * */ public abstract void checkButtonEnable(); @@ -134,31 +137,31 @@ public abstract class BlockCreator extends JComponent i /** * 获取当前工具栏组 - * + * * @return 工具栏组 - * + * * @date 2015-2-5-上午11:29:07 - * + * */ public abstract ToolBarDef[] toolbars4Target(); /** * 在Form的工具栏组 - * + * * @return 组件数组 - * + * * @date 2015-2-5-上午11:31:46 - * + * */ public abstract JComponent[] toolBarButton4Form(); - + /** * 获取当前菜单栏组 - * + * * @return 菜单栏组 - * + * * @date 2015-2-5-上午11:29:07 - * + * */ public abstract MenuDef[] menus4Target(); @@ -167,12 +170,12 @@ public abstract class BlockCreator extends JComponent i /** * 获取菜单里的快捷方式数组 - * + * * @return 菜单里的快捷方式数组 - * + * * @date 2015-2-5-上午11:27:08 - * + * */ public abstract ShortCut[] shortcut4TemplateMenu(); -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java b/designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java index 686084177..cac1a0e22 100644 --- a/designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java +++ b/designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java @@ -30,20 +30,20 @@ import com.fr.stable.unit.UnitRectangle; * @since 6.5.4 创建于2011-5-5 聚合报表块编辑器 */ public abstract class BlockEditor extends JComponent{ - + protected PolyDesigner designer; protected BlockCreator creator; protected int resolution = ScreenResolution.getScreenResolution(); protected T editComponent; - + private JComponent addHeightTool;// 改变高度的组件 private JComponent addWidthTool; // 改变宽度的组件 private JComponent moveTool; // 拖动聚合块的组件 - + private boolean isDragging; private Absorptionline lineInX; private Absorptionline lineInY; - + private BlockForbiddenWindow forbiddenWindow; public BlockEditor(PolyDesigner designer, BlockCreator creator) { @@ -74,16 +74,16 @@ public abstract class BlockEditor this.moveTool = new BlockControlButton(); this.add(BlockEditorLayout.BOTTOMCORNER, this.moveTool); - + this.forbiddenWindow = new BlockForbiddenWindow(); } - + /** * 重置当前鼠标选中状态 - * + * */ public abstract void resetSelectionAndChooseState(); - + protected abstract T createEffective(); protected abstract Dimension getAddHeigthPreferredSize(); @@ -91,9 +91,9 @@ public abstract class BlockEditor protected abstract Dimension getAddWidthPreferredSize(); protected abstract void initDataChangeListener(); - + protected abstract RowOperationMouseHandler createRowOperationMouseHandler(); - + protected abstract ColumnOperationMouseHandler createColumnOperationMouseHandler(); protected void addColumnRowListeners() { @@ -122,28 +122,31 @@ public abstract class BlockEditor initSize(); LayoutUtils.layoutRootContainer(BlockEditor.this); } - + @Override public boolean equals(Object o) { + if (o == null) { + return false; + } return ComparatorUtils.equals(o.getClass().getName(), this.getClass().getName()); } }); } - + public void setDragging(boolean isDragging) { this.isDragging = isDragging; } - + /** * 当前是否处于拖动状态 - * + * * @return 是否处于拖动状态 - * + * */ public boolean isDragging() { return this.isDragging; } - + public void setXAbsorptionline(Absorptionline line) { this.lineInX = line; } @@ -151,27 +154,27 @@ public abstract class BlockEditor public void setYAbsorptionline(Absorptionline line) { this.lineInY = line; } - - + + /** * 显示禁止重叠窗口 - * + * * @param x x坐标 * @param y y坐标 - * + * */ public void showForbiddenWindow(int x, int y){ this.forbiddenWindow.showWindow(x, y); } - + /** * 隐藏禁止重叠窗口 - * + * */ public void hideForbiddenWindow(){ this.forbiddenWindow.hideWindow(); } - + public void paintAbsorptionline(Graphics g) { if(lineInX != null) { lineInX.paint(g,designer); @@ -202,7 +205,7 @@ public abstract class BlockEditor public Dimension getCornerSize() { return new Dimension(); } - + private class BlockControlButton extends UIButton { @Override public ButtonUI getUI() { @@ -220,4 +223,4 @@ public abstract class BlockEditor }; } } -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java b/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java index 470b382c9..e262e917e 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java +++ b/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java @@ -1,6 +1,7 @@ package com.fr.start.fx; import com.fr.concurrent.NamedThreadFactory; +import com.fr.log.FineLoggerFactory; import com.sun.javafx.iio.ImageFrame; import com.sun.javafx.iio.ImageLoadListener; import com.sun.javafx.iio.ImageLoader; @@ -79,6 +80,7 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { } @Override + @SuppressWarnings("squid:S2142") public PlatformImage getFrame(int index) { while (images[index] == null) { synchronized (this) { @@ -86,7 +88,7 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { try { this.wait(); } catch (InterruptedException e) { - e.printStackTrace(); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } diff --git a/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java b/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java index 073cee7ae..00ad51293 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java +++ b/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java @@ -55,6 +55,7 @@ public class SplashFxWindow extends Application { * * @return 运行实例 */ + @SuppressWarnings("squid:S2142") public static SplashFxWindow waitForStartUpTest() { try { LATCH.await();