From 9dd806a40ff153526e1f6199bfcfd19e050c4127 Mon Sep 17 00:00:00 2001 From: neil Date: Mon, 10 Apr 2017 18:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=8C=20?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/beans/location/MoveUtils.java | 1130 ++++---- .../com/fr/design/locale/designer.properties | 19 +- .../design/locale/designer_en_US.properties | 18 +- .../design/locale/designer_ja_JP.properties | 17 +- .../design/locale/designer_ko_KR.properties | 17 +- .../design/locale/designer_zh_CN.properties | 20 +- .../design/locale/designer_zh_TW.properties | 22 +- .../fr/design/chart/axis/MinMaxValuePane.java | 71 +- .../layout/FRAbsoluteLayoutAdapter.java | 698 ++--- .../adapters/layout/FRFitLayoutAdapter.java | 2385 +++++++++-------- .../beans/location/AccessDirection.java | 330 +-- 11 files changed, 2380 insertions(+), 2347 deletions(-) diff --git a/designer_base/src/com/fr/design/beans/location/MoveUtils.java b/designer_base/src/com/fr/design/beans/location/MoveUtils.java index 91a62ed5f..d89848446 100644 --- a/designer_base/src/com/fr/design/beans/location/MoveUtils.java +++ b/designer_base/src/com/fr/design/beans/location/MoveUtils.java @@ -1,544 +1,588 @@ -/* - * Copyright(c) 2001-2011, FineReport Inc, All Rights Reserved. - */ -package com.fr.design.beans.location; - -import javax.swing.*; -import java.awt.*; -import java.util.ArrayList; - -/** - * Created by IntelliJ IDEA. - * - * @author: Richer - * @since : 6.5.5 Date: 11-7-1 Time: 下午2:22 - */ -public class MoveUtils { - - public static final int SORPTION_UNIT = 5; - private static final int EQUIDISTANTLINE_UNIT = 4; - - private static ArrayList equidistantLines = new ArrayList<>(); - - private MoveUtils() { - - } - - public interface RectangleDesigner { - - /** - * 获取块边界的迭代器 - * - * @return 块边界的迭代器 - * @date 2015-2-12-下午2:43:47 - */ - RectangleIterator createRectangleIterator(); - - /** - * 设置X轴的线 - * - * @param line 连接线 - * @date 2015-2-12-下午2:44:04 - */ - void setXAbsorptionline(Absorptionline line); - - /** - * 设置Y轴的线 - * - * @param line 连接线 - * @date 2015-2-12-下午2:44:04 - */ - void setYAbsorptionline(Absorptionline line); - - /** - * 获取当前选中块的垂直线数组 - * - * @return 块的垂直线数组 - */ - int[] getVerticalLine(); - - /** - * 获取当前选中块的水平线数组 - * - * @return 块的水平线数组 - */ - int[] getHorizontalLine(); - - /** - * 设置designer内部组件是否重叠的标志位 - * - * @param isIntersects 是否重叠 - */ - void setWidgetsIntersected(boolean isIntersects); - - /** - * 获取designer内部组件是否重叠的标志位 - * - * @return 重叠 - */ - boolean isWidgetsIntersected(); - - /** - * 获取designer相对屏幕的位置 - * - * @return 位置 - */ - Point getDesignerLocationOnScreen(); - - /** - * 设置等距线 - * - * @param line 吸附线 - */ - void setEquidistantLine(Absorptionline line); - - /** - * 获取设计器垂直滚动条的值 - * - * @return 滚动条的值 - */ - int getDesignerScrollVerticalValue(); - - /** - * 获取设计器水平滚动条的值 - * - * @return 滚动条的值 - */ - int getDesignerScrollHorizontalValue(); - } - - public interface RectangleIterator { - - /** - * 是否存在下一个块 - * - * @return 是否存在下一个块 - * @date 2015-2-12-下午2:41:32 - */ - boolean hasNext(); - - /** - * 获取下一个块的bounds - * - * @return 下一个块的bounds - * @date 2015-2-12-下午2:41:55 - */ - Rectangle nextRectangle(); - - /** - * 获取块的垂直线数组 - * - * @return 块的垂直线数组 - * @date 2015-2-12-下午2:42:27 - */ - int[] getVerticalLine(); - - /** - * 获取块的水平线数组 - * - * @return 块的水平线数组 - * @date 2015-2-12-下午2:42:27 - */ - int[] getHorizontalLine(); - } - - private static class PlacePointing { - public PlacePointing(int x) { - this.palce = x; - } - - private boolean isFind() { - return direction != -1; - } - - private int palce; - private int direction = -1; - } - - private static void findX(PlacePointing px, Rectangle bounds, int left, int right, int width) { - if (px.isFind()) { - return; - } - if (Math.abs(bounds.x + bounds.width / 2 - (left + right) / 2) <= SORPTION_UNIT) { - px.palce = bounds.x + bounds.width / 2 - width / 2; - px.direction = SwingConstants.CENTER; - } - int x1 = bounds.x; - if (Math.abs(x1 - left) <= SORPTION_UNIT) { - px.palce = x1; - px.direction = SwingConstants.LEFT; - } - if (Math.abs(x1 - right) <= SORPTION_UNIT) { - px.palce = x1 - width; - px.direction = SwingConstants.RIGHT; - } - int x2 = bounds.x + bounds.width; - if (Math.abs(x2 - left) <= SORPTION_UNIT) { - px.palce = x2; - px.direction = SwingConstants.LEFT; - } - if (Math.abs(x2 - right) <= SORPTION_UNIT) { - px.palce = x2 - width; - px.direction = SwingConstants.RIGHT; - } - if (Math.abs(bounds.x + bounds.width / 2 - left) <= SORPTION_UNIT) { - px.palce = bounds.x + bounds.width / 2; - px.direction = SwingConstants.LEFT; - } - if (Math.abs(bounds.x + bounds.width / 2 - right) <= SORPTION_UNIT) { - px.palce = bounds.x + bounds.width / 2 - width; - px.direction = SwingConstants.RIGHT; - } - } - - private static void findY(PlacePointing py, Rectangle bounds, int top, int bottom, int height) { - if (py.isFind()) { - return; - } - - if (Math.abs(bounds.y + bounds.height / 2 - (top + bottom) / 2) <= SORPTION_UNIT) { - py.palce = bounds.y + bounds.height / 2 - height / 2; - py.direction = SwingConstants.CENTER; - } - int y1 = bounds.y; - if (Math.abs(y1 - top) <= SORPTION_UNIT) { - py.palce = y1; - py.direction = SwingConstants.TOP; - } - if (Math.abs(y1 - bottom) <= SORPTION_UNIT) { - py.palce = y1 - height; - py.direction = SwingConstants.BOTTOM; - } - int y2 = bounds.y + bounds.height; - if (Math.abs(y2 - top) <= SORPTION_UNIT) { - py.palce = y2; - py.direction = SwingConstants.TOP; - } - if (Math.abs(y2 - bottom) <= SORPTION_UNIT) { - py.palce = y2 - height; - py.direction = SwingConstants.BOTTOM; - } - if (Math.abs(bounds.y + bounds.height / 2 - top) <= SORPTION_UNIT) { - py.palce = bounds.y + bounds.height / 2; - py.direction = SwingConstants.TOP; - } - if (Math.abs(bounds.y + bounds.height / 2 - bottom) <= SORPTION_UNIT) { - py.palce = bounds.y + bounds.height / 2 - height; - py.direction = SwingConstants.BOTTOM; - } - } - - private static void findEquidistantLine(Rectangle bounds, int left, int top, int height, int width) { - //最近的距离与坐标 - EquidistantLine equidistantLineInfo = new EquidistantLine(0, 0, 0); - //等距线从各边中点画出,先要判断是不是在范围内 - int topMiddleX = left + width / 2; - int leftMiddleY = top + height / 2; - if ((topMiddleX > bounds.getX()) && (topMiddleX < (bounds.getX() + bounds.getWidth()))) { - //当前操作rec在bounds的下方 - if (top > (bounds.getY() + bounds.getHeight())) { - equidistantLineInfo.setDistance(top - (bounds.y + bounds.height)); - equidistantLineInfo.setReference(bounds.y + bounds.height); - equidistantLineInfo.setDirection(SwingConstants.TOP); - } - //当前操作rec在bounds上方 - if ((top + height) < bounds.getY()) { - equidistantLineInfo.setDistance(bounds.y - (top + height)); - equidistantLineInfo.setReference(bounds.y); - equidistantLineInfo.setDirection(SwingConstants.BOTTOM); - } - } else if ((leftMiddleY > bounds.getY()) && (leftMiddleY < (bounds.getY() + bounds.getHeight()))) { - //当前操作rec在bounds的右侧 - if (left > (bounds.getX() + bounds.getWidth())) { - equidistantLineInfo.setDistance(left - (bounds.x + bounds.width)); - equidistantLineInfo.setReference(bounds.x + bounds.width); - equidistantLineInfo.setDirection(SwingConstants.LEFT); - } - //当前操作rec在bounds的左侧 - if ((left + width) < bounds.getX()) { - equidistantLineInfo.setDistance(bounds.x - (left + width)); - equidistantLineInfo.setReference(bounds.x); - equidistantLineInfo.setDirection(SwingConstants.RIGHT); - } - } - if (equidistantLineInfo.getDistance() > 0) { - equidistantLines.add(equidistantLineInfo); - } - } - - - /** - * 吸附 - * - * @param x x坐标 - * @param y y坐标 - * @param width 宽度 - * @param height 高度 - * @param designer 块设计器 - * @return 吸附后坐标 - * @date 2015-2-12-下午2:39:16 - */ - public static Point sorption(int x, int y, int width, int height, RectangleDesigner designer, boolean isParameterLayout) { - - int left = x, top = y, bottom = top + height, right = left + width; - - Rectangle operatingRectangle = new Rectangle(x, y, width, height); - - equidistantLines.clear(); - - PlacePointing px = new PlacePointing(x); - PlacePointing py = new PlacePointing(y); - - PlacePointing pEquidistantX = new PlacePointing(x); - PlacePointing pEquidistantY = new PlacePointing(y); - - RectangleIterator iterator = designer.createRectangleIterator(); - - java.util.List cacheRecs = new ArrayList(); - while (iterator.hasNext()) { - Rectangle bounds = iterator.nextRectangle(); - cacheRecs.add(bounds); - findX(px, bounds, left, right, width); - findY(py, bounds, top, bottom, height); - - if (!isParameterLayout) { - findEquidistantLine(bounds, left, top, height, width); - } - } - - createXAbsorptionline(px, designer, width, cacheRecs); - createYAbsorptionline(py, designer, height, cacheRecs); - operatingRectangle.x = px.palce; - operatingRectangle.y = py.palce; - createEquidistantLine(pEquidistantX, pEquidistantY, operatingRectangle, designer); - Point sorptionPoint = new Point(px.palce, py.palce); - if (!px.isFind()) { - sorptionPoint.x = pEquidistantX.palce; - } - if (!py.isFind()) { - sorptionPoint.y = pEquidistantY.palce; - } - return sorptionPoint; - } - - - private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List cacheRecs) { - Absorptionline line = null; - RectangleIterator iterator = designer.createRectangleIterator(); - int[] selfVertical = designer.getVerticalLine(); - if (px.direction == SwingConstants.CENTER) { - line = Absorptionline.createXMidAbsorptionline(px.palce + width / 2); - int left = px.palce; - int right = px.palce + width; - for (Rectangle bounds : cacheRecs) { - if (bounds.x == left || bounds.x + bounds.width == left) { - line.setFirstLine(left); - } - if (bounds.x == right || bounds.x + bounds.width == right) { - line.setSecondLine(right); - } - updateVerticalLine(selfVertical, iterator, line); - if (line.isFull()) { - break; - } - } - } else if (px.direction == SwingConstants.LEFT || px.direction == SwingConstants.RIGHT) { - int left = px.direction == SwingConstants.LEFT ? px.palce + width : px.palce; - line = Absorptionline.createXAbsorptionline(px.direction == SwingConstants.LEFT ? px.palce : px.palce + width); - int middle = px.palce + width / 2; - for (Rectangle bounds : cacheRecs) { - if (bounds.x == left || bounds.x + bounds.width == left) { - line.setSecondLine(left); - } - if (bounds.x + bounds.width / 2 == middle) { - line.setMidLine(middle); - } - updateVerticalLine(selfVertical, iterator, line); - if (line.isFull()) { - break; - } - } - } - designer.setXAbsorptionline(line); - } - - private static void createYAbsorptionline(PlacePointing py, RectangleDesigner designer, int height, java.util.List cacheRecs) { - Absorptionline line = null; - RectangleIterator iterator = designer.createRectangleIterator(); - int[] selfHorizontal = designer.getHorizontalLine(); - if (py.direction == SwingConstants.CENTER) { - line = Absorptionline.createYMidAbsorptionline(py.palce + height / 2); - int top = py.palce; - int bottom = py.palce + height; - for (Rectangle bounds : cacheRecs) { - if (bounds.y == top || bounds.y + bounds.height == top) { - line.setFirstLine(top); - } - if (bounds.y == bottom || bounds.y + bounds.height == bottom) { - line.setSecondLine(bottom); - } - updateHorizontalLine(selfHorizontal, iterator, line); - if (line.isFull()) { - break; - } - } - } else if (py.direction == SwingConstants.TOP || py.direction == SwingConstants.BOTTOM) { - int top = py.direction == SwingConstants.TOP ? py.palce + height : py.palce; - line = Absorptionline.createYAbsorptionline(py.direction == SwingConstants.TOP ? py.palce : py.palce + height); - int middle = py.palce + height / 2; - for (Rectangle bounds : cacheRecs) { - if (bounds.y == top || bounds.y + bounds.height == top) { - line.setSecondLine(top); - } - if (bounds.y + bounds.height / 2 == middle) { - line.setMidLine(middle); - } - updateHorizontalLine(selfHorizontal, iterator, line); - if (line.isFull()) { - break; - } - } - } - designer.setYAbsorptionline(line); - } - - private static void createEquidistantLine(PlacePointing px, PlacePointing py, Rectangle operatingRectangle, RectangleDesigner designer) { - processEquidistantLinesList(px, py, operatingRectangle); - Absorptionline line = null; - if (equidistantLines.size() > 0) { - int top = -1; - int left = -1; - int bottom = -1; - int right = -1; - for (int i = 0; i < equidistantLines.size(); i++) { - if (equidistantLines.get(i).getDirection() == SwingConstants.TOP) { - top = equidistantLines.get(i).getReference(); - } - if (equidistantLines.get(i).getDirection() == SwingConstants.LEFT) { - left = equidistantLines.get(i).getReference(); - } - if (equidistantLines.get(i).getDirection() == SwingConstants.BOTTOM) { - bottom = equidistantLines.get(i).getReference(); - } - if (equidistantLines.get(i).getDirection() == SwingConstants.RIGHT) { - right = equidistantLines.get(i).getReference(); - } - } - operatingRectangle.x -= designer.getDesignerScrollHorizontalValue(); - operatingRectangle.y -= designer.getDesignerScrollVerticalValue(); - line = Absorptionline.createEquidistantAbsorptionline(operatingRectangle, - top - designer.getDesignerScrollVerticalValue(), - left - designer.getDesignerScrollHorizontalValue(), - bottom - designer.getDesignerScrollVerticalValue(), - right - designer.getDesignerScrollHorizontalValue()); - } - designer.setEquidistantLine(line); - } - - private static void processEquidistantLinesList(PlacePointing pEquidistantX, PlacePointing pEquidistantY, Rectangle operatingRectangle) { - EquidistantLine[] equidistantLines1 = new EquidistantLine[EQUIDISTANTLINE_UNIT]; - //先按方向处理,只保留四个方向上距离最近 - for (int count = 0; count < equidistantLines.size(); count++) { - for (int direction = 0; direction < EQUIDISTANTLINE_UNIT; direction++) { - if (equidistantLines.get(count).getDirection() == (direction + 1)) {//direction 1,2,3,4 分别对应top,left,bottom,right - if (equidistantLines1[direction] != null - && equidistantLines1[direction].getDistance() > equidistantLines.get(count).getDistance() - || equidistantLines1[direction] == null) { - equidistantLines1[direction] = equidistantLines.get(count); - } - } - } - } - - equidistantLines.clear(); - //找list中横纵分别等距的组合 - if (equidistantLines1[0] != null && equidistantLines1[2] != null) {//top, bottom - int offset = equidistantLines1[0].getDistance() - equidistantLines1[2].getDistance(); - if (Math.abs(offset) <= SORPTION_UNIT * 2) { - pEquidistantY.direction = SwingConstants.TOP; - equidistantLines.add(equidistantLines1[0]); - equidistantLines.add(equidistantLines1[2]); - pEquidistantY.palce = operatingRectangle.y - offset / 2; - operatingRectangle.y = pEquidistantY.palce; - } - } - if (equidistantLines1[1] != null && equidistantLines1[3] != null) {//left, right - int offset = equidistantLines1[1].getDistance() - equidistantLines1[3].getDistance(); - if (Math.abs(offset) <= SORPTION_UNIT * 2) { - pEquidistantX.direction = SwingConstants.LEFT; - equidistantLines.add(equidistantLines1[1]); - equidistantLines.add(equidistantLines1[3]); - pEquidistantX.palce = operatingRectangle.x - offset / 2; - operatingRectangle.x = pEquidistantX.palce; - } - } - } - - //更新纵向行列线 - private static void updateVerticalLine(int[] selfVertical, RectangleIterator iterator, Absorptionline line) { - int[] targetArray = iterator.getVerticalLine(); - if (intersectArrays(targetArray, selfVertical)) { - line.setVerticalLines(targetArray); - } - } - - //更新横向行列线 - private static void updateHorizontalLine(int[] selfHorizontal, RectangleIterator iterator, Absorptionline line) { - int[] targetArray = iterator.getHorizontalLine(); - if (intersectArrays(targetArray, selfHorizontal)) { - line.setHorizontalLines(targetArray); - } - } - - //检测两个数组是否有相交的部分 - private static boolean intersectArrays(int[] targetArray, int[] selfArray) { - for (int i : targetArray) { - for (int j : selfArray) { - if (i == j) { - return true; - } - } - } - - return false; - } - - private static class EquidistantLine { - //与操作rectangle的距离 - private int distance; - //参考rectangle的位置 - private int reference; - //等距线的方向 - private int direction; - - EquidistantLine(int distance, int reference, int direction) { - this.distance = distance; - this.reference = reference; - this.direction = direction; - } - - public void setDistance(int distance) { - this.distance = distance; - } - - public int getDistance() { - return this.distance; - } - - public void setReference(int reference) { - this.reference = reference; - } - - public int getReference() { - return this.reference; - } - - public void setDirection(int direction) { - this.direction = direction; - } - - public int getDirection() { - return this.direction; - } - } +/* + * Copyright(c) 2001-2011, FineReport Inc, All Rights Reserved. + */ +package com.fr.design.beans.location; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; + +/** + * Created by IntelliJ IDEA. + * + * @author: Richer + * @since : 6.5.5 Date: 11-7-1 Time: 下午2:22 + */ +public class MoveUtils { + + public static final int SORPTION_UNIT = 5; + private static final int EQUIDISTANTLINE_UNIT = 4; + + public static WidgetForbidWindow widgetForbidWindow = new WidgetForbidWindow(); + + public static ArrayList equidistantLines = new ArrayList<>(); + + private MoveUtils() { + + } + + public interface RectangleDesigner { + + /** + * 获取块边界的迭代器 + * + * @return 块边界的迭代器 + * + * @date 2015-2-12-下午2:43:47 + * + */ + RectangleIterator createRectangleIterator(); + + /** + * 设置X轴的线 + * + * @param line 连接线 + * + * @date 2015-2-12-下午2:44:04 + * + */ + void setXAbsorptionline(Absorptionline line); + + /** + * 设置Y轴的线 + * + * @param line 连接线 + * + * @date 2015-2-12-下午2:44:04 + * + */ + void setYAbsorptionline(Absorptionline line); + + /** + * 获取当前选中块的垂直线数组 + * + * @return 块的垂直线数组 + * + */ + int[] getVerticalLine(); + + /** + * 获取当前选中块的水平线数组 + * + * @return 块的水平线数组 + * + */ + int[] getHorizontalLine(); + + /** + * 设置designer内部组件是否重叠的标志位 + * @param isIntersects 是否重叠 + */ + void setWidgetsIntersected(boolean isIntersects); + + /** + * 获取designer内部组件是否重叠的标志位 + * @return 重叠 + */ + boolean isWidgetsIntersected(); + + /** + * 获取designer相对屏幕的位置 + * @return 位置 + */ + Point getDesignerLocationOnScreen(); + + /** + * 设置等距线 + * @param line 吸附线 + */ + void setEquidistantLine(Absorptionline line); + + /** + * 获取设计器垂直滚动条的值 + * @return 滚动条的值 + */ + int getDesignerScrollVerticalValue(); + + /** + * 获取设计器水平滚动条的值 + * @return 滚动条的值 + */ + int getDesignerScrollHorizontalValue(); + } + + public interface RectangleIterator { + + /** + * 是否存在下一个块 + * + * @return 是否存在下一个块 + * + * @date 2015-2-12-下午2:41:32 + * + */ + boolean hasNext(); + + /** + * 获取下一个块的bounds + * + * @return 下一个块的bounds + * + * @date 2015-2-12-下午2:41:55 + * + */ + Rectangle nextRectangle(); + + /** + * 获取块的垂直线数组 + * + * @return 块的垂直线数组 + * + * @date 2015-2-12-下午2:42:27 + * + */ + int[] getVerticalLine(); + + /** + * 获取块的水平线数组 + * + * @return 块的水平线数组 + * + * @date 2015-2-12-下午2:42:27 + * + */ + int[] getHorizontalLine(); + } + + private static class PlacePointing { + public PlacePointing(int x) { + this.palce = x; + } + + private boolean isFind() { + return direction != -1; + } + + private int palce; + private int direction = -1; + } + + private static void findX(PlacePointing px, Rectangle bounds, int left, int right, int width) { + if (px.isFind()) { + return; + } + if (Math.abs(bounds.x + bounds.width / 2 - (left + right) / 2) <= SORPTION_UNIT) { + px.palce = bounds.x + bounds.width / 2 - width / 2; + px.direction = SwingConstants.CENTER; + } + int x1 = bounds.x; + if (Math.abs(x1 - left) <= SORPTION_UNIT) { + px.palce = x1; + px.direction = SwingConstants.LEFT; + } + if (Math.abs(x1 - right) <= SORPTION_UNIT) { + px.palce = x1 - width; + px.direction = SwingConstants.RIGHT; + } + int x2 = bounds.x + bounds.width; + if (Math.abs(x2 - left) <= SORPTION_UNIT) { + px.palce = x2; + px.direction = SwingConstants.LEFT; + } + if (Math.abs(x2 - right) <= SORPTION_UNIT) { + px.palce = x2 - width; + px.direction = SwingConstants.RIGHT; + } + if (Math.abs(bounds.x + bounds.width / 2 - left) <= SORPTION_UNIT) { + px.palce = bounds.x + bounds.width / 2; + px.direction = SwingConstants.LEFT; + } + if (Math.abs(bounds.x + bounds.width / 2 - right) <= SORPTION_UNIT) { + px.palce = bounds.x + bounds.width / 2 - width; + px.direction = SwingConstants.RIGHT; + } + } + + private static void findY(PlacePointing py, Rectangle bounds, int top, int bottom, int height) { + if (py.isFind()) { + return; + } + + if (Math.abs(bounds.y + bounds.height / 2 - (top + bottom) / 2) <= SORPTION_UNIT) { + py.palce = bounds.y + bounds.height / 2 - height / 2; + py.direction = SwingConstants.CENTER; + } + int y1 = bounds.y; + if (Math.abs(y1 - top) <= SORPTION_UNIT) { + py.palce = y1; + py.direction = SwingConstants.TOP; + } + if (Math.abs(y1 - bottom) <= SORPTION_UNIT) { + py.palce = y1 - height; + py.direction = SwingConstants.BOTTOM; + } + int y2 = bounds.y + bounds.height; + if (Math.abs(y2 - top) <= SORPTION_UNIT) { + py.palce = y2; + py.direction = SwingConstants.TOP; + } + if (Math.abs(y2 - bottom) <= SORPTION_UNIT) { + py.palce = y2 - height; + py.direction = SwingConstants.BOTTOM; + } + if (Math.abs(bounds.y + bounds.height / 2 - top) <= SORPTION_UNIT) { + py.palce = bounds.y + bounds.height / 2; + py.direction = SwingConstants.TOP; + } + if (Math.abs(bounds.y + bounds.height / 2 - bottom) <= SORPTION_UNIT) { + py.palce = bounds.y + bounds.height / 2 - height; + py.direction = SwingConstants.BOTTOM; + } + } + + private static void findEquidistantLine(Rectangle bounds, int left, int top, int height, int width) { + //最近的距离与坐标 + EquidistantLine equidistantLineInfo = new EquidistantLine(0, 0, 0); + //等距线从各边中点画出,先要判断是不是在范围内 + int topMiddleX = left + width / 2; + int leftMiddleY = top + height / 2; + if ((topMiddleX > bounds.getX()) && (topMiddleX < (bounds.getX() + bounds.getWidth()))){ + //当前操作rec在bounds的下方 + if (top > (bounds.getY() + bounds.getHeight())){ + equidistantLineInfo.setDistance(top - (bounds.y + bounds.height)); + equidistantLineInfo.setReference(bounds.y + bounds.height); + equidistantLineInfo.setDirection(SwingConstants.TOP); + } + //当前操作rec在bounds上方 + if ((top + height) < bounds.getY()){ + equidistantLineInfo.setDistance(bounds.y - (top + height)); + equidistantLineInfo.setReference(bounds.y); + equidistantLineInfo.setDirection(SwingConstants.BOTTOM); + } + } + else if ((leftMiddleY > bounds.getY()) && (leftMiddleY < (bounds.getY() + bounds.getHeight()))){ + //当前操作rec在bounds的右侧 + if (left > (bounds.getX() + bounds.getWidth())){ + equidistantLineInfo.setDistance(left - (bounds.x + bounds.width)); + equidistantLineInfo.setReference(bounds.x + bounds.width); + equidistantLineInfo.setDirection(SwingConstants.LEFT); + } + //当前操作rec在bounds的左侧 + if ((left + width) < bounds.getX()){ + equidistantLineInfo.setDistance(bounds.x - (left + width)); + equidistantLineInfo.setReference(bounds.x); + equidistantLineInfo.setDirection(SwingConstants.RIGHT); + } + } + if(equidistantLineInfo.getDistance() > 0) { + equidistantLines.add(equidistantLineInfo); + } + } + + public static void displayForbidWindow(int x, int y) { + widgetForbidWindow.showWindow(x, y); + } + + public static void hideForbidWindow() { + widgetForbidWindow.hideWindow(); + } + + /** + * 吸附 + * + * @param x x坐标 + * @param y y坐标 + * @param width 宽度 + * @param height 高度 + * @param designer 块设计器 + * + * @return 吸附后坐标 + * + * @date 2015-2-12-下午2:39:16 + * + */ + public static Point sorption(int x, int y, int width, int height, RectangleDesigner designer, boolean isParameterLayout) { + + int left = x, top = y, bottom = top + height, right = left + width; + + Rectangle operatingRectangle = new Rectangle(x, y, width, height); + + equidistantLines.clear(); + + PlacePointing px = new PlacePointing(x); + PlacePointing py = new PlacePointing(y); + + PlacePointing pEquidistantX = new PlacePointing(x); + PlacePointing pEquidistantY = new PlacePointing(y); + + RectangleIterator iterator = designer.createRectangleIterator(); + + java.util.List cacheRecs = new ArrayList(); + //是否存在控件重叠 + boolean isWidgetsIntersects = false; + while (iterator.hasNext()) { + Rectangle bounds = iterator.nextRectangle(); + cacheRecs.add(bounds); + boolean isIntersects = operatingRectangle.intersects(bounds); + findX(px, bounds, left, right, width); + findY(py, bounds, top, bottom, height); + + if(!isParameterLayout){ + if(isIntersects) { + isWidgetsIntersects = true; + } + else{ + findEquidistantLine(bounds, left, top, height, width); + } + } + } + showForbiddenWindow(designer, x, y, isWidgetsIntersects); + + createXAbsorptionline(px, designer, width, cacheRecs); + createYAbsorptionline(py, designer, height, cacheRecs); + operatingRectangle.x = px.palce; + operatingRectangle.y = py.palce; + createEquidistantLine(pEquidistantX, pEquidistantY, operatingRectangle, designer); + Point sorptionPoint = new Point(px.palce,py.palce); + if (!px.isFind()){ + sorptionPoint.x = pEquidistantX.palce; + } + if (!py.isFind()){ + sorptionPoint.y = pEquidistantY.palce; + } + return sorptionPoint; + } + + public static void showForbiddenWindow(RectangleDesigner designer, int x, int y, boolean isIntersects){ + if (isIntersects){ + if(designer.getDesignerLocationOnScreen() != null) { + displayForbidWindow(x + designer.getDesignerLocationOnScreen().x, y + designer.getDesignerLocationOnScreen().y); + } + designer.setWidgetsIntersected(true); + } + else{ + designer.setWidgetsIntersected(false); + hideForbidWindow(); + } + } + + private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List cacheRecs) { + Absorptionline line = null; + RectangleIterator iterator = designer.createRectangleIterator(); + int[] selfVertical = designer.getVerticalLine(); + if (px.direction == SwingConstants.CENTER) { + line = Absorptionline.createXMidAbsorptionline(px.palce + width / 2); + int left = px.palce; + int right = px.palce + width; + for (Rectangle bounds : cacheRecs) { + if (bounds.x == left || bounds.x + bounds.width == left) { + line.setFirstLine(left); + } + if (bounds.x == right || bounds.x + bounds.width == right) { + line.setSecondLine(right); + } + updateVerticalLine(selfVertical, iterator, line); + if (line.isFull()) { + break; + } + } + } else if (px.direction == SwingConstants.LEFT || px.direction == SwingConstants.RIGHT) { + int left = px.direction == SwingConstants.LEFT ? px.palce + width : px.palce; + line = Absorptionline.createXAbsorptionline(px.direction == SwingConstants.LEFT ? px.palce : px.palce + width); + int middle = px.palce + width / 2; + for (Rectangle bounds : cacheRecs) { + if (bounds.x == left || bounds.x + bounds.width == left) { + line.setSecondLine(left); + } + if (bounds.x + bounds.width / 2 == middle) { + line.setMidLine(middle); + } + updateVerticalLine(selfVertical, iterator, line); + if (line.isFull()) { + break; + } + } + } + designer.setXAbsorptionline(line); + } + + private static void createYAbsorptionline(PlacePointing py, RectangleDesigner designer, int height, java.util.List cacheRecs) { + Absorptionline line = null; + RectangleIterator iterator = designer.createRectangleIterator(); + int[] selfHorizontal = designer.getHorizontalLine(); + if (py.direction == SwingConstants.CENTER) { + line = Absorptionline.createYMidAbsorptionline(py.palce + height / 2); + int top = py.palce; + int bottom = py.palce + height; + for (Rectangle bounds : cacheRecs) { + if (bounds.y == top || bounds.y + bounds.height == top) { + line.setFirstLine(top); + } + if (bounds.y == bottom || bounds.y + bounds.height == bottom) { + line.setSecondLine(bottom); + } + updateHorizontalLine(selfHorizontal, iterator, line); + if (line.isFull()) { + break; + } + } + } else if (py.direction == SwingConstants.TOP || py.direction == SwingConstants.BOTTOM) { + int top = py.direction == SwingConstants.TOP ? py.palce + height : py.palce; + line = Absorptionline.createYAbsorptionline(py.direction == SwingConstants.TOP ? py.palce : py.palce + height); + int middle = py.palce + height / 2; + for (Rectangle bounds : cacheRecs) { + if (bounds.y == top || bounds.y + bounds.height == top) { + line.setSecondLine(top); + } + if (bounds.y + bounds.height / 2 == middle) { + line.setMidLine(middle); + } + updateHorizontalLine(selfHorizontal, iterator, line); + if (line.isFull()) { + break; + } + } + } + designer.setYAbsorptionline(line); + } + + private static void createEquidistantLine(PlacePointing px, PlacePointing py, Rectangle operatingRectangle, RectangleDesigner designer){ + processEquidistantLinesList(px, py, operatingRectangle); + Absorptionline line = null; + if(equidistantLines.size() > 0) { + int top = -1; + int left = -1; + int bottom = -1; + int right = -1; + for(int i = 0; i < equidistantLines.size(); i++){ + if (equidistantLines.get(i).getDirection() == SwingConstants.TOP){ + top = equidistantLines.get(i).getReference(); + } + if (equidistantLines.get(i).getDirection() == SwingConstants.LEFT){ + left = equidistantLines.get(i).getReference(); + } + if (equidistantLines.get(i).getDirection() == SwingConstants.BOTTOM){ + bottom = equidistantLines.get(i).getReference(); + } + if (equidistantLines.get(i).getDirection() == SwingConstants.RIGHT){ + right = equidistantLines.get(i).getReference(); + } + } + operatingRectangle.x -= designer.getDesignerScrollHorizontalValue(); + operatingRectangle.y -= designer.getDesignerScrollVerticalValue(); + line = Absorptionline.createEquidistantAbsorptionline(operatingRectangle, + top - designer.getDesignerScrollVerticalValue(), + left - designer.getDesignerScrollHorizontalValue(), + bottom - designer.getDesignerScrollVerticalValue(), + right - designer.getDesignerScrollHorizontalValue()); + } + designer.setEquidistantLine(line); + } + + private static void processEquidistantLinesList(PlacePointing pEquidistantX, PlacePointing pEquidistantY, Rectangle operatingRectangle){ + EquidistantLine[] equidistantLines1 = new EquidistantLine[EQUIDISTANTLINE_UNIT]; + //先按方向处理,只保留四个方向上距离最近 + for(int count = 0; count < equidistantLines.size(); count++){ + for (int direction = 0; direction < EQUIDISTANTLINE_UNIT; direction++){ + if(equidistantLines.get(count).getDirection() == (direction + 1)){//direction 1,2,3,4 分别对应top,left,bottom,right + if(equidistantLines1[direction] != null + && equidistantLines1[direction].getDistance() > equidistantLines.get(count).getDistance() + || equidistantLines1[direction] == null) { + equidistantLines1[direction] = equidistantLines.get(count); + } + } + } + } + + equidistantLines.clear(); + //找list中横纵分别等距的组合 + if (equidistantLines1[0] != null && equidistantLines1[2] != null){//top, bottom + int offset = equidistantLines1[0].getDistance() - equidistantLines1[2].getDistance(); + if (Math.abs(offset) <= SORPTION_UNIT * 2){ + pEquidistantY.direction = SwingConstants.TOP; + equidistantLines.add(equidistantLines1[0]); + equidistantLines.add(equidistantLines1[2]); + pEquidistantY.palce = operatingRectangle.y - offset / 2; + operatingRectangle.y = pEquidistantY.palce; + } + } + if (equidistantLines1[1] != null && equidistantLines1[3] != null){//left, right + int offset = equidistantLines1[1].getDistance() - equidistantLines1[3].getDistance(); + if (Math.abs(offset) <= SORPTION_UNIT * 2){ + pEquidistantX.direction = SwingConstants.LEFT; + equidistantLines.add(equidistantLines1[1]); + equidistantLines.add(equidistantLines1[3]); + pEquidistantX.palce = operatingRectangle.x - offset / 2; + operatingRectangle.x = pEquidistantX.palce; + } + } + } + + //更新纵向行列线 + private static void updateVerticalLine(int[] selfVertical, RectangleIterator iterator, Absorptionline line){ + int[] targetArray = iterator.getVerticalLine(); + if (intersectArrays(targetArray, selfVertical)){ + line.setVerticalLines(targetArray); + } + } + + //更新横向行列线 + private static void updateHorizontalLine(int[] selfHorizontal, RectangleIterator iterator, Absorptionline line){ + int[] targetArray = iterator.getHorizontalLine(); + if (intersectArrays(targetArray, selfHorizontal)){ + line.setHorizontalLines(targetArray); + } + } + + //检测两个数组是否有相交的部分 + private static boolean intersectArrays(int[] targetArray, int[] selfArray){ + for (int i : targetArray) { + for (int j : selfArray) { + if(i == j){ + return true; + } + } + } + + return false; + } + + private static class EquidistantLine{ + //与操作rectangle的距离 + private int distance; + //参考rectangle的位置 + private int reference; + //等距线的方向 + private int direction; + + EquidistantLine(int distance, int reference, int direction){ + this.distance = distance; + this.reference = reference; + this.direction = direction; + } + + public void setDistance(int distance){ + this.distance = distance; + } + + public int getDistance(){ + return this.distance; + } + + public void setReference(int reference){ + this.reference = reference; + } + + public int getReference(){ + return this.reference; + } + + public void setDirection(int direction){ + this.direction = direction; + } + + public int getDirection(){ + return this.direction; + } + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index caa3e9d35..e3ee03999 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -91,7 +91,6 @@ FR-Designer_DS-Dictionary= FR-Designer_Data-confusion= FR-Designer_Data_Type= FR-Designer_Double_Click_Edit_OR_Clear= -FR-Designer_Edit_Button_ToolBar= FR-Designer_Email= FR-Designer_Enabled= FR-Designer_End-Date= @@ -101,6 +100,7 @@ FR-Designer_FS_Close_Other_Templates= FR-Designer_File= FR-Designer_Filter_Conditions= FR-Designer_Finish-Modify-Share= +FR-Designer_Fit= FR-Designer_Fit-App= FR-Designer_Font-Family= FR-Designer_Font-Size= @@ -162,7 +162,6 @@ FR-Designer_Refresh_Parameter_In_SQL= FR-Designer_Reg_Expressions= FR-Designer_Reg_Max_Length= FR-Designer_Reg_Min_Length= -FR-Designer_Remove_Button_ToolBar= FR-Designer_ReportColumns-Columns= FR-Designer_Return-Date= FR-Designer_RichText= @@ -543,14 +542,14 @@ FR-Designer_Left_Display=Left FR-Designer_About_Version=Version FR-Designer_About_CopyRight=Copy Right FR-Designer_Service_Phone=Service Phone -FR-Designer_Allow_Null=Allow Null +FR-Designer_Allow_Null=Allow null FR-Designer_PageSetup_Page=Page FR-Designer_Custom_Job_Description=Description FR-Designer_Property=Property FR-Designer_ClassName=Class Name FR-Designer_Polyblock_Edit=Polyblock Edit -FR-Designer_Function_Description_Area_Text=The class must inherit 'com.fr.script.AbstractFunction'. The compiled class should be copied to\nJ2EE server '{R1}WEB-INF{R2}classes' directory.\nAdd the source code(.java file) into the same folder if need.\nExample: {R3}classes} +FR-Designer_Function_Description_Area_Text=The class must inherit 'com.fr.script.AbstractFunction'. The compiled class should be copied to\nJ2EE server '{R1}' directory.\nAdd the source code(.java file) into the same folder if need.\nExample: {R2}} FR-Designer_PageSetup_Horizontal=Horizontal FR-Designer_PageSetup_Vertical=Vertical FR-Designer_Gradient_Direction=Gradient Direction @@ -564,6 +563,10 @@ FR-Designer_Show_As_Download=Display the binary content using download link FR-Designer_File_Name_For_Download=File Name For Download FR-Designer_No=No FR-Designer_Pagination=Page Break +FR-Designer-Move_Tab_First=move to first +FR-Designer-Move_Tab_End=move to end +FR-Designer-Move_Tab_Next=move to next +FR-Designer-Move_Tab_Prev=move to previous FR-Designer_DS_TableData=Data Set FR-Designer_Parameter-Formula=Formula FR-Designer_Plugin_Should_Update_Please_Contact_Developer=Plugin version is too low, and is not compatible with current API. Please contact the developer to update. @@ -584,10 +587,4 @@ FR-Designer_Mouse_Click_Tips= FR-Designer-Move_Tab_First=move to first FR-Designer-Move_Tab_End=move to end FR-Designer-Move_Tab_Next=move to next -FR-Designer-Move_Tab_Prev=move to previous -FR-Designer_AxisReversed=Axis Reversed -FR-Designer_Logarithmic=Logarithmic -FR-Designer_Chart_Log_Base=Log Base -FR-Designer_Chart_F_Radar_Axis=Chart_F_Radar_Axis -FR-Designer_Too_Large_To_Paste=too large to paste -FR-Designer_Too_Small_To_Paste=Too small to paste +FR-Designer-Move_Tab_Prev=move to previous \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index ccf30126a..a86a7fb14 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -91,7 +91,6 @@ FR-Designer_DS-Dictionary=Data Dictionary FR-Designer_Data-confusion=Data Confusion FR-Designer_Data_Type=Data type FR-Designer_Double_Click_Edit_OR_Clear=Double Click to Edit or Clear -FR-Designer_Edit_Button_ToolBar=Edit Button ToolBar FR-Designer_Email=Mail FR-Designer_Enabled=Enabled FR-Designer_End-Date=End Date @@ -164,7 +163,6 @@ FR-Designer_Refresh_Parameter_In_SQL=Whether to refresh parameters in the SQL FR-Designer_Reg_Expressions=Regular expressions FR-Designer_Reg_Max_Length=max length FR-Designer_Reg_Min_Length=min length -FR-Designer_Remove_Button_ToolBar=Remove Button ToolBar FR-Designer_ReportColumns-Columns=Multi-columns/lines FR-Designer_Return-Date=Return Date FR-Designer_RichText=Insert Rich Text @@ -544,14 +542,14 @@ FR-Designer_Left_Display=Left FR-Designer_About_Version=Version FR-Designer_About_CopyRight=Copy Right FR-Designer_Service_Phone=Service Phone -FR-Designer_Allow_Null=Allow Null +FR-Designer_Allow_Null=Allow null FR-Designer_PageSetup_Page=Page FR-Designer_Custom_Job_Description=Description FR-Designer_Property=Property FR-Designer_ClassName=Class Name FR-Designer_Polyblock_Edit=Aggregation block edition -FR-Designer_Function_Description_Area_Text=The class must inherit 'com.fr.script.AbstractFunction'. The compiled class files should be copied to\nJ2EE server '{R1}WEB-INF{R2}classes' directory.\nAdd the source code(.java file) into the same folder if need.\nExample: {R3}classes +FR-Designer_Function_Description_Area_Text=The class must inherit 'com.fr.script.AbstractFunction'. The compiled class should be copied to\nJ2EE server '{R1}' directory.\nAdd the source code(.java file) into the same folder if need.\nExample: {R2}} FR-Designer_PageSetup_Horizontal=Horizontal FR-Designer_PageSetup_Vertical=Vertical FR-Designer_Gradient_Direction=Gradient Direction @@ -565,6 +563,10 @@ FR-Designer_Show_As_Download=Display the binary content using download link FR-Designer_File_Name_For_Download=File Name For Download FR-Designer_No=No FR-Designer_Pagination=Page Break +FR-Designer-Move_Tab_First=move to first +FR-Designer-Move_Tab_End=move to end +FR-Designer-Move_Tab_Next=move to next +FR-Designer-Move_Tab_Prev=move to previous FR-Designer_DS_TableData=Data Set FR-Designer_Parameter-Formula=Formula FR-Designer_Plugin_Should_Update_Please_Contact_Developer=Plugin version is too low, and is not compatible with current API. Please contact the developer to update. @@ -585,10 +587,4 @@ FR-Designer_Mouse_Click_Tips=The background of the mouse to click the button, in FR-Designer-Move_Tab_First=move to first FR-Designer-Move_Tab_End=move to end FR-Designer-Move_Tab_Next=move to next -FR-Designer-Move_Tab_Prev=move to previous -FR-Designer_AxisReversed=Axis in reverse order -FR-Designer_Logarithmic=Log scale -FR-Designer_Chart_Log_Base=Log Base -FR-Designer_Chart_F_Radar_Axis=Value Axis -FR-Designer_Too_Large_To_Paste=Too large to paste! -FR-Designer_Too_Small_To_Paste=Too small to paste! +FR-Designer-Move_Tab_Prev=move to previous \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 1b1c1a6c0..943cf181d 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -91,7 +91,6 @@ FR-Designer_DS-Dictionary=\u30C7\u30FC\u30BF\u5B57\u5178 FR-Designer_Data-confusion=\u30C7\u30FC\u30BF\u6DF7\u4EA4 FR-Designer_Data_Type=\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7 FR-Designer_Double_Click_Edit_OR_Clear=\u30C0\u30D6\u30EB\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u7DE8\u96C6\u307E\u305F\u306F\u30AF\u30EA\u30A2\u3059\u308B -FR-Designer_Edit_Button_ToolBar=\u30DC\u30BF\u30F3\u306B\u3042\u308B\u30C4\u30FC\u30EB\u6B04\u7DE8\u96C6 FR-Designer_Email=\u30E1\u30FC\u30EB FR-Designer_Enabled=\u4F7F\u7528\u53EF\u80FD FR-Designer_End-Date=\u7D42\u4E86\u65E5\u671F @@ -163,7 +162,6 @@ FR-Designer_Refresh_Parameter_In_SQL=SQL\u4E2D\u306E\u30D1\u30E9\u30E1\u30FC\u30 FR-Designer_Reg_Expressions=\u6B63\u5247\u8868\u73FE\u5F0F FR-Designer_Reg_Max_Length=\u6700\u5927\u9577\u3055 FR-Designer_Reg_Min_Length=\u6700\u5C0F\u9577\u3055 -FR-Designer_Remove_Button_ToolBar=\u30DC\u30BF\u30F3\u304C\u3042\u308B\u30C4\u30FC\u30EB\u30D0\u30FC\u3092\u30EA\u30E0\u30FC\u30D6 FR-Designer_ReportColumns-Columns=\u6BB5\u7D44\u307F FR-Designer_Return-Date=\u65E5\u671F\u306B\u623B\u308B FR-Designer_RichText=\u30EA\u30C3\u30C1\u6587\u66F8\u633F\u5165 @@ -525,7 +523,7 @@ FR-Designer_Property=\u5C5E\u6027 FR-Designer_ClassName=\u985E\u540D FR-Designer_Polyblock_Edit=\u30A2\u30B0\u30EA\u30B2\u30FC\u30B7\u30E7\u30F3\u30D6\u30ED\u30C3\u30AF\u7DE8\u96C6 -FR-Designer_Function_Description_Area_Text=\u3053\u306E\u30AF\u30E9\u30B9\u306F\u7D99\u627F\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"com.fr.script.AbstractFunction"\u3002\u3092\u7D99\u627F\u3059\u3079\u304D\u3067\u3059\u3002\u30B3\u30F3\u30D1\u30A4\u30EB\u5F8C\u306E\u985E\u30D5\u30A1\u30A4\u30EB\u3092\nJ2EE\u30B5\u30FC\u30D0\u30FC "{R1}WEB-INF{R2}classes" \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3002\u306B\u30B3\u30D4\u30FC\u3057\u3066\u3001class\u306B\u5BFE\u5FDC\u3059\u308Bjava\u30D5\u30A1\u30A4\u30EB\u3082\u5F53\u76EE\u6B21\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\u3002\n\u4F8B\u3048\u3070\uFF1A{R3}classes +FR-Designer_Function_Description_Area_Text=\u3053\u306E\u30AF\u30E9\u30B9\u306F\u7D99\u627F\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"com.fr.script.AbstractFunction"\u3002\u3092\u7D99\u627F\u3059\u3079\u304D\u3067\u3059\u3002\u30B3\u30F3\u30D1\u30A4\u30EB\u5F8C\u306E\u985E\u30D5\u30A1\u30A4\u30EB\u3092\nJ2EE\u30B5\u30FC\u30D0\u30FC "{R1}" \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3002\u306B\u30B3\u30D4\u30FC\u3057\u3066\u3001class\u306B\u5BFE\u5FDC\u3059\u308Bjava\u30D5\u30A1\u30A4\u30EB\u3082\u5F53\u76EE\u6B21\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\u3002\n\u4F8B\u3048\u3070\uFF1A{R2} FR-Designer_PageSetup_Horizontal=\u6A2A\u65B9\u5411 FR-Designer_PageSetup_Vertical=\u7E26\u65B9\u5411 FR-Designer_Gradient_Direction=\u65B9\u5411\u3092\u5F90\u3005\u306B\u5909\u5316 @@ -539,6 +537,10 @@ FR-Designer_Show_As_Download=\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u30EA\u30F3\u3 FR-Designer_File_Name_For_Download=\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u30D5\u30A1\u30A4\u30EB\u540D FR-Designer_No=\u3044\u3044\u3048 FR-Designer_Pagination=\u30DA\u30FC\u30B8\u30F3\u30B0 +FR-Designer-Move_Tab_First= +FR-Designer-Move_Tab_End= +FR-Designer-Move_Tab_Next= +FR-Designer-Move_Tab_Prev= FR-Designer_DS_TableData=\u30C7\u30FC\u30BF\u30BD\u30FC\u30B9 FR-Designer_Parameter-Formula=\u6570\u5F0F FR-Designer_Background_Null= @@ -552,11 +554,4 @@ FR-Designer_Background_Image_Select= FR-Designer_Initial_Background_Tips= FR-Designer_Mouse_Move_Tips= FR-Designer_Mouse_Click_Tips= -FR-Designer-Move_Tab_First= -FR-Designer-Move_Tab_End= -FR-Designer-Move_Tab_Next= -FR-Designer-Move_Tab_Prev= -FR-Designer_AxisReversed=\u8EF8\u9006\u914D\u5217 -FR-Designer_Logarithmic=\u5BFE\u6570\u76EE\u76DB\u308A -FR-Designer_Chart_Log_Base=\u5E95\u6570 -FR-Designer_Chart_F_Radar_Axis=\u5782\u76F4\u8EF8 +FR-Designer_Plugin_Should_Update_Please_Contact_Developer= diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index 9df9125a9..db796ce43 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -91,7 +91,6 @@ FR-Designer_DS-Dictionary=\uB370\uC774\uD130\uC0AC\uC804 FR-Designer_Data-confusion=\uB370\uC774\uD130\uD63C\uD569 FR-Designer_Data_Type=\uB370\uC774\uD130\uC720\uD615 FR-Designer_Double_Click_Edit_OR_Clear=\uB354\uBE14\uD074\uB9AD\uD558\uC5EC\uD3B8\uC9D1\uB610\uB294\uD074\uB9AC\uC5B4\uC2E4\uD589 -FR-Designer_Edit_Button_ToolBar=\uD0A4\uAC00\uC788\uB294\uD234\uBC14\uD3B8\uC9D1 FR-Designer_Email=\uBA54\uC77C FR-Designer_Enabled=\uC0AC\uC6A9\uAC00\uB2A5 FR-Designer_End-Date=\uC885\uB8CC\uB0A0\uC9DC @@ -163,7 +162,6 @@ FR-Designer_Refresh_Parameter_In_SQL=SQL\uC758\uB9E4\uAC1C\uBCC0\uC218\uB97C\uC0 FR-Designer_Reg_Expressions=\uC815\uADDC\uD45C\uD604\uC2DD FR-Designer_Reg_Max_Length=\uCD5C\uB300\uAE38\uC774 FR-Designer_Reg_Min_Length=\uCD5C\uC18C\uAE38\uC774 -FR-Designer_Remove_Button_ToolBar=\uD0A4\uAC00\uC788\uB294\uD234\uBC14\uC81C\uAC70 FR-Designer_ReportColumns-Columns=\uC140\uB098\uB204\uAE30 FR-Designer_Return-Date=\uB0A0\uC9DC\uB3CC\uC544\uAC00\uAE30 FR-Designer_RichText=\uB9AC\uCE58\uD14D\uC2A4\uD2B8\uBC15\uC2A4\uC0BD\uC785 @@ -522,7 +520,7 @@ FR-Designer_ClassName=\uD074\uB798\uC2A4\uB124\uC784 FR-Designer_Template_Web_Attributes=\uD15C\uD50C\uB9BF \uC6F9 \uC18D\uC131 FR-Designer_Polyblock_Edit=\uCDE8\uD569\uBE14\uB7ED\uD3B8\uC9D1 -FR-Designer_Function_Description_Area_Text=\uD574\uB2F9\uD074\uB798\uC2A4\uB294\uACC4\uC2B9\uD574\uC57C\uD55C\uB2E4."com.fr.script.AbstractFunction".\uCEF4\uD30C\uC77C\uD6C4\uC758\uD074\uB798\uC2A4\uD30C\uC77C\uC744~\uB85C\uBCF5\uC0AC\nJ2EE\uC11C\uBC84 "{R1}WEB-INF{R2}classes" \uB514\uB809\uD130\uB9AC, \uD544\uC694\uC2DC class \uC0C1\uC751\uD558\uB294 java\uC18C\uC2A4\uD30C\uC77C\uB3C4\uD574\uB2F9\uB514\uB809\uD130\uB9AC\uD558\uB2E8\uC5D0\uB450\uC5B4\uD3B8\uC9D1\uBC0F\uCC3E\uC544\uBCF4\uAE30\uB97C\uD560\uC218\uC788\uC2B5\uB2C8\uB2E4.\n\uC608: {R3}classes +FR-Designer_Function_Description_Area_Text=\uD574\uB2F9\uD074\uB798\uC2A4\uB294\uACC4\uC2B9\uD574\uC57C\uD55C\uB2E4."com.fr.script.AbstractFunction".\uCEF4\uD30C\uC77C\uD6C4\uC758\uD074\uB798\uC2A4\uD30C\uC77C\uC744~\uB85C\uBCF5\uC0AC\nJ2EE\uC11C\uBC84 "{R1}" \uB514\uB809\uD130\uB9AC, \uD544\uC694\uC2DC class \uC0C1\uC751\uD558\uB294 java\uC18C\uC2A4\uD30C\uC77C\uB3C4\uD574\uB2F9\uB514\uB809\uD130\uB9AC\uD558\uB2E8\uC5D0\uB450\uC5B4\uD3B8\uC9D1\uBC0F\uCC3E\uC544\uBCF4\uAE30\uB97C\uD560\uC218\uC788\uC2B5\uB2C8\uB2E4.\n\uC608: {R2} FR-Designer_PageSetup_Horizontal=\uAC00\uB85C FR-Designer_PageSetup_Vertical=\uC138\uB85C FR-Designer_Gradient_Direction=\uADF8\uB77C\uB370\uC774\uC158 \uBC29\uD5A5 @@ -536,6 +534,10 @@ FR-Designer_Show_As_Download=\uB2E4\uC6B4\uB85C\uB4DC\uB9C1\uD06C\uB85C2\uC9C4\u FR-Designer_File_Name_For_Download=\uB2E4\uC6B4\uB85C\uB4DC\uD30C\uC77C\uBA85 FR-Designer_No=\uC544\uB2C8\uC624 FR-Designer_Pagination=\uD398\uC774\uC9C0\uB098\uB204\uAE30 +FR-Designer-Move_Tab_First= +FR-Designer-Move_Tab_End= +FR-Designer-Move_Tab_Next= +FR-Designer-Move_Tab_Prev= FR-Designer_DS_TableData=\uB370\uC774\uD130\uC138\uD2B8 FR-Designer_Parameter-Formula=\uC218\uC2DD FR-Designer_Background_Null= @@ -549,11 +551,4 @@ FR-Designer_Background_Image_Select= FR-Designer_Initial_Background_Tips= FR-Designer_Mouse_Move_Tips= FR-Designer_Mouse_Click_Tips= -FR-Designer-Move_Tab_First= -FR-Designer-Move_Tab_End= -FR-Designer-Move_Tab_Next= -FR-Designer-Move_Tab_Prev= -FR-Designer_AxisReversed=\uCD95\uC5ED\uC21C -FR-Designer_Logarithmic=\uB85C\uADF8\uB208\uAE08 -FR-Designer_Chart_Log_Base=\uAE30\uC218 -FR-Designer_Chart_F_Radar_Axis=\uAC12\uCD95 +FR-Designer_Plugin_Should_Update_Please_Contact_Developer= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 060eddbd7..726a6d0f6 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -91,7 +91,6 @@ FR-Designer_DS-Dictionary=\u6570\u636E\u5B57\u5178 FR-Designer_Data-confusion=\u6570\u636E\u6DF7\u6DC6 FR-Designer_Data_Type=\u6570\u636E\u7C7B\u578B FR-Designer_Double_Click_Edit_OR_Clear=\u53CC\u51FB\u8FDB\u884C\u7F16\u8F91\u6216\u6E05\u9664 -FR-Designer_Edit_Button_ToolBar=\u7F16\u8F91\u6309\u94AE\u6240\u5728\u5DE5\u5177\u680F FR-Designer_Email=\u90AE\u4EF6 FR-Designer_Enabled=\u53EF\u7528 FR-Designer_End-Date=\u7ED3\u675F\u65E5\u671F @@ -164,7 +163,6 @@ FR-Designer_Refresh_Parameter_In_SQL=\u662F\u5426\u5237\u65B0SQL\u4E2D\u7684\u53 FR-Designer_Reg_Expressions=\u6B63\u5219\u8868\u8FBE\u5F0F FR-Designer_Reg_Max_Length=\u6700\u5927\u957F\u5EA6 FR-Designer_Reg_Min_Length=\u6700\u5C0F\u957F\u5EA6 -FR-Designer_Remove_Button_ToolBar=\u79FB\u9664\u6309\u94AE\u6240\u5728\u5DE5\u5177\u680F FR-Designer_ReportColumns-Columns=\u5206\u680F FR-Designer_Return-Date=\u8FD4\u56DE\u65E5\u671F FR-Designer_RichText=\u63D2\u5165\u5BCC\u6587\u672C @@ -555,7 +553,7 @@ FR-Designer_Property=\u5C5E\u6027 FR-Designer_ClassName=\u7C7B\u540D FR-Designer_Polyblock_Edit=\u805A\u5408\u5757\u7F16\u8F91 -FR-Designer_Function_Description_Area_Text=\u8BE5\u7C7B\u5FC5\u987B\u7EE7\u627F"com.fr.script.AbstractFunction"\u3002\u5E94\u5C06\u7F16\u8BD1\u540E\u7684\u7C7B\u6587\u4EF6\u62F7\u8D1D\u5230\nJ2EE\u670D\u52A1\u5668 "{R1}WEB-INF{R2}classes" \u76EE\u5F55\uFF0C\u5982\u679C\u5FC5\u8981\u7684\u8BDD\u5C06class\u5BF9\u5E94\u7684java\u6E90\u6587\u4EF6\u4E5F\u653E\u7F6E\u5230\u8BE5\u76EE\u5F55\u4E0B\u65B9\u4FBF\u7F16\u8F91\u548C\u67E5\u770B\u3002\n\u4F8B\u5982\uFF1A{R3}classes +FR-Designer_Function_Description_Area_Text=\u8BE5\u7C7B\u5FC5\u987B\u7EE7\u627F"com.fr.script.AbstractFunction"\u3002\u5E94\u5C06\u7F16\u8BD1\u540E\u7684\u7C7B\u6587\u4EF6\u62F7\u8D1D\u5230\nJ2EE\u670D\u52A1\u5668 "{R1}" \u76EE\u5F55\uFF0C\u5982\u679C\u5FC5\u8981\u7684\u8BDD\u5C06class\u5BF9\u5E94\u7684java\u6E90\u6587\u4EF6\u4E5F\u653E\u7F6E\u5230\u8BE5\u76EE\u5F55\u4E0B\u65B9\u4FBF\u7F16\u8F91\u548C\u67E5\u770B\u3002\n\u4F8B\u5982\uFF1A{R2} FR-Designer_PageSetup_Horizontal=\u6A2A\u5411 FR-Designer_PageSetup_Vertical=\u7EB5\u5411 FR-Designer_Gradient_Direction=\u6E10\u53D8\u65B9\u5411 @@ -569,12 +567,16 @@ FR-Designer_Show_As_Download=\u7528\u4E0B\u8F7D\u94FE\u63A5\u663E\u793A\u4E8C\u8 FR-Designer_File_Name_For_Download=\u4E0B\u8F7D\u6587\u4EF6\u540D FR-Designer_No=\u5426 FR-Designer_Pagination=\u5206\u9875 +FR-Designer-Move_Tab_First=\u79FB\u52A8\u5230\u9996\u4F4D +FR-Designer-Move_Tab_End=\u79FB\u52A8\u5230\u672B\u5C3E +FR-Designer-Move_Tab_Next=\u5F80\u540E\u79FB\u52A8 +FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52A8 FR-Designer_DS_TableData=\u6570\u636E\u96C6 FR-Designer_Parameter-Formula=\u516C\u5F0F FR-Designer_Plugin_Should_Update_Please_Contact_Developer=\u63D2\u4EF6\u7248\u672C\u8FC7\u4F4E, \u5B58\u5728API\u4E0D\u517C\u5BB9, \u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u5347\u7EA7\u63D2\u4EF6 FR-Designer_WidgetOrder=\u63A7\u4EF6\u987A\u5E8F FR-Designer_Mobile_Form_Analysis_Annotation=\u6CE8\u91CA\uFF1A\u53EF\u4EE5\u901A\u8FC7\u8BE5\u5C5E\u6027\u63A7\u5236\u8868\u5355\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\u3002 -FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CA\: \u53EF\u4EE5\u901A\u8FC7\u8BE5\u5C5E\u6027\u63A7\u5236\u62A5\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9875\u9884\u89C8\uFF0C\u586B\u62A5\u9884\u89C8\u65F6\u5C5E\u6027\u65E0\u6548\u3002 +FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CA: \u53EF\u4EE5\u901A\u8FC7\u8BE5\u5C5E\u6027\u63A7\u5236\u62A5\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9875\u9884\u89C8\uFF0C\u586B\u62A5\u9884\u89C8\u65F6\u5C5E\u6027\u65E0\u6548\u3002 FR-Designer_Background_Null=\u6CA1\u6709\u80CC\u666F FR-Designer_Background_Color=\u989C\u8272 FR-Designer_Background_Texture=\u7EB9\u7406 @@ -586,13 +588,3 @@ FR-Designer_Background_Image_Select=\u9009\u62E9\u56FE\u7247 FR-Designer_Initial_Background_Tips=\u6309\u94AE\u7684\u521D\u59CB\u80CC\u666F FR-Designer_Mouse_Move_Tips=\u9F20\u6807\u79FB\u52A8\u5230\u6309\u94AE\u4E0A\u7684\u80CC\u666F\uFF0C\u82E5\u65E0\u5219\u4E0D\u6539\u53D8\u80CC\u666F FR-Designer_Mouse_Click_Tips=\u9F20\u6807\u70B9\u51FB\u6309\u94AE\u65F6\u80CC\u666F\uFF0C\u82E5\u65E0\u5219\u4E0D\u6539\u53D8\u80CC\u666F -FR-Designer-Move_Tab_First=\u79FB\u52A8\u5230\u9996\u4F4D -FR-Designer-Move_Tab_End=\u79FB\u52A8\u5230\u672B\u5C3E -FR-Designer-Move_Tab_Next=\u5F80\u540E\u79FB\u52A8 -FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52A8 -FR-Designer_AxisReversed=\u8F74\u9006\u5E8F -FR-Designer_Logarithmic=\u5BF9\u6570\u523B\u5EA6 -FR-Designer_Chart_Log_Base=\u5E95\u6570 -FR-Designer_Chart_F_Radar_Axis=\u503C\u8F74 -FR-Designer_Too_Large_To_Paste=\u7EC4\u4EF6\u5927\u5C0F\u8D85\u51FA\u8FB9\u754C\uFF0C\u65E0\u6CD5\u7C98\u8D34\uFF01 -FR-Designer_Too_Small_To_Paste=\u6B64\u5904\u65E0\u6CD5\u7C98\u8D34\uFF0C\u5C0F\u4E8E\u7EC4\u4EF6\u6700\u5C0F\u9AD8\u5EA6\uFF01 diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index bb7ab2dc6..f8b28dba3 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -91,7 +91,6 @@ FR-Designer_DS-Dictionary=\u8CC7\u6599\u5B57\u5178 FR-Designer_Data-confusion=\u8CC7\u6599\u6DF7\u6DC6 FR-Designer_Data_Type=\u8CC7\u6599\u985E\u578B FR-Designer_Double_Click_Edit_OR_Clear=\u96D9\u64CA\u9032\u884C\u7DE8\u8F2F\u6216\u6E05\u9664 -FR-Designer_Edit_Button_ToolBar=\u7DE8\u8F2F\u6309\u9215\u6240\u5728\u5DE5\u5177\u6B04 FR-Designer_Email=\u90F5\u4EF6 FR-Designer_Enabled=\u53EF\u7528 FR-Designer_End-Date=\u7D50\u675F\u65E5\u671F @@ -163,7 +162,6 @@ FR-Designer_Refresh_Parameter_In_SQL=\u5728SQL\u4E2D\u91CD\u65B0\u6574\u7406\u76 FR-Designer_Reg_Expressions=\u6B63\u5247\u8868\u9054\u5F0F FR-Designer_Reg_Max_Length=\u6700\u5927\u9577\u5EA6 FR-Designer_Reg_Min_Length=\u6700\u5C0F\u9577\u5EA6 -FR-Designer_Remove_Button_ToolBar=\u79FB\u9664\u6309\u9215\u6240\u5728\u5DE5\u5177\u6B04 FR-Designer_ReportColumns-Columns=\u5831\u8868\u6B04\u4F4D FR-Designer_Return-Date=\u8FD4\u56DE\u65E5\u671F FR-Designer_RichText= RTF @@ -543,7 +541,7 @@ FR-Designer_Property=\u5C6C\u6027 FR-Designer_ClassName=\u985E\u540D FR-Designer_Polyblock_Edit=\u805A\u5408\u584A\u7DE8\u8F2F -FR-Designer_Function_Description_Area_Text=\u8A72\u985E\u5FC5\u9808\u7E7C\u627F"com.fr.script.AbstractFunction"\u3002\u61C9\u5C07\u7DE8\u8B6F\u5F8C\u7684\u985E\u6A94\u6848\u62F7\u8C9D\u5230\nJ2EE\u4F3A\u670D\u5668 "{R1}WEB-INF{R2}classes" \u76EE\u9304\uFF0C\u5982\u679C\u5FC5\u8981\u7684\u8A71\u5C07class\u5C0D\u61C9\u7684java\u539F\u59CB\u6A94\u6848\u4E5F\u653E\u7F6E\u5230\u8A72\u76EE\u9304\u4E0B\u65B9\u4FBF\u7DE8\u8F2F\u548C\u67E5\u770B\u3002\n\u4F8B\u5982\uFF1A{R3}classes +FR-Designer_Function_Description_Area_Text=\u8A72\u985E\u5FC5\u9808\u7E7C\u627F"com.fr.script.AbstractFunction"\u3002\u61C9\u5C07\u7DE8\u8B6F\u5F8C\u7684\u985E\u6A94\u6848\u62F7\u8C9D\u5230\nJ2EE\u4F3A\u670D\u5668 "{R1}" \u76EE\u9304\uFF0C\u5982\u679C\u5FC5\u8981\u7684\u8A71\u5C07class\u5C0D\u61C9\u7684java\u539F\u59CB\u6A94\u6848\u4E5F\u653E\u7F6E\u5230\u8A72\u76EE\u9304\u4E0B\u65B9\u4FBF\u7DE8\u8F2F\u548C\u67E5\u770B\u3002\n\u4F8B\u5982\uFF1A{R2} FR-Designer_PageSetup_Horizontal=\u6A2A\u5411 FR-Designer_PageSetup_Vertical=\u7E31\u5411 FR-Designer_Gradient_Direction=\u6F38\u8B8A\u65B9\u5411 @@ -557,9 +555,13 @@ FR-Designer_Show_As_Download=\u7528\u4E0B\u8F09\u93C8\u63A5\u986F\u793A\u4E8C\u9 FR-Designer_File_Name_For_Download=\u4E0B\u8F09\u6A94\u6848\u540D FR-Designer_No=\u5426 FR-Designer_Pagination=\u5206\u9801 +FR-Designer-Move_Tab_First=\u79FB\u52D5\u5230\u9996\u4F4D +FR-Designer-Move_Tab_End=\u79FB\u52D5\u5230\u672B\u5C3E +FR-Designer-Move_Tab_Next=\u5F80\u5F8C\u79FB\u52D5 +FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52D5 FR-Designer_DS_TableData=\u8CC7\u6599\u96C6 FR-Designer_Parameter-Formula=\u516C\u5F0F -FR-Designer_Plugin_Should_Update_Please_Contact_Developer=\u63D2\u4EF6\u7248\u672C\u904E\u4F4E, \u5B58\u5728API\u4E0D\u517C\u5BB9, \u8ACB\u806F\u7E6B\u958B\u767C\u8005\u5347\u7D1A\u63D2\u4EF6 +FR-Designer_Plugin_Should_Update_Please_Contact_Developer=\u633F\u4EF6\u7248\u672C\u904E\u4F4E\uFF0C\u5B58\u5728API\u4E0D\u76F8\u5BB9\uFF0C\u8ACB\u806F\u7CFB\u958B\u767C\u8005\u965E\u7D1A\u633F\u4EF6 FR-Designer_WidgetOrder=\u63A7\u4EF6\u9806\u5E8F FR-Designer_Mobile_Form_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u8868\u55AE\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\u3002 FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u5831\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9801\u9810\u89BD\uFF0C\u586B\u5831\u9810\u89BD\u6642\u5C6C\u6027\u7121\u6548\u3002 @@ -573,14 +575,4 @@ FR-Designer_Background_Clear= FR-Designer_Background_Image_Select= FR-Designer_Initial_Background_Tips= FR-Designer_Mouse_Move_Tips= -FR-Designer_Mouse_Click_Tips= -FR-Designer-Move_Tab_First=\u79FB\u52D5\u5230\u9996\u4F4D -FR-Designer-Move_Tab_End=\u79FB\u52D5\u5230\u672B\u5C3E -FR-Designer-Move_Tab_Next=\u5F80\u5F8C\u79FB\u52D5 -FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52D5 -FR-Designer_AxisReversed=\u8EF8\u9006\u5E8F -FR-Designer_Logarithmic=\u5C0D\u6578\u523B\u5EA6 -FR-Designer_Chart_Log_Base=\u5E95\u6578 -FR-Designer_Chart_F_Radar_Axis=\u503C\u8EF8 -FR-Designer_Too_Large_To_Paste=\u7D44\u4EF6\u5927\u5C0F\u8D85\u51FA\u908A\u754C\uFF0C\u7121\u6CD5\u7C98\u8CBC\uFF01 -FR-Designer_Too_Small_To_Paste=\u6B64\u8655\u7121\u6CD5\u7C98\u8CBC\uFF0C\u5C0F\u65BC\u7D44\u4EF6\u6700\u5C0F\u9AD8\u5EA6\uFF01 +FR-Designer_Mouse_Click_Tips= \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java b/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java index 0c61e64f3..7fc7d9db3 100644 --- a/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java +++ b/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java @@ -30,8 +30,7 @@ public class MinMaxValuePane extends JPanel { protected UICheckBox isCustomSecUnitBox; protected UITextField secUnitField; - - public MinMaxValuePane() { + public MinMaxValuePane() { minCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Min_Value"})); minValueField = new UITextField(6); maxCheckBox = new UICheckBox(Inter.getLocText(new String[]{"Custom", "Max_Value"})); @@ -40,45 +39,37 @@ public class MinMaxValuePane extends JPanel { mainUnitField = new UITextField(6); isCustomSecUnitBox = new UICheckBox(Inter.getLocText("FR-Chart_SecondGraduationUnit")); secUnitField = new UITextField(6); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - - Component[][] components = getPanelComponents(); - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, getRowSize(p), columnSize); - this.setLayout(new BorderLayout()); - this.add(panel, BorderLayout.CENTER); - addComponentListener(components); - } - - protected double[] getRowSize(double p) { - return new double[]{p, p, p, p}; - } - - public void addComponentListener(Component[][] components) { - for (int i = 0; i < components.length; i++) { - ((UICheckBox) components[i][0]).addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - checkBoxUse(); - } - }); - ChartSwingUtils.addListener((UICheckBox) components[i][0], (UITextField) components[i][1]); - } - } - - protected Component[][] getPanelComponents() { - return new Component[][]{ + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = { p, f }; + double[] rowSize = { p, p, p, p}; + + Component[][] components = getPanelComponents(); + JPanel panel = TableLayoutHelper.createTableLayoutPane(components ,rowSize,columnSize); + this.setLayout(new BorderLayout()); + this.add(panel,BorderLayout.CENTER); + + for(int i = 0; i < components.length; i++) { + ((UICheckBox)components[i][0]).addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + checkBoxUse(); + } + }); + ChartSwingUtils.addListener((UICheckBox)components[i][0], (UITextField)components[i][1]); + } + } + protected Component[][] getPanelComponents() { + return new Component[][]{ new Component[]{minCheckBox, minValueField}, new Component[]{maxCheckBox, maxValueField}, new Component[]{isCustomMainUnitBox, mainUnitField}, new Component[]{isCustomSecUnitBox, secUnitField}, - }; - } + }; + } - protected void checkBoxUse() { + private void checkBoxUse() { minValueField.setEnabled(minCheckBox.isSelected()); maxValueField.setEnabled(maxCheckBox.isSelected()); @@ -109,7 +100,7 @@ public class MinMaxValuePane extends JPanel { if(axis.getMinValue() != null) { minValueField.setText(axis.getMinValue().toString()); } - } + } // 最大值 if (axis.isCustomMaxValue()) { @@ -117,7 +108,7 @@ public class MinMaxValuePane extends JPanel { if(axis.getMaxValue() != null) { maxValueField.setText(axis.getMaxValue().toString()); } - } + } // 主次刻度单位 if (axis.isCustomMainUnit()) { @@ -125,7 +116,7 @@ public class MinMaxValuePane extends JPanel { if(axis.getMainUnit() != null) { mainUnitField.setText(axis.getMainUnit().toString()); } - } + } if(axis.isCustomSecUnit()) { isCustomSecUnitBox.setSelected(true); @@ -158,7 +149,7 @@ public class MinMaxValuePane extends JPanel { updateUnit(axis); } - protected void updateUnit(Axis axis) { + private void updateUnit(Axis axis) { // 主要刻度 if (isCustomMainUnitBox.isSelected()){ String increment = mainUnitField.getText(); diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index 603626e13..7810fc9a6 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -1,346 +1,354 @@ -package com.fr.design.designer.beans.adapters.layout; - -import com.fr.design.beans.GroupModel; -import com.fr.design.designer.beans.ConstraintsGroupModel; -import com.fr.design.designer.beans.HoverPainter; -import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter; -import com.fr.design.designer.creator.*; -import com.fr.design.designer.properties.BoundsGroupModel; -import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; -import com.fr.design.utils.ComponentUtils; -import com.fr.design.utils.gui.LayoutUtils; -import com.fr.form.ui.container.WAbsoluteLayout; -import com.fr.general.ComparatorUtils; -import com.fr.general.FRLogger; - -import java.awt.*; - -public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { - //是不是添加到父容器上 - private boolean isAdd2ParentLayout = false; - private HoverPainter painter; - - public FRAbsoluteLayoutAdapter(XLayoutContainer container) { - super(container); - painter = new FRAbsoluteLayoutPainter(container); - initMinSize(); - } - - private void initMinSize() { - XWAbsoluteLayout layout = (XWAbsoluteLayout) container; - minWidth = layout.getActualMinWidth(); - minHeight = layout.getActualMinHeight(); - actualVal = layout.getAcualInterval(); - margin = layout.toData().getMargin(); - } - - @Override - public HoverPainter getPainter() { - return painter; - } - - /** - * 是否能在指定位置添加组件 - * - * @param creator 组件 - * @param x 坐标x - * @param y 坐标y - * @return 能则返回true - */ - //这个地方的逻辑非常复杂, - // 1.当前绝对布局是不可编辑且是最外层,那么其他控件添加在它周围, - // 2.当前绝对布局是不可编辑且不是最外层,那么控件不可添加,(嵌套) - // 3.当前绝对布局可编辑,那么控件添加 - @Override - public boolean accept(XCreator creator, int x, int y) { - Component comp = container.getComponentAt(x, y); - //布局控件要先判断是不是可编辑 - //可以编辑,按原有逻辑判断 - //不可编辑,当成一整个控件处理 - if (comp == null) { - return false; - } - //参数面板内的组件不允许拖往绝对布局中 - if (creator.getParent() != null && ((XCreator) creator.getParent()).acceptType(XWParameterLayout.class)) { - Rectangle rec = creator.getBounds(); - rec.y = creator.getParent().getHeight() - rec.height; - creator.setBounds(rec); - return false; - } - //判断组件能不能拖入绝对布局 - if (!creator.canEnterIntoAbsolutePane()) { - return false; - } - XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); - if (topLayout != null) { - if (topLayout.isEditable()) { - return topLayoutAccept(creator, x, y); - } - //绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局 - else if (((XLayoutContainer) topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { - return false; - } else { - return acceptWidget(x, y); - } - } else { - FRLogger.getLogger().error("top layout is null!"); - } - - return false; - } - - //topLayout假如可以编辑的话就往里面添加组件 - private boolean topLayoutAccept(XCreator creator, int x, int y) { - //允许组件重叠,可以不判断有没有和当前控件重叠 - //先计算当前控件的位置 - int creatorX, creatorY; - if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { - Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); - creatorX = creatorRectangle.x; - creatorY = creatorRectangle.y; - } else { - //这边计算得到的组件其实位置是正确的, - //因为传入的x和y已经加上了宽度或者高度的一半,再减去相同的宽度和高度的一半是没区别的, - // 例如高度为21,那么就是+10-10; - // 高度为20,那么就是+10-10; 没区别 - int w = creator.getWidth() / 2; - int h = creator.getHeight() / 2; - creatorX = x - w; - creatorY = y - h; - } - if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) { - return false; - } - if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()) { - return false; - } - return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() - && creator.getWidth() <= container.getWidth(); - } - - /** - * 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 - * - * @param parentComp 鼠标所在区域的组件 - * @param x 坐标x - * @param y 坐标y - * @return 是则返回true - */ - public boolean isTrisectionArea(Component parentComp, int x, int y) { - XCreator creator = (XCreator) parentComp; - trisectAreaDirect = 0; - if (container.getComponentCount() <= 1) { - return false; - } - int maxWidth = parentComp.getWidth(); - int maxHeight = parentComp.getHeight(); - int xL = parentComp.getX(); - int yL = parentComp.getY(); - // 组件宽高的十分之一和默认值取大 - int minRangeWidth = Math.max(maxWidth / BORDER_PROPORTION, DEFAULT_AREA_LENGTH); - int minRangeHeight = Math.max(maxHeight / BORDER_PROPORTION, DEFAULT_AREA_LENGTH); - if (y < yL + minRangeHeight) { - // 在组件上侧三等分 - trisectAreaDirect = COMP_TOP; - } else if (y > yL + maxHeight - minRangeHeight) { - // 在组件下侧三等分 - trisectAreaDirect = COMP_BOTTOM; - } else if (x < xL + minRangeWidth) { - // 在组件左侧三等分 - trisectAreaDirect = COMP_LEFT; - } else if (x > xL + maxWidth - minRangeWidth) { - // 在组件右侧三等分 - trisectAreaDirect = COMP_RIGHT; - } - // tab布局的边界特殊处理,不进行三等分 - if (!creator.getTargetChildrenList().isEmpty()) { - return false; - } - - return !ComparatorUtils.equals(trisectAreaDirect, 0); - } - - //当前绝对布局不可编辑,就当成一个控件,组件添加在周围 - private boolean acceptWidget(int x, int y) { - isFindRelatedComps = false; - //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 - Component comp = container.getComponentAt(x, y); - //如果当前处于边缘地带, 那么就把他贴到父容器上 - XLayoutContainer parent = container.findNearestFit(); - container = parent != null ? parent : container; - isAdd2ParentLayout = true; - - int componentHeight = comp.getHeight(); - int componentWidth = comp.getWidth(); - //上半部分高度 - int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); - //下半部分高度 - int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); - - if (isCrossPointArea(comp, x, y)) { - return canAcceptWhileCrossPoint(comp, x, y); - } - - if (isTrisectionArea(comp, x, y)) { - return canAcceptWhileTrisection(comp, x, y); - } - - boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; - boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; - return y > upHeight && y < downHeight ? horizonValid : verticalValid; - } - - /** - * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 - * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 - * - * @param creator 被添加的新组件 - * @param x 添加的位置x,该位置是相对于container的 - * @param y 添加的位置y,该位置是相对于container的 - * @return 是否添加成功,成功返回true,否则false - */ - @Override - public boolean addBean(XCreator creator, int x, int y) { - Rectangle rect = ComponentUtils.getRelativeBounds(container); - - int posX = x + rect.x; - int posY = y + rect.y; - if (!accept(creator, x, y)) { - return false; - } - addComp(creator, posX, posY); - ((XWidgetCreator) creator).recalculateChildrenSize(); - return true; - } - - @Override - protected void addComp(XCreator creator, int x, int y) { - if (!isAdd2ParentLayout) { - Rectangle r = ComponentUtils.getRelativeBounds(container); - x = x - r.x; - y = y - r.y; - if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { - - Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); - x = creatorRectangle.x - r.x; - y = creatorRectangle.y - r.y; - } else { - int w = creator.getWidth() / 2; - int h = creator.getHeight() / 2; - x = x - w; - y = y - h; - } - fix(creator, x, y); - - if (creator.hasTitleStyle()) { - addParentCreator(creator); - } else { - container.add(creator, creator.toData().getWidgetName()); - } - XWAbsoluteLayout layout = (XWAbsoluteLayout) container; - layout.updateBoundsWidget(creator); - updateCreatorBackBound(); - LayoutUtils.layoutRootContainer(container); - } else { - fixAbsolute(creator, x, y); - if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { - addParentCreator(creator); - } else { - container.add(creator, creator.toData().getWidgetName()); - } - XWFitLayout layout = (XWFitLayout) container; - // 更新对应的BoundsWidget - layout.updateBoundsWidget(); - updateCreatorBackBound(); - } - } - - private void updateCreatorBackBound() { - for (int i = 0, size = container.getComponentCount(); i < size; i++) { - XCreator creator = (XCreator) container.getComponent(i); - creator.updateChildBound(minHeight); - creator.setBackupBound(creator.getBounds()); - } - } - - private void addParentCreator(XCreator child) { - XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight()); - container.add(parentPanel, child.toData().getWidgetName()); - } - - /** - * 新拖入组件时,计算调整其他关联组件位置大小 - * - * @param child 新拖入的组件 - * @param x 鼠标所在x坐标 - * @param y 鼠标所在y坐标 - */ - private void fixAbsolute(XCreator child, int x, int y) { - Component parentComp = container.getComponentAt(x, y); - if (container.getComponentCount() == 0) { - child.setLocation(0, 0); - child.setSize(parentComp.getWidth(), parentComp.getHeight()); - } else if (isCrossPointArea(parentComp, x, y)) { - //交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入 - fixCrossPointArea(parentComp, child, x, y); - return; - } else if (isTrisectionArea(parentComp, x, y)) { - // 在边界三等分区域,就不再和组件二等分了 - fixTrisect(parentComp, child, x, y); - return; - } else { - fixHalve(parentComp, child, x, y); - } - } - - /** - * 组件拖拽后调整大小 - * - * @param creator 组件 - */ - @Override - public void fix(XCreator creator) { - WAbsoluteLayout wabs = (WAbsoluteLayout) container.toData(); - fix(creator, creator.getX(), creator.getY()); - wabs.setBounds(creator.toData(), creator.getBounds()); - - XWAbsoluteLayout layout = (XWAbsoluteLayout) container; - layout.updateBoundsWidget(creator); - } - - /** - * 调整组件大小到合适尺寸位置 - * - * @param creator 组件 - * @param x 坐标x - * @param y 坐标y - */ - public void fix(XCreator creator, int x, int y) { - int height = creator.getHeight(); - int width = creator.getWidth(); - if (x < 0) { - x = container.getX(); - } else if (x + creator.getWidth() > container.getWidth()) { - x = container.getWidth() - width; - } - - if (y < 0) { - y = container.getY(); - } else if (y + creator.getHeight() > container.getHeight()) { - y = container.getHeight() - height; - } - - creator.setBounds(x, y, width, height); - } - - @Override - public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { - return new BoundsGroupModel((XWAbsoluteLayout) container, creator); - } - - @Override - public GroupModel getLayoutProperties() { - XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container; - return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout); - } +package com.fr.design.designer.beans.adapters.layout; + +import java.awt.*; + +import com.fr.design.beans.GroupModel; +import com.fr.design.designer.beans.ConstraintsGroupModel; +import com.fr.design.designer.beans.HoverPainter; +import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter; +import com.fr.design.designer.creator.*; +import com.fr.design.designer.properties.BoundsGroupModel; +import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.design.utils.ComponentUtils; +import com.fr.design.utils.gui.LayoutUtils; +import com.fr.general.ComparatorUtils; +import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; +import com.fr.general.FRLogger; + +public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { + //是不是添加到父容器上 + private boolean isAdd2ParentLayout = false; + private HoverPainter painter; + + public FRAbsoluteLayoutAdapter(XLayoutContainer container) { + super(container); + painter = new FRAbsoluteLayoutPainter(container); + initMinSize(); + } + + private void initMinSize() { + XWAbsoluteLayout layout = (XWAbsoluteLayout) container; + minWidth = layout.getActualMinWidth(); + minHeight = layout.getActualMinHeight(); + actualVal = layout.getAcualInterval(); + margin = layout.toData().getMargin(); + } + + @Override + public HoverPainter getPainter() { + return painter; + } + + /** + * 是否能在指定位置添加组件 + * @param creator 组件 + * @param x 坐标x + * @param y 坐标y + * @return 能则返回true + */ + //这个地方的逻辑非常复杂, + // 1.当前绝对布局是不可编辑且是最外层,那么其他控件添加在它周围, + // 2.当前绝对布局是不可编辑且不是最外层,那么控件不可添加,(嵌套) + // 3.当前绝对布局可编辑,那么控件添加 + @Override + public boolean accept(XCreator creator, int x, int y) { + Component comp = container.getComponentAt(x, y); + //布局控件要先判断是不是可编辑 + //可以编辑,按原有逻辑判断 + //不可编辑,当成一整个控件处理 + if (comp == null){ + return false; + } + //参数面板内的组件不允许拖往绝对布局中 + if (creator.getParent() != null && ((XCreator)creator.getParent()).acceptType(XWParameterLayout.class)){ + Rectangle rec = creator.getBounds(); + rec.y = creator.getParent().getHeight() - rec.height; + creator.setBounds(rec); + return false; + } + //判断下组件能不能拖入绝对布局 + if (!creator.canEnterIntoAbsolutePane()){ + return false; + } + XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout(); + if(topLayout != null){ + if (topLayout.isEditable()){ + return topLayoutAccept(creator, x, y, topLayout); + } + //绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局 + else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { + return false; + } + else { + return acceptWidget(creator, x, y); + } + } + else{ + FRLogger.getLogger().error("top layout is null!"); + } + + return false; + } + + //toplayout假如可以编辑的话就往里面添加组件 + private boolean topLayoutAccept(XCreator creator, int x, int y, XLayoutContainer topLayout) { + //判断有没有和当前控件重叠 + //先计算当前控件的位置 + int creatorX, creatorY; + if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { + + Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); + creatorX = creatorRectangle.x; + creatorY = creatorRectangle.y; + } else { + int w = creator.getWidth() / 2; + int h = creator.getHeight() / 2; + creatorX = x - w; + creatorY = y - h; + } + //再判断和布局中其他控件重叠 + Rectangle curRec = new Rectangle(creatorX, creatorY, creator.getWidth(), creator.getHeight()); + WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout)topLayout.toData(); + for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) { + BoundsWidget temp = (BoundsWidget) wAbsoluteLayout.getWidget(i); + Rectangle rectangle = temp.getBounds(); + if (curRec.intersects(rectangle)){ + return false; + } + } + if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) { + return false; + } + if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()){ + return false; + } + return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() + && creator.getWidth() <= container.getWidth(); + } + + /** + * 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 + * @param parentComp 鼠标所在区域的组件 + * @param x 坐标x + * @param y 坐标y + * @return 是则返回true + */ + public boolean isTrisectionArea(Component parentComp, int x, int y) { + XCreator creator = (XCreator)parentComp; + trisectAreaDirect = 0; + if (container.getComponentCount()<=1) { + return false; + } + int maxWidth = parentComp.getWidth(); + int maxHeight = parentComp.getHeight(); + int xL = parentComp.getX(); + int yL = parentComp.getY(); + // 组件宽高的十分之一和默认值取大 + int minRangeWidth = Math.max(maxWidth/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); + int minRangeHeight = Math.max(maxHeight/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); + if(yyL+maxHeight-minRangeHeight) { + // 在组件下侧三等分 + trisectAreaDirect = COMP_BOTTOM; + } else if (xxL+maxWidth-minRangeWidth) { + // 在组件右侧三等分 + trisectAreaDirect = COMP_RIGHT; + } + // tab布局的边界特殊处理,不进行三等分 + if(!creator.getTargetChildrenList().isEmpty()){ + return false; + } + + return !ComparatorUtils.equals(trisectAreaDirect, 0); + } + + //当前绝对布局不可编辑,就当成一个控件,组件添加在周围 + private boolean acceptWidget(XCreator creator, int x, int y){ + isFindRelatedComps = false; + //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 + Component comp = container.getComponentAt(x, y); + boolean isMatchEdge = false; + //如果当前处于边缘地带, 那么就把他贴到父容器上 + XLayoutContainer parent = container.findNearestFit(); + container = parent != null ? parent : container; + isAdd2ParentLayout = true; + + int componentHeight = comp.getHeight(); + int componentWidth = comp.getWidth(); + //上半部分高度 + int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); + //下半部分高度 + int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); + + if (isCrossPointArea(comp, x, y)) { + return canAcceptWhileCrossPoint(comp, x, y); + } + + if (isTrisectionArea(comp, x, y)) { + return canAcceptWhileTrisection(comp, x, y); + } + + boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; + boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; + return y > upHeight && y < downHeight ? horizonValid : verticalValid; + } + + /** + * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 + * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 + * + * @param creator 被添加的新组件 + * @param x 添加的位置x,该位置是相对于container的 + * @param y 添加的位置y,该位置是相对于container的 + * @return 是否添加成功,成功返回true,否则false + */ + @Override + public boolean addBean(XCreator creator, int x, int y) { + Rectangle rect = ComponentUtils.getRelativeBounds(container); + + int posX = x + rect.x; + int posY = y + rect.y; + if (!accept(creator, x, y)) { + return false; + } + addComp(creator, posX, posY); + ((XWidgetCreator) creator).recalculateChildrenSize(); + return true; + } + + @Override + protected void addComp(XCreator creator, int x, int y) { + if(!isAdd2ParentLayout) { + Rectangle r = ComponentUtils.getRelativeBounds(container); + x = x - r.x; + y = y - r.y; + if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { + + Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); + x = creatorRectangle.x - r.x; + y = creatorRectangle.y - r.y; + } else { + int w = creator.getWidth() / 2; + int h = creator.getHeight() / 2; + x = x - w; + y = y - h; + } + fix(creator, x, y); + + if (creator.hasTitleStyle()) { + addParentCreator(creator); + } else { + container.add(creator, creator.toData().getWidgetName()); + } + XWAbsoluteLayout layout = (XWAbsoluteLayout) container; + layout.updateBoundsWidget(creator); + updateCreatorBackBound(); + LayoutUtils.layoutRootContainer(container); + }else{ + fixAbsolute(creator, x, y); + if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { + addParentCreator(creator); + } else { + container.add(creator, creator.toData().getWidgetName()); + } + XWFitLayout layout = (XWFitLayout) container; + // 更新对应的BoundsWidget + layout.updateBoundsWidget(); + updateCreatorBackBound(); + } + } + + private void updateCreatorBackBound() { + for (int i=0,size=container.getComponentCount(); i container.getWidth()) { + width = container.getWidth() - x; + } + + if (y < 0) { + height += y; + y = 0; + } else if (y + creator.getHeight() > container.getHeight()) { + height = container.getHeight() - y; + } + + creator.setBounds(x, y, width, height); + } + + @Override + public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { + return new BoundsGroupModel((XWAbsoluteLayout)container, creator); + } + + @Override + public GroupModel getLayoutProperties() { + XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container; + return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index eca82e502..7401b8d07 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -1,1189 +1,1198 @@ -/** - * - */ -package com.fr.design.designer.beans.adapters.layout; - -import com.fr.design.beans.GroupModel; -import com.fr.design.designer.beans.ConstraintsGroupModel; -import com.fr.design.designer.beans.HoverPainter; -import com.fr.design.designer.beans.painters.FRFitLayoutPainter; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.cardlayout.XWCardLayout; -import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; -import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; -import com.fr.design.designer.properties.FRFitLayoutConstraints; -import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.mainframe.JForm; -import com.fr.design.utils.ComponentUtils; -import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.container.WLayout; -import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; -import com.fr.form.ui.widget.BoundsWidget; -import com.fr.general.ComparatorUtils; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -/** - * 自适应布局的容器适配器 - * - * @author jim - * @date 2014-6-24 - */ -public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { - - public static final String WIDGETPANEICONPATH = "/com/fr/web/images/form/resources/layout_absolute.png"; - private static final int DEPENDING_SCOPE = 3; - private HoverPainter painter; - //区分拖拽和编辑宽高 - private boolean isEdit; - - public boolean isEdit() { - return isEdit; - } - - public void setEdit(boolean edit) { - isEdit = edit; - } - - /** - * 构造函数 - * - * @param container XWFitLayout容器 - */ - public FRFitLayoutAdapter(XLayoutContainer container) { - super(container); - painter = new FRFitLayoutPainter(container); - initMinSize(); - } - - private void initMinSize() { - XWFitLayout layout = (XWFitLayout) container; - minWidth = layout.getActualMinWidth(); - minHeight = layout.getActualMinHeight(); - actualVal = layout.getAcualInterval(); - margin = layout.toData().getMargin(); - } - - @Override - public HoverPainter getPainter() { - return painter; - } - - /** - * 返回布局自身属性,方便一些特有设置在layout刷新时处理 - */ - @Override - public GroupModel getLayoutProperties() { - XWFitLayout xfl = (XWFitLayout) container; - return new FRFitLayoutPropertiesGroupModel(xfl); - } - - /** - * 添加组件 - * - * @param child 待添加的组件 - * @param x 坐标x - * @param y 坐标y - */ - @Override - public void addComp(XCreator child, int x, int y) { - fix(child, x, y); - if (child.shouldScaleCreator() || child.hasTitleStyle()) { - addParentCreator(child); - } else { - container.add(child, child.toData().getWidgetName()); - } - XWFitLayout layout = (XWFitLayout) container; - // 更新对应的BoundsWidget - layout.updateBoundsWidget(); - updateCreatorBackBound(); - } - - public void updateCreatorBackBound() { - for (int i = 0, size = container.getComponentCount(); i < size; i++) { - XCreator creator = (XCreator) container.getComponent(i); - creator.updateChildBound(minHeight); - creator.setBackupBound(creator.getBounds()); - } - } - - - private void addParentCreator(XCreator child) { - XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight); - container.add(parentPanel, child.toData().getWidgetName()); - } - - /** - * 能否对应位置放置当前组件 - * - * @param creator 组件 - * @param x 添加的位置x,该位置是相对于container的 - * @param y 添加的位置y,该位置是相对于container的 - * @return 是否可以放置 - */ - @Override - public boolean accept(XCreator creator, int x, int y) { - // 计算是否能拖入鼠标区域时,会用到fix 的方法 - isFindRelatedComps = false; - //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 - Component comp = container.getComponentAt(x, y); - if (comp == null || checkInterval(comp)) { - return false; - } - //如果当前处于边缘地带, 那么就把他贴到父容器上 - boolean isMatchEdge = matchEdge(x, y); - - int componentHeight = comp.getHeight(); - int componentWidth = comp.getWidth(); - //上半部分高度 - int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); - //下半部分高度 - int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); - - //布局控件要先判断是不是可编辑 - XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); - if (topLayout != null && !isMatchEdge && !topLayout.isEditable()) { - return false; - } - - if (isCrossPointArea(comp, x, y)) { - return canAcceptWhileCrossPoint(comp, x, y); - } - - if (isTrisectionArea(comp, x, y)) { - return canAcceptWhileTrisection(comp, x, y); - } - - boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; - boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; - return y > upHeight && y < downHeight ? horizonValid : verticalValid; - } - - // 间隔区域 - private boolean checkInterval(Component comp) { - return container.getComponentCount() > 0 && comp == container; - } - - /** - * 是否在组件边缘 - * - * @param x 横坐标 - * @param y 纵坐标 - * @return 是否在组件边缘 - */ - public boolean matchEdge(int x, int y) { - if (intersectsEdge(x, y, container)) { - //寻找最近的fit, 在边缘地段添加的控件, 将其送给该fit - XLayoutContainer parent = container.findNearestFit(); - container = parent != null ? parent : container; - return true; - } - return false; - } - - /** - * 是否在组件边缘 - * - * @param x 横坐标 - * @param y 纵坐标 - * @param container 参照组件 - * @return 是否在组件边缘 - */ - //是否包含于边缘地段, 按顺序上, 下, 左, 右检测 - public boolean intersectsEdge(int x, int y, XLayoutContainer container) { - int containerX = container.getX(); - int containerY = container.getY(); - int containerWidth = container.getWidth(); - int containerHeight = container.getHeight(); - - // 当前坐标点 - Rectangle currentXY = new Rectangle(x, y, 1, 1); - // 上边缘 - Rectangle upEdge = new Rectangle(containerX, containerY, containerWidth, BORDER_PROPORTION); - if (upEdge.intersects(currentXY)) { - return true; - } - - int bottomY = containerY + containerHeight - BORDER_PROPORTION; - // 下边缘 - Rectangle bottomEdge = new Rectangle(containerX, bottomY, containerWidth, BORDER_PROPORTION); - if (bottomEdge.intersects(currentXY)) { - return true; - } - - //左右边缘的高度 -10*2 是为了不和上下边缘重合 - int verticalHeight = containerHeight - BORDER_PROPORTION * 2; - int leftY = containerY + BORDER_PROPORTION; - // 左边缘 - Rectangle leftEdge = new Rectangle(containerX, leftY, BORDER_PROPORTION, verticalHeight); - if (leftEdge.intersects(currentXY)) { - return true; - } - - int rightY = containerY + BORDER_PROPORTION; - int rightX = containerX + containerWidth - BORDER_PROPORTION; - // 右边缘 - Rectangle rightEdge = new Rectangle(rightX, rightY, BORDER_PROPORTION, verticalHeight); - return rightEdge.intersects(currentXY); - } - - /** - * 交叉点区域时,能否对应位置放入组件 - */ - protected boolean canAcceptWhileCrossPoint(Component comp, int x, int y) { - return super.canAcceptWhileCrossPoint(comp, x, y); - } - - protected boolean canAcceptWhileTrisection(Component comp, int x, int y) { - return super.canAcceptWhileTrisection(comp, x, y); - } - - /** - * 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 - * - * @param parentComp 鼠标所在区域的组件 - * @param x 坐标x - * @param y 坐标y - * @return 是则返回true - */ - public boolean isTrisectionArea(Component parentComp, int x, int y) { - return super.isTrisectionArea(parentComp, x, y); - } - - /** - * 是否为组件交叉点区域 或者是相邻三组建中间点 - * - * @param currentComp 当前组件 - * @param x 坐标x - * @param y 坐标y - * @return 是则返回true - */ - public boolean isCrossPointArea(Component currentComp, int x, int y) { - return super.isCrossPointArea(currentComp, x, y); - } - - - protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) { - return mainLayout.getBounds(); - } - - private Rectangle adjustBackupBound(Rectangle backupBound, XWCardMainBorderLayout mainLayout) { - // 参数界面高度对纵坐标产生的影响 - JForm jform = (JForm) (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - if (jform.getFormDesign().getParaComponent() != null) { - backupBound.y -= jform.getFormDesign().getParaHeight(); - } - - Rectangle rec = getLayoutBound(mainLayout); - // XWTabLayout里面的横纵坐标收到外层XWCardMainBorderLayout的横纵坐标影响 - // 减掉之后可以按照它原来的逻辑执行 - backupBound.x -= rec.x; - backupBound.y -= rec.y; - XWCardLayout cardLayout = mainLayout.getCardPart(); - LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); - // 当tab布局为标题样式时,才需要处理标题栏高度产生的影响 - if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { - backupBound.y -= WCardMainBorderLayout.TAB_HEIGHT; - } - return backupBound; - } - - /** - * 拖拽控件边框后,根据控件的大小尺寸,进行相关组件的调整 - * - * @param creator 组件 - */ - @Override - public void fix(XCreator creator) { - //拖拽组件原大小、位置 - Rectangle backupBound = creator.getBackupBound(); - backupBound.x -= container.getX(); - backupBound.y -= container.getY(); - //当前拖拽组件的位置 - int x = creator.getX(); - int y = creator.getY(); - - // 获取容器所有内部组件横坐标 - int[] posXs = container.getHors(); - // 获取容器所有内部组件纵坐标 - int[] posYs = container.getVeris(); - - XLayoutContainer outerLayout = container.getOuterLayout(); - if (!ComparatorUtils.equals(outerLayout, container.getBackupParent())) { - XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) outerLayout; - backupBound = adjustBackupBound(backupBound, mainLayout); - } - - //拖拽组件拖拽以后的大小 - int w = creator.getWidth(); - int h = creator.getHeight(); - initCompsList(); - creator.setBounds(backupBound); - int difference = 0; - if (x != backupBound.x) { - dealLeft(backupBound, x, posXs, difference, creator); - } else if (w != backupBound.width) { - dealRight(backupBound, x, w, posXs, difference, creator); - } else if (y != backupBound.y) { - dealTop(backupBound, y, posYs, difference, creator); - } else if (h != backupBound.height) { - dealButtom(backupBound, y, h, posYs, difference, creator); - } - clearCompsList(); - XWFitLayout layout = (XWFitLayout) container; - layout.updateBoundsWidget(); // 更新对应的BoundsWidget - updateCreatorBackBound(); - } - - /** - * 拖拽控件边框后,根据控件的大小尺寸,进行相关组件的调整 - * - * @param backupBound 边界备份 - * @param bounds 组件边界 - * @param xCreator 组件 - * @param row 选中的行 - * @param difference 偏移量 - */ - public void calculateBounds(Rectangle backupBound, Rectangle bounds, XCreator xCreator, int row, int difference) { - Rectangle rc = new Rectangle(0, 0, 0, 0); - XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); - if (parent != null) { - Rectangle rec = ComponentUtils.getRelativeBounds(parent); - rc.x = rec.x; - rc.y = rec.y; - } - int x = backupBound.x - rc.x, y = backupBound.y - rc.y; - //处理左右延伸 - switch (row) { - case 0: - if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight() + rc.x) { - x += difference; - } - break; - case 1: - if (backupBound.y + backupBound.height == container.getHeight() - margin.getBottom() + rc.y) { - y += difference; - } - break; - } - bounds.setLocation(x, y); - xCreator.setBackupBound(backupBound); - xCreator.setBounds(bounds); - this.fix(xCreator); - } - - private void dealLeft(Rectangle backupBound, int x, int[] posXs, int difference, XCreator creator) { - if (backupBound.x == margin.getLeft()) { - return; - } - x = adjustCoordinateByDependingLine(x, posXs); - difference = x - backupBound.x; - dealDirectionAtLeft(backupBound, difference, creator); - } - - private void dealRight(Rectangle backupBound, int x, int w, int[] posXs, int difference, XCreator creator) { - if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight()) { - return; - } - w = adjustDiffByDependingLine(x, posXs, w); - difference = w - backupBound.width; //拖拽长度 - dealDirectionAtRight(backupBound, difference, creator); - } - - private void dealTop(Rectangle backupBound, int y, int[] posYs, int difference, XCreator creator) { - if (backupBound.y == margin.getTop()) { - return; - } - y = adjustCoordinateByDependingLine(y, posYs); - difference = y - backupBound.y; - dealDirectionAtTop(backupBound, difference, creator); - } - - private void dealButtom(Rectangle backupBound, int y, int h, int[] posYs, int difference, XCreator creator) { - if (backupBound.y + backupBound.height == container.getHeight() - margin.getBottom()) { - return; - } - h = adjustDiffByDependingLine(y, posYs, h); - difference = h - backupBound.height; - dealDirectionABottom(backupBound, difference, creator); - } - - // 根据需要依附的位置调整拖拽的坐标值 - private int adjustCoordinateByDependingLine(int coordinate, int[] coordinates) { - if (!isEdit) { - for (int i = 0; i < coordinates.length; i++) { - if (coordinate == coordinates[i]) { - continue; - } - if (coordinate > coordinates[i] - DEPENDING_SCOPE && coordinate < coordinates[i] + DEPENDING_SCOPE) { - coordinate = coordinates[i]; - break; - } - } - } - return coordinate; - } - - // 根据需要依附的位置调整拖拽的距离 - private int adjustDiffByDependingLine(int coordinate, int[] coordinates, int diff) { - if (!isEdit) { - for (int i = 0; i < coordinates.length; i++) { - if (coordinate + diff > coordinates[i] - DEPENDING_SCOPE && coordinate + diff < coordinates[i] + DEPENDING_SCOPE) { - diff = coordinates[i] - coordinate; - break; - } - } - } - return diff; - } - - // 左侧边框拉伸,循环找出对齐的两侧控件 - private void dealDirectionAtLeft(Rectangle backupBound, int difference, Component creator) { - rightComps.add(creator); - Component rightComp = null; - int leftx = backupBound.x - DEFAULT_AREA_LENGTH - actualVal; - // 取左侧边框右面的组件x值 - int rightx = backupBound.x + DEFAULT_AREA_LENGTH; - Component leftComp = container.getLeftComp(backupBound.x, backupBound.y); - leftComps.add(leftComp); - //先找上侧对齐时(y相等)的左右两边组件 - int ry = backupBound.y; - int ly = leftComp.getY(); - int min = margin.getTop(); - int max = container.getHeight() - margin.getBottom(); - while (ry >= min && ly >= min) { - if (ry == ly) { - break; - } else { - if (ry > ly) { - rightComp = container.getTopComp(rightx, ry); - ry = rightComp.getY(); - rightComps.add(rightComp); - } else { - leftComp = container.getTopComp(leftx, ly); - ly = leftComp.getY(); - leftComps.add(leftComp); - } - } - } - // 下侧对齐时(y+h相等)两边组件 - ry = backupBound.y + backupBound.height; - ly = leftComps.get(0).getY() + leftComps.get(0).getHeight(); - while (ry <= max && ly <= max) { - if (ry == ly) { - break; - } else { - if (ry > ly) { - leftComp = container.getComponentAt(leftx, ly + DEFAULT_AREA_LENGTH + actualVal); - ly = leftComp.getY() + leftComp.getHeight(); - leftComps.add(leftComp); - } else { - rightComp = container.getComponentAt(rightx, ry + DEFAULT_AREA_LENGTH + actualVal); - ry = rightComp.getY() + rightComp.getHeight(); - rightComps.add(rightComp); - } - } - } - dealHorDirection(backupBound.x, difference); - } - - // 右侧边框拉伸,循环找出对齐的两侧控件 - private void dealDirectionAtRight(Rectangle backupBound, int difference, Component creator) { - leftComps.add(creator); - Component leftComp = null; - int leftx = backupBound.x + backupBound.width - DEFAULT_AREA_LENGTH; - // 取右侧边框右面的组件x值 - int rightx = backupBound.x + backupBound.width + DEFAULT_AREA_LENGTH + actualVal; - Component rightComp = container.getRightComp(backupBound.x, backupBound.y, backupBound.width); - rightComps.add(rightComp); - int ly = backupBound.y, ry = rightComp.getY(); - int min = margin.getTop(); - int max = container.getHeight() - margin.getBottom(); - while (ry >= min && ly >= min) { - if (ry == ly) { - break; - } else { - if (ry > ly) { - rightComp = container.getTopComp(rightx, ry); - ry = rightComp.getY(); - rightComps.add(rightComp); - } else { - leftComp = container.getTopComp(leftx, ly); - ly = leftComp.getY(); - leftComps.add(leftComp); - } - } - } - ly = backupBound.y + backupBound.height; - ry = rightComps.get(0).getY() + rightComps.get(0).getHeight(); - while (ry <= max && ly <= max) { - if (ry == ly) { - break; - } else { - if (ry > ly) { - leftComp = container.getComponentAt(leftx, ly + DEFAULT_AREA_LENGTH + actualVal); - ly = leftComp.getY() + leftComp.getHeight(); - leftComps.add(leftComp); - } else { - rightComp = container.getComponentAt(rightx, ry + DEFAULT_AREA_LENGTH + actualVal); - ry = rightComp.getY() + rightComp.getHeight(); - rightComps.add(rightComp); - } - } - } - dealHorDirection(backupBound.x + backupBound.width + actualVal, difference); - } - - /** - * 水平方向上拉伸边框的处理 - */ - private void dealHorDirection(int objx, int difference) { - if (difference > 0) { - difference = Math.min(getMinWidth(rightComps) - minWidth, difference); - } else { - difference = Math.max(difference, minWidth - getMinWidth(leftComps)); - } - //重新计算左右两侧组件size、point - if (calculateLefttRelatComponent(difference)) { - calculateRightRelatComponent(objx + difference, -difference); - } - } - - // 上侧边框拉伸,循环找出对齐的两侧控件 - private void dealDirectionAtTop(Rectangle backupBound, int difference, Component creator) { - downComps.add(creator); - // 取上侧边框上面的组件用的y值 - int topy = backupBound.y - DEFAULT_AREA_LENGTH - actualVal; - // 上侧边框下面的组件y值 - int bottomy = backupBound.y + DEFAULT_AREA_LENGTH; - Component topComp = container.getTopComp(backupBound.x, backupBound.y); - upComps.add(topComp); - Component bottomComp = null; - int min = margin.getLeft(); - int max = container.getWidth() - margin.getRight(); - //先找左侧侧对齐时(x相等)的上下两边组件 - int ux = topComp.getX(); - int dx = backupBound.x; - while (ux >= min && dx >= min) { - if (ux == dx) { - break; - } else { - if (ux < dx) { - bottomComp = container.getLeftComp(dx, bottomy); - dx = bottomComp.getX(); - downComps.add(bottomComp); - } else { - topComp = container.getLeftComp(ux, topy); - ux = topComp.getX(); - upComps.add(topComp); - } - } - } - // 右侧对齐时(x+w相等)两边组件 - ux = upComps.get(0).getX() + upComps.get(0).getWidth(); - dx = backupBound.x + backupBound.width; - while (ux <= max && dx <= max) { - if (ux == dx) { - break; - } else { - if (ux < dx) { - topComp = container.getComponentAt(ux + DEFAULT_AREA_LENGTH + actualVal, topy); - ux = topComp.getX() + topComp.getWidth(); - upComps.add(topComp); - } else { - bottomComp = container.getComponentAt(dx + DEFAULT_AREA_LENGTH + actualVal, bottomy); - dx = bottomComp.getX() + bottomComp.getWidth(); - downComps.add(bottomComp); - } - } - } - - dealVertiDirection(backupBound.y, difference); - } - - // 下侧边框拉伸,循环找出对齐的两侧控件 - private void dealDirectionABottom(Rectangle backupBound, int difference, Component creator) { - upComps.add(creator); - Component topComp = null; - Component bottomComp = container.getBottomComp(backupBound.x, backupBound.y, backupBound.height); - // 下侧边框下面的组件y坐标 - int bottomy = backupBound.y + backupBound.height + DEFAULT_AREA_LENGTH + actualVal; - // 取下侧边框上面的组件用的y值 - int topy = backupBound.y + backupBound.height - DEFAULT_AREA_LENGTH; - downComps.add(bottomComp); - int dx = bottomComp.getX(); - int ux = backupBound.x; - int min = margin.getLeft(); - int max = container.getWidth() - margin.getRight(); - while (ux >= min && dx >= min) { - if (ux == dx) { - break; - } else { - if (ux < dx) { - bottomComp = container.getLeftComp(dx, bottomy); - dx = bottomComp.getX(); - downComps.add(bottomComp); - } else { - topComp = container.getLeftComp(ux, topy); - ux = topComp.getX(); - upComps.add(topComp); - } - } - } - dx = downComps.get(0).getX() + downComps.get(0).getWidth(); - ux = backupBound.x + backupBound.width; - while (ux <= max && dx <= max) { - if (ux == dx) { - break; - } else { - if (ux < dx) { - topComp = container.getComponentAt(ux + DEFAULT_AREA_LENGTH + actualVal, topy); - ux = topComp.getX() + topComp.getWidth(); - upComps.add(topComp); - } else { - bottomComp = container.getComponentAt(dx + DEFAULT_AREA_LENGTH + actualVal, bottomy); - dx = bottomComp.getX() + bottomComp.getWidth(); - downComps.add(bottomComp); - } - } - } - dealVertiDirection(backupBound.y + backupBound.height + actualVal, difference); - } - - /** - * 垂直方向上拉伸边框的处理 - */ - private void dealVertiDirection(int objY, int difference) { - if (difference > 0) { - difference = Math.min(getMinHeight(downComps) - minHeight, difference); - } else { - difference = Math.max(difference, minHeight - getMinHeight(upComps)); - } - //重新计算上下两侧组件size、point - if (calculateUpRelatComponent(difference)) { - calculateDownRelatComponent(objY + difference, -difference); - } - } - - /** - * 新拖入组件时,计算调整其他关联组件位置大小 - * - * @param child 新拖入的组件 - * @param x 鼠标所在x坐标 - * @param y 鼠标所在y坐标 - */ - public void fix(XCreator child, int x, int y) { - Component parentComp = container.getComponentAt(x, y); - if (container.getComponentCount() == 0) { - child.setLocation(0, 0); - child.setSize(parentComp.getWidth(), parentComp.getHeight()); - } else if (isCrossPointArea(parentComp, x, y)) { - //交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入 - fixCrossPointArea(parentComp, child, x, y); - return; - } else if (isTrisectionArea(parentComp, x, y)) { - // 在边界三等分区域,就不再和组件二等分了 - fixTrisect(parentComp, child, x, y); - return; - } else { - fixHalve(parentComp, child, x, y); - } - } - - /** - * 平分,正常情况拖入组件时,按照上1/4区域、下1/4区域为上下平分,中左侧1/2区域、中右侧1/2区域为左右平分 - */ - protected void fixHalve(Component currentComp, XCreator child, int x, int y) { - super.fixHalve(currentComp, child, x, y); - } - - /** - * 组件交叉区域进行插入时,调整受到变动的其他组件,之前是交叉区域插入也按照三等分逻辑,后面测试中发现有bug,改为和bi一样的鼠标所在侧平分 - * 默认左上角、右下角区域是垂直方向插入组件 - * 右上角和左下角是水平方向插入组件,这样避免田字块时重复 - */ - protected void fixCrossPointArea(Component currentComp, XCreator child, int x, int y) { - super.fixCrossPointArea(currentComp, child, x, y); - } - - /** - * 三等分区域时,调整相关联的组件 - * - * @param currentComp 鼠标所在组件 - * @param child 待插入组件 - */ - protected void fixTrisect(Component currentComp, XCreator child, int x, int y) { - super.fixTrisect(currentComp, child, x, y); - } - - /** - * 删除组件或者重新拖动时,其它组件重新计算位置大小 - */ - protected void delete(XCreator creator, int creatorWidth, int creatorHeight) { - int x = creator.getX(); - int y = creator.getY(); - recalculateChildrenSize(x, y, creatorWidth, creatorHeight); - } - - /** - * 重新计算内部组件大小 - * - * @param x 坐标x - * @param y 坐标y - * @param creatorWidth 删除的组件之前所在布局的宽度 - * @param creatorHeight 删除的组件之前所在布局的高度 - */ - public void recalculateChildrenSize(int x, int y, int creatorWidth, int creatorHeight) { - if (container.getComponentCount() == 0) { - return; - } else { - initCompsList(); - int width = creatorWidth; - int height = creatorHeight; - calculateRelatedComponent(x, y, width, height); - if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) { - calculateRightRelatComponent(x, width + actualVal); - } else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) { - calculateLefttRelatComponent(width + actualVal); - } else if (!downComps.isEmpty() && getAllWidth(downComps) == width) { - calculateDownRelatComponent(y, height + actualVal); - } else if (!upComps.isEmpty() && getAllWidth(upComps) == width) { - calculateUpRelatComponent(height + actualVal); - } else { - // 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理 - calculateNoRelatedComponent(x, y, width, height); - } - } - clearCompsList(); - } - - /** - * 四侧边框都没有对齐的,此时每侧有且只有一个方向不对齐 - * 比如右侧不对齐,那么必然右上或右下没对齐,不会同时不对齐,否则不会出现此情况 - * 正常删除是右左下上优先原则,这边目前只调整右侧以至填充完整, - * 右侧不对齐时的组件先上下微调,再向左侧填充。 - */ - private void calculateNoRelatedComponent(int x, int y, int width, int height) { - // 只有最后一个组件了,直接删除 - if (container.getComponentCount() <= 1) { - return; - } - // 删除当前组件时,由于没有刚好边框对齐的其他组件,这时候需要调整的组件 - Component rightComp = container.getRightComp(x, y, width); - if (rightComp == null) { - return; - } - - int ry = rightComp.getY(); - clearCompsList(); - initCompsList(); - Rectangle rec = new Rectangle(x, y, width, height); - if (ry != y) { - calculateNoRelatedWhileRightTop(rec, rightComp); - } else { - calculateNoRelatedWhileRightBott(rec, rightComp); - } - - } - - private void calculateNoRelatedWhileRightTop(Rectangle bound, Component rcomp) { - if (rcomp == null) { - return; - } - - int ry = rcomp.getY(); - int rh = rcomp.getHeight(); - int rw = rcomp.getWidth(); - int dh = bound.y - ry - actualVal; - // 没法缩小高度 - if (dh < minHeight) { - // 没法缩小时则拉伸rcomp的上边框 - dealDirectionAtTop(rcomp.getBounds(), dh + actualVal, rcomp); - //调整的时候可能有组件达到最小高度,判断下 - if (rcomp.getY() != bound.y) { - clearCompsList(); - initCompsList(); - dealDirectionAtTop(rcomp.getBounds(), bound.y - rcomp.getY() - minHeight - actualVal, rcomp); - ry = rcomp.getY(); - int rx = rcomp.getX(); - rcomp.setBounds(rx, ry, rw, minHeight); - recalculateChildrenSize(rx, bound.y, rw, rh - dh - actualVal); - recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); - return; - } - } else { - // 右侧控件底部对齐 - if (rh + ry == bound.y + bound.height) { - rcomp.setSize(rw, dh); - bound.width += rw; - bound.width += actualVal; - } else { - recalculateChildrenSize(bound.x, ry + rh + actualVal, bound.width, bound.height + bound.y - rh - ry - actualVal); - recalculateChildrenSize(bound.x, bound.y, bound.width, ry + rh - bound.y); - return; - } - } - recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); - } - - private void calculateNoRelatedWhileRightBott(Rectangle bound, Component rcomp) { - rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); - int ry = rcomp.getY(); - int rh = rcomp.getHeight(); - int rw = rcomp.getWidth(); - int dh = ry + rh - bound.y - bound.height - actualVal; - if (dh < minHeight) { - dealDirectionABottom(rcomp.getBounds(), -dh - actualVal, rcomp); - //调整的时候可能有组件达到最小高度,判断下 - if (rcomp.getHeight() + ry != bound.y + bound.height) { - clearCompsList(); - initCompsList(); - dh = ry + rcomp.getHeight() - bound.y - bound.height - actualVal; - dealDirectionABottom(rcomp.getBounds(), minHeight - dh, rcomp); - rh = rcomp.getHeight(); - int rx = rcomp.getX(); - rcomp.setBounds(rx, bound.y + bound.height + actualVal, rw, minHeight); - recalculateChildrenSize(rx, ry, rw, rh - minHeight - actualVal); - recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); - return; - } - } else { - if (ry == bound.y) { - rcomp.setBounds(rcomp.getX(), bound.y + bound.height + actualVal, rw, dh); - bound.width += rw; - bound.width += actualVal; - } else { - recalculateChildrenSize(bound.x, bound.y, bound.width, ry - bound.y - actualVal); - recalculateChildrenSize(bound.x, ry, bound.width, bound.height - ry + bound.y); - return; - } - } - recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); - } - - private int getMinWidth(List comps) { - if (comps.isEmpty()) { - return 0; - } - int minWidth = container.getWidth() - margin.getLeft() - margin.getRight(); - for (int i = 0, size = comps.size(); i < size; i++) { - minWidth = minWidth > comps.get(i).getWidth() ? comps.get(i).getWidth() : minWidth; - } - return minWidth; - } - - private int getMinHeight(List comps) { - if (comps.isEmpty()) { - return 0; - } - int minH = container.getHeight() - margin.getTop() - margin.getBottom(); - for (int i = 0, size = comps.size(); i < size; i++) { - minH = minH > comps.get(i).getHeight() ? comps.get(i).getHeight() : minH; - } - return minH; - } - - // 删除时计算待删除组件上下侧的组件是否何其对齐 - private int getAllHeight(List comps) { - int allHeight = 0; - if (comps.isEmpty()) { - return allHeight; - } - int n = comps.size(); - for (int i = 0; i < n; i++) { - allHeight += comps.get(i).getHeight(); - } - allHeight += (n - 1) * actualVal; - return allHeight; - } - - private int getAllWidth(List comps) { - int allWidth = 0; - if (comps.isEmpty()) { - return allWidth; - } - int n = comps.size(); - for (int i = 0; i < n; i++) { - allWidth += comps.get(i).getWidth(); - } - allWidth += (n - 1) * actualVal; - return allWidth; - } - - /** - * 获取有哪些相关联的组件 - */ - protected void calculateRelatedComponent(int objX, int objY, int objWidth, int objHeight) { - int count = container.getComponentCount(); - for (int i = 0; i < count; i++) { - Component relatComp = container.getComponent(i); - int rx = relatComp.getX(); - int ry = relatComp.getY(); - int rwidth = relatComp.getWidth(); - int rheight = relatComp.getHeight(); - int verti = ry - objY; - int hori = rx - objX; - boolean isHori = verti >= 0 && objHeight >= (rheight + verti); - boolean isVerti = hori >= 0 && objWidth >= (rwidth + hori); - if (isHori && (objX + objWidth + actualVal) == rx) { - rightComps.add(relatComp); - } else if (isHori && objX == (rx + rwidth + actualVal)) { - leftComps.add(relatComp); - } else if (isVerti && (objY + objHeight + actualVal) == ry) { - downComps.add(relatComp); - } else if (isVerti && objY == (ry + rheight + actualVal)) { - upComps.add(relatComp); - } - } - } - - /** - * 拖拽组件时遍历某一侧组件得到该侧组件能够缩放的最小宽度,tab布局最小宽度 = 内部组件数 * 单个组件最小宽度 - * - * @param list 某一侧组件的集合 如:leftComps - * @return int 最小宽度 - */ - private int getCompsMinWidth(List list) { - return getMaxCompsNum(list, true) * WLayout.MIN_WIDTH; - } - - /** - * 拖拽组件遍历某一侧得到该侧组件能够缩放的最小高度,tab布局最小高度 = 内部组件数 * 单个组件最小高度 + 标题高度 - * - * @param list 某一侧组件集合 - * @return int 最小高度 - */ - private int getCompsMinHeight(List list) { - for (int i = 0; i < list.size(); i++) { - XCreator creator = (XCreator) list.get(i); - ArrayList childrenList = creator.getTargetChildrenList(); - if (!childrenList.isEmpty()) { - return getMaxCompsNum(list, false) * WLayout.MIN_HEIGHT + WCardMainBorderLayout.TAB_HEIGHT; - } - } - return WLayout.MIN_HEIGHT; - } - - /** - * 根据子组件的横(纵)坐标获取某一侧组件的最大内部组件数 - * - * @param list 某一侧组件集合 - * @param isHor 是否以横坐标为准 - * @return int 最大内部组件数 - */ - private int getMaxCompsNum(List list, boolean isHor) { - int maxCompNums = 1; - for (int i = 0, size = list.size(); i < size; i++) { - XCreator creator = (XCreator) list.get(i); - ArrayList childrenList = creator.getTargetChildrenList(); - int count = childrenList.size(); - if (count > 0) { - for (int j = 0; j < count; j++) { - XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j); - int[] positions = isHor ? tabLayout.getHors(true) : tabLayout.getVeris(true); - int compNums = positions.length - 1; - maxCompNums = Math.max(compNums, maxCompNums); - } - } - } - return maxCompNums; - } - - /** - * 根据偏移量缩放内部组件大小,(tab布局用到) - * - * @param creator tab布局 - * @param offset 偏移量 - * @param isHor 是否为横向拖拽 - */ - private void adjustCompsSize(XCreator creator, int offset, boolean isHor) { - ArrayList childrenList = creator.getTargetChildrenList(); - int size = childrenList.size(); - if (size > 0) { - for (int j = 0; j < size; j++) { - XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j); - tabLayout.setBackupBound(tabLayout.getBounds()); - int refSize = isHor ? tabLayout.getWidth() : tabLayout.getHeight(); - double percent = (double) offset / refSize; - if (percent < 0 && !tabLayout.canReduce(percent)) { - return; - } - setAdjustedSize(tabLayout, offset, isHor); - for (int m = 0; m < tabLayout.getComponentCount(); m++) { - XCreator childCreator = tabLayout.getXCreator(m); - BoundsWidget wgt = tabLayout.toData().getBoundsWidget(childCreator.toData()); - wgt.setBounds(tabLayout.getComponent(m).getBounds()); - } - adjustCreatorsSize(percent, tabLayout, isHor); - } - - } - } - - // 纵向拖拽,先将tab布局的高度设置为拖拽后的实际高度 - private void setAdjustedHeight(XWTabFitLayout tabLayout, int offset) { - tabLayout.setSize(tabLayout.getWidth(), tabLayout.getHeight() + offset); - } - - // 横向拖拽,先将tab布局的宽度设置为拖拽后的实际宽度 - private void setAdjustedSize(XWTabFitLayout tabLayout, int offset, boolean isHor) { - if (offset < 0) { - // 缩放时需要备份原tab布局宽高 - tabLayout.setReferDim(new Dimension(tabLayout.getWidth(), tabLayout.getHeight())); - } - if (isHor) { - tabLayout.setSize(tabLayout.getWidth() + offset, tabLayout.getHeight()); - return; - } - setAdjustedHeight(tabLayout, offset); - } - - // 按照拖拽偏移量,对tab布局进行缩放 - private void adjustCreatorsSize(double percent, XWTabFitLayout tabLayout, boolean isHor) { - if (isHor) { - tabLayout.adjustCreatorsWidth(percent); - return; - } - tabLayout.adjustCreatorsHeight(percent); - } - - - /** - * 删除或拉伸控件右边框 调整右侧组件位置大小 - * - * @param objX 调整后的坐标x - * @param objWidth 调整后的宽度 - */ - protected void calculateRightRelatComponent(int objX, int objWidth) { - int count = rightComps.size(); - for (int i = 0; i < count; i++) { - XCreator creator = (XCreator) rightComps.get(i); - adjustCompsSize(creator, objWidth, true); - int ry = creator.getY(); - int rwidth = creator.getWidth(); - int rheight = creator.getHeight(); - creator.setLocation(objX, ry); - creator.setSize(rwidth + objWidth, rheight); - } - } - - /** - * 实际拖拽偏移量是否超出了可调整的宽度范围 - * - * @param offset 实际偏移量 - * @return boolean 是否超出调整范围 - */ - private boolean isBeyondAdjustWidthScope(int offset) { - boolean isBeyondScope = false; - isBeyondScope = offset < 0 ? isBeyondWidthScope(offset, leftComps) : isBeyondWidthScope(offset, rightComps); - return isBeyondScope; - } - - // 实际拖拽偏移量是否超出某一侧的可调整宽度 - private boolean isBeyondWidthScope(int offset, List compsList) { - int compMinWidth = getCompsMinWidth(compsList); - for (int i = 0; i < compsList.size(); i++) { - XCreator creator = (XCreator) compsList.get(i); - if (Math.abs(offset) > (creator.getWidth() - compMinWidth)) { - return true; - } - } - return false; - } - - /** - * 删除或拉伸控件左边框时 调整左侧的组件位置大小; - */ - protected boolean calculateLefttRelatComponent(int objWidth) { - if (isBeyondAdjustWidthScope(objWidth)) { - return false; - } - int count = leftComps.size(); - for (int i = 0; i < count; i++) { - XCreator creator = (XCreator) leftComps.get(i); - adjustCompsSize(creator, objWidth, true); - int rwidth = creator.getWidth(); - int rheight = creator.getHeight(); - creator.setSize(rwidth + objWidth, rheight); - } - return true; - } - - /** - * 删除或拉伸下边框 调整下方的组件位置大小 - */ - protected void calculateDownRelatComponent(int objY, int objHeight) { - int count = downComps.size(); - for (int i = 0; i < count; i++) { - XCreator creator = (XCreator) downComps.get(i); - adjustCompsSize(creator, objHeight, false); - int rx = creator.getX(); - int rwidth = creator.getWidth(); - int rheight = creator.getHeight(); - creator.setLocation(rx, objY); - creator.setSize(rwidth, rheight + objHeight); - } - } - - /** - * 实际拖拽偏移量是否超出了可调整的高度范围 - * - * @param offset 实际偏移量 - * @return boolean 是否超出调整范围 - */ - private boolean isBeyondAdjustHeightScope(int offset) { - boolean isBeyondScope = false; - isBeyondScope = offset < 0 ? isBeyondHeightScope(offset, upComps) : isBeyondHeightScope(offset, downComps); - return isBeyondScope; - } - - // 实际拖拽偏移量是否超出某一侧的可调整高度 - private boolean isBeyondHeightScope(int offset, List compsList) { - int minHeight = getCompsMinHeight(compsList); - for (int i = 0; i < compsList.size(); i++) { - XCreator creator = (XCreator) compsList.get(i); - if (Math.abs(offset) > (creator.getHeight() - minHeight)) { - return true; - } - } - return false; - } - - /** - * 删除或拉伸上边框 调整上方的组件位置大小 - */ - protected boolean calculateUpRelatComponent(int objHeight) { - if (isBeyondAdjustHeightScope(objHeight)) { - return false; - } - int count = upComps.size(); - for (int i = 0; i < count; i++) { - XCreator creator = (XCreator) upComps.get(i); - adjustCompsSize(creator, objHeight, false); - int rwidth = creator.getWidth(); - int rheight = creator.getHeight(); - creator.setSize(rwidth, rheight + objHeight); - } - return true; - } - - /** - * 不调整,只计算位置 - * - * @return child的位置 - */ - public int[] getChildPosition(Component currentComp, XCreator child, int x, int y) { - return super.getChildPosition(currentComp, child, x, y); - } - - @Override - public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { - return new FRFitLayoutConstraints((XWFitLayout) container, creator); - } +/** + * + */ +package com.fr.design.designer.beans.adapters.layout; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; + +import com.fr.design.beans.GroupModel; +import com.fr.design.designer.beans.ConstraintsGroupModel; +import com.fr.design.designer.beans.HoverPainter; +import com.fr.design.designer.beans.painters.FRFitLayoutPainter; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.cardlayout.XWCardLayout; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; +import com.fr.design.designer.properties.FRFitLayoutConstraints; +import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.mainframe.JForm; +import com.fr.design.utils.ComponentUtils; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.container.WLayout; +import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; +import com.fr.general.ComparatorUtils; +import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; + +/** + * 自适应布局的容器适配器 + * + * @author jim + * @date 2014-6-24 + */ +public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { + + public static final String WIDGETPANEICONPATH = "/com/fr/web/images/form/resources/layout_absolute.png"; + private static final int DEPENDING_SCOPE = 3; + private HoverPainter painter; + //区分拖拽和编辑宽高 + private boolean isEdit; + + public boolean isEdit() { + return isEdit; + } + + public void setEdit(boolean edit) { + isEdit = edit; + } + /** + * 构造函数 + * + * @param container XWFitLayout容器 + */ + public FRFitLayoutAdapter(XLayoutContainer container) { + super(container); + painter = new FRFitLayoutPainter(container); + initMinSize(); + } + + private void initMinSize() { + XWFitLayout layout = (XWFitLayout) container; + minWidth = layout.getActualMinWidth(); + minHeight = layout.getActualMinHeight(); + actualVal = layout.getAcualInterval(); + margin = layout.toData().getMargin(); + } + + @Override + public HoverPainter getPainter() { + return painter; + } + + /** + * 返回布局自身属性,方便一些特有设置在layout刷新时处理 + */ + @Override + public GroupModel getLayoutProperties() { + XWFitLayout xfl = (XWFitLayout) container; + return new FRFitLayoutPropertiesGroupModel(xfl); + } + + /** + * 添加组件 + * + * @param child 待添加的组件 + * @param x 坐标x + * @param y 坐标y + */ + @Override + public void addComp(XCreator child, int x, int y) { + fix(child, x, y); + if (child.shouldScaleCreator() || child.hasTitleStyle()) { + addParentCreator(child); + } else { + container.add(child, child.toData().getWidgetName()); + } + XWFitLayout layout = (XWFitLayout) container; + // 更新对应的BoundsWidget + layout.updateBoundsWidget(); + updateCreatorBackBound(); + } + + public void updateCreatorBackBound() { + for (int i = 0, size = container.getComponentCount(); i < size; i++) { + XCreator creator = (XCreator) container.getComponent(i); + creator.updateChildBound(minHeight); + creator.setBackupBound(creator.getBounds()); + } + } + + + private void addParentCreator(XCreator child) { + XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight); + container.add(parentPanel, child.toData().getWidgetName()); + } + + /** + * 能否对应位置放置当前组件 + * + * @param creator 组件 + * @param x 添加的位置x,该位置是相对于container的 + * @param y 添加的位置y,该位置是相对于container的 + * @return 是否可以放置 + */ + @Override + public boolean accept(XCreator creator, int x, int y) { + // 计算是否能拖入鼠标区域时,会用到fix 的方法 + isFindRelatedComps = false; + //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 + Component comp = container.getComponentAt(x, y); + if (checkInterval(comp)) { + return false; + } + //如果当前处于边缘地带, 那么就把他贴到父容器上 + boolean isMatchEdge = matchEdge(x, y); + + int componentHeight = comp.getHeight(); + int componentWidth = comp.getWidth(); + //上半部分高度 + int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); + //下半部分高度 + int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); + + //布局控件要先判断是不是可编辑 + XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); + if (topLayout != null && !isMatchEdge && !topLayout.isEditable()) { + return false; + } + + if (isCrossPointArea(comp, x, y)) { + return canAcceptWhileCrossPoint(comp, x, y); + } + + if (isTrisectionArea(comp, x, y)) { + return canAcceptWhileTrisection(comp, x, y); + } + + boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; + boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; + return y > upHeight && y < downHeight ? horizonValid : verticalValid; + } + + // 间隔区域 + private boolean checkInterval(Component comp) { + return container.getComponentCount() > 0 && comp == container; + } + + /** + * 是否在组件边缘 + * + * @param x 横坐标 + * @param y 纵坐标 + * @return 是否在组件边缘 + */ + public boolean matchEdge(int x, int y) { + if (intersectsEdge(x, y, container)) { + //寻找最近的fit, 在边缘地段添加的控件, 将其送给该fit + XLayoutContainer parent = container.findNearestFit(); + container = parent != null ? parent : container; + return true; + } + return false; + } + + /** + * 是否在组件边缘 + * + * @param x 横坐标 + * @param y 纵坐标 + * @param container 参照组件 + * @return 是否在组件边缘 + */ + //是否包含于边缘地段, 按顺序上, 下, 左, 右检测 + public boolean intersectsEdge(int x, int y, XLayoutContainer container) { + int containerX = container.getX(); + int containerY = container.getY(); + int containerWidth = container.getWidth(); + int containerHeight = container.getHeight(); + + // 当前坐标点 + Rectangle currentXY = new Rectangle(x, y, 1, 1); + // 上边缘 + Rectangle upEdge = new Rectangle(containerX, containerY, containerWidth, BORDER_PROPORTION); + if (upEdge.intersects(currentXY)) { + return true; + } + + int bottomY = containerY + containerHeight - BORDER_PROPORTION; + // 下边缘 + Rectangle bottomEdge = new Rectangle(containerX, bottomY, containerWidth, BORDER_PROPORTION); + if (bottomEdge.intersects(currentXY)) { + return true; + } + + //左右边缘的高度 -10*2 是为了不和上下边缘重合 + int verticalHeight = containerHeight - BORDER_PROPORTION * 2; + int leftY = containerY + BORDER_PROPORTION; + // 左边缘 + Rectangle leftEdge = new Rectangle(containerX, leftY, BORDER_PROPORTION, verticalHeight); + if (leftEdge.intersects(currentXY)) { + return true; + } + + int rightY = containerY + BORDER_PROPORTION; + int rightX = containerX + containerWidth - BORDER_PROPORTION; + // 右边缘 + Rectangle rightEdge = new Rectangle(rightX, rightY, BORDER_PROPORTION, verticalHeight); + return rightEdge.intersects(currentXY); + } + + /** + * 交叉点区域时,能否对应位置放入组件 + */ + protected boolean canAcceptWhileCrossPoint(Component comp, int x, int y) { + return super.canAcceptWhileCrossPoint(comp, x, y); + } + + protected boolean canAcceptWhileTrisection(Component comp, int x, int y) { + return super.canAcceptWhileTrisection(comp, x, y); + } + + /** + * 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 + * + * @param parentComp 鼠标所在区域的组件 + * @param x 坐标x + * @param y 坐标y + * @return 是则返回true + */ + public boolean isTrisectionArea(Component parentComp, int x, int y) { + return super.isTrisectionArea(parentComp, x, y); + } + + /** + * 是否为组件交叉点区域 或者是相邻三组建中间点 + * + * @param currentComp 当前组件 + * @param x 坐标x + * @param y 坐标y + * @return 是则返回true + */ + public boolean isCrossPointArea(Component currentComp, int x, int y) { + return super.isCrossPointArea(currentComp, x, y); + } + + protected void initCompsList() { + super.initCompsList(); + } + + protected void clearCompsList() { + super.clearCompsList(); + } + + protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout){ + return mainLayout.getBounds(); + } + + private Rectangle adjustBackupBound(Rectangle backupBound, XWCardMainBorderLayout mainLayout) { + // 参数界面高度对纵坐标产生的影响 + JForm jform = (JForm) (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + if (jform.getFormDesign().getParaComponent() != null) { + backupBound.y -= jform.getFormDesign().getParaHeight(); + } + + Rectangle rec = getLayoutBound(mainLayout); + // XWTabLayout里面的横纵坐标收到外层XWCardMainBorderLayout的横纵坐标影响 + // 减掉之后可以按照它原来的逻辑执行 + backupBound.x -= rec.x; + backupBound.y -= rec.y; + XWCardLayout cardLayout = mainLayout.getCardPart(); + LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); + // 当tab布局为标题样式时,才需要处理标题栏高度产生的影响 + if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { + backupBound.y -= WCardMainBorderLayout.TAB_HEIGHT; + } + return backupBound; + } + + /** + * 拖拽控件边框后,根据控件的大小尺寸,进行相关组件的调整 + * + * @param creator 组件 + */ + @Override + public void fix(XCreator creator) { + //拖拽组件原大小、位置 + Rectangle backupBound = creator.getBackupBound(); + backupBound.x -= container.getX(); + backupBound.y -= container.getY(); + //当前拖拽组件的位置 + int x = creator.getX(); + int y = creator.getY(); + + // 获取容器所有内部组件横坐标 + int[] posXs = container.getHors(); + // 获取容器所有内部组件纵坐标 + int[] posYs = container.getVeris(); + + XLayoutContainer outerLayout = container.getOuterLayout(); + if (!ComparatorUtils.equals(outerLayout, container.getBackupParent())) { + XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) outerLayout; + backupBound = adjustBackupBound(backupBound, mainLayout); + } + + //拖拽组件拖拽以后的大小 + int w = creator.getWidth(); + int h = creator.getHeight(); + initCompsList(); + creator.setBounds(backupBound); + int difference = 0; + if (x != backupBound.x) { + dealLeft(backupBound, x, posXs, difference, creator); + } else if (w != backupBound.width) { + dealRight(backupBound, x, w, posXs, difference, creator); + } else if (y != backupBound.y) { + dealTop(backupBound, y, posYs, difference, creator); + } else if (h != backupBound.height) { + dealButtom(backupBound, y, h, posYs, difference, creator); + } + clearCompsList(); + XWFitLayout layout = (XWFitLayout) container; + layout.updateBoundsWidget(); // 更新对应的BoundsWidget + updateCreatorBackBound(); + } + + /** + * 拖拽控件边框后,根据控件的大小尺寸,进行相关组件的调整 + * + * @param backupBound 边界备份 + * @param bounds 组件边界 + * @param xCreator 组件 + * @param row 选中的行 + * @param difference 偏移量 + */ + public void calculateBounds(Rectangle backupBound, Rectangle bounds, XCreator xCreator, int row, int difference) { + Rectangle rc = new Rectangle(0,0,0,0); + XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); + if (parent != null) { + Rectangle rec = ComponentUtils.getRelativeBounds(parent); + rc.x = rec.x; + rc.y = rec.y; + } + int x = backupBound.x - rc.x, y = backupBound.y - rc.y; + //处理左右延伸 + switch (row) { + case 0: + if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight() +rc.x) { + x += difference; + } + break; + case 1: + if(backupBound.y + backupBound.height == container.getHeight() - margin.getBottom() +rc.y){ + y += difference; + } + break; + } + bounds.setLocation(x,y); + xCreator.setBackupBound(backupBound); + xCreator.setBounds(bounds); + this.fix(xCreator); + } + + private void dealLeft(Rectangle backupBound, int x, int[] posXs, int difference, XCreator creator) { + if (backupBound.x == margin.getLeft()) { + return; + } + x = adjustCoordinateByDependingLine(x, posXs); + difference = x - backupBound.x; + dealDirectionAtLeft(backupBound, difference, creator); + } + + private void dealRight(Rectangle backupBound, int x, int w, int[] posXs, int difference, XCreator creator) { + if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight()) { + return; + } + w = adjustDiffByDependingLine(x, posXs, w); + difference = w - backupBound.width; //拖拽长度 + dealDirectionAtRight(backupBound, difference, creator); + } + + private void dealTop(Rectangle backupBound, int y, int[] posYs, int difference, XCreator creator) { + if (backupBound.y == margin.getTop()) { + return; + } + y = adjustCoordinateByDependingLine(y, posYs); + difference = y - backupBound.y; + dealDirectionAtTop(backupBound, difference, creator); + } + + private void dealButtom(Rectangle backupBound, int y, int h, int[] posYs, int difference, XCreator creator) { + if (backupBound.y + backupBound.height == container.getHeight() - margin.getBottom()) { + return; + } + h = adjustDiffByDependingLine(y, posYs, h); + difference = h - backupBound.height; + dealDirectionABottom(backupBound, difference, creator); + } + + // 根据需要依附的位置调整拖拽的坐标值 + private int adjustCoordinateByDependingLine(int coordinate, int[] coordinates) { + if(!isEdit) { + for (int i = 0; i < coordinates.length; i++) { + if (coordinate == coordinates[i]) { + continue; + } + if (coordinate > coordinates[i] - DEPENDING_SCOPE && coordinate < coordinates[i] + DEPENDING_SCOPE) { + coordinate = coordinates[i]; + break; + } + } + } + return coordinate; + } + + // 根据需要依附的位置调整拖拽的距离 + private int adjustDiffByDependingLine(int coordinate, int[] coordinates, int diff) { + if(!isEdit) { + for (int i = 0; i < coordinates.length; i++) { + if (coordinate + diff > coordinates[i] - DEPENDING_SCOPE && coordinate + diff < coordinates[i] + DEPENDING_SCOPE) { + diff = coordinates[i] - coordinate; + break; + } + } + } + return diff; + } + + // 左侧边框拉伸,循环找出对齐的两侧控件 + private void dealDirectionAtLeft(Rectangle backupBound, int difference, Component creator) { + rightComps.add(creator); + Component rightComp = null; + int leftx = backupBound.x - DEFAULT_AREA_LENGTH - actualVal; + // 取左侧边框右面的组件x值 + int rightx = backupBound.x + DEFAULT_AREA_LENGTH; + Component leftComp = container.getLeftComp(backupBound.x, backupBound.y); + leftComps.add(leftComp); + //先找上侧对齐时(y相等)的左右两边组件 + int ry = backupBound.y; + int ly = leftComp.getY(); + int min = margin.getTop(); + int max = container.getHeight() - margin.getBottom(); + while (ry >= min && ly >= min) { + if (ry == ly) { + break; + } else { + if (ry > ly) { + rightComp = container.getTopComp(rightx, ry); + ry = rightComp.getY(); + rightComps.add(rightComp); + } else { + leftComp = container.getTopComp(leftx, ly); + ly = leftComp.getY(); + leftComps.add(leftComp); + } + } + } + // 下侧对齐时(y+h相等)两边组件 + ry = backupBound.y + backupBound.height; + ly = leftComps.get(0).getY() + leftComps.get(0).getHeight(); + while (ry <= max && ly <= max) { + if (ry == ly) { + break; + } else { + if (ry > ly) { + leftComp = container.getComponentAt(leftx, ly + DEFAULT_AREA_LENGTH + actualVal); + ly = leftComp.getY() + leftComp.getHeight(); + leftComps.add(leftComp); + } else { + rightComp = container.getComponentAt(rightx, ry + DEFAULT_AREA_LENGTH + actualVal); + ry = rightComp.getY() + rightComp.getHeight(); + rightComps.add(rightComp); + } + } + } + dealHorDirection(backupBound.x, difference); + } + + // 右侧边框拉伸,循环找出对齐的两侧控件 + private void dealDirectionAtRight(Rectangle backupBound, int difference, Component creator) { + leftComps.add(creator); + Component leftComp = null; + int leftx = backupBound.x + backupBound.width - DEFAULT_AREA_LENGTH; + // 取右侧边框右面的组件x值 + int rightx = backupBound.x + backupBound.width + DEFAULT_AREA_LENGTH + actualVal; + Component rightComp = container.getRightComp(backupBound.x, backupBound.y, backupBound.width); + rightComps.add(rightComp); + int ly = backupBound.y, ry = rightComp.getY(); + int min = margin.getTop(); + int max = container.getHeight() - margin.getBottom(); + while (ry >= min && ly >= min) { + if (ry == ly) { + break; + } else { + if (ry > ly) { + rightComp = container.getTopComp(rightx, ry); + ry = rightComp.getY(); + rightComps.add(rightComp); + } else { + leftComp = container.getTopComp(leftx, ly); + ly = leftComp.getY(); + leftComps.add(leftComp); + } + } + } + ly = backupBound.y + backupBound.height; + ry = rightComps.get(0).getY() + rightComps.get(0).getHeight(); + while (ry <= max && ly <= max) { + if (ry == ly) { + break; + } else { + if (ry > ly) { + leftComp = container.getComponentAt(leftx, ly + DEFAULT_AREA_LENGTH + actualVal); + ly = leftComp.getY() + leftComp.getHeight(); + leftComps.add(leftComp); + } else { + rightComp = container.getComponentAt(rightx, ry + DEFAULT_AREA_LENGTH + actualVal); + ry = rightComp.getY() + rightComp.getHeight(); + rightComps.add(rightComp); + } + } + } + dealHorDirection(backupBound.x + backupBound.width + actualVal, difference); + } + + /** + * 水平方向上拉伸边框的处理 + */ + private void dealHorDirection(int objx, int difference) { + if (difference > 0) { + difference = Math.min(getMinWidth(rightComps) - minWidth, difference); + } else { + difference = Math.max(difference, minWidth - getMinWidth(leftComps)); + } + //重新计算左右两侧组件size、point + if (CalculateLefttRelatComponent(difference)) { + CalculateRightRelatComponent(objx + difference, -difference); + } + } + + // 上侧边框拉伸,循环找出对齐的两侧控件 + private void dealDirectionAtTop(Rectangle backupBound, int difference, Component creator) { + downComps.add(creator); + // 取上侧边框上面的组件用的y值 + int topy = backupBound.y - DEFAULT_AREA_LENGTH - actualVal; + // 上侧边框下面的组件y值 + int bottomy = backupBound.y + DEFAULT_AREA_LENGTH; + Component topComp = container.getTopComp(backupBound.x, backupBound.y); + upComps.add(topComp); + Component bottomComp = null; + int min = margin.getLeft(); + int max = container.getWidth() - margin.getRight(); + //先找左侧侧对齐时(x相等)的上下两边组件 + int ux = topComp.getX(); + int dx = backupBound.x; + while (ux >= min && dx >= min) { + if (ux == dx) { + break; + } else { + if (ux < dx) { + bottomComp = container.getLeftComp(dx, bottomy); + dx = bottomComp.getX(); + downComps.add(bottomComp); + } else { + topComp = container.getLeftComp(ux, topy); + ux = topComp.getX(); + upComps.add(topComp); + } + } + } + // 右侧对齐时(x+w相等)两边组件 + ux = upComps.get(0).getX() + upComps.get(0).getWidth(); + dx = backupBound.x + backupBound.width; + while (ux <= max && dx <= max) { + if (ux == dx) { + break; + } else { + if (ux < dx) { + topComp = container.getComponentAt(ux + DEFAULT_AREA_LENGTH + actualVal, topy); + ux = topComp.getX() + topComp.getWidth(); + upComps.add(topComp); + } else { + bottomComp = container.getComponentAt(dx + DEFAULT_AREA_LENGTH + actualVal, bottomy); + dx = bottomComp.getX() + bottomComp.getWidth(); + downComps.add(bottomComp); + } + } + } + + dealVertiDirection(backupBound.y, difference); + } + + // 下侧边框拉伸,循环找出对齐的两侧控件 + private void dealDirectionABottom(Rectangle backupBound, int difference, Component creator) { + upComps.add(creator); + Component topComp = null; + Component bottomComp = container.getBottomComp(backupBound.x, backupBound.y, backupBound.height); + // 下侧边框下面的组件y坐标 + int bottomy = backupBound.y + backupBound.height + DEFAULT_AREA_LENGTH + actualVal; + // 取下侧边框上面的组件用的y值 + int topy = backupBound.y + backupBound.height - DEFAULT_AREA_LENGTH; + downComps.add(bottomComp); + int dx = bottomComp.getX(); + int ux = backupBound.x; + int min = margin.getLeft(); + int max = container.getWidth() - margin.getRight(); + while (ux >= min && dx >= min) { + if (ux == dx) { + break; + } else { + if (ux < dx) { + bottomComp = container.getLeftComp(dx, bottomy); + dx = bottomComp.getX(); + downComps.add(bottomComp); + } else { + topComp = container.getLeftComp(ux, topy); + ux = topComp.getX(); + upComps.add(topComp); + } + } + } + dx = downComps.get(0).getX() + downComps.get(0).getWidth(); + ux = backupBound.x + backupBound.width; + while (ux <= max && dx <= max) { + if (ux == dx) { + break; + } else { + if (ux < dx) { + topComp = container.getComponentAt(ux + DEFAULT_AREA_LENGTH + actualVal, topy); + ux = topComp.getX() + topComp.getWidth(); + upComps.add(topComp); + } else { + bottomComp = container.getComponentAt(dx + DEFAULT_AREA_LENGTH + actualVal, bottomy); + dx = bottomComp.getX() + bottomComp.getWidth(); + downComps.add(bottomComp); + } + } + } + dealVertiDirection(backupBound.y + backupBound.height + actualVal, difference); + } + + /** + * 垂直方向上拉伸边框的处理 + */ + private void dealVertiDirection(int objY, int difference) { + if (difference > 0) { + difference = Math.min(getMinHeight(downComps) - minHeight, difference); + } else { + difference = Math.max(difference, minHeight - getMinHeight(upComps)); + } + //重新计算上下两侧组件size、point + if (CalculateUpRelatComponent(difference)) { + CalculateDownRelatComponent(objY + difference, -difference); + } + ; + } + + /** + * 新拖入组件时,计算调整其他关联组件位置大小 + * + * @param child 新拖入的组件 + * @param x 鼠标所在x坐标 + * @param y 鼠标所在y坐标 + */ + public void fix(XCreator child, int x, int y) { + Component parentComp = container.getComponentAt(x, y); + if (container.getComponentCount() == 0) { + child.setLocation(0, 0); + child.setSize(parentComp.getWidth(), parentComp.getHeight()); + } else if (isCrossPointArea(parentComp, x, y)) { + //交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入 + fixCrossPointArea(parentComp, child, x, y); + return; + } else if (isTrisectionArea(parentComp, x, y)) { + // 在边界三等分区域,就不再和组件二等分了 + fixTrisect(parentComp, child, x, y); + return; + } else { + fixHalve(parentComp, child, x, y); + } + } + + /** + * 平分,正常情况拖入组件时,按照上1/4区域、下1/4区域为上下平分,中左侧1/2区域、中右侧1/2区域为左右平分 + */ + protected void fixHalve(Component currentComp, XCreator child, int x, int y) { + super.fixHalve(currentComp, child, x, y); + } + + /** + * 组件交叉区域进行插入时,调整受到变动的其他组件,之前是交叉区域插入也按照三等分逻辑,后面测试中发现有bug,改为和bi一样的鼠标所在侧平分 + * 默认左上角、右下角区域是垂直方向插入组件 + * 右上角和左下角是水平方向插入组件,这样避免田字块时重复 + */ + protected void fixCrossPointArea(Component currentComp, XCreator child, int x, int y) { + super.fixCrossPointArea(currentComp, child, x, y); + } + + /** + * 三等分区域时,调整相关联的组件 + * + * @param currentComp 鼠标所在组件 + * @param child 待插入组件 + */ + protected void fixTrisect(Component currentComp, XCreator child, int x, int y) { + super.fixTrisect(currentComp, child, x, y); + } + + /** + * 删除组件或者重新拖动时,其它组件重新计算位置大小 + */ + protected void delete(XCreator creator, int creatorWidth, int creatorHeight) { + int x = creator.getX(); + int y = creator.getY(); + recalculateChildrenSize(x, y, creatorWidth, creatorHeight); + } + + /** + * 重新计算内部组件大小 + * + * @param x 坐标x + * @param y 坐标y + * @param creatorWidth 删除的组件之前所在布局的宽度 + * @param creatorHeight 删除的组件之前所在布局的高度 + */ + public void recalculateChildrenSize(int x, int y, int creatorWidth, int creatorHeight) { + if (container.getComponentCount() == 0) { + return; + } else { + initCompsList(); + int width = creatorWidth; + int height = creatorHeight; + calculateRelatedComponent(x, y, width, height); + if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) { + CalculateRightRelatComponent(x, width + actualVal); + } else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) { + CalculateLefttRelatComponent(width + actualVal); + } else if (!downComps.isEmpty() && getAllWidth(downComps) == width) { + CalculateDownRelatComponent(y, height + actualVal); + } else if (!upComps.isEmpty() && getAllWidth(upComps) == width) { + CalculateUpRelatComponent(height + actualVal); + } else { + // 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理 + calculateNoRelatedComponent(x, y, width, height); + } + } + clearCompsList(); + } + + /** + * 四侧边框都没有对齐的,此时每侧有且只有一个方向不对齐 + * 比如右侧不对齐,那么必然右上或右下没对齐,不会同时不对齐,否则不会出现此情况 + * 正常删除是右左下上优先原则,这边目前只调整右侧以至填充完整, + * 右侧不对齐时的组件先上下微调,再向左侧填充。 + */ + private void calculateNoRelatedComponent(int x, int y, int width, int height) { + // 只有最后一个组件了,直接删除 + if (container.getComponentCount() <= 1) { + return; + } + // 删除当前组件时,由于没有刚好边框对齐的其他组件,这时候需要调整的组件 + Component rightComp = container.getRightComp(x, y, width); + if (rightComp == null) { + return; + } + + int ry = rightComp.getY(); + clearCompsList(); + initCompsList(); + Rectangle rec = new Rectangle(x, y, width, height); + if (ry != y) { + calculateNoRelatedWhileRightTop(rec, rightComp); + } else { + calculateNoRelatedWhileRightBott(rec, rightComp); + } + + } + + private void calculateNoRelatedWhileRightTop(Rectangle bound, Component rcomp) { + if (rcomp == null) { + return; + } + + int ry = rcomp.getY(); + int rh = rcomp.getHeight(); + int rw = rcomp.getWidth(); + int dh = bound.y - ry - actualVal; + // 没法缩小高度 + if (dh < minHeight) { + // 没法缩小时则拉伸rcomp的上边框 + dealDirectionAtTop(rcomp.getBounds(), dh + actualVal, rcomp); + //调整的时候可能有组件达到最小高度,判断下 + if (rcomp.getY() != bound.y) { + clearCompsList(); + initCompsList(); + dealDirectionAtTop(rcomp.getBounds(), bound.y - rcomp.getY() - minHeight - actualVal, rcomp); + ry = rcomp.getY(); + int rx = rcomp.getX(); + rcomp.setBounds(rx, ry, rw, minHeight); + recalculateChildrenSize(rx, bound.y, rw, rh - dh - actualVal); + recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); + return; + } + } else { + // 右侧控件底部对齐 + if (rh + ry == bound.y + bound.height) { + rcomp.setSize(rw, dh); + bound.width += rw; + bound.width += actualVal; + } else { + recalculateChildrenSize(bound.x, ry + rh + actualVal, bound.width, bound.height + bound.y - rh - ry - actualVal); + recalculateChildrenSize(bound.x, bound.y, bound.width, ry + rh - bound.y); + return; + } + } + recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); + } + + private void calculateNoRelatedWhileRightBott(Rectangle bound, Component rcomp) { + rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); + int ry = rcomp.getY(); + int rh = rcomp.getHeight(); + int rw = rcomp.getWidth(); + int dh = ry + rh - bound.y - bound.height - actualVal; + if (dh < minHeight) { + dealDirectionABottom(rcomp.getBounds(), -dh - actualVal, rcomp); + //调整的时候可能有组件达到最小高度,判断下 + if (rcomp.getHeight() + ry != bound.y + bound.height) { + clearCompsList(); + initCompsList(); + dh = ry + rcomp.getHeight() - bound.y - bound.height - actualVal; + dealDirectionABottom(rcomp.getBounds(), minHeight - dh, rcomp); + rh = rcomp.getHeight(); + int rx = rcomp.getX(); + rcomp.setBounds(rx, bound.y + bound.height + actualVal, rw, minHeight); + recalculateChildrenSize(rx, ry, rw, rh - minHeight - actualVal); + recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); + return; + } + } else { + if (ry == bound.y) { + rcomp.setBounds(rcomp.getX(), bound.y + bound.height + actualVal, rw, dh); + bound.width += rw; + bound.width += actualVal; + } else { + recalculateChildrenSize(bound.x, bound.y, bound.width, ry - bound.y - actualVal); + recalculateChildrenSize(bound.x, ry, bound.width, bound.height - ry + bound.y); + return; + } + } + recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); + } + + private int getMinWidth(List comps) { + if (comps.isEmpty()) { + return 0; + } + int minWidth = container.getWidth() - margin.getLeft() - margin.getRight(); + for (int i = 0, size = comps.size(); i < size; i++) { + minWidth = minWidth > comps.get(i).getWidth() ? comps.get(i).getWidth() : minWidth; + } + return minWidth; + } + + private int getMinHeight(List comps) { + if (comps.isEmpty()) { + return 0; + } + int minH = container.getHeight() - margin.getTop() - margin.getBottom(); + for (int i = 0, size = comps.size(); i < size; i++) { + minH = minH > comps.get(i).getHeight() ? comps.get(i).getHeight() : minH; + } + return minH; + } + + // 删除时计算待删除组件上下侧的组件是否何其对齐 + private int getAllHeight(List comps) { + int allHeight = 0; + if (comps.isEmpty()) { + return allHeight; + } + int n = comps.size(); + for (int i = 0; i < n; i++) { + allHeight += comps.get(i).getHeight(); + } + allHeight += (n - 1) * actualVal; + return allHeight; + } + + private int getAllWidth(List comps) { + int allWidth = 0; + if (comps.isEmpty()) { + return allWidth; + } + int n = comps.size(); + for (int i = 0; i < n; i++) { + allWidth += comps.get(i).getWidth(); + } + allWidth += (n - 1) * actualVal; + return allWidth; + } + + /** + * 获取有哪些相关联的组件 + */ + protected void calculateRelatedComponent(int objX, int objY, int objWidth, int objHeight) { + int count = container.getComponentCount(); + for (int i = 0; i < count; i++) { + Component relatComp = container.getComponent(i); + int rx = relatComp.getX(); + int ry = relatComp.getY(); + int rwidth = relatComp.getWidth(); + int rheight = relatComp.getHeight(); + int verti = ry - objY; + int hori = rx - objX; + boolean isHori = verti >= 0 && objHeight >= (rheight + verti); + boolean isVerti = hori >= 0 && objWidth >= (rwidth + hori); + if (isHori && (objX + objWidth + actualVal) == rx) { + rightComps.add(relatComp); + } else if (isHori && objX == (rx + rwidth + actualVal)) { + leftComps.add(relatComp); + } else if (isVerti && (objY + objHeight + actualVal) == ry) { + downComps.add(relatComp); + } else if (isVerti && objY == (ry + rheight + actualVal)) { + upComps.add(relatComp); + } + } + } + + /** + * 拖拽组件时遍历某一侧组件得到该侧组件能够缩放的最小宽度,tab布局最小宽度 = 内部组件数 * 单个组件最小宽度 + * + * @param list 某一侧组件的集合 如:leftComps + * @return int 最小宽度 + */ + private int getCompsMinWidth(List list) { + return getMaxCompsNum(list, true) * WLayout.MIN_WIDTH; + } + + /** + * 拖拽组件遍历某一侧得到该侧组件能够缩放的最小高度,tab布局最小高度 = 内部组件数 * 单个组件最小高度 + 标题高度 + * + * @param list 某一侧组件集合 + * @return int 最小高度 + */ + private int getCompsMinHeight(List list) { + for (int i = 0; i < list.size(); i++) { + XCreator creator = (XCreator) list.get(i); + ArrayList childrenList = creator.getTargetChildrenList(); + if (!childrenList.isEmpty()) { + return getMaxCompsNum(list, false) * WLayout.MIN_HEIGHT + WCardMainBorderLayout.TAB_HEIGHT; + } + } + return WLayout.MIN_HEIGHT; + } + + /** + * 根据子组件的横(纵)坐标获取某一侧组件的最大内部组件数 + * + * @param list 某一侧组件集合 + * @param isHor 是否以横坐标为准 + * @return int 最大内部组件数 + */ + private int getMaxCompsNum(List list, boolean isHor) { + int maxCompNums = 1; + for (int i = 0, size = list.size(); i < size; i++) { + XCreator creator = (XCreator) list.get(i); + ArrayList childrenList = creator.getTargetChildrenList(); + int count = childrenList.size(); + if (count > 0) { + for (int j = 0; j < count; j++) { + XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j); + int[] positions = isHor ? tabLayout.getHors(true) : tabLayout.getVeris(true); + int compNums = positions.length - 1; + maxCompNums = Math.max(compNums, maxCompNums); + } + } + } + return maxCompNums; + } + + /** + * 根据偏移量缩放内部组件大小,(tab布局用到) + * + * @param creator tab布局 + * @param offset 偏移量 + * @param isHor 是否为横向拖拽 + */ + private void adjustCompsSize(XCreator creator, int offset, boolean isHor) { + ArrayList childrenList = creator.getTargetChildrenList(); + int size = childrenList.size(); + if (size > 0) { + for (int j = 0; j < size; j++) { + XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j); + tabLayout.setBackupBound(tabLayout.getBounds()); + int refSize = isHor ? tabLayout.getWidth() : tabLayout.getHeight(); + double percent = (double) offset / refSize; + if (percent < 0 && !tabLayout.canReduce(percent)) { + return; + } + setAdjustedSize(tabLayout, offset, isHor); + for (int m = 0; m < tabLayout.getComponentCount(); m++) { + XCreator childCreator = tabLayout.getXCreator(m); + BoundsWidget wgt = (BoundsWidget) tabLayout.toData().getBoundsWidget(childCreator.toData()); + wgt.setBounds(tabLayout.getComponent(m).getBounds()); + } + adjustCreatorsSize(percent, tabLayout, isHor); + } + + } + } + + // 纵向拖拽,先将tab布局的高度设置为拖拽后的实际高度 + private void setAdjustedHeight(XWTabFitLayout tabLayout, int offset) { + tabLayout.setSize(tabLayout.getWidth(), tabLayout.getHeight() + offset); + } + + // 横向拖拽,先将tab布局的宽度设置为拖拽后的实际宽度 + private void setAdjustedSize(XWTabFitLayout tabLayout, int offset, boolean isHor) { + if (offset < 0) { + // 缩放时需要备份原tab布局宽高 + tabLayout.setReferDim(new Dimension(tabLayout.getWidth(), tabLayout.getHeight())); + } + if (isHor) { + tabLayout.setSize(tabLayout.getWidth() + offset, tabLayout.getHeight()); + return; + } + setAdjustedHeight(tabLayout, offset); + } + + // 按照拖拽偏移量,对tab布局进行缩放 + private void adjustCreatorsSize(double percent, XWTabFitLayout tabLayout, boolean isHor) { + if (isHor) { + tabLayout.adjustCreatorsWidth(percent); + return; + } + tabLayout.adjustCreatorsHeight(percent); + } + + + /** + * 删除或拉伸控件右边框 调整右侧组件位置大小 + * + * @param objX 调整后的坐标x + * @param objWidth 调整后的宽度 + */ + protected void CalculateRightRelatComponent(int objX, int objWidth) { + int count = rightComps.size(); + for (int i = 0; i < count; i++) { + XCreator creator = (XCreator) rightComps.get(i); + adjustCompsSize(creator, objWidth, true); + int ry = creator.getY(); + int rwidth = creator.getWidth(); + int rheight = creator.getHeight(); + creator.setLocation(objX, ry); + creator.setSize(rwidth + objWidth, rheight); + } + } + + /** + * 实际拖拽偏移量是否超出了可调整的宽度范围 + * + * @param offset 实际偏移量 + * @return boolean 是否超出调整范围 + */ + private boolean isBeyondAdjustWidthScope(int offset) { + boolean isBeyondScope = false; + isBeyondScope = offset < 0 ? isBeyondWidthScope(offset, leftComps) : isBeyondWidthScope(offset, rightComps); + return isBeyondScope; + } + + // 实际拖拽偏移量是否超出某一侧的可调整宽度 + private boolean isBeyondWidthScope(int offset, List compsList) { + int compMinWidth = getCompsMinWidth(compsList); + for (int i = 0; i < compsList.size(); i++) { + XCreator creator = (XCreator) compsList.get(i); + if (Math.abs(offset) > (creator.getWidth() - compMinWidth)) { + return true; + } + } + return false; + } + + /** + * 删除或拉伸控件左边框时 调整左侧的组件位置大小; + */ + protected boolean CalculateLefttRelatComponent(int objWidth) { + if (isBeyondAdjustWidthScope(objWidth)) { + return false; + } + int count = leftComps.size(); + for (int i = 0; i < count; i++) { + XCreator creator = (XCreator) leftComps.get(i); + adjustCompsSize(creator, objWidth, true); + int rwidth = creator.getWidth(); + int rheight = creator.getHeight(); + creator.setSize(rwidth + objWidth, rheight); + } + return true; + } + + /** + * 删除或拉伸下边框 调整下方的组件位置大小 + */ + protected void CalculateDownRelatComponent(int objY, int objHeight) { + int count = downComps.size(); + for (int i = 0; i < count; i++) { + XCreator creator = (XCreator) downComps.get(i); + adjustCompsSize(creator, objHeight, false); + int rx = creator.getX(); + int rwidth = creator.getWidth(); + int rheight = creator.getHeight(); + creator.setLocation(rx, objY); + creator.setSize(rwidth, rheight + objHeight); + } + } + + /** + * 实际拖拽偏移量是否超出了可调整的高度范围 + * + * @param offset 实际偏移量 + * @return boolean 是否超出调整范围 + */ + private boolean isBeyondAdjustHeightScope(int offset) { + boolean isBeyondScope = false; + isBeyondScope = offset < 0 ? isBeyondHeightScope(offset, upComps) : isBeyondHeightScope(offset, downComps); + return isBeyondScope; + } + + // 实际拖拽偏移量是否超出某一侧的可调整高度 + private boolean isBeyondHeightScope(int offset, List compsList) { + int minHeight = getCompsMinHeight(compsList); + for (int i = 0; i < compsList.size(); i++) { + XCreator creator = (XCreator) compsList.get(i); + if (Math.abs(offset) > (creator.getHeight() - minHeight)) { + return true; + } + } + return false; + } + + /** + * 删除或拉伸上边框 调整上方的组件位置大小 + */ + protected boolean CalculateUpRelatComponent(int objHeight) { + if (isBeyondAdjustHeightScope(objHeight)) { + return false; + } + int count = upComps.size(); + for (int i = 0; i < count; i++) { + XCreator creator = (XCreator) upComps.get(i); + adjustCompsSize(creator, objHeight, false); + int rwidth = creator.getWidth(); + int rheight = creator.getHeight(); + creator.setSize(rwidth, rheight + objHeight); + } + return true; + } + + /** + * 不调整,只计算位置 + * + * @return child的位置 + */ + public int[] getChildPosition(Component currentComp, XCreator child, int x, int y) { + return super.getChildPosition(currentComp, child, x, y); + } + + @Override + public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { + return new FRFitLayoutConstraints((XWFitLayout) container, creator); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java b/designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java index 088f29a0a..572ac721e 100644 --- a/designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java +++ b/designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java @@ -10,7 +10,8 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelection; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.container.WAbsoluteLayout; -import com.fr.form.ui.widget.BoundsWidget; +import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; +import com.fr.form.ui.container.WParameterLayout; import java.awt.*; @@ -24,184 +25,197 @@ public abstract class AccessDirection implements Direction { private int ymin; private int xmin; - abstract int getCursor(); - - protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle currentBounds, FormDesigner designer, - Rectangle oldBounds); - - protected int[] sorption(int x, int y, Rectangle currentBounds, FormDesigner designer) { - // 自适应布局不需要吸附线,但需要对齐线,对齐线后面处理 - if (!designer.hasWAbsoluteLayout()) { - designer.getStateModel().setEquidistantLine(null); - designer.getStateModel().setXAbsorptionline(null); - designer.getStateModel().setYAbsorptionline(null); - return new int[]{x, y}; - } else { - Point relativePoint = getRelativePoint(x, y, currentBounds, designer); - sorptionPoint(relativePoint, currentBounds, designer); - return new int[]{relativePoint.x, relativePoint.y}; - } - - } - - protected Point getRelativePoint(int x, int y, Rectangle currentBounds, FormDesigner designer) { - if (x < 0) { - x = 0; - } else if (x > designer.getRootComponent().getWidth() && designer.getSelectionModel().hasSelectionComponent()) { - x = designer.getRootComponent().getWidth(); - } + abstract int getCursor(); + + protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle current_bounds, FormDesigner designer, + Rectangle oldbounds); + + protected int[] sorption(int x, int y,Rectangle current_bounds, FormDesigner designer) { + // 自适应布局不需要吸附线,但需要对齐线,对齐线后面处理 + if (!designer.hasWAbsoluteLayout()) { + designer.getStateModel().setEquidistantLine(null); + designer.getStateModel().setXAbsorptionline(null); + designer.getStateModel().setYAbsorptionline(null); + return new int[] { x, y }; + } else { + int posy = current_bounds.y; + + Point relativePoint = getRelativePoint(x, y, current_bounds,designer); + sorptionPoint(relativePoint,current_bounds, designer); + return new int[] { relativePoint.x, relativePoint.y }; + } + + } + + protected Point getRelativePoint(int x, int y, Rectangle current_bounds,FormDesigner designer) { + if (x < 0) { + x = 0; + } else if (x > designer.getRootComponent().getWidth() && designer.getSelectionModel().hasSelectionComponent()) { + x = designer.getRootComponent().getWidth(); + } //参数面板可以无下限拉长 - if (y < 0) { - y = 0; - } else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent() + if (y < 0) { + y = 0; + } else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent() && !designer.getSelectionModel().getSelection().getSelectedCreator().acceptType(XWParameterLayout.class)) { - y = designer.getRootComponent().getHeight() + designer.getParaHeight(); - } - return new Point(x, y); - } - - protected void sorptionPoint(Point point, Rectangle currentBounds, FormDesigner designer) { - boolean findInX = currentBounds.getWidth() <= MoveUtils.SORPTION_UNIT; - boolean findInY = currentBounds.getHeight() <= MoveUtils.SORPTION_UNIT; - WAbsoluteLayout layout = getLayout(designer); - FormSelection selection = designer.getSelectionModel().getSelection(); - for (int i = 0, count = layout.getWidgetCount(); i < count; i++) { - BoundsWidget temp = (BoundsWidget) layout.getWidget(i); - if (!temp.isVisible() || selection.contains(temp.getWidget())) { - continue; - } - Rectangle bounds = getWidgetRelativeBounds(temp.getBounds(), selection); - if (!findInX) { - int x1 = bounds.x; - if (Math.abs(x1 - point.x) <= MoveUtils.SORPTION_UNIT) { - point.x = x1; - findInX = true; - } - int x2 = bounds.x + bounds.width; - if (Math.abs(x2 - point.x) <= MoveUtils.SORPTION_UNIT) { - point.x = x2; - findInX = true; - } - } - if (!findInY) { - int y1 = bounds.y; - if (Math.abs(y1 - point.y) <= MoveUtils.SORPTION_UNIT) { - point.y = y1; - findInY = true; - } - int y2 = bounds.y + bounds.height; - if (Math.abs(y2 - point.y) <= MoveUtils.SORPTION_UNIT) { - point.y = y2; - findInY = true; - } - - } - if (findInX && findInY) { - break; - } - - } - setDesignerStateModelProperties(designer, findInX, findInY, currentBounds, point); - } - - private void setDesignerStateModelProperties(FormDesigner designer, boolean findInX, boolean findInY, Rectangle - currentBounds, Point point) { - designer.getStateModel().setXAbsorptionline(findInX && currentBounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null); - designer.getStateModel().setYAbsorptionline(findInY && currentBounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null); - designer.getStateModel().setEquidistantLine(null); - } - - private Rectangle getWidgetRelativeBounds(Rectangle bounds, FormSelection selection) { - Rectangle relativeRec = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); - XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); - if (parent == null) { - return relativeRec; - } - Rectangle rec = ComponentUtils.getRelativeBounds(parent); - relativeRec.x += rec.x; - relativeRec.y += rec.y; - return relativeRec; - } - - - private WAbsoluteLayout getLayout(final FormDesigner designer) { + y = designer.getRootComponent().getHeight() + designer.getParaHeight(); + } + return new Point(x, y); + } + + protected void sorptionPoint(Point point, Rectangle current_bounds,FormDesigner designer) { + boolean findInX = current_bounds.getWidth() <= MoveUtils.SORPTION_UNIT ? true : false; + boolean findInY = current_bounds.getHeight() <= MoveUtils.SORPTION_UNIT ? true : false; + WAbsoluteLayout layout =getLayout(designer); + FormSelection selection = designer.getSelectionModel().getSelection(); + boolean isWidgetsIntersect = false; + for (int i = 0, count = layout.getWidgetCount(); i < count; i++) { + BoundsWidget temp = (BoundsWidget) layout.getWidget(i); + if (!temp.isVisible() || selection.contains(temp.getWidget())) { + continue; + } + Rectangle bounds = getWidgetRelativeBounds(temp.getBounds(), selection); + if (!findInX) { + int x1 = bounds.x; + if (Math.abs(x1 - point.x) <= MoveUtils.SORPTION_UNIT) { + point.x = x1; + findInX = true; + } + int x2 = bounds.x + bounds.width; + if (Math.abs(x2 - point.x) <= MoveUtils.SORPTION_UNIT) { + point.x = x2; + findInX = true; + } + } + if (!findInY) { + int y1 = bounds.y; + if (Math.abs(y1 - point.y) <= MoveUtils.SORPTION_UNIT) { + point.y = y1; + findInY = true; + } + int y2 = bounds.y + bounds.height; + if (Math.abs(y2 - point.y) <= MoveUtils.SORPTION_UNIT) { + point.y = y2; + findInY = true; + } + + } + if (findInX && findInY) { + break; + } + + if (current_bounds.intersects(bounds) && !(layout instanceof WParameterLayout)){ + isWidgetsIntersect = true; + } + } + processRectangleIntersects(designer, point.x, point.y, isWidgetsIntersect); + setDesignerStateModelProperties(designer, findInX, findInY, current_bounds, point); + } + + private void setDesignerStateModelProperties (FormDesigner designer, boolean findInX, boolean findInY, Rectangle current_bounds, Point point) { + designer.getStateModel().setXAbsorptionline(findInX && current_bounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null); + designer.getStateModel().setYAbsorptionline(findInY && current_bounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null); + designer.getStateModel().setEquidistantLine(null); + } + + private Rectangle getWidgetRelativeBounds(Rectangle bounds, FormSelection selection){ + Rectangle relativeRec = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); + XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); + if (parent == null) { + return relativeRec; + } + Rectangle rec = ComponentUtils.getRelativeBounds(parent); + relativeRec.x += rec.x; + relativeRec.y += rec.y; + return relativeRec; + } + + private void processRectangleIntersects(FormDesigner designer, int x, int y, boolean isIntersects){ + if(isIntersects){ + if(designer.getLocationOnScreen() != null) { + MoveUtils.displayForbidWindow(x + designer.getLocationOnScreen().x, y + designer.getLocationOnScreen().y); + } + designer.setWidgetsIntersect(true); + } + else{ + MoveUtils.hideForbidWindow(); + designer.setWidgetsIntersect(false); + } + } + + private WAbsoluteLayout getLayout(final FormDesigner designer){ XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator( designer.getTarget().getContainer()); WAbsoluteLayout layout; - if (formLayoutContainer.acceptType(XWBorderLayout.class)) {//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面 - Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent(); - if (container instanceof XWAbsoluteLayout) { - layout = ((XWAbsoluteLayout) container).toData(); - } else { - layout = (WAbsoluteLayout) designer.getParaComponent().toData(); - } - } else { + if (formLayoutContainer.acceptType(XWBorderLayout.class)){//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面 + Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent(); + if(container instanceof XWAbsoluteLayout){ + layout = ((XWAbsoluteLayout)container).toData(); + } + else { + layout = (WAbsoluteLayout) designer.getParaComponent().toData(); + } + } else{ layout = (WAbsoluteLayout) designer.getTarget().getContainer(); } - return layout; + return layout; } - /** - * 拖拽 - * - * @param dx 坐标x - * @param dy 坐标y - * @param designer 设计界面 - */ - public void drag(int dx, int dy, FormDesigner designer) { - Rectangle rec = getDraggedBounds(dx, dy, designer.getSelectionModel().getSelection().getRelativeBounds(), designer, designer.getSelectionModel().getSelection().getBackupBounds()); - if (rec != null) { - designer.getSelectionModel().getSelection().setSelectionBounds(rec, designer); - } else { - return; - } + /** + * 拖拽 + * @param dx 坐标x + * @param dy 坐标y + * @param designer 设计界面 + */ + public void drag(int dx, int dy, FormDesigner designer) { + Rectangle rec = getDraggedBounds(dx, dy, designer.getSelectionModel().getSelection().getRelativeBounds(), designer, designer.getSelectionModel().getSelection().getBackupBounds()); //设定控件最小高度21,因每次拖曳至少移动1,防止控件高度等于21时,拖曳导致rec.y的变化使得控件不停的向上或向下移动。 - if (rec.height == MINHEIGHT) { + if(rec.height == MINHEIGHT){ ymin = rec.y; } - if (rec.height == MINHEIGHT - 1) { + if(rec.height == MINHEIGHT - 1){ ymin = ymin == rec.y ? rec.y : rec.y - 1; } - if (rec.height < MINHEIGHT) { + if(rec.height < MINHEIGHT){ rec.height = MINHEIGHT; rec.y = ymin; } // 增加下宽度也设最小为21 if (rec.width == MINWIDTH) { - xmin = rec.x; + xmin = rec.x; } - if (rec.width == MINWIDTH - 1) { - xmin = xmin == rec.x ? rec.x : rec.x - 1; + if(rec.width == MINWIDTH - 1){ + xmin = xmin == rec.x ? rec.x : rec.x - 1; } if (rec.width < MINWIDTH) { - rec.width = MINWIDTH; - rec.x = xmin; - } - - } - - /** - * 更新鼠标指针形状 - * - * @param formEditor 设计界面组件 - */ - public void updateCursor(FormDesigner formEditor) { - - // 调用位置枚举的多态方法getCursor获取鼠标形状 - int type = getCursor(); - - if (type != formEditor.getCursor().getType()) { - // 设置当前形状 - formEditor.setCursor(Cursor.getPredefinedCursor(type)); + rec.width = MINWIDTH; + rec.x = xmin; } - } - - /** - * 生成组件备用的bound - * - * @param formEditor 设计界面组件 - */ - public void backupBounds(FormDesigner formEditor) { - formEditor.getSelectionModel().getSelection().backupBounds(); - } + if(rec != null) { + designer.getSelectionModel().getSelection().setSelectionBounds(rec, designer); + } + } + + /** + * 更新鼠标指针形状 + * @param formEditor 设计界面组件 + */ + public void updateCursor(FormDesigner formEditor) { + + // 调用位置枚举的多态方法getCursor获取鼠标形状 + int type = getCursor(); + + if (type != formEditor.getCursor().getType()) { + // 设置当前形状 + formEditor.setCursor(Cursor.getPredefinedCursor(type)); + } + } + + /** + * 生成组件备用的bound + * @param formEditor 设计界面组件 + */ + public void backupBounds(FormDesigner formEditor) { + formEditor.getSelectionModel().getSelection().backupBounds(); + } } \ No newline at end of file