Browse Source

修正几个不规范的地方

master
fanglei 8 years ago
parent
commit
58ad4ecbf0
  1. 2
      designer/src/com/fr/poly/hanlder/BottomCornerMouseHanlder.java
  2. 2
      designer_base/src/com/fr/design/beans/location/MoveUtils.java
  3. 17
      designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java
  4. 14
      designer_base/src/com/fr/design/gui/itable/PropertyGroup.java
  5. 10
      designer_form/src/com/fr/design/designer/beans/location/Inner.java
  6. 5
      designer_form/src/com/fr/design/mainframe/ConnectorHelper.java
  7. 3
      designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java
  8. 3
      designer_form/src/com/fr/design/mainframe/MobileWidgetTable.java

2
designer/src/com/fr/poly/hanlder/BottomCornerMouseHanlder.java

@ -170,7 +170,7 @@ public class BottomCornerMouseHanlder extends MouseInputAdapter {
* @return 重叠 * @return 重叠
*/ */
@Override @Override
public boolean isWidgetsIntersects() { public boolean isWidgetsIntersected() {
return false; return false;
} }

2
designer_base/src/com/fr/design/beans/location/MoveUtils.java

@ -84,7 +84,7 @@ public class MoveUtils {
* 获取designer内部组件是否重叠的标志位 * 获取designer内部组件是否重叠的标志位
* @return 重叠 * @return 重叠
*/ */
boolean isWidgetsIntersects(); //TODO 消除PMD检查错误,把getWidgetsIntersects改成isWidgetsIntersects boolean isWidgetsIntersected();
/** /**
* 获取designer相对屏幕的位置 * 获取designer相对屏幕的位置

17
designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java

@ -28,23 +28,17 @@ public abstract class AbstractPropertyTable extends JTable {
// // 所有数据组, 把数据分组,一个可折叠的项里面的所有行 为一组 // // 所有数据组, 把数据分组,一个可折叠的项里面的所有行 为一组
protected ArrayList<PropertyGroup> groups; protected ArrayList<PropertyGroup> groups;
protected TableModel default_table_model;
// 属性表被选中的行加一个浅蓝色的背景 // 属性表被选中的行加一个浅蓝色的背景
public static final Color PROPERTY_SELECTION_BACKGROUND = new Color(153, 204, 255); public static final Color PROPERTY_SELECTION_BACKGROUND = new Color(153, 204, 255);
// 属性表的行高 // 属性表的行高
public static final int PROPERTY_TABLE_ROW_HEIGHT = 22; public static final int PROPERTY_TABLE_ROW_HEIGHT = 22;
private static final int PROPERTY_ICON_WIDTH = 10;
public AbstractPropertyTable() { public AbstractPropertyTable() {
this.setTableProperties(); this.setTableProperties();
this.initPopup(); this.initPopup();
default_table_model = new DefaultTableModel(); this.setModel(new DefaultTableModel());
this.setModel(default_table_model);
} }
/**
* 设置表格属性
*/
private void setTableProperties() { private void setTableProperties() {
JTableHeader header = getTableHeader(); JTableHeader header = getTableHeader();
header.setReorderingAllowed(false); header.setReorderingAllowed(false);
@ -86,8 +80,11 @@ public abstract class AbstractPropertyTable extends JTable {
PropertyGroup group = groups.get(pIndex.x); PropertyGroup group = groups.get(pIndex.x);
//如果是标题行 //如果是标题行
if (pIndex.y == 0) { if (pIndex.y == 0) {
//采用group中定义好的标题行渲染器 if (column == 0) {
return group.getRenderer(); return group.getFirstRenderer();
} else {
return group.getSecondRenderer();
}
} else { } else {
//如果是非标题行第一列,采用默认渲染器 //如果是非标题行第一列,采用默认渲染器
if (column == 0) { if (column == 0) {
@ -183,7 +180,7 @@ public abstract class AbstractPropertyTable extends JTable {
int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint()); int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint());
if (row != -1) { if (row != -1) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < PROPERTY_ICON_WIDTH) { if (pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < 10) {
toggleCollapse(pIndex.x); toggleCollapse(pIndex.x);
} }
} }

14
designer_base/src/com/fr/design/gui/itable/PropertyGroup.java

@ -12,11 +12,13 @@ public class PropertyGroup {
private GroupModel model; // 描述这个属性组中的数据model private GroupModel model; // 描述这个属性组中的数据model
private String name; // 这组属性的标题名称 private String name; // 这组属性的标题名称
private boolean collapsed; // 这组属性是否折叠 private boolean collapsed; // 这组属性是否折叠
private GroupRenderer renderer; // 属性标题渲染器 private GroupRenderer renderer1;
private GroupRenderer renderer2;
public PropertyGroup(GroupModel model) { public PropertyGroup(GroupModel model) {
this(model.getGroupName(), model, false); this(model.getGroupName(), model, false);
renderer = new GroupRenderer(); renderer1 = new GroupRenderer();
renderer2 = new GroupRenderer();
} }
public PropertyGroup(String name, GroupModel model, boolean collapsed) { public PropertyGroup(String name, GroupModel model, boolean collapsed) {
@ -49,8 +51,12 @@ public class PropertyGroup {
this.collapsed = collapsed; this.collapsed = collapsed;
} }
public TableCellRenderer getRenderer() { public TableCellRenderer getFirstRenderer() {
return renderer; return renderer1;
}
public TableCellRenderer getSecondRenderer() {
return renderer2;
} }
} }

10
designer_form/src/com/fr/design/designer/beans/location/Inner.java

@ -46,12 +46,10 @@ public class Inner extends AccessDirection {
return new Point(x, y); return new Point(x, y);
} }
//TODO 原先这个类是通过一个new一个匿名类继承RectangleDesigner接口实现的,但是报了方法超过50行的PMD错误 private class RectDesigner implements RectangleDesigner {
//TODO 暂时就先这样命名,请原作者看到后重新命名
private class RectangleDesigner1 implements RectangleDesigner {
private FormDesigner designer = null; private FormDesigner designer = null;
public RectangleDesigner1(FormDesigner designer) { public RectDesigner(FormDesigner designer) {
this.designer = designer; this.designer = designer;
} }
@ -101,7 +99,7 @@ public class Inner extends AccessDirection {
* @return 重叠 * @return 重叠
*/ */
@Override @Override
public boolean isWidgetsIntersects() { public boolean isWidgetsIntersected() {
return designer.isWidgetsIntersect(); return designer.isWidgetsIntersect();
} }
@ -138,7 +136,7 @@ public class Inner extends AccessDirection {
@Override @Override
protected void sorptionPoint(Point point, Rectangle current_bounds, final FormDesigner designer) { protected void sorptionPoint(Point point, Rectangle current_bounds, final FormDesigner designer) {
RectangleDesigner1 rd = new RectangleDesigner1(designer); RectDesigner rd = new RectDesigner(designer);
//判断当前操作的是不是参数面板,要特殊处理 //判断当前操作的是不是参数面板,要特殊处理
boolean isParameterLayout = ((XCreator)(designer.getSelectionModel().getSelection().getSelectedCreator().getParent())).acceptType(XWParameterLayout.class); boolean isParameterLayout = ((XCreator)(designer.getSelectionModel().getSelection().getSelectedCreator().getParent())).acceptType(XWParameterLayout.class);
point.setLocation(MoveUtils.sorption(point.x, point.y, current_bounds.width, current_bounds.height, rd, isParameterLayout)); point.setLocation(MoveUtils.sorption(point.x, point.y, current_bounds.width, current_bounds.height, rd, isParameterLayout));

5
designer_form/src/com/fr/design/mainframe/ConnectorHelper.java

@ -19,8 +19,7 @@ public class ConnectorHelper {
public static final int NEAR = 5; public static final int NEAR = 5;
private static double ratio = 0.5; private static double ratio = 0.5;
// TODO 为了消除魔术数错误,我不清楚这个15代表什么,先这样命名了,原作者看到了请改一下 private final static int ADSORPTION = 15; // 吸附距离
private final static int MAGICNUMBER = 15;
private ArrayList<Point> drawingPoint; private ArrayList<Point> drawingPoint;
private FormDesigner designer; private FormDesigner designer;
private boolean drawing; private boolean drawing;
@ -88,7 +87,7 @@ public class ConnectorHelper {
public void createDefalutLine() { public void createDefalutLine() {
if (drawingPoint != null if (drawingPoint != null
&& drawingPoint.size() > 1 && drawingPoint.size() > 1
&& ConnectorCreator.getMinimumDistance(drawingPoint.get(0), drawingPoint.get(drawingPoint.size() - 1)) > MAGICNUMBER) { && ConnectorCreator.getMinimumDistance(drawingPoint.get(0), drawingPoint.get(drawingPoint.size() - 1)) > ADSORPTION) {
((XWAbsoluteLayout) designer.getRootComponent()).addConnector(new Connector().addAll(drawingPoint)); ((XWAbsoluteLayout) designer.getRootComponent()).addConnector(new Connector().addAll(drawingPoint));
} }
drawingPoint = null; drawingPoint = null;

3
designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java

@ -82,9 +82,6 @@ class MobileParaWidgetTable extends JTable {
add(moveComponent); add(moveComponent);
} }
/**
* 设置表格属性
*/
private void setTableProperties() { private void setTableProperties() {
JTableHeader header = getTableHeader(); JTableHeader header = getTableHeader();
header.setReorderingAllowed(false); header.setReorderingAllowed(false);

3
designer_form/src/com/fr/design/mainframe/MobileWidgetTable.java

@ -67,9 +67,6 @@ public class MobileWidgetTable extends JTable {
add(moveComponent); add(moveComponent);
} }
/**
* 设置表格属性
*/
private void setTableProperties() { private void setTableProperties() {
JTableHeader header = getTableHeader(); JTableHeader header = getTableHeader();
header.setReorderingAllowed(false); header.setReorderingAllowed(false);

Loading…
Cancel
Save