Browse Source

REPORT-20327 sonar问题修复

research/11.0
kerry 5 years ago
parent
commit
afdd96c1a3
  1. 27
      designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java
  2. 37
      designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java
  3. 53
      designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java
  4. 4
      designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java
  5. 1
      designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java

27
designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java

@ -47,7 +47,7 @@ import java.util.ArrayList;
*/ */
public class PolyDesignUI extends ComponentUI { public class PolyDesignUI extends ComponentUI {
private static final Color PAGINATE_LINE_COLOR = Color.GRAY; private static final Color PAGINATE_LINE_COLOR = Color.GRAY;
private static final double SCROLL_POINT = 50; private static final double SCROLL_POINT = 50;
private static final int SCROLL_DISTANCE = 15; private static final int SCROLL_DISTANCE = 15;
private static final int TEN = 10; private static final int TEN = 10;
@ -65,11 +65,11 @@ public class PolyDesignUI extends ComponentUI {
/** /**
* 从组件中获取设计器, 并赋值 * 从组件中获取设计器, 并赋值
* *
* @param c 组件对象 * @param c 组件对象
* *
* @date 2015-2-12-下午2:38:05 * @date 2015-2-12-下午2:38:05
* *
*/ */
public void installUI(JComponent c) { public void installUI(JComponent c) {
designer = ((PolyArea) c).getPolyDesigner(); designer = ((PolyArea) c).getPolyDesigner();
@ -137,7 +137,7 @@ public class PolyDesignUI extends ComponentUI {
} }
} }
} }
private void changeForbiddenWindowVisibility(BlockCreator creator){ private void changeForbiddenWindowVisibility(BlockCreator creator){
Rectangle pixRec = creator.getBounds(); Rectangle pixRec = creator.getBounds();
boolean intersected = designer.intersectsAllBlock(creator); boolean intersected = designer.intersectsAllBlock(creator);
@ -145,12 +145,12 @@ public class PolyDesignUI extends ComponentUI {
creator.getEditor().hideForbiddenWindow(); creator.getEditor().hideForbiddenWindow();
return; return;
} }
int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX()*time - designer.getHorizontalValue()); int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX()*time - designer.getHorizontalValue());
int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY()*time - designer.getVerticalValue()); int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY()*time - designer.getVerticalValue());
creator.getEditor().showForbiddenWindow(x, y); creator.getEditor().showForbiddenWindow(x, y);
} }
private Rectangle getCreatorPixRectangle(BlockCreator creator, Point location){ private Rectangle getCreatorPixRectangle(BlockCreator creator, Point location){
int width = creator.getWidth(); int width = creator.getWidth();
int height = creator.getHeight(); int height = creator.getHeight();
@ -158,21 +158,22 @@ public class PolyDesignUI extends ComponentUI {
int resy = location.y - height / 2 + designer.getVerticalValue(); int resy = location.y - height / 2 + designer.getVerticalValue();
return new Rectangle(resx, resy, width, height); return new Rectangle(resx, resy, width, height);
} }
@SuppressWarnings("squid:S2142")
private void scrollWhenCreatorAtCorner(final BlockCreator creator){ private void scrollWhenCreatorAtCorner(final BlockCreator creator){
Thread scrollThread = new Thread(new Runnable() { Thread scrollThread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
Thread.sleep(100); Thread.sleep(100);
int rightCornerX = creator.getX() + creator.getWidth(); int rightCornerX = creator.getX() + creator.getWidth();
int rightCornerY = creator.getY() + creator.getHeight(); int rightCornerY = creator.getY() + creator.getHeight();
JScrollBar horizonBar = designer.getHorizontalScrollBar(); JScrollBar horizonBar = designer.getHorizontalScrollBar();
JScrollBar verticalBar = designer.getVerticalScrollBar(); JScrollBar verticalBar = designer.getVerticalScrollBar();
int scrollX = designer.getWidth() + horizonBar.getValue(); int scrollX = designer.getWidth() + horizonBar.getValue();
int scrollY = designer.getHeight() + verticalBar.getValue(); int scrollY = designer.getHeight() + verticalBar.getValue();
@ -180,7 +181,7 @@ public class PolyDesignUI extends ComponentUI {
if(rightCornerX > scrollX - SCROLL_POINT){ if(rightCornerX > scrollX - SCROLL_POINT){
horizonBar.setValue(horizonBar.getValue() + SCROLL_DISTANCE); horizonBar.setValue(horizonBar.getValue() + SCROLL_DISTANCE);
} }
if(rightCornerY > scrollY - SCROLL_POINT){ if(rightCornerY > scrollY - SCROLL_POINT){
verticalBar.setValue(verticalBar.getValue() + SCROLL_DISTANCE); 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(y), 0, resy);
GraphHelper.drawString(g, convertUnit(x), resx, 10); GraphHelper.drawString(g, convertUnit(x), resx, 10);
} }
private String convertUnit(int i) { private String convertUnit(int i) {
short unit = designer.getRulerLengthUnit(); short unit = designer.getRulerLengthUnit();
// int resolution = ScreenResolution.getScreenResolution(); // int resolution = ScreenResolution.getScreenResolution();

37
designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java

@ -54,6 +54,9 @@ public abstract class BlockCreator<T extends TemplateBlock> extends JComponent i
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) {
return false;
}
return ComparatorUtils.equals(o.getClass().getName(), this.getClass().getName()); return ComparatorUtils.equals(o.getClass().getName(), this.getClass().getName());
} }
}); });
@ -81,7 +84,7 @@ public abstract class BlockCreator<T extends TemplateBlock> extends JComponent i
//默认大小, 报表块默认3列6行, 图表块默认330*240 //默认大小, 报表块默认3列6行, 图表块默认330*240
public abstract UnitRectangle getDefaultBlockBounds(); public abstract UnitRectangle getDefaultBlockBounds();
// 不同的Block有不同的显示器 // 不同的Block有不同的显示器
protected abstract JComponent initMonitor(); protected abstract JComponent initMonitor();
@ -97,9 +100,9 @@ public abstract class BlockCreator<T extends TemplateBlock> extends JComponent i
/** /**
* 检测按钮状态 * 检测按钮状态
* *
* @date 2015-2-5-上午11:33:46 * @date 2015-2-5-上午11:33:46
* *
*/ */
public abstract void checkButtonEnable(); public abstract void checkButtonEnable();
@ -134,31 +137,31 @@ public abstract class BlockCreator<T extends TemplateBlock> extends JComponent i
/** /**
* 获取当前工具栏组 * 获取当前工具栏组
* *
* @return 工具栏组 * @return 工具栏组
* *
* @date 2015-2-5-上午11:29:07 * @date 2015-2-5-上午11:29:07
* *
*/ */
public abstract ToolBarDef[] toolbars4Target(); public abstract ToolBarDef[] toolbars4Target();
/** /**
* 在Form的工具栏组 * 在Form的工具栏组
* *
* @return 组件数组 * @return 组件数组
* *
* @date 2015-2-5-上午11:31:46 * @date 2015-2-5-上午11:31:46
* *
*/ */
public abstract JComponent[] toolBarButton4Form(); public abstract JComponent[] toolBarButton4Form();
/** /**
* 获取当前菜单栏组 * 获取当前菜单栏组
* *
* @return 菜单栏组 * @return 菜单栏组
* *
* @date 2015-2-5-上午11:29:07 * @date 2015-2-5-上午11:29:07
* *
*/ */
public abstract MenuDef[] menus4Target(); public abstract MenuDef[] menus4Target();
@ -167,12 +170,12 @@ public abstract class BlockCreator<T extends TemplateBlock> extends JComponent i
/** /**
* 获取菜单里的快捷方式数组 * 获取菜单里的快捷方式数组
* *
* @return 菜单里的快捷方式数组 * @return 菜单里的快捷方式数组
* *
* @date 2015-2-5-上午11:27:08 * @date 2015-2-5-上午11:27:08
* *
*/ */
public abstract ShortCut[] shortcut4TemplateMenu(); public abstract ShortCut[] shortcut4TemplateMenu();
} }

53
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 聚合报表块编辑器 * @since 6.5.4 创建于2011-5-5 聚合报表块编辑器
*/ */
public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock> extends JComponent{ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock> extends JComponent{
protected PolyDesigner designer; protected PolyDesigner designer;
protected BlockCreator<U> creator; protected BlockCreator<U> creator;
protected int resolution = ScreenResolution.getScreenResolution(); protected int resolution = ScreenResolution.getScreenResolution();
protected T editComponent; protected T editComponent;
private JComponent addHeightTool;// 改变高度的组件 private JComponent addHeightTool;// 改变高度的组件
private JComponent addWidthTool; // 改变宽度的组件 private JComponent addWidthTool; // 改变宽度的组件
private JComponent moveTool; // 拖动聚合块的组件 private JComponent moveTool; // 拖动聚合块的组件
private boolean isDragging; private boolean isDragging;
private Absorptionline lineInX; private Absorptionline lineInX;
private Absorptionline lineInY; private Absorptionline lineInY;
private BlockForbiddenWindow forbiddenWindow; private BlockForbiddenWindow forbiddenWindow;
public BlockEditor(PolyDesigner designer, BlockCreator<U> creator) { public BlockEditor(PolyDesigner designer, BlockCreator<U> creator) {
@ -74,16 +74,16 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
this.moveTool = new BlockControlButton(); this.moveTool = new BlockControlButton();
this.add(BlockEditorLayout.BOTTOMCORNER, this.moveTool); this.add(BlockEditorLayout.BOTTOMCORNER, this.moveTool);
this.forbiddenWindow = new BlockForbiddenWindow(); this.forbiddenWindow = new BlockForbiddenWindow();
} }
/** /**
* 重置当前鼠标选中状态 * 重置当前鼠标选中状态
* *
*/ */
public abstract void resetSelectionAndChooseState(); public abstract void resetSelectionAndChooseState();
protected abstract T createEffective(); protected abstract T createEffective();
protected abstract Dimension getAddHeigthPreferredSize(); protected abstract Dimension getAddHeigthPreferredSize();
@ -91,9 +91,9 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
protected abstract Dimension getAddWidthPreferredSize(); protected abstract Dimension getAddWidthPreferredSize();
protected abstract void initDataChangeListener(); protected abstract void initDataChangeListener();
protected abstract RowOperationMouseHandler createRowOperationMouseHandler(); protected abstract RowOperationMouseHandler createRowOperationMouseHandler();
protected abstract ColumnOperationMouseHandler createColumnOperationMouseHandler(); protected abstract ColumnOperationMouseHandler createColumnOperationMouseHandler();
protected void addColumnRowListeners() { protected void addColumnRowListeners() {
@ -122,28 +122,31 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
initSize(); initSize();
LayoutUtils.layoutRootContainer(BlockEditor.this); LayoutUtils.layoutRootContainer(BlockEditor.this);
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) {
return false;
}
return ComparatorUtils.equals(o.getClass().getName(), this.getClass().getName()); return ComparatorUtils.equals(o.getClass().getName(), this.getClass().getName());
} }
}); });
} }
public void setDragging(boolean isDragging) { public void setDragging(boolean isDragging) {
this.isDragging = isDragging; this.isDragging = isDragging;
} }
/** /**
* 当前是否处于拖动状态 * 当前是否处于拖动状态
* *
* @return 是否处于拖动状态 * @return 是否处于拖动状态
* *
*/ */
public boolean isDragging() { public boolean isDragging() {
return this.isDragging; return this.isDragging;
} }
public void setXAbsorptionline(Absorptionline line) { public void setXAbsorptionline(Absorptionline line) {
this.lineInX = line; this.lineInX = line;
} }
@ -151,27 +154,27 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
public void setYAbsorptionline(Absorptionline line) { public void setYAbsorptionline(Absorptionline line) {
this.lineInY = line; this.lineInY = line;
} }
/** /**
* 显示禁止重叠窗口 * 显示禁止重叠窗口
* *
* @param x x坐标 * @param x x坐标
* @param y y坐标 * @param y y坐标
* *
*/ */
public void showForbiddenWindow(int x, int y){ public void showForbiddenWindow(int x, int y){
this.forbiddenWindow.showWindow(x, y); this.forbiddenWindow.showWindow(x, y);
} }
/** /**
* 隐藏禁止重叠窗口 * 隐藏禁止重叠窗口
* *
*/ */
public void hideForbiddenWindow(){ public void hideForbiddenWindow(){
this.forbiddenWindow.hideWindow(); this.forbiddenWindow.hideWindow();
} }
public void paintAbsorptionline(Graphics g) { public void paintAbsorptionline(Graphics g) {
if(lineInX != null) { if(lineInX != null) {
lineInX.paint(g,designer); lineInX.paint(g,designer);
@ -202,7 +205,7 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
public Dimension getCornerSize() { public Dimension getCornerSize() {
return new Dimension(); return new Dimension();
} }
private class BlockControlButton extends UIButton { private class BlockControlButton extends UIButton {
@Override @Override
public ButtonUI getUI() { public ButtonUI getUI() {
@ -220,4 +223,4 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
}; };
} }
} }
} }

4
designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java

@ -1,6 +1,7 @@
package com.fr.start.fx; package com.fr.start.fx;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.log.FineLoggerFactory;
import com.sun.javafx.iio.ImageFrame; import com.sun.javafx.iio.ImageFrame;
import com.sun.javafx.iio.ImageLoadListener; import com.sun.javafx.iio.ImageLoadListener;
import com.sun.javafx.iio.ImageLoader; import com.sun.javafx.iio.ImageLoader;
@ -79,6 +80,7 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader {
} }
@Override @Override
@SuppressWarnings("squid:S2142")
public PlatformImage getFrame(int index) { public PlatformImage getFrame(int index) {
while (images[index] == null) { while (images[index] == null) {
synchronized (this) { synchronized (this) {
@ -86,7 +88,7 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader {
try { try {
this.wait(); this.wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
} }

1
designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java

@ -55,6 +55,7 @@ public class SplashFxWindow extends Application {
* *
* @return 运行实例 * @return 运行实例
*/ */
@SuppressWarnings("squid:S2142")
public static SplashFxWindow waitForStartUpTest() { public static SplashFxWindow waitForStartUpTest() {
try { try {
LATCH.await(); LATCH.await();

Loading…
Cancel
Save