Browse Source

Merge pull request #1084 in DESIGN/design from ~KERRY/design_10.0:feature/10.0 to feature/10.0

* commit 'afdd96c1a36094e1b073695def74b287ffa79e69':
  REPORT-20327 sonar问题修复
persist/11.0
kerry 5 years ago
parent
commit
ece325042e
  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 {
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();

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
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<T extends TemplateBlock> extends JComponent i
//默认大小, 报表块默认3列6行, 图表块默认330*240
public abstract UnitRectangle getDefaultBlockBounds();
// 不同的Block有不同的显示器
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
*
*
*/
public abstract void checkButtonEnable();
@ -134,31 +137,31 @@ public abstract class BlockCreator<T extends TemplateBlock> 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<T extends TemplateBlock> extends JComponent i
/**
* 获取菜单里的快捷方式数组
*
*
* @return 菜单里的快捷方式数组
*
*
* @date 2015-2-5-上午11:27:08
*
*
*/
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 聚合报表块编辑器
*/
public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock> extends JComponent{
protected PolyDesigner designer;
protected BlockCreator<U> 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<U> creator) {
@ -74,16 +74,16 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
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<T extends JComponent,U extends TemplateBlock>
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<T extends JComponent,U extends TemplateBlock>
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<T extends JComponent,U extends TemplateBlock>
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<T extends JComponent,U extends TemplateBlock>
public Dimension getCornerSize() {
return new Dimension();
}
private class BlockControlButton extends UIButton {
@Override
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;
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);
}
}
}

1
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();

Loading…
Cancel
Save