From b8f32bf0a061df0bcd591c602b0f415d63fdddbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Sat, 10 Jul 2021 21:20:46 +0800 Subject: [PATCH 1/9] =?UTF-8?q?REPORT-54998=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E5=8F=B3=E4=B8=8B=E8=A7=92=E2=80=98?= =?UTF-8?q?=E5=8D=81=E2=80=99=E6=8B=96=E5=8A=A8=EF=BC=8C=E5=90=91=E5=8F=B3?= =?UTF-8?q?=E5=90=91=E4=B8=8B=E6=AD=A3=E5=B8=B8=EF=BC=8C=E5=90=91=E5=B7=A6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E9=80=92=E5=87=8F=EF=BC=8C=E5=90=91=E4=B8=8A?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/grid/GridMouseAdapter.java | 2 +- .../java/com/fr/grid/IntelliElements.java | 128 +++++++++++------- 2 files changed, 82 insertions(+), 48 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index b0f91a902..55bbcfed3 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -474,7 +474,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous grid.getDragRectangle().y = cellRectangle.y; grid.getDragRectangle().height = cellRectangle.height; } else { - grid.getDragRectangle().y = cellRectangle.y; + grid.getDragRectangle().y = selectedCellPoint.getRow(); grid.getDragRectangle().height = cellRectangle.y - selectedCellPoint.getRow() + cellRectangle.height; } } diff --git a/designer-realize/src/main/java/com/fr/grid/IntelliElements.java b/designer-realize/src/main/java/com/fr/grid/IntelliElements.java index ca1ed55d8..823448553 100644 --- a/designer-realize/src/main/java/com/fr/grid/IntelliElements.java +++ b/designer-realize/src/main/java/com/fr/grid/IntelliElements.java @@ -183,42 +183,40 @@ public class IntelliElements { } - public void doIntelliAction() { - for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex++) { - for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex++) { - TemplateCellElement sourceCellElement = getSourceCellElementByColumnRow(colIndex, rowIndex); + public abstract void doIntelliAction(); - if (sourceCellElement == null) { - sourceCellElement = new DefaultTemplateCellElement(); - } - TemplateCellElement newCellElement = new DefaultTemplateCellElement(colIndex, rowIndex); - applyStyle(newCellElement, sourceCellElement);//style - if (sourceCellElement.getValue() instanceof DSColumn) { - try{ - DSColumn dsColumn = (DSColumn)((DSColumn) sourceCellElement.getValue()).clone(); - newCellElement.setValue(dsColumn); - }catch (CloneNotSupportedException e){ - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - newCellElement.setCellExpandAttr(sourceCellElement.getCellExpandAttr()); - } else if (sourceCellElement.getValue() instanceof Number) { - newCellElement.setValue(processNumber((Number) sourceCellElement.getValue())); - } else if (sourceCellElement.getValue() instanceof BaseFormula) { - BaseFormula formula = (BaseFormula) sourceCellElement.getValue(); - formula = this.generateSimpleFormula(formula, 1); - newCellElement.setValue(formula); - } else { - try { - //richer:不改变原单元格 - newCellElement.setValue(BaseUtils.cloneObject(sourceCellElement.getValue())); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } + public void expandCellValue(int colIndex, int rowIndex) { + TemplateCellElement sourceCellElement = getSourceCellElementByColumnRow(colIndex, rowIndex); - report.addCellElement(newCellElement); + if (sourceCellElement == null) { + sourceCellElement = new DefaultTemplateCellElement(); + } + TemplateCellElement newCellElement = new DefaultTemplateCellElement(colIndex, rowIndex); + applyStyle(newCellElement, sourceCellElement);//style + if (sourceCellElement.getValue() instanceof DSColumn) { + try{ + DSColumn dsColumn = (DSColumn)((DSColumn) sourceCellElement.getValue()).clone(); + newCellElement.setValue(dsColumn); + }catch (CloneNotSupportedException e){ + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + newCellElement.setCellExpandAttr(sourceCellElement.getCellExpandAttr()); + } else if (sourceCellElement.getValue() instanceof Number) { + newCellElement.setValue(processNumber((Number) sourceCellElement.getValue())); + } else if (sourceCellElement.getValue() instanceof BaseFormula) { + BaseFormula formula = (BaseFormula) sourceCellElement.getValue(); + formula = this.generateSimpleFormula(formula, 1); + newCellElement.setValue(formula); + } else { + try { + //richer:不改变原单元格 + newCellElement.setValue(BaseUtils.cloneObject(sourceCellElement.getValue())); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + + report.addCellElement(newCellElement); } protected abstract int getStartColumnIndex(); @@ -328,6 +326,15 @@ public class IntelliElements { }; } + @Override + public void doIntelliAction() { + for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex ++) { + for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) { + expandCellValue(colIndex, rowIndex); + } + } + } + @Override public boolean havetoModify() { return IntelliElements.this.dragCellRectangle.width > IntelliElements.this.oldCellRectangle.width; @@ -397,34 +404,43 @@ public class IntelliElements { }; } + @Override + public void doIntelliAction() { + for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex > colEnd; colIndex --) { + for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) { + expandCellValue(colIndex, rowIndex); + } + } + } + @Override public boolean havetoModify() { return true; } @Override - public int getStartRowIndex() { + public int getStartRowIndex() { return IntelliElements.this.oldCellRectangle.y; } @Override - public int getEndRowIndex() { + public int getEndRowIndex() { return IntelliElements.this.oldCellRectangle.y + IntelliElements.this.oldCellRectangle.height; } @Override - public int getStartColumnIndex() { - return IntelliElements.this.dragCellRectangle.x; + public int getStartColumnIndex() { + return IntelliElements.this.oldCellRectangle.x - 1; } @Override - public int getEndColumnIndex() { - return IntelliElements.this.oldCellRectangle.x; + public int getEndColumnIndex() { + return IntelliElements.this.dragCellRectangle.x - 1; } @Override public TemplateCellElement getSourceCellElementByColumnRow(int columnIndex, int rowIndex) { - return report.getTemplateCellElement(IntelliElements.this.oldCellRectangle.x + (columnIndex - IntelliElements.this.dragCellRectangle.x) % (IntelliElements.this.oldCellRectangle.width), rowIndex); + return report.getTemplateCellElement(columnIndex + IntelliElements.this.oldCellRectangle.width, rowIndex); } @Override @@ -465,6 +481,15 @@ public class IntelliElements { }; } + @Override + public void doIntelliAction() { + for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex ++) { + for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) { + expandCellValue(colIndex, rowIndex); + } + } + } + @Override public boolean havetoModify() { return IntelliElements.this.dragCellRectangle.height > IntelliElements.this.oldCellRectangle.height; @@ -534,33 +559,42 @@ public class IntelliElements { } @Override - public boolean havetoModify() { + public void doIntelliAction() { + for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex++) { + for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex > rowEnd; rowIndex--) { + expandCellValue(colIndex, rowIndex); + } + } + } + + @Override + public boolean havetoModify() { return true; } @Override - public int getStartRowIndex() { - return IntelliElements.this.dragCellRectangle.y; + public int getStartRowIndex() { + return IntelliElements.this.oldCellRectangle.y - 1; } @Override - public int getEndRowIndex() { - return IntelliElements.this.oldCellRectangle.y; + public int getEndRowIndex() { + return IntelliElements.this.dragCellRectangle.y - 1; } @Override - public int getStartColumnIndex() { + public int getStartColumnIndex() { return IntelliElements.this.oldCellRectangle.x; } @Override - public int getEndColumnIndex() { + public int getEndColumnIndex() { return IntelliElements.this.oldCellRectangle.x + IntelliElements.this.oldCellRectangle.width; } @Override public TemplateCellElement getSourceCellElementByColumnRow(int columnIndex, int rowIndex) { - return report.getTemplateCellElement(columnIndex, IntelliElements.this.oldCellRectangle.y + (rowIndex - IntelliElements.this.dragCellRectangle.y) % (IntelliElements.this.oldCellRectangle.height)); + return report.getTemplateCellElement(columnIndex, rowIndex + IntelliElements.this.oldCellRectangle.height); } @Override From 783f0b7043e7bc41e680456d82573d5a833f6a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 12 Jul 2021 14:00:53 +0800 Subject: [PATCH 2/9] =?UTF-8?q?REPORT-54998=20=E4=BF=AE=E6=AD=A3=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E6=8B=93=E5=B1=95=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/grid/IntelliElements.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/IntelliElements.java b/designer-realize/src/main/java/com/fr/grid/IntelliElements.java index 823448553..e53e8b952 100644 --- a/designer-realize/src/main/java/com/fr/grid/IntelliElements.java +++ b/designer-realize/src/main/java/com/fr/grid/IntelliElements.java @@ -445,7 +445,7 @@ public class IntelliElements { @Override protected Number processNumber(Number i) { - return i; + return FunctionHelper.asNumber(i.doubleValue() - 1); } @Override @@ -599,7 +599,7 @@ public class IntelliElements { @Override protected Number processNumber(Number i) { - return i; + return FunctionHelper.asNumber(i.doubleValue() - 1); } @Override From e4fe8267847615ecd0549f4b1691ce9a35c0db55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 12 Jul 2021 18:06:54 +0800 Subject: [PATCH 3/9] =?UTF-8?q?REPORT-54998=20=E5=AE=8C=E5=96=84=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E8=BF=99=E8=BE=B9=E7=9A=84=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BD=BF=E5=85=B6=E6=9B=B4=E5=8A=A0=E6=B8=85?= =?UTF-8?q?=E6=99=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/grid/GridMouseAdapter.java | 153 ++++++++++++++---- 1 file changed, 118 insertions(+), 35 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index 55bbcfed3..da2f6f174 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -46,6 +46,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous private static final int TOOLTIP_X_Y_FIX = 4; private static final double COPY_CROSS_INNER_DISTANCE = 1.5; private static final double COPY_CROSS_OUTER_DISTANCE = 2.5; + private static final int DIRECTION_UP = 1; + private static final int DIRECTION_DOWN = 2; + private static final int DIRECTION_LEFT = 3; + private static final int DIRECTION_RIGHT = 4; /** * 拖拽时候刷新时间间隔 */ @@ -457,48 +461,127 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous if (cellRectangle.contains(selectedCellPoint.getColumn(), selectedCellPoint.getRow())) { grid.getDragRectangle().setBounds(cellRectangle); } else { + if (isOutECBlockPane(evtX, evtY)) { + return; + } int xDistance = evtX - this.oldEvtX; int yDistance = evtY - this.oldEvtY; - if (Math.abs(yDistance) > Math.abs(xDistance)) { - grid.getDragRectangle().x = cellRectangle.x; - grid.getDragRectangle().width = cellRectangle.width; - if (yDistance >= 0) { - // 聚合报表要求拖拽的时候要在本块的内部进行 不能无限往下拖 - if (reportPane instanceof ECBlockPane && evtY > reportPane.getBounds().height - ECBlockGap) { - return; - } - grid.getDragRectangle().y = cellRectangle.y; - grid.getDragRectangle().height = selectedCellPoint.getRow() - cellRectangle.y + 1; + int dragDirection = calculateDragDirection(xDistance, yDistance); + grid.getDragRectangle().x = calculateDragRectangleX(selectedCellPoint, cellRectangle, dragDirection); + grid.getDragRectangle().y = calculateDragRectangleY(selectedCellPoint, cellRectangle, dragDirection); + grid.getDragRectangle().width = calculateDragRectangleWidth(selectedCellPoint, cellRectangle, dragDirection); + grid.getDragRectangle().height = calculateDragRectangleHeight(selectedCellPoint, cellRectangle, dragDirection); + } + reportPane.ensureColumnRowVisible(selectedCellPoint.getColumn() + 1, selectedCellPoint.getRow() + 1); + } + + private int calculateDragDirection(int xDistance, int yDistance) { + if (Math.abs(yDistance) > Math.abs(xDistance)) { + if (yDistance >= 0) { + return DIRECTION_DOWN; + } else { + return DIRECTION_UP; + } + } else { + if (xDistance >= 0) { + return DIRECTION_RIGHT; + } else { + return DIRECTION_LEFT; + } + } + } + + private int calculateDragRectangleX(ColumnRow currentMouseCell, Rectangle startRec, int direction) { + int result = 0; + switch(direction) { + case DIRECTION_DOWN: + case DIRECTION_UP: + case DIRECTION_RIGHT: + result = startRec.x; + break; + case DIRECTION_LEFT: + if (isInsideSelectedCell(currentMouseCell, startRec, direction)) { + result = startRec.x; } else { - if (selectedCellPoint.getRow() >= cellRectangle.y && selectedCellPoint.getRow() < cellRectangle.y + cellRectangle.height) { - grid.getDragRectangle().y = cellRectangle.y; - grid.getDragRectangle().height = cellRectangle.height; - } else { - grid.getDragRectangle().y = selectedCellPoint.getRow(); - grid.getDragRectangle().height = cellRectangle.y - selectedCellPoint.getRow() + cellRectangle.height; - } + result = currentMouseCell.getColumn(); } - } else { - grid.getDragRectangle().y = cellRectangle.y; - grid.getDragRectangle().height = cellRectangle.height; - if (xDistance >= 0) { - if (reportPane instanceof ECBlockPane && evtX > reportPane.getBounds().width - ECBlockGap) { - return; - } - grid.getDragRectangle().x = cellRectangle.x; - grid.getDragRectangle().width = selectedCellPoint.getColumn() - cellRectangle.x + 1; + break; + } + return result; + } + + private int calculateDragRectangleY(ColumnRow currentMouseCell, Rectangle startRec, int direction) { + int result = 0; + switch(direction) { + case DIRECTION_RIGHT: + case DIRECTION_LEFT: + case DIRECTION_DOWN: + result = startRec.y; + break; + case DIRECTION_UP: + if (isInsideSelectedCell(currentMouseCell, startRec, direction)) { + result = startRec.y; } else { - if (selectedCellPoint.getColumn() >= cellRectangle.x && selectedCellPoint.getColumn() < cellRectangle.x + cellRectangle.width) { - grid.getDragRectangle().x = cellRectangle.x; - grid.getDragRectangle().width = cellRectangle.width; - } else { - grid.getDragRectangle().x = selectedCellPoint.getColumn(); - grid.getDragRectangle().width = cellRectangle.x - selectedCellPoint.getColumn() + cellRectangle.width; - } + result = currentMouseCell.getRow(); } - } + break; } - reportPane.ensureColumnRowVisible(selectedCellPoint.getColumn() + 1, selectedCellPoint.getRow() + 1); + return result; + } + + private int calculateDragRectangleWidth(ColumnRow currentMouseCell, Rectangle startRec, int direction) { + int result = 0; + switch(direction) { + case DIRECTION_DOWN: + case DIRECTION_UP: + result = startRec.width; + break; + case DIRECTION_RIGHT: + result = currentMouseCell.getColumn() - startRec.x + 1; + break; + case DIRECTION_LEFT: + if (isInsideSelectedCell(currentMouseCell, startRec, direction)) { + result = startRec.width; + } else { + result = startRec.x - currentMouseCell.getColumn() + startRec.width; + } + break; + } + return result; + } + + private int calculateDragRectangleHeight(ColumnRow currentMouseCell, Rectangle startRec, int direction) { + int result = 0; + switch(direction) { + case DIRECTION_DOWN: + result = currentMouseCell.getRow() - startRec.y + 1; + break; + case DIRECTION_UP: + if (isInsideSelectedCell(currentMouseCell, startRec, direction)) { + result = startRec.y - currentMouseCell.getRow() + startRec.height; + } else { + result = startRec.height; + } + break; + case DIRECTION_RIGHT: + case DIRECTION_LEFT: + result = startRec.height; + break; + } + return result; + } + + private boolean isOutECBlockPane(int evtX, int evtY) { + ElementCasePane reportPane = grid.getElementCasePane(); + if (reportPane instanceof ECBlockPane) { + return (evtY > reportPane.getBounds().height - ECBlockGap) || (evtX > reportPane.getBounds().width - ECBlockGap); + } + return true; + } + + private boolean isInsideSelectedCell(ColumnRow currentMouseCell, Rectangle startRec, int direction) { + return (direction == DIRECTION_UP && currentMouseCell.getRow() >= startRec.y && currentMouseCell.getRow() < startRec.y + startRec.height) || + (direction == DIRECTION_LEFT && currentMouseCell.getColumn() >= startRec.x && currentMouseCell.getColumn() < startRec.x + startRec.width); } private void doShiftSelectCell(double evtX, double evtY) { From 3f195ec59136ec51606f6502b7300cc1a5043f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 12 Jul 2021 18:42:59 +0800 Subject: [PATCH 4/9] =?UTF-8?q?REPORT-54998=20=E4=BF=AE=E6=AD=A3=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/grid/GridMouseAdapter.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index da2f6f174..f09c34b07 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -455,11 +455,11 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous private void doWithCellElementDragged(int evtX, int evtY, CellSelection cs) { ElementCasePane reportPane = grid.getElementCasePane(); - java.awt.Rectangle cellRectangle = cs.toRectangle(); + java.awt.Rectangle startRec = cs.toRectangle(); - ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution); - if (cellRectangle.contains(selectedCellPoint.getColumn(), selectedCellPoint.getRow())) { - grid.getDragRectangle().setBounds(cellRectangle); + ColumnRow currentMouseCell = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution); + if (startRec.contains(currentMouseCell.getColumn(), currentMouseCell.getRow())) { + grid.getDragRectangle().setBounds(startRec); } else { if (isOutECBlockPane(evtX, evtY)) { return; @@ -467,12 +467,12 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous int xDistance = evtX - this.oldEvtX; int yDistance = evtY - this.oldEvtY; int dragDirection = calculateDragDirection(xDistance, yDistance); - grid.getDragRectangle().x = calculateDragRectangleX(selectedCellPoint, cellRectangle, dragDirection); - grid.getDragRectangle().y = calculateDragRectangleY(selectedCellPoint, cellRectangle, dragDirection); - grid.getDragRectangle().width = calculateDragRectangleWidth(selectedCellPoint, cellRectangle, dragDirection); - grid.getDragRectangle().height = calculateDragRectangleHeight(selectedCellPoint, cellRectangle, dragDirection); + grid.getDragRectangle().x = calculateDragRectangleX(currentMouseCell, startRec, dragDirection); + grid.getDragRectangle().y = calculateDragRectangleY(currentMouseCell, startRec, dragDirection); + grid.getDragRectangle().width = calculateDragRectangleWidth(currentMouseCell, startRec, dragDirection); + grid.getDragRectangle().height = calculateDragRectangleHeight(currentMouseCell, startRec, dragDirection); } - reportPane.ensureColumnRowVisible(selectedCellPoint.getColumn() + 1, selectedCellPoint.getRow() + 1); + reportPane.ensureColumnRowVisible(currentMouseCell.getColumn() + 1, currentMouseCell.getRow() + 1); } private int calculateDragDirection(int xDistance, int yDistance) { From c64c4b7a5ff352d9eb3cf3db71bd8047973f1178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 13 Jul 2021 15:46:34 +0800 Subject: [PATCH 5/9] =?UTF-8?q?REPORT-55034=20=E8=81=9A=E5=90=88=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=EF=BC=8C=E5=8D=95=E5=85=83=E6=A0=BC=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=9D=A2=E6=9D=BF=EF=BC=8C=E5=9C=A8=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=8F=82=E6=95=B0=E9=9D=A2=E6=9D=BF=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=9D=A2=E6=9D=BF=E6=9C=AA=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/JWorkBook.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 0f1ced379..d43926e6a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -1019,6 +1019,9 @@ public class JWorkBook extends JTemplate { // EastRegionContainerPane.getInstance().replaceDownPane(new JPanel()); QuickEditorRegion.getInstance().populate(QuickEditor.DEFAULT_EDITOR); } else { + if (polyDesigner.getSelectionType() == PolyDesigner.SelectionType.INNER) { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); + } EastRegionContainerPane.getInstance().replaceDownPane(CellElementPropertyPane.getInstance()); } EastRegionContainerPane.getInstance().replaceUpPane(QuickEditorRegion.getInstance()); From ce0437869c2a858fa6c05159281eeb0f999767ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 13 Jul 2021 19:00:14 +0800 Subject: [PATCH 6/9] =?UTF-8?q?REPORT-54998=20=E5=AE=8C=E5=96=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/grid/GridMouseAdapter.java | 160 ++++++++---------- 1 file changed, 74 insertions(+), 86 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index f09c34b07..7fb4af329 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -458,20 +458,15 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous java.awt.Rectangle startRec = cs.toRectangle(); ColumnRow currentMouseCell = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution); - if (startRec.contains(currentMouseCell.getColumn(), currentMouseCell.getRow())) { - grid.getDragRectangle().setBounds(startRec); - } else { - if (isOutECBlockPane(evtX, evtY)) { - return; - } - int xDistance = evtX - this.oldEvtX; - int yDistance = evtY - this.oldEvtY; - int dragDirection = calculateDragDirection(xDistance, yDistance); - grid.getDragRectangle().x = calculateDragRectangleX(currentMouseCell, startRec, dragDirection); - grid.getDragRectangle().y = calculateDragRectangleY(currentMouseCell, startRec, dragDirection); - grid.getDragRectangle().width = calculateDragRectangleWidth(currentMouseCell, startRec, dragDirection); - grid.getDragRectangle().height = calculateDragRectangleHeight(currentMouseCell, startRec, dragDirection); + if (isOutECBlockPane(evtX, evtY)) { + return; } + int xDistance = evtX - this.oldEvtX; + int yDistance = evtY - this.oldEvtY; + int dragDirection = calculateDragDirection(xDistance, yDistance); + ColumnRow realCell = calculateRealCell(currentMouseCell, startRec, dragDirection); + grid.getDragRectangle().setBounds(calculateDragRectangle(realCell, startRec, dragDirection)); + reportPane.ensureColumnRowVisible(currentMouseCell.getColumn() + 1, currentMouseCell.getRow() + 1); } @@ -491,97 +486,90 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous } } - private int calculateDragRectangleX(ColumnRow currentMouseCell, Rectangle startRec, int direction) { - int result = 0; + /** + * 计算当前十字标所在格子对应的真正参与计算拖拽边框的格子 + * @param currentMouseCell 当前鼠标所在的格子 + * @param startRec 起始格子 + * @param direction 拖拽方向 + * @return 当前十字标所在格子对应的真正参与计算拖拽边框的格子 + */ + private ColumnRow calculateRealCell(ColumnRow currentMouseCell, Rectangle startRec, int direction) { + ColumnRow realCell; switch(direction) { case DIRECTION_DOWN: case DIRECTION_UP: - case DIRECTION_RIGHT: - result = startRec.x; + realCell = ColumnRow.valueOf(startRec.x, currentMouseCell.row); break; - case DIRECTION_LEFT: - if (isInsideSelectedCell(currentMouseCell, startRec, direction)) { - result = startRec.x; - } else { - result = currentMouseCell.getColumn(); - } - break; - } - return result; - } - - private int calculateDragRectangleY(ColumnRow currentMouseCell, Rectangle startRec, int direction) { - int result = 0; - switch(direction) { case DIRECTION_RIGHT: case DIRECTION_LEFT: - case DIRECTION_DOWN: - result = startRec.y; + realCell = ColumnRow.valueOf(currentMouseCell.column, startRec.y); break; - case DIRECTION_UP: - if (isInsideSelectedCell(currentMouseCell, startRec, direction)) { - result = startRec.y; - } else { - result = currentMouseCell.getRow(); - } + default: + realCell = currentMouseCell; break; } - return result; + return realCell; } - private int calculateDragRectangleWidth(ColumnRow currentMouseCell, Rectangle startRec, int direction) { - int result = 0; - switch(direction) { - case DIRECTION_DOWN: - case DIRECTION_UP: - result = startRec.width; - break; - case DIRECTION_RIGHT: - result = currentMouseCell.getColumn() - startRec.x + 1; - break; - case DIRECTION_LEFT: - if (isInsideSelectedCell(currentMouseCell, startRec, direction)) { - result = startRec.width; - } else { - result = startRec.x - currentMouseCell.getColumn() + startRec.width; - } - break; + /** + * 计算拖拽的边框 + * @param realCell 当前十字标所在格子对应的真正参与计算拖拽边框的格子 + * @param startRec 起始格子 + * @param direction 拖拽方向 + * @return 拖拽的边框 + */ + private Rectangle calculateDragRectangle(ColumnRow realCell, Rectangle startRec, int direction) { + Rectangle rectangle = new Rectangle(); + if (startRec.contains(realCell.column, realCell.row)) { + rectangle.setBounds(startRec); + } else { + boolean clockWise = isClockWise(direction); + int x, y, width, height; + if (clockWise) { + x = startRec.x; + y = startRec.y; + width = Math.abs(realCell.column - startRec.x) + 1; // 加一是因为计算顺时针边框宽度或者高度的时候,没把realCell自身高度算进去 + height = Math.abs(realCell.row - startRec.y) + 1; + } else { + x = realCell.column; + y = realCell.row; + width = Math.abs(realCell.column - startRec.x) + startRec.width; + height = Math.abs(realCell.row - startRec.y) + startRec.height; + } + + // 上面的只计算了顺时针和逆时针的width,height,但是还要顺时针里面还要区分从左往右和从上往下,这里是用于修正 + boolean isHorizontal = isHorizontal(direction); + if (isHorizontal) { + height = startRec.height; // 水平方向,绘制的边框肯定就等于起始格子的高度 + } else { + width = startRec.width; // 垂直方向,绘制的边框肯定就等于起始给子的宽度 + } + rectangle.setBounds(x, y, width, height); } - return result; + return rectangle; } - private int calculateDragRectangleHeight(ColumnRow currentMouseCell, Rectangle startRec, int direction) { - int result = 0; - switch(direction) { - case DIRECTION_DOWN: - result = currentMouseCell.getRow() - startRec.y + 1; - break; - case DIRECTION_UP: - if (isInsideSelectedCell(currentMouseCell, startRec, direction)) { - result = startRec.y - currentMouseCell.getRow() + startRec.height; - } else { - result = startRec.height; - } - break; - case DIRECTION_RIGHT: - case DIRECTION_LEFT: - result = startRec.height; - break; - } - return result; + /** + * 判断拖拽方向是否是顺时针 从左往右,从上往下为顺时针,从右往左,从下往上为逆时针 + * @param direction 方向 + * @return 是否是顺时针 + */ + private boolean isClockWise(int direction) { + return direction == DIRECTION_DOWN || direction == DIRECTION_RIGHT; } - private boolean isOutECBlockPane(int evtX, int evtY) { - ElementCasePane reportPane = grid.getElementCasePane(); - if (reportPane instanceof ECBlockPane) { - return (evtY > reportPane.getBounds().height - ECBlockGap) || (evtX > reportPane.getBounds().width - ECBlockGap); - } - return true; + /** + * 判断拖拽方向是否为水平还是垂直 + * @param direction 方向 + * @return 是否为水平 + */ + private boolean isHorizontal(int direction) { + return direction == DIRECTION_RIGHT || direction == DIRECTION_LEFT; } - private boolean isInsideSelectedCell(ColumnRow currentMouseCell, Rectangle startRec, int direction) { - return (direction == DIRECTION_UP && currentMouseCell.getRow() >= startRec.y && currentMouseCell.getRow() < startRec.y + startRec.height) || - (direction == DIRECTION_LEFT && currentMouseCell.getColumn() >= startRec.x && currentMouseCell.getColumn() < startRec.x + startRec.width); + private boolean isOutECBlockPane(int evtX, int evtY) { + ElementCasePane reportPane = grid.getElementCasePane(); + return reportPane instanceof ECBlockPane && ((evtY > reportPane.getBounds().height - ECBlockGap) || (evtX > reportPane.getBounds().width - ECBlockGap)); } private void doShiftSelectCell(double evtX, double evtY) { From 34fd37a8780a2e4e82699bf5abec54a4a520de37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 13 Jul 2021 19:59:30 +0800 Subject: [PATCH 7/9] =?UTF-8?q?REPORT-54998=20=E5=AE=8C=E5=96=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/grid/GridMouseAdapter.java | 78 +++++-------------- 1 file changed, 19 insertions(+), 59 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index 7fb4af329..b0f8fff46 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -464,8 +464,8 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous int xDistance = evtX - this.oldEvtX; int yDistance = evtY - this.oldEvtY; int dragDirection = calculateDragDirection(xDistance, yDistance); - ColumnRow realCell = calculateRealCell(currentMouseCell, startRec, dragDirection); - grid.getDragRectangle().setBounds(calculateDragRectangle(realCell, startRec, dragDirection)); + Rectangle endRec = calculateEndRec(currentMouseCell, startRec, dragDirection); + grid.getDragRectangle().setBounds(calculateDragRectangle(startRec, endRec)); reportPane.ensureColumnRowVisible(currentMouseCell.getColumn() + 1, currentMouseCell.getRow() + 1); } @@ -487,86 +487,46 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous } /** - * 计算当前十字标所在格子对应的真正参与计算拖拽边框的格子 + * 计算拖拽的结尾矩形 * @param currentMouseCell 当前鼠标所在的格子 * @param startRec 起始格子 * @param direction 拖拽方向 - * @return 当前十字标所在格子对应的真正参与计算拖拽边框的格子 + * @return 计算拖拽的结尾矩形 */ - private ColumnRow calculateRealCell(ColumnRow currentMouseCell, Rectangle startRec, int direction) { - ColumnRow realCell; + private Rectangle calculateEndRec(ColumnRow currentMouseCell, Rectangle startRec, int direction) { + Rectangle rec; switch(direction) { case DIRECTION_DOWN: case DIRECTION_UP: - realCell = ColumnRow.valueOf(startRec.x, currentMouseCell.row); + rec = new Rectangle(startRec.x, currentMouseCell.row, 1, 1); break; case DIRECTION_RIGHT: case DIRECTION_LEFT: - realCell = ColumnRow.valueOf(currentMouseCell.column, startRec.y); + rec = new Rectangle(currentMouseCell.column, startRec.y, 1, 1); break; default: - realCell = currentMouseCell; + rec = new Rectangle(); break; } - return realCell; + return rec; } /** - * 计算拖拽的边框 - * @param realCell 当前十字标所在格子对应的真正参与计算拖拽边框的格子 - * @param startRec 起始格子 - * @param direction 拖拽方向 + * 计算拖拽的边框,传俩矩形确认出一个大矩形,就是所要的结果 + * @param startRec 起始格子矩形 + * @param endRec 结尾格子矩形 * @return 拖拽的边框 */ - private Rectangle calculateDragRectangle(ColumnRow realCell, Rectangle startRec, int direction) { + private Rectangle calculateDragRectangle(Rectangle startRec, Rectangle endRec) { Rectangle rectangle = new Rectangle(); - if (startRec.contains(realCell.column, realCell.row)) { - rectangle.setBounds(startRec); - } else { - boolean clockWise = isClockWise(direction); - int x, y, width, height; - if (clockWise) { - x = startRec.x; - y = startRec.y; - width = Math.abs(realCell.column - startRec.x) + 1; // 加一是因为计算顺时针边框宽度或者高度的时候,没把realCell自身高度算进去 - height = Math.abs(realCell.row - startRec.y) + 1; - } else { - x = realCell.column; - y = realCell.row; - width = Math.abs(realCell.column - startRec.x) + startRec.width; - height = Math.abs(realCell.row - startRec.y) + startRec.height; - } - - // 上面的只计算了顺时针和逆时针的width,height,但是还要顺时针里面还要区分从左往右和从上往下,这里是用于修正 - boolean isHorizontal = isHorizontal(direction); - if (isHorizontal) { - height = startRec.height; // 水平方向,绘制的边框肯定就等于起始格子的高度 - } else { - width = startRec.width; // 垂直方向,绘制的边框肯定就等于起始给子的宽度 - } - rectangle.setBounds(x, y, width, height); - } + int x = Math.min(startRec.x, endRec.x); + int y = Math.min(startRec.y, endRec.y); + int rightBottomX = Math.max(startRec.x + startRec.width, endRec.x + endRec.width); + int rightBottomY = Math.max(startRec.y + startRec.height, endRec.y + endRec.height); + rectangle.setBounds(x, y, rightBottomX - x, rightBottomY - y); return rectangle; } - /** - * 判断拖拽方向是否是顺时针 从左往右,从上往下为顺时针,从右往左,从下往上为逆时针 - * @param direction 方向 - * @return 是否是顺时针 - */ - private boolean isClockWise(int direction) { - return direction == DIRECTION_DOWN || direction == DIRECTION_RIGHT; - } - - /** - * 判断拖拽方向是否为水平还是垂直 - * @param direction 方向 - * @return 是否为水平 - */ - private boolean isHorizontal(int direction) { - return direction == DIRECTION_RIGHT || direction == DIRECTION_LEFT; - } - private boolean isOutECBlockPane(int evtX, int evtY) { ElementCasePane reportPane = grid.getElementCasePane(); return reportPane instanceof ECBlockPane && ((evtY > reportPane.getBounds().height - ECBlockGap) || (evtX > reportPane.getBounds().width - ECBlockGap)); From bdad7f09e27485894ce414b1444d6a7eab1dbf56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 13 Jul 2021 20:15:42 +0800 Subject: [PATCH 8/9] =?UTF-8?q?REPORT-54998=20=E8=BF=9B=E4=B8=80=E6=AD=A5?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E5=85=B7=E4=BD=93=E7=9A=84=E6=96=B9=E5=90=91=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E7=95=99=E6=B0=B4=E5=B9=B3=E6=88=96=E8=80=85?= =?UTF-8?q?=E5=9E=82=E7=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/grid/GridMouseAdapter.java | 44 +++++-------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index b0f8fff46..0a6ba5042 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -463,52 +463,30 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous } int xDistance = evtX - this.oldEvtX; int yDistance = evtY - this.oldEvtY; - int dragDirection = calculateDragDirection(xDistance, yDistance); - Rectangle endRec = calculateEndRec(currentMouseCell, startRec, dragDirection); + boolean isHorizontal = isHorizontal(xDistance, yDistance); + Rectangle endRec = calculateEndRec(currentMouseCell, startRec, isHorizontal); grid.getDragRectangle().setBounds(calculateDragRectangle(startRec, endRec)); reportPane.ensureColumnRowVisible(currentMouseCell.getColumn() + 1, currentMouseCell.getRow() + 1); } - private int calculateDragDirection(int xDistance, int yDistance) { - if (Math.abs(yDistance) > Math.abs(xDistance)) { - if (yDistance >= 0) { - return DIRECTION_DOWN; - } else { - return DIRECTION_UP; - } - } else { - if (xDistance >= 0) { - return DIRECTION_RIGHT; - } else { - return DIRECTION_LEFT; - } - } + private boolean isHorizontal(int xDistance, int yDistance) { + return Math.abs(yDistance) <= Math.abs(xDistance); } /** * 计算拖拽的结尾矩形 * @param currentMouseCell 当前鼠标所在的格子 * @param startRec 起始格子 - * @param direction 拖拽方向 + * @param isHorizontal 拖拽方向 水平or垂直 * @return 计算拖拽的结尾矩形 */ - private Rectangle calculateEndRec(ColumnRow currentMouseCell, Rectangle startRec, int direction) { - Rectangle rec; - switch(direction) { - case DIRECTION_DOWN: - case DIRECTION_UP: - rec = new Rectangle(startRec.x, currentMouseCell.row, 1, 1); - break; - case DIRECTION_RIGHT: - case DIRECTION_LEFT: - rec = new Rectangle(currentMouseCell.column, startRec.y, 1, 1); - break; - default: - rec = new Rectangle(); - break; - } - return rec; + private Rectangle calculateEndRec(ColumnRow currentMouseCell, Rectangle startRec, boolean isHorizontal) { + if (isHorizontal) { + return new Rectangle(currentMouseCell.column, startRec.y, 1, 1); + } else { + return new Rectangle(startRec.x, currentMouseCell.row, 1, 1); + } } /** From b3ca4897870e1e88e3bedfc3491458209ba5aab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 13 Jul 2021 20:16:29 +0800 Subject: [PATCH 9/9] =?UTF-8?q?REPORT-54998=20=E5=8E=BB=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/grid/GridMouseAdapter.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index 0a6ba5042..dfd7f29fd 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -46,10 +46,6 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous private static final int TOOLTIP_X_Y_FIX = 4; private static final double COPY_CROSS_INNER_DISTANCE = 1.5; private static final double COPY_CROSS_OUTER_DISTANCE = 2.5; - private static final int DIRECTION_UP = 1; - private static final int DIRECTION_DOWN = 2; - private static final int DIRECTION_LEFT = 3; - private static final int DIRECTION_RIGHT = 4; /** * 拖拽时候刷新时间间隔 */