Browse Source

REPORT-2897 9.0设计器修改

缩放条部分
master
MoMeak 7 years ago
parent
commit
7173e76d4c
  1. 18
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  2. 39
      designer/src/com/fr/design/mainframe/JWorkBook.java
  3. 28
      designer/src/com/fr/design/mainframe/ReportComponentComposite.java
  4. 12
      designer/src/com/fr/grid/Grid.java
  5. 13
      designer/src/com/fr/grid/GridColumn.java
  6. 11
      designer/src/com/fr/grid/GridColumnUI.java
  7. 4
      designer/src/com/fr/grid/GridHeader.java
  8. 38
      designer/src/com/fr/grid/GridMouseAdapter.java
  9. 15
      designer/src/com/fr/grid/GridRow.java
  10. 36
      designer/src/com/fr/grid/GridRowUI.java
  11. 7
      designer/src/com/fr/grid/GridUI.java
  12. 82
      designer/src/com/fr/grid/GridUtils.java
  13. 5
      designer_base/src/com/fr/design/mainframe/DesignerFrame.java
  14. 59
      designer_base/src/com/fr/design/mainframe/JSliderPane.java
  15. 4
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  16. 62
      designer_form/src/com/fr/design/mainframe/FormArea.java
  17. 10
      designer_form/src/com/fr/design/mainframe/JForm.java

18
designer/src/com/fr/design/mainframe/ElementCasePane.java

@ -11,12 +11,9 @@ import java.awt.Rectangle;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Constructor;
import java.util.Set;
@ -191,7 +188,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
/**
* Constructor.
*/
public ElementCasePane(T t) {
public ElementCasePane(T t) {
super(t);
// marks:能触发processEvent,不管是否给component增加listener。这里是使在reportPane中的任意位置滑动鼠标轮都能
// 下拉grid。
@ -213,6 +210,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
protected void initComponents() {
this.setLayout(new RGridLayout());
//todo 直接修改分辨率
this.resolution = ScreenResolution.getScreenResolution();
this.initGridComponent();
@ -231,7 +229,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
verScrollBar = new DynamicScrollBar(Adjustable.VERTICAL, this, this.resolution);
horScrollBar = new DynamicScrollBar(Adjustable.HORIZONTAL, this, this.resolution);
this.add(RGridLayout.VerticalBar, this.verScrollBar);
// this.add(RGridLayout.HorizontalBar, this.horScrollBar);
// this.add(RGridLayout.HorizontalBar, this.horScrollBar);
// Init input/action map defaultly.
initInputActionMap();
@ -1049,7 +1047,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
ElementCase elementCase = this.getEditingElementCase();
boolean cancel = false;
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(this, evt.getX(), evt.getY());
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(this, evt.getX(), evt.getY(), this.resolution);
ReportPageAttrProvider reportPageAttr = elementCase.getReportPageAttr();
ElementCase report = this.getEditingElementCase();
if (reportPageAttr != null) {
@ -1142,7 +1140,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
HeadColumnAction headcolumnAction = new HeadColumnAction(this);
FootColumnAction footcolumnAction = new FootColumnAction(this);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(this, evt.getX(), evt.getY());
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(this, evt.getX(), evt.getY(),this.resolution);
ElementCase elementCase = this.getEditingElementCase();
boolean cancel = false;
ReportPageAttrProvider reportPageAttr = elementCase.getReportPageAttr();

39
designer/src/com/fr/design/mainframe/JWorkBook.java

@ -1,9 +1,9 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.parameter.ParameterUI;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction;
@ -51,16 +51,17 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.general.ModuleContext;
import com.fr.general.web.ParameterConsts;
import com.fr.grid.Grid;
import com.fr.grid.GridUtils;
import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.main.parameter.ReportParameterAttr;
import com.fr.poly.PolyDesigner;
import com.fr.privilege.finegrain.WorkSheetPrivilegeControl;
import com.fr.report.cellcase.CellCase;
import com.fr.report.ReportHelper;
import com.fr.report.elementcase.ElementCase;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.poly.PolyWorkSheet;
import com.fr.report.report.Report;
import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils;
@ -86,6 +87,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
private UIModeControlContainer centerPane;
private ReportComponentComposite reportComposite;
private ParameterDefinitePane parameterPane;
private int resolution;
public JWorkBook() {
super(new WorkBook(new WorkSheet()), "WorkBook");
@ -159,6 +161,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
}
}
/**
* 无条件取消格式刷
*/
@ -317,6 +320,34 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
parameterPane.getParaDesigner().removeSelection();
}
/**
* 缩放条
*/
@Override
public void setScale(int resolution) {
//更新resolution
this.resolution = resolution;
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setResolution(resolution);
//更新Grid
Grid grid = reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid();
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(reportComposite.centerCardPane.editingComponet.elementCasePane.getEditingElementCase());
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(reportComposite.centerCardPane.editingComponet.elementCasePane.getEditingElementCase());
grid.setVerticalExtent(GridUtils.getExtentValue(0, rowHeightList, grid.getHeight(), resolution));
grid.setHorizontalExtent(GridUtils.getExtentValue(0, columnWidthList, grid.getWidth(), resolution));
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().updateUI();
//更新Column和Row
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridColumn().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridColumn().updateUI();
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridRow().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridRow().updateUI();
}
@Override
public int getScale() {
return this.resolution;
}
public int getToolBarHeight() {
return TOOLBARPANEDIMHEIGHT;
}

28
designer/src/com/fr/design/mainframe/ReportComponentComposite.java

@ -36,11 +36,12 @@ public class ReportComponentComposite extends JComponent {
private JPanel hbarContainer;
private JPanel jSliderContainer;
/**
* Constructor with workbook..
*
* @param workBook the current workbook.
*/
public ReportComponentComposite(JWorkBook jwb) {
this.parent = jwb;
@ -52,7 +53,7 @@ public class ReportComponentComposite extends JComponent {
this.add(CellElementRegion, BorderLayout.NORTH);
this.add(createSouthControlPane(), BorderLayout.SOUTH);
}
protected void doBeforeChange(int oldIndex) {
if (oldIndex >= 0) {
templateStateList.set(oldIndex, centerCardPane.editingComponet.createEditingState());
@ -153,13 +154,30 @@ public class ReportComponentComposite extends JComponent {
}
private JComponent createSouthControlPane() {
// hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
// hbarContainer.add(createSouthControlPaneWithJSliderPane());
hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar());
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, hbarContainer);
// JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, hbarContainer);
JPanel southPane = new JPanel(new BorderLayout());
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, JSliderPane.getInstance());
splitpane.setBorder(null);
splitpane.setDividerSize(3);
splitpane.setResizeWeight(0.6);
return splitpane;
splitpane.setResizeWeight(1);
southPane.add(hbarContainer,BorderLayout.NORTH);
southPane.add(splitpane,BorderLayout.CENTER);
return southPane;
}
private JComponent createSouthControlPaneWithJSliderPane() {
hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar());
JSplitPane splitWithJSliderPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, hbarContainer, JSliderPane.getInstance());
splitWithJSliderPane.setBorder(null);
splitWithJSliderPane.setDividerLocation(0.9);
splitWithJSliderPane.setDividerSize(3);
splitWithJSliderPane.setResizeWeight(1);
return splitWithJSliderPane;
}
public void setSelectedIndex(int selectedIndex) {

12
designer/src/com/fr/grid/Grid.java

@ -114,6 +114,7 @@ public class Grid extends BaseGridComponent {
private int resolution;
// 判断SmartJTablePane是否显示,做为动态虚线标识符
private boolean notShowingTableSelectPane = true;
private GridMouseAdapter gridMouseAdapter;
public Grid(int resolution) {
this.resolution = resolution;
@ -121,7 +122,7 @@ public class Grid extends BaseGridComponent {
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
GridKeyAction.initGridInputActionMap(this);
GridMouseAdapter gridMouseAdapter = new GridMouseAdapter(this);
gridMouseAdapter = new GridMouseAdapter(this);
this.addMouseListener(gridMouseAdapter);
this.addMouseMotionListener(gridMouseAdapter);
@ -136,6 +137,10 @@ public class Grid extends BaseGridComponent {
this.updateUI();
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
/**
* 应用界面设置
*
@ -149,6 +154,7 @@ public class Grid extends BaseGridComponent {
setUI(localComponentUI);
}
/**
* 是否显示格子线
*
@ -173,6 +179,10 @@ public class Grid extends BaseGridComponent {
this.getElementCasePane().repaint();
}
public GridMouseAdapter getGridMouseAdapter(){
return this.gridMouseAdapter;
}
/**
* Gets grid line color.
*

13
designer/src/com/fr/grid/GridColumn.java

@ -6,9 +6,14 @@ package com.fr.grid;
import java.awt.Dimension;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.GridUIProcessor;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.stable.StableUtils;
import javax.swing.plaf.ComponentUI;
/**
* GridColumn used to paint and edit grid column.
*
@ -17,6 +22,8 @@ import com.fr.stable.StableUtils;
*/
public class GridColumn extends GridHeader<String> {
private int resolution = ScreenResolution.getScreenResolution();
@Override
protected void initByConstructor() {
GridColumnMouseHandler gridColumnMouseHandler = new GridColumnMouseHandler(this);
@ -32,7 +39,11 @@ public class GridColumn extends GridHeader<String> {
@Override
public void updateUI() {
this.setUI(new GridColumnUI());
this.setUI(new GridColumnUI(resolution));
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
/**

11
designer/src/com/fr/grid/GridColumnUI.java

@ -16,6 +16,8 @@ import com.fr.base.ScreenResolution;
import com.fr.cache.list.IntList;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.GridScaleEdit;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.grid.selection.Selection;
import com.fr.privilege.finegrain.ColumnRowPrivilegeControl;
@ -29,7 +31,14 @@ import com.fr.report.elementcase.ElementCase;
public class GridColumnUI extends ComponentUI {
protected Color withoutDetailsBackground = Color.lightGray;
protected int resolution = ScreenResolution.getScreenResolution();
private int resolution ;
public GridColumnUI(int resolution){
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
this.resolution = resolution;
}
@Override
public void paint(Graphics g, JComponent c) {

4
designer/src/com/fr/grid/GridHeader.java

@ -6,7 +6,7 @@ import java.awt.Color;
public abstract class GridHeader<T> extends BaseGridComponent {
public final static int SIZE_ADJUST = 4;
//属性
private Color separatorLineColor = new Color(172, 168, 153); //separator lines
private Color selectedForeground = Color.black;
@ -22,7 +22,7 @@ public abstract class GridHeader<T> extends BaseGridComponent {
initByConstructor();
}
protected abstract void initByConstructor();
protected abstract T getDisplay(int index) ;

38
designer/src/com/fr/grid/GridMouseAdapter.java

@ -7,6 +7,8 @@ import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.GridScaleEdit;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.present.CellWriteAttrPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.grid.selection.CellSelection;
@ -71,6 +73,8 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
private int ECBlockGap = 40;
private int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
protected GridMouseAdapter(Grid grid) {
this.grid = grid;
}
@ -101,7 +105,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
// 用户没有按住Shift键时,tempOldSelectedCell是一直变化的。如果一直按住shift,是不变的
ElementCasePane ePane = grid.getElementCasePane();
if (!evt.isShiftDown() && ePane.getSelection() instanceof CellSelection) {
tempOldSelectedCell = GridUtils.getAdjustEventColumnRow(ePane, oldEvtX, oldEvtY);
tempOldSelectedCell = GridUtils.getAdjustEventColumnRow_withresolution(ePane, oldEvtX, oldEvtY,resolution);
}
}
@ -118,7 +122,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
int horizentalScrollValue = grid.getHorizontalValue();
int verticalScrollValue = grid.getVerticalValue();
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
FU evtX_fu = FU.valueOfPix(this.oldEvtX, resolution);
FU evtY_fu = FU.valueOfPix(this.oldEvtY, resolution);
@ -142,7 +146,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
FloatElement selectedFloatElement = (FloatElement) tmpFloatElementCursor[0];
reportPane.setSelection(new FloatSelection(selectedFloatElement.getName()));
} else {
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(reportPane, this.oldEvtX, this.oldEvtY);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, this.oldEvtX, this.oldEvtY, this.resolution);
if (!reportPane.getSelection().containsColumnRow(selectedCellPoint)) {
GridUtils.doSelectCell(reportPane, selectedCellPoint.getColumn(), selectedCellPoint.getRow());
}
@ -187,7 +191,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
// peter:选择GridSelection,支持Shift
doOneClickSelection(this.oldEvtX, this.oldEvtY, isShiftDown, isControlDown);
// 得到点击所在的column and row
ColumnRow columnRow = GridUtils.getEventColumnRow(reportPane, this.oldEvtX, this.oldEvtY);
ColumnRow columnRow = GridUtils.getEventColumnRow_withresolution(reportPane, this.oldEvtX, this.oldEvtY, this.resolution);
TemplateCellElement cellElement = report.getTemplateCellElement(columnRow.getColumn(), columnRow.getRow());
if (clickCount >= 2 && !BaseUtils.isAuthorityEditing()) {
grid.startEditing();
@ -206,7 +210,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
*/
private void showWidetWindow(TemplateCellElement cellElement, TemplateElementCase report) {
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
double fixed_pos_x = this.oldEvtX - columnWidthList.getRangeValue(grid.getHorizontalValue(), cellElement.getColumn()).toPixD(resolution);
@ -223,6 +227,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
&& cell_width - fixed_pos_x < WIDGET_WIDTH && cell_height - fixed_pos_y < WIDGET_WIDTH;
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
/**
* @param evt
*/
@ -372,7 +380,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
doWithCellElementDragged(evtX, evtY, (CellSelection) selection);
} else if (grid.getDragType() == GridUtils.DRAG_CELLSELECTION && !BaseUtils.isAuthorityEditing()) {
// peter:获得调整过的Selected Column Row.
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(reportPane, evtX, evtY);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution);
if (selectedCellPoint.getColumn() != grid.getDragRectangle().x || selectedCellPoint.getRow() != grid.getDragRectangle().y) {
grid.getDragRectangle().x = selectedCellPoint.getColumn();
grid.getDragRectangle().y = selectedCellPoint.getRow();
@ -393,7 +401,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
private void doWithFloatElementDragged(int evtX, int evtY, FloatSelection fs) {
ElementCase report = grid.getElementCasePane().getEditingElementCase();
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
String floatName = fs.getSelectedFloatName();
FloatElement floatElement = report.getFloatElement(floatName);
int cursorType = grid.getCursor().getType();
@ -453,7 +461,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
ElementCasePane reportPane = grid.getElementCasePane();
java.awt.Rectangle cellRectangle = cs.toRectangle();
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(reportPane, evtX, evtY);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution);
if (cellRectangle.contains(selectedCellPoint.getColumn(), selectedCellPoint.getRow())) {
grid.getDragRectangle().setBounds(cellRectangle);
} else {
@ -507,7 +515,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
if (s instanceof FloatSelection) {
return;
}
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(reportPane, evtX, evtY);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution);
int selectedCellPointX = selectedCellPoint.getColumn();
int selectedCellPointY = selectedCellPoint.getRow();
CellSelection gridSelection = ((CellSelection) s).clone();
@ -543,7 +551,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
return;
}
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(reportPane, evtX, evtY);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evtX, evtY, resolution);
//拷贝,而不是直接强制使用以监听单元格选择变化
CellSelection gridSelection = ((CellSelection) s).clone();
gridSelection.setSelectedType(((CellSelection) s).getSelectedType());
@ -606,7 +614,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
} else {
grid.setCursor(UIConstants.CELL_DEFAULT_CURSOR);
}
ColumnRow selectedCellColumnRow = GridUtils.getEventColumnRow(reportPane, evtX, evtY);
ColumnRow selectedCellColumnRow = GridUtils.getEventColumnRow_withresolution(reportPane, evtX, evtY, resolution);
TemplateCellElement curCellElement = report.getTemplateCellElement(selectedCellColumnRow.getColumn(), selectedCellColumnRow.getRow());
if (curCellElement != null) {
@ -630,7 +638,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
* @param report
*/
private void setCursorAndToolTips(TemplateCellElement curCellElement, TemplateElementCase report) {
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
// 计算相对Grid的显示位置.
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
@ -674,7 +682,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
double leftColDistance = columnWidthList.getRangeValue(grid.getHorizontalValue(), cs.getColumn()).toPixD(resolution);
double rightColDistance = columnWidthList.getRangeValue(grid.getHorizontalValue(), cs.getColumn() + cs.getColumnSpan()).toPixD(resolution);
@ -725,7 +733,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
} else if (isControlDown) {
doControlSelectCell(evtX, evtY);
} else {
ColumnRow selectedCellPoint = GridUtils.getEventColumnRow(reportPane, evtX, evtY);
ColumnRow selectedCellPoint = GridUtils.getEventColumnRow_withresolution(reportPane, evtX, evtY, resolution);
int type = reportPane.ensureColumnRowVisible(selectedCellPoint.getColumn(), selectedCellPoint.getRow());
if (type == ElementCasePane.NO_OVER) {
GridUtils.doSelectCell(reportPane, selectedCellPoint.getColumn(), selectedCellPoint.getRow());
@ -766,7 +774,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
this.oldEvtX = evtX;
this.oldEvtY = evtY;
FloatElement el = report.getFloatElement(floatName);
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
int verticalValue = grid.getVerticalValue();
int horizentalValue = grid.getHorizontalValue();
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);

15
designer/src/com/fr/grid/GridRow.java

@ -6,8 +6,13 @@ package com.fr.grid;
import java.awt.Dimension;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.GridUIProcessor;
import com.fr.design.mainframe.ElementCasePane;
import javax.swing.plaf.ComponentUI;
/**
* GridRow used to paint and edit grid row.
*
@ -15,6 +20,9 @@ import com.fr.design.mainframe.ElementCasePane;
* @since 2012-3-22下午6:12:03
*/
public class GridRow extends GridHeader<Integer> {
private int resolution = ScreenResolution.getScreenResolution();
@Override
protected void initByConstructor() {
GridRowMouseHandler gridRowMouseHandler = new GridRowMouseHandler(this);
@ -30,9 +38,14 @@ public class GridRow extends GridHeader<Integer> {
@Override
public void updateUI() {
this.setUI(new GridRowUI());
this.setUI(new GridRowUI(resolution));
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
/**
* Gets the preferred size.
*/

36
designer/src/com/fr/grid/GridRowUI.java

@ -15,6 +15,8 @@ import com.fr.base.ScreenResolution;
import com.fr.cache.list.IntList;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.GridScaleEdit;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.grid.selection.Selection;
import com.fr.privilege.finegrain.ColumnRowPrivilegeControl;
@ -27,6 +29,14 @@ import com.fr.report.elementcase.ElementCase;
*/
public class GridRowUI extends ComponentUI {
private Color detailsBackground = Color.lightGray;
private int resolution ;
GridRowUI(int resolution){
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
this.resolution = resolution;
}
@Override
public void paint(Graphics g, JComponent c) {
@ -49,7 +59,6 @@ public class GridRowUI extends ComponentUI {
// paint more rows(double extent), for dragging.
int verticalEndValue = verticalValue + verticalExtent + 1;
double horizontalLineHeight = size.getHeight();
int resolution = ScreenResolution.getScreenResolution();
// use background to paint first.
// denny: 用来标识已有数据
@ -149,23 +158,20 @@ public class GridRowUI extends ComponentUI {
float fmAscent = GraphHelper.getFontMetrics(gridRow.getFont()).getAscent();
double stringWidth = gridRow.getFont().getStringBounds(paintText, fontRenderContext).getWidth();
double stringHeight = gridRow.getFont().getStringBounds(paintText, fontRenderContext).getHeight();
// AUGUST:如果高度太小了就不画了
if (stringHeight <= tmpIncreaseHeight + 2) {
if (isSelectedBounds) {
g2d.setColor(gridRow.getSelectedForeground());
if (isSelectedBounds) {
g2d.setColor(gridRow.getSelectedForeground());
} else {
// p:检查eanbled
if (gridRow.isEnabled()) {
g2d.setColor(gridRow.getForeground());
} else {
// p:检查eanbled
if (gridRow.isEnabled()) {
g2d.setColor(gridRow.getForeground());
} else {
g2d.setPaint(UIManager.getColor("controlShadow"));
}
g2d.setPaint(UIManager.getColor("controlShadow"));
}
GraphHelper.drawString(g2d, paintText, (size.width - stringWidth) / 2, tmpHeight1 + (tmpIncreaseHeight - stringHeight) / 2 + GridHeader.SIZE_ADJUST / 2 + fmAscent
- 2);
}
GraphHelper.drawString(g2d, paintText, (size.width - stringWidth) / 2, tmpHeight1 + (tmpIncreaseHeight - stringHeight) / 2 + GridHeader.SIZE_ADJUST / 2 + fmAscent
- 2);
}
}

7
designer/src/com/fr/grid/GridUI.java

@ -429,6 +429,7 @@ public class GridUI extends ComponentUI {
this.calculateForcedPagingOfCellElement(reportPane, tmpCellElement, hideWidth, hideHeight);
storeFatherLocation(selectedCellElement, tmpCellElement);
// element bounds
// TODO: 2017/7/13 tmpRectangle : 72*19
this.caculateScrollVisibleBounds(this.tmpRectangle, tmpCellElement.getColumn(),
tmpCellElement.getRow(), tmpCellElement.getColumnSpan(),
tmpCellElement.getRowSpan());
@ -455,8 +456,9 @@ public class GridUI extends ComponentUI {
paintCellElementList.add(tmpCellElement);
paintCellElementRectangleList.add(this.tmpRectangle.clone());
int cellWidth = (int) this.tmpRectangle.getWidth(), cellHeight = (int) this.tmpRectangle
.getHeight();
int cellWidth = (int) this.tmpRectangle.getWidth();
int cellHeight = (int) this.tmpRectangle.getHeight();
// denny_Grid: 画Grid中单元格的内容(包括单元格的背景Content + Background), 不包括边框
painter.paintBackground(g2d, report, tmpCellElement, cellWidth, cellHeight);
@ -1077,6 +1079,7 @@ public class GridUI extends ComponentUI {
grid.ajustEditorComponentBounds(); // refresh size
}
private void dealWithSizeBeforePaint(Grid grid, TemplateElementCase elementCase) {
// 取出所有的行高和列宽的List
this.rowHeightList = ReportHelper.getRowHeightList(elementCase);

82
designer/src/com/fr/grid/GridUtils.java

@ -6,6 +6,8 @@ import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.GridScaleEdit;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.CellSelection;
@ -48,6 +50,7 @@ public class GridUtils {
//peter:下面这几个量是在Drag列的时候用.
public final static int DRAG_CELL_SIZE = 1; //peter:drag的时候改变格子的宽度.
public final static int DRAG_SELECT_UNITS = 2; //peter:drag的时候,选中单元格.
// public static int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
/**
* Is above float element.(the return may be null). <br>
@ -67,7 +70,8 @@ public class GridUtils {
double[] floatArray = caculateFloatElementLocations(tmpFloatElement, ReportHelper.getColumnWidthList(report),
ReportHelper.getRowHeightList(report), reportPane.getGrid().getVerticalValue(), reportPane.getGrid().getHorizontalValue());
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
//peter:悬浮元素的范围.
Rectangle2D floatElementRect = new Rectangle2D.Double(floatArray[0], floatArray[1], tmpFloatElement.getWidth().toPixD(resolution), tmpFloatElement.getHeight().toPixD(resolution));
//peter:不是当前选中的悬浮元素,不支持六个改变大小的点.
@ -123,8 +127,8 @@ public class GridUtils {
*/
public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList,
int verticalValue, int horizentalValue) {
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
double floatX = columnWidthList.getRangeValue(horizentalValue, 0).toPixD(resolution) + floatElement.getLeftDistance().toPixD(resolution);
double floatY = rowHeightList.getRangeValue(verticalValue, 0).toPixD(resolution) + floatElement.getTopDistance().toPixD(resolution);
@ -166,7 +170,66 @@ public class GridUtils {
private static int cc_selected_column_or_row(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList) {
double tmpIntIndex = 0;
int selectedCellIndex = 0;
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
if (mouseEvtPosition < 0) {
selectedCellIndex = value;
for (; true; selectedCellIndex--) {
if (tmpIntIndex < mouseEvtPosition) {
break;
}
tmpIntIndex -= sizeList.get(selectedCellIndex).toPixD(resolution);
}
} else {
boolean isInnerFrozen = false;
for (int i = beginValue; i < 0; i++) {
tmpIntIndex += sizeList.get(i).toPixD(resolution);
if (tmpIntIndex > mouseEvtPosition) {
selectedCellIndex = i;
isInnerFrozen = true;
break;
}
}
if (!isInnerFrozen) {
selectedCellIndex = value;
for (; true; selectedCellIndex++) {
tmpIntIndex += sizeList.get(selectedCellIndex).toPixD(resolution);
if (tmpIntIndex > mouseEvtPosition) {
break;
}
}
}
}
return selectedCellIndex;
}
public static ColumnRow getEventColumnRow_withresolution(ElementCasePane reportPane, double evtX, double evtY, int resolution) {
ElementCase report = reportPane.getEditingElementCase();
// Width and height list.
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
int verticalValue = reportPane.getGrid().getVerticalValue();
int horizentalValue = reportPane.getGrid().getHorizontalValue();
// denny: get verticalBeginValue and horizontalBeginValue;
int verticalBeginValue = reportPane.getGrid().getVerticalBeginValue();
int horizontalBeginValue = reportPane.getGrid().getHorizontalBeginValue();
return ColumnRow.valueOf(
cc_selected_column_or_row_withresolution(evtX, horizontalBeginValue, horizentalValue, columnWidthList, resolution),
cc_selected_column_or_row_withresolution(evtY, verticalBeginValue, verticalValue, rowHeightList, resolution)
);
}
private static int cc_selected_column_or_row_withresolution(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList, int resolution) {
double tmpIntIndex = 0;
int selectedCellIndex = 0;
// int resolution = ScreenResolution.getScreenResolution();
if (mouseEvtPosition < 0) {
selectedCellIndex = value;
for (; true; selectedCellIndex--) {
@ -222,6 +285,16 @@ public class GridUtils {
return ColumnRow.valueOf(col, row);
}
public static ColumnRow getAdjustEventColumnRow_withresolution(ElementCasePane reportPane, double evtX, double evtY, int resolution) {
ColumnRow selectedCellPoint = GridUtils.getEventColumnRow_withresolution(reportPane, evtX, evtY, resolution);
int col = Math.max(selectedCellPoint.getColumn(), 0);
int row = Math.max(selectedCellPoint.getRow(), 0);
return ColumnRow.valueOf(col, row);
}
/**
* 是否可将当前单元格变为可见的格子
*/
@ -395,4 +468,5 @@ public class GridUtils {
}
}
}

5
designer_base/src/com/fr/design/mainframe/DesignerFrame.java

@ -255,6 +255,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
basePane.add(centerPane, BorderLayout.CENTER);
laoyoutWestPane();
// JPanel eastRegionPane = new JPanel(new BorderLayout());
// eastRegionPane.add(EastRegionContainerPane.getInstance(), BorderLayout.CENTER);
// eastRegionPane.add(JSliderPane.getInstance(), BorderLayout.SOUTH);
// basePane.add(eastRegionPane, BorderLayout.EAST);
basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST);
basePane.setBounds(0, 0, contentWidth, contentHeight);

59
designer_base/src/com/fr/design/mainframe/JSliderPane.java

@ -1,23 +1,32 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.fun.GridUIProcessor;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.islider.UISlider;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.grid.DefaultGridUIProcessor;
import com.fr.grid.Grid;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSliderUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.util.Observable;
/**
* Created by MoMeak on 2017/7/13.
@ -25,6 +34,8 @@ import java.awt.event.ActionListener;
public class JSliderPane extends JPanel {
private final int KERNING = 2;
public int showValue = 100;
public double resolutionTimes = 1.0;
private static JSliderPane THIS;
private UITextField showVal;
private UISlider slider;
@ -32,11 +43,11 @@ public class JSliderPane extends JPanel {
private int sliderValue;
private UIButton downButton;
private UIButton upButton;
private int showValue;
//拖动条处理和button、直接输入不一样
private boolean isButtonOrIsTxt = true;
public JSliderPane() {
this.setLayout(new BorderLayout());
slider = new UISlider(0,100,50);
@ -45,7 +56,7 @@ public class JSliderPane extends JPanel {
showVal = new UITextField();
showVal.setText("100%");
showVal.setPreferredSize(new Dimension(40,18));
showVal.getDocument().addDocumentListener(showValDocumentListener);
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveDown.png"));
@ -55,15 +66,6 @@ public class JSliderPane extends JPanel {
downButton.addActionListener(buttonActionListener);
upButton.addActionListener(buttonActionListener);
// double f = TableLayout.FILL;
// double p = TableLayout.PREFERRED;
// Component[][] components = new Component[][]{
// new Component[]{downButton, slider, upButton, showVal},
// };
// double[] rowSize = {p};
// double[] columnSize = {p,p,p,p};
// JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
JPanel panel = new JPanel(new FlowLayout(1,1,0));
panel.add(downButton);
@ -85,9 +87,10 @@ public class JSliderPane extends JPanel {
}
public static final JSliderPane getInstance() {
if (THIS == null) {
THIS = new JSliderPane();
}
// if (THIS == null) {
// THIS = new JSliderPane();
// }
THIS = new JSliderPane();
return THIS;
}
@ -118,6 +121,7 @@ public class JSliderPane extends JPanel {
public void insertUpdate(DocumentEvent e) {
isButtonOrIsTxt = true;
refreshSlider();
refreshBody();
}
@Override
@ -142,7 +146,28 @@ public class JSliderPane extends JPanel {
}
}
ActionListener buttonActionListener = new ActionListener() {
private void refreshBody(){
this.resolutionTimes = divide(showValue,100,2);
int resolution = (int) (ScreenResolution.getScreenResolution()*resolutionTimes);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution);
}
public double getResolutionTimes(){
return this.resolutionTimes;
}
public int getshowValue(){
return this.showValue;
}
public static double divide(double v1, double v2,int scale) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.divide(b2,scale).doubleValue();
}
ActionListener buttonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%")));
@ -178,6 +203,10 @@ public class JSliderPane extends JPanel {
}
public UITextField getShowVal(){
return this.showVal;
}
public static void main(String[] args)
{
JFrame jf = new JFrame("test");

4
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -210,6 +210,10 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
*/
public abstract void removeParameterPaneSelection();
public abstract void setScale(int resolution);
public abstract int getScale();
protected abstract DesignModelAdapter<T, ?> createDesignModel();
/**

62
designer_form/src/com/fr/design/mainframe/FormArea.java

@ -20,6 +20,8 @@ import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
@ -45,8 +47,8 @@ import com.fr.general.Inter;
public class FormArea extends JComponent implements ScrollRulerComponent {
private static final double SLIDER_FLOAT = 120.0;
private static final double SLIDER_MIN = 60.0;
private static final double SLIDER_FLOAT = 400.0;
private static final double SLIDER_MIN = 10.0;
public static final double DEFAULT_SLIDER = 100.0;
private static final int ROTATIONS = 50;
private FormDesigner designer;
@ -59,11 +61,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
//显示和设置表单界面大小的控件
private UINumberField widthPane;
private UINumberField heightPane;
private UINumberSlidePane slidePane;
private JSliderPane slidePane;
private boolean isValid = true;
// 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER;
private double screenValue;
private JSliderPane sliderPane;
public FormScrollBar getHorScrollBar() {
return horScrollBar;
@ -114,8 +117,13 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
widthPane.setPreferredSize(new Dimension(60, 0));
heightPane = new UINumberField();
heightPane.setPreferredSize(new Dimension(60, 0));
slidePane = new UINumberSlidePane(SLIDER_MIN, SLIDER_FLOAT);
slidePane.setPreferredSize(new Dimension(200,0));
// slidePane = new UINumberSlidePane(SLIDER_MIN, SLIDER_FLOAT);
// slidePane.setPreferredSize(new Dimension(260,20));
slidePane = JSliderPane.getInstance();
slidePane.setPreferredSize(new Dimension(300,20));
JPanel resizePane =TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{
{tipsPane, new UILabel(), widthPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel("x"),
heightPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel(), slidePane}},
@ -124,8 +132,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
setWidgetsConfig();
// 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小
slidePane.setEnabled(false);
slidePane.setVisible(false);
// initTransparent();
slidePane.setVisible(true);
initTransparent();
initCalculateSize();
}
@ -143,16 +151,36 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private void initTransparent() {
initCalculateSize();
slidePane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
double value = ((UINumberSlidePane) e.getSource()).getValue();
reCalculateRoot(value, true);
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(form != null){
form.fireTargetModified();
}
}
});
slidePane.getShowVal().getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
// slidePane.getShowVal().getDocument()
double value = slidePane.getshowValue();
reCalculateRoot(value, true);
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(form != null){
form.fireTargetModified();
}
}
@Override
public void removeUpdate(DocumentEvent e) {
}
@Override
public void changedUpdate(DocumentEvent e) {
}
});
// slidePane.addChangeListener(new ChangeListener() {
// public void stateChanged(ChangeEvent e) {
// double value = ((UINumberSlidePane) e.getSource()).getValue();
// reCalculateRoot(value, true);
// JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
// if(form != null){
// form.fireTargetModified();
// }
// }
// });
}
/**

10
designer_form/src/com/fr/design/mainframe/JForm.java

@ -240,6 +240,16 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return;
}
@Override
public void setScale(int resolution) {
}
@Override
public int getScale() {
return 0;
}
/**
* 创建权限细粒度编辑面板
*

Loading…
Cancel
Save