Browse Source

REPORT-2897 9.0设计器修改

缩放条部分
master
MoMeak 7 years ago
parent
commit
7173e76d4c
  1. 14
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  2. 39
      designer/src/com/fr/design/mainframe/JWorkBook.java
  3. 26
      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. 38
      designer/src/com/fr/grid/GridMouseAdapter.java
  8. 15
      designer/src/com/fr/grid/GridRow.java
  9. 16
      designer/src/com/fr/grid/GridRowUI.java
  10. 7
      designer/src/com/fr/grid/GridUI.java
  11. 82
      designer/src/com/fr/grid/GridUtils.java
  12. 5
      designer_base/src/com/fr/design/mainframe/DesignerFrame.java
  13. 55
      designer_base/src/com/fr/design/mainframe/JSliderPane.java
  14. 4
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  15. 48
      designer_form/src/com/fr/design/mainframe/FormArea.java
  16. 10
      designer_form/src/com/fr/design/mainframe/JForm.java

14
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.Clipboard;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent; import java.awt.event.*;
import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent;
import java.awt.event.InputEvent; import java.beans.PropertyChangeListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.Set; import java.util.Set;
@ -213,6 +210,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
protected void initComponents() { protected void initComponents() {
this.setLayout(new RGridLayout()); this.setLayout(new RGridLayout());
//todo 直接修改分辨率
this.resolution = ScreenResolution.getScreenResolution(); this.resolution = ScreenResolution.getScreenResolution();
this.initGridComponent(); this.initGridComponent();
@ -1049,7 +1047,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
ElementCase elementCase = this.getEditingElementCase(); ElementCase elementCase = this.getEditingElementCase();
boolean cancel = false; 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(); ReportPageAttrProvider reportPageAttr = elementCase.getReportPageAttr();
ElementCase report = this.getEditingElementCase(); ElementCase report = this.getEditingElementCase();
if (reportPageAttr != null) { if (reportPageAttr != null) {
@ -1142,7 +1140,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
HeadColumnAction headcolumnAction = new HeadColumnAction(this); HeadColumnAction headcolumnAction = new HeadColumnAction(this);
FootColumnAction footcolumnAction = new FootColumnAction(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(); ElementCase elementCase = this.getEditingElementCase();
boolean cancel = false; boolean cancel = false;
ReportPageAttrProvider reportPageAttr = elementCase.getReportPageAttr(); ReportPageAttrProvider reportPageAttr = elementCase.getReportPageAttr();

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

@ -1,9 +1,9 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.parameter.ParameterUI;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.AllowAuthorityEditAction;
@ -51,16 +51,17 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.ModuleContext; import com.fr.general.ModuleContext;
import com.fr.general.web.ParameterConsts; 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.io.exporter.EmbeddedTableDataExporter;
import com.fr.main.TemplateWorkBook; import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.main.parameter.ReportParameterAttr; import com.fr.main.parameter.ReportParameterAttr;
import com.fr.poly.PolyDesigner; import com.fr.poly.PolyDesigner;
import com.fr.privilege.finegrain.WorkSheetPrivilegeControl; 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.elementcase.TemplateElementCase;
import com.fr.report.poly.PolyWorkSheet;
import com.fr.report.report.Report;
import com.fr.report.worksheet.WorkSheet; import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -86,6 +87,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
private UIModeControlContainer centerPane; private UIModeControlContainer centerPane;
private ReportComponentComposite reportComposite; private ReportComponentComposite reportComposite;
private ParameterDefinitePane parameterPane; private ParameterDefinitePane parameterPane;
private int resolution;
public JWorkBook() { public JWorkBook() {
super(new WorkBook(new WorkSheet()), "WorkBook"); 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(); 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() { public int getToolBarHeight() {
return TOOLBARPANEDIMHEIGHT; return TOOLBARPANEDIMHEIGHT;
} }

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

@ -36,11 +36,12 @@ public class ReportComponentComposite extends JComponent {
private JPanel hbarContainer; private JPanel hbarContainer;
private JPanel jSliderContainer;
/** /**
* Constructor with workbook.. * Constructor with workbook..
* *
* @param workBook the current workbook.
*/ */
public ReportComponentComposite(JWorkBook jwb) { public ReportComponentComposite(JWorkBook jwb) {
this.parent = jwb; this.parent = jwb;
@ -153,13 +154,30 @@ public class ReportComponentComposite extends JComponent {
} }
private JComponent createSouthControlPane() { private JComponent createSouthControlPane() {
// hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
// hbarContainer.add(createSouthControlPaneWithJSliderPane());
hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar()); 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.setBorder(null);
splitpane.setDividerSize(3); splitpane.setDividerSize(3);
splitpane.setResizeWeight(0.6); splitpane.setResizeWeight(1);
return splitpane; 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) { 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; private int resolution;
// 判断SmartJTablePane是否显示,做为动态虚线标识符 // 判断SmartJTablePane是否显示,做为动态虚线标识符
private boolean notShowingTableSelectPane = true; private boolean notShowingTableSelectPane = true;
private GridMouseAdapter gridMouseAdapter;
public Grid(int resolution) { public Grid(int resolution) {
this.resolution = 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); enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
GridKeyAction.initGridInputActionMap(this); GridKeyAction.initGridInputActionMap(this);
GridMouseAdapter gridMouseAdapter = new GridMouseAdapter(this); gridMouseAdapter = new GridMouseAdapter(this);
this.addMouseListener(gridMouseAdapter); this.addMouseListener(gridMouseAdapter);
this.addMouseMotionListener(gridMouseAdapter); this.addMouseMotionListener(gridMouseAdapter);
@ -136,6 +137,10 @@ public class Grid extends BaseGridComponent {
this.updateUI(); this.updateUI();
} }
public void setResolution(int resolution) {
this.resolution = resolution;
}
/** /**
* 应用界面设置 * 应用界面设置
* *
@ -149,6 +154,7 @@ public class Grid extends BaseGridComponent {
setUI(localComponentUI); setUI(localComponentUI);
} }
/** /**
* 是否显示格子线 * 是否显示格子线
* *
@ -173,6 +179,10 @@ public class Grid extends BaseGridComponent {
this.getElementCasePane().repaint(); this.getElementCasePane().repaint();
} }
public GridMouseAdapter getGridMouseAdapter(){
return this.gridMouseAdapter;
}
/** /**
* Gets grid line color. * 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 java.awt.Dimension;
import com.fr.base.GraphHelper; 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.design.mainframe.ElementCasePane;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import javax.swing.plaf.ComponentUI;
/** /**
* GridColumn used to paint and edit grid column. * GridColumn used to paint and edit grid column.
* *
@ -17,6 +22,8 @@ import com.fr.stable.StableUtils;
*/ */
public class GridColumn extends GridHeader<String> { public class GridColumn extends GridHeader<String> {
private int resolution = ScreenResolution.getScreenResolution();
@Override @Override
protected void initByConstructor() { protected void initByConstructor() {
GridColumnMouseHandler gridColumnMouseHandler = new GridColumnMouseHandler(this); GridColumnMouseHandler gridColumnMouseHandler = new GridColumnMouseHandler(this);
@ -32,7 +39,11 @@ public class GridColumn extends GridHeader<String> {
@Override @Override
public void updateUI() { 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.cache.list.IntList;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.ElementCasePane; 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.design.roleAuthority.ReportAndFSManagePane;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.privilege.finegrain.ColumnRowPrivilegeControl; import com.fr.privilege.finegrain.ColumnRowPrivilegeControl;
@ -29,7 +31,14 @@ import com.fr.report.elementcase.ElementCase;
public class GridColumnUI extends ComponentUI { public class GridColumnUI extends ComponentUI {
protected Color withoutDetailsBackground = Color.lightGray; 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 @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {

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

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

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

@ -429,6 +429,7 @@ public class GridUI extends ComponentUI {
this.calculateForcedPagingOfCellElement(reportPane, tmpCellElement, hideWidth, hideHeight); this.calculateForcedPagingOfCellElement(reportPane, tmpCellElement, hideWidth, hideHeight);
storeFatherLocation(selectedCellElement, tmpCellElement); storeFatherLocation(selectedCellElement, tmpCellElement);
// element bounds // element bounds
// TODO: 2017/7/13 tmpRectangle : 72*19
this.caculateScrollVisibleBounds(this.tmpRectangle, tmpCellElement.getColumn(), this.caculateScrollVisibleBounds(this.tmpRectangle, tmpCellElement.getColumn(),
tmpCellElement.getRow(), tmpCellElement.getColumnSpan(), tmpCellElement.getRow(), tmpCellElement.getColumnSpan(),
tmpCellElement.getRowSpan()); tmpCellElement.getRowSpan());
@ -455,8 +456,9 @@ public class GridUI extends ComponentUI {
paintCellElementList.add(tmpCellElement); paintCellElementList.add(tmpCellElement);
paintCellElementRectangleList.add(this.tmpRectangle.clone()); 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), 不包括边框 // denny_Grid: 画Grid中单元格的内容(包括单元格的背景Content + Background), 不包括边框
painter.paintBackground(g2d, report, tmpCellElement, cellWidth, cellHeight); painter.paintBackground(g2d, report, tmpCellElement, cellWidth, cellHeight);
@ -1077,6 +1079,7 @@ public class GridUI extends ComponentUI {
grid.ajustEditorComponentBounds(); // refresh size grid.ajustEditorComponentBounds(); // refresh size
} }
private void dealWithSizeBeforePaint(Grid grid, TemplateElementCase elementCase) { private void dealWithSizeBeforePaint(Grid grid, TemplateElementCase elementCase) {
// 取出所有的行高和列宽的List // 取出所有的行高和列宽的List
this.rowHeightList = ReportHelper.getRowHeightList(elementCase); 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.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.mainframe.ElementCasePane; 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.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
@ -48,6 +50,7 @@ public class GridUtils {
//peter:下面这几个量是在Drag列的时候用. //peter:下面这几个量是在Drag列的时候用.
public final static int DRAG_CELL_SIZE = 1; //peter:drag的时候改变格子的宽度. public final static int DRAG_CELL_SIZE = 1; //peter:drag的时候改变格子的宽度.
public final static int DRAG_SELECT_UNITS = 2; //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> * Is above float element.(the return may be null). <br>
@ -67,7 +70,8 @@ public class GridUtils {
double[] floatArray = caculateFloatElementLocations(tmpFloatElement, ReportHelper.getColumnWidthList(report), double[] floatArray = caculateFloatElementLocations(tmpFloatElement, ReportHelper.getColumnWidthList(report),
ReportHelper.getRowHeightList(report), reportPane.getGrid().getVerticalValue(), reportPane.getGrid().getHorizontalValue()); 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:悬浮元素的范围. //peter:悬浮元素的范围.
Rectangle2D floatElementRect = new Rectangle2D.Double(floatArray[0], floatArray[1], tmpFloatElement.getWidth().toPixD(resolution), tmpFloatElement.getHeight().toPixD(resolution)); Rectangle2D floatElementRect = new Rectangle2D.Double(floatArray[0], floatArray[1], tmpFloatElement.getWidth().toPixD(resolution), tmpFloatElement.getHeight().toPixD(resolution));
//peter:不是当前选中的悬浮元素,不支持六个改变大小的点. //peter:不是当前选中的悬浮元素,不支持六个改变大小的点.
@ -123,8 +127,8 @@ public class GridUtils {
*/ */
public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList, public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList,
int verticalValue, int horizentalValue) { 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 floatX = columnWidthList.getRangeValue(horizentalValue, 0).toPixD(resolution) + floatElement.getLeftDistance().toPixD(resolution);
double floatY = rowHeightList.getRangeValue(verticalValue, 0).toPixD(resolution) + floatElement.getTopDistance().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) { private static int cc_selected_column_or_row(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList) {
double tmpIntIndex = 0; double tmpIntIndex = 0;
int selectedCellIndex = 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) { if (mouseEvtPosition < 0) {
selectedCellIndex = value; selectedCellIndex = value;
for (; true; selectedCellIndex--) { for (; true; selectedCellIndex--) {
@ -222,6 +285,16 @@ public class GridUtils {
return ColumnRow.valueOf(col, row); 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); basePane.add(centerPane, BorderLayout.CENTER);
laoyoutWestPane(); 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.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST);
basePane.setBounds(0, 0, contentWidth, contentHeight); basePane.setBounds(0, 0, contentWidth, contentHeight);

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

@ -1,23 +1,32 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; 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.file.MutilTempalteTabPane;
import com.fr.design.fun.GridUIProcessor;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.islider.UISlider; import com.fr.design.gui.islider.UISlider;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.grid.DefaultGridUIProcessor;
import com.fr.grid.Grid;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSliderUI; import javax.swing.plaf.basic.BasicSliderUI;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.util.Observable;
/** /**
* Created by MoMeak on 2017/7/13. * Created by MoMeak on 2017/7/13.
@ -25,6 +34,8 @@ import java.awt.event.ActionListener;
public class JSliderPane extends JPanel { public class JSliderPane extends JPanel {
private final int KERNING = 2; private final int KERNING = 2;
public int showValue = 100;
public double resolutionTimes = 1.0;
private static JSliderPane THIS; private static JSliderPane THIS;
private UITextField showVal; private UITextField showVal;
private UISlider slider; private UISlider slider;
@ -32,11 +43,11 @@ public class JSliderPane extends JPanel {
private int sliderValue; private int sliderValue;
private UIButton downButton; private UIButton downButton;
private UIButton upButton; private UIButton upButton;
private int showValue;
//拖动条处理和button、直接输入不一样 //拖动条处理和button、直接输入不一样
private boolean isButtonOrIsTxt = true; private boolean isButtonOrIsTxt = true;
public JSliderPane() { public JSliderPane() {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
slider = new UISlider(0,100,50); slider = new UISlider(0,100,50);
@ -45,7 +56,7 @@ public class JSliderPane extends JPanel {
showVal = new UITextField(); showVal = new UITextField();
showVal.setText("100%"); showVal.setText("100%");
showVal.setPreferredSize(new Dimension(40,18));
showVal.getDocument().addDocumentListener(showValDocumentListener); showVal.getDocument().addDocumentListener(showValDocumentListener);
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveDown.png")); 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); downButton.addActionListener(buttonActionListener);
upButton.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)); JPanel panel = new JPanel(new FlowLayout(1,1,0));
panel.add(downButton); panel.add(downButton);
@ -85,9 +87,10 @@ public class JSliderPane extends JPanel {
} }
public static final JSliderPane getInstance() { public static final JSliderPane getInstance() {
if (THIS == null) { // if (THIS == null) {
// THIS = new JSliderPane();
// }
THIS = new JSliderPane(); THIS = new JSliderPane();
}
return THIS; return THIS;
} }
@ -118,6 +121,7 @@ public class JSliderPane extends JPanel {
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
isButtonOrIsTxt = true; isButtonOrIsTxt = true;
refreshSlider(); refreshSlider();
refreshBody();
} }
@Override @Override
@ -142,6 +146,27 @@ public class JSliderPane extends JPanel {
} }
} }
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() { ActionListener buttonActionListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -178,6 +203,10 @@ public class JSliderPane extends JPanel {
} }
public UITextField getShowVal(){
return this.showVal;
}
public static void main(String[] args) public static void main(String[] args)
{ {
JFrame jf = new JFrame("test"); 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 removeParameterPaneSelection();
public abstract void setScale(int resolution);
public abstract int getScale();
protected abstract DesignModelAdapter<T, ?> createDesignModel(); protected abstract DesignModelAdapter<T, ?> createDesignModel();
/** /**

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

Loading…
Cancel
Save