Browse Source

Merge remote-tracking branch 'mm/9.0' into 9.0

master
plough 7 years ago
parent
commit
e99d6ff940
  1. 6
      designer/src/com/fr/design/cell/bar/DynamicScrollBar.java
  2. 14
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  3. 101
      designer/src/com/fr/design/mainframe/JWorkBook.java
  4. 4
      designer/src/com/fr/design/mainframe/ReportComponent.java
  5. 2
      designer/src/com/fr/design/mainframe/ReportComponentCardPane.java
  6. 26
      designer/src/com/fr/design/mainframe/ReportComponentComposite.java
  7. 54
      designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java
  8. 11
      designer/src/com/fr/design/present/BarCodePane.java
  9. 35
      designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java
  10. 4
      designer/src/com/fr/grid/Grid.java
  11. 20
      designer/src/com/fr/grid/GridColumn.java
  12. 9
      designer/src/com/fr/grid/GridColumnMouseHandler.java
  13. 12
      designer/src/com/fr/grid/GridHeader.java
  14. 14
      designer/src/com/fr/grid/GridRow.java
  15. 18
      designer/src/com/fr/poly/PolyArea.java
  16. 87
      designer/src/com/fr/poly/PolyDesignUI.java
  17. 62
      designer/src/com/fr/poly/PolyDesigner.java
  18. 4
      designer/src/com/fr/poly/creator/BlockCreator.java
  19. 2
      designer/src/com/fr/poly/creator/BlockEditor.java
  20. 14
      designer/src/com/fr/poly/creator/ChartBlockCreator.java
  21. 13
      designer/src/com/fr/poly/creator/ChartBlockEditor.java
  22. 5
      designer/src/com/fr/poly/creator/ECBlockEditor.java
  23. 229
      designer_base/src/com/fr/design/mainframe/JSliderPane.java
  24. 15
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  25. 13
      designer_chart/src/com/fr/design/chart/gui/ChartComponent.java
  26. 61
      designer_form/src/com/fr/design/mainframe/FormArea.java
  27. 11
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  28. 26
      designer_form/src/com/fr/design/mainframe/FormDesignerUI.java
  29. 62
      designer_form/src/com/fr/design/mainframe/JForm.java

6
designer/src/com/fr/design/cell/bar/DynamicScrollBar.java

@ -59,6 +59,10 @@ public class DynamicScrollBar extends JScrollBar {
});
}
public void setDpi(int dpi){
this.dpi = dpi;
}
public ElementCasePane getReportPane() {
return reportPane;
}
@ -112,6 +116,8 @@ public class DynamicScrollBar extends JScrollBar {
}
}
private abstract class DynamicScrollBarHelper extends BarHelper {
protected abstract DynamicUnitList getSizeList();

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

@ -12,8 +12,6 @@ import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Constructor;
import java.util.Set;
@ -211,7 +209,9 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
this.setLayout(new RGridLayout());
//todo 直接修改分辨率
this.resolution = ScreenResolution.getScreenResolution();
if (this.resolution == 0){
this.resolution = ScreenResolution.getScreenResolution();
}
this.initGridComponent();
@ -346,6 +346,14 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
}
public void setResolution(int resolution){
this.resolution = resolution;
}
public int getResolution(){
return this.resolution;
}
/**
* 所有的操作都必须在可见范围内否则不做任何操作
*

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

@ -1,9 +1,6 @@
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.*;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction;
@ -14,6 +11,7 @@ import com.fr.design.actions.report.ReportExportAttrAction;
import com.fr.design.actions.report.ReportMobileAttrAction;
import com.fr.design.actions.report.ReportParameterAction;
import com.fr.design.actions.report.ReportWebAttrAction;
import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.TargetComponent;
@ -59,6 +57,7 @@ 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.poly.creator.BlockCreator;
import com.fr.privilege.finegrain.WorkSheetPrivilegeControl;
import com.fr.report.ReportHelper;
import com.fr.report.elementcase.ElementCase;
@ -71,6 +70,7 @@ import com.fr.stable.module.Module;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import javax.swing.Icon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileOutputStream;
@ -149,6 +149,16 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
return processInfo;
}
@Override
public void setJTemplateResolution(int resolution) {
this.resolution = resolution;
}
@Override
public int getJTemplateResolution() {
return this.resolution;
}
/**
* 判断sheet权限
*
@ -335,20 +345,75 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
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();
if (reportComposite.centerCardPane.editingComponet.elementCasePane != null){
reportComposite.centerCardPane.editingComponet.elementCasePane.setResolution(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
((DynamicScrollBar)reportComposite.centerCardPane.editingComponet.elementCasePane.getVerticalScrollBar()).setDpi(resolution);
((DynamicScrollBar)reportComposite.centerCardPane.editingComponet.elementCasePane.getHorizontalScrollBar()).setDpi(resolution);
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();
}
if (reportComposite.centerCardPane.polyDezi != null){
reportComposite.centerCardPane.polyDezi.setResolution(resolution);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setJTemplateResolution(resolution);
reportComposite.centerCardPane.polyDezi.updateUI();
}
// reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setVerticalValue(10);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
@Override
public int selfAdaptUpdate(){
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
if (reportComposite.centerCardPane.polyDezi.getSelection() !=null){
BlockCreator blockCreator =reportComposite.centerCardPane.polyDezi.getSelection();
double x = blockCreator.getEditorBounds().getX();
double y = blockCreator.getEditorBounds().getY();
reportComposite.centerCardPane.polyDezi.setHorizontalValue((int) x);
reportComposite.centerCardPane.polyDezi.setVerticalValue((int) y);
double creatorHeight = blockCreator.getEditorBounds().height;
double creatorWidth = blockCreator.getEditorBounds().width;
double areaHeight = reportComposite.centerCardPane.polyDezi.polyArea.getHeight();
double areaWidth = reportComposite.centerCardPane.polyDezi.polyArea.getWidth();
if (creatorWidth == 0||creatorHeight == 0){
return resolution;
}
double time =(areaHeight/creatorHeight)<(areaWidth/creatorWidth) ? (areaHeight/creatorHeight) : (areaWidth/creatorWidth);
return (int) (time * reportComposite.centerCardPane.polyDezi.getResolution());
}else if (reportComposite.centerCardPane.editingComponet.elementCasePane != null) {
ElementCasePane reportPane = reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getElementCasePane();
int column = reportPane.getSelection().getSelectedColumns()[0];
double columnLength = reportPane.getSelection().getSelectedColumns().length;
double columnExtent = reportPane.getGrid().getHorizontalExtent();
int row = reportPane.getSelection().getSelectedRows()[0];
double rowLength = reportPane.getSelection().getSelectedRows().length;
double rowExtent = reportPane.getGrid().getVerticalExtent();
if (columnLength == 0||rowLength == 0){
return resolution;
}
double time =(columnExtent/columnLength)<(rowExtent/rowLength) ? (columnExtent/columnLength) : (rowExtent/rowLength);
if (reportPane.isHorizontalScrollBarVisible()) {
reportPane.getVerticalScrollBar().setValue(row);
reportPane.getHorizontalScrollBar().setValue(column);
}
return (int) (time * reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getResolution());
}else {
return resolution;
}
}
@Override

4
designer/src/com/fr/design/mainframe/ReportComponent.java

@ -27,9 +27,13 @@ import com.fr.design.selection.Selectedable;
*/
public abstract class ReportComponent<T extends TemplateReport, E extends ElementCasePane, S extends SelectableElement> extends TargetComponent<T> implements Selectedable<S> {
protected E elementCasePane;
// protected P polyElementCasePane;
public E getEditingElementCasePane() {
return elementCasePane;
}
// public P getEditingPolyElementCasePane() {
// return polyElementCasePane;
// }
public ReportComponent(T t) {
super(t);
}

2
designer/src/com/fr/design/mainframe/ReportComponentCardPane.java

@ -25,7 +25,7 @@ public class ReportComponentCardPane extends JComponent implements TargetModifie
private CardLayout cl;
private WorkSheetDesigner sheetDezi;
private PolyDesigner polyDezi;
protected PolyDesigner polyDezi;
public ReportComponentCardPane() {
this.setLayout(cl = new CardLayout());

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

@ -1,11 +1,15 @@
package com.fr.design.mainframe;
import java.awt.BorderLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@ -15,6 +19,7 @@ import com.fr.design.designer.EditingState;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.icontainer.UIModeControlContainer;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import com.fr.grid.Grid;
@ -60,25 +65,28 @@ public class ReportComponentComposite extends JComponent {
CellElementRegion = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(CellElementRegion, BorderLayout.NORTH);
this.add(createSouthControlPane(), BorderLayout.SOUTH);
jSliderContainer.getShowVal().getDocument().addDocumentListener(jSliderContainerListener);
jSliderContainer.getShowVal().addChangeListener(showValSpinnerChangeListener);
jSliderContainer.getSelfAdaptButton().addItemListener(selfAdaptButtonItemListener);
}
DocumentListener jSliderContainerListener = new DocumentListener() {
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void insertUpdate(DocumentEvent e) {
double value = Integer.parseInt(jSliderContainer.getShowVal().getText().substring(0, jSliderContainer.getShowVal().getText().indexOf("%")));
public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner)e.getSource()).getValue();
value = value>MAX ? MAX : value;
value = value<MIN ? MIN : value;
int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution);
}
};
ItemListener selfAdaptButtonItemListener = new ItemListener() {
@Override
public void removeUpdate(DocumentEvent e) {
}
@Override
public void changedUpdate(DocumentEvent e) {
public void itemStateChanged(ItemEvent e) {
if (jSliderContainer.getSelfAdaptButton().isSelected()){
int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate();
jSliderContainer.getShowVal().setValue(resolution*HUND/ScreenResolution.getScreenResolution());
}
}
};

54
designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java

@ -1,29 +1,41 @@
package com.fr.design.mainframe.form;
import com.fr.base.ScreenResolution;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.form.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider;
import com.fr.report.worksheet.FormElementCase;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* 整个FormElementCase编辑区域 包括滚动条中间的grid或者聚合块下面的sheetTab
*/
public class FormReportComponentComposite extends JComponent implements TargetModifiedListener, FormECCompositeProvider{
private FormElementCaseDesigner elementCaseDesigner;
private static final int MAX = 400;
private static final int HUND = 100;
private static final int MIN = 10;
public FormElementCaseDesigner elementCaseDesigner;
private BaseJForm jForm;
private FormTabPane sheetNameTab;
private JPanel hbarContainer;
private JSliderPane jSliderContainer;
public FormReportComponentComposite(BaseJForm jform, FormElementCaseDesigner elementCaseDesign, FormElementCaseContainerProvider ecContainer) {
@ -33,10 +45,33 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
this.add(elementCaseDesigner, BorderLayout.CENTER);
sheetNameTab = new FormTabPane(ecContainer, jform);
this.add(createSouthControlPane(), BorderLayout.SOUTH);
jSliderContainer.getShowVal().addChangeListener(showValSpinnerChangeListener);
jSliderContainer.getSelfAdaptButton().addItemListener(selfAdaptButtonItemListener);
elementCaseDesigner.addTargetModifiedListener(this);
}
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner)e.getSource()).getValue();
value = value>MAX ? MAX : value;
value = value<MIN ? MIN : value;
int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND);
JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution);
}
};
ItemListener selfAdaptButtonItemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (jSliderContainer.getSelfAdaptButton().isSelected()){
int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate();
jSliderContainer.getShowVal().setValue(resolution*HUND/ScreenResolution.getScreenResolution());
}
}
};
private java.util.List<TargetModifiedListener> targetModifiedList = new java.util.ArrayList<TargetModifiedListener>();
/**
@ -62,13 +97,18 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
}
private JComponent createSouthControlPane() {
JPanel southPane = new JPanel(new BorderLayout());
hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
hbarContainer.add(elementCaseDesigner.getHorizontalScrollBar());
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, hbarContainer);
jSliderContainer = JSliderPane.getInstance();
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, jSliderContainer);
southPane.add(hbarContainer,BorderLayout.NORTH);
southPane.add(splitpane,BorderLayout.CENTER);
splitpane.setBorder(null);
splitpane.setDividerSize(3);
splitpane.setResizeWeight(0.6);
return splitpane;
splitpane.setResizeWeight(1);
return southPane;
}
/**

11
designer/src/com/fr/design/present/BarCodePane.java

@ -69,6 +69,17 @@ public class BarCodePane extends FurtherBasicBeanPane<BarcodePresent> {
addlistener();
}
public static void main(String[] args){
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel)jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new BarCodePane(),BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(270, 400);
jf.setVisible(true);
}
private void initComponents() {
barCodePreviewPane = new BarCodePreviewPane();
this.barWidthSpinner = new UIBasicSpinner(new SpinnerNumberModel(1, 1, 100, 0.1));

35
designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java

@ -41,7 +41,6 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
protected static final int SEPARATOR_GAP = 5;
private GridHeader gHeader;
private int dragType = GridUtils.DRAG_NONE;
//james 是否为选定多行的drag
private boolean isMultiSelectDragPermited = false;
@ -53,10 +52,16 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
private int dragIndex = 0;
private JToolTip tip = null;
private JWindow tipWindow = null;
protected int resolution = ScreenResolution.getScreenResolution();
public AbstractGridHeaderMouseHandler(GridHeader gHeader) {
this.gHeader = gHeader;
}
if (gHeader instanceof GridColumn){
this.resolution = ((GridColumn)gHeader).getResolution();
}else {
this.resolution = ((GridRow)gHeader).getResolution();
}
}
public void setStartMultiSelectIndex(int index) {
this.startMultiSelectIndex = index;
@ -98,7 +103,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
@Override
public boolean run(MouseEvent evt, int index, double tmpSize1, double tmpSize2, int tmpIncreaseSize, int oldEndValueSize, ElementCase report, DynamicUnitList sizeList) {
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
// richer:这边这么做的原因是调整了行高列宽后需要通知聚合块改变边界
Method method = null;
try {
@ -142,7 +147,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
private ScrollAction PRESS_ACTION = new ScrollAction() {
@Override
public boolean run(MouseEvent evt, int index, double tmpSize1, double tmpSize2, int tmpIncreaseSize, int oldEndValueSize, ElementCase report, DynamicUnitList sizeList) {
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) {
dragType = GridUtils.DRAG_CELL_SIZE;
@ -177,7 +182,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
double tmpIncreaseSize = 0;
double oldEndValueSize = 0;
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
for (int index = beginValue; index < endValue; index++) { // denny:
// beginValue
@ -215,7 +220,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
ePane.getGrid().stopEditing();// james 停止当前的所有编辑
// peter:选中格子位置.
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(ePane, evt.getX(), evt.getY());
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(ePane, evt.getX(), evt.getY(),resolution);
iterateScrollBar(ePane, evt, PRESS_ACTION);
@ -255,7 +260,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
* @param evtY
*/
private void doShiftSelectHeader(ElementCasePane ePane, double evtX, double evtY) {
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(ePane, evtX, evtY);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(ePane, evtX, evtY, resolution);
int selectedCellPointX = selectedCellPoint.getColumn();// column.
int selectedCellPointY = selectedCellPoint.getRow();// row.
CellSelection cs = ((CellSelection) ePane.getSelection()).clone();
@ -294,7 +299,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
private String createToolTipString(double doubleValue, double totalDoubleValue) {
int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit();
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
FU ulen = FU.valueOfPix((int) doubleValue, resolution);
FU tulen = FU.valueOfPix((int) totalDoubleValue, resolution);
String unit;
@ -317,11 +322,11 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
unit = Inter.getLocText("Unit_MM");
}
StringBuilder sb = new StringBuilder();
sb.append(Utils.convertNumberStringToString(new Float(len)))
.append('/').append(Utils.convertNumberStringToString(new Float(tlen)))
sb.append(String.format("%.2f", new Double(len)))
.append('/').append(String.format("%.2f", new Double(tlen)))
.append(unit).append('(')
.append(Utils.doubleToString(doubleValue)).append('/')
.append(Utils.doubleToString(totalDoubleValue))
.append((int)(doubleValue)).append('/')
.append((int)(totalDoubleValue))
.append(Inter.getLocText("px"))
.append(')');
return sb.toString();
@ -401,7 +406,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
if (!this.isMultiSelectDragPermited) {
return;
}
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(ePane, evt.getX(), evt.getY());
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(ePane, evt.getX(), evt.getY(), resolution);
endMultiSelectIndex = getColumnOrRowByGridHeader(selectedCellPoint);
resetGridSelectionByDrag(cs, ePane, startMultiSelectIndex, endMultiSelectIndex);
cs.setSelectedType(doChooseFrom());
@ -421,7 +426,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
iterateScrollBar(ePane, evt, DRAG_ACTION);
DynamicUnitList sizeList = getSizeList(report);
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
this.setToolTipText2(this.createToolTipString(sizeList.get(dragIndex).toPixD(resolution), sizeList.getRangeValue(0, dragIndex + 1).toPixD(resolution)));
}
@ -472,7 +477,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
double tmpSize1 = 0;
double tmpSize2;
double tmpIncreaseSize = 0;
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
for (int i = beginValue; i < endValue; i++) {
if (i == 0) {

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

@ -141,6 +141,10 @@ public class Grid extends BaseGridComponent {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
/**
* 应用界面设置
*

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

@ -10,6 +10,7 @@ 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.JSliderPane;
import com.fr.stable.StableUtils;
import javax.swing.plaf.ComponentUI;
@ -22,11 +23,15 @@ import javax.swing.plaf.ComponentUI;
*/
public class GridColumn extends GridHeader<String> {
private int resolution = ScreenResolution.getScreenResolution();
public int resolution = ScreenResolution.getScreenResolution();
private GridColumnMouseHandler gridColumnMouseHandler;
@Override
protected void initByConstructor() {
GridColumnMouseHandler gridColumnMouseHandler = new GridColumnMouseHandler(this);
resolution = ScreenResolution.getScreenResolution();
this.setResolution(resolution);
gridColumnMouseHandler = new GridColumnMouseHandler(this);
this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler);
this.updateUI();
@ -39,6 +44,12 @@ public class GridColumn extends GridHeader<String> {
@Override
public void updateUI() {
this.removeMouseListener(gridColumnMouseHandler);
this.removeMouseMotionListener(gridColumnMouseHandler);
gridColumnMouseHandler = new GridColumnMouseHandler(this);
this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler);
// gridColumnMouseHandler.setResolution(resolution);
this.setUI(new GridColumnUI(resolution));
}
@ -46,6 +57,11 @@ public class GridColumn extends GridHeader<String> {
this.resolution = resolution;
}
@Override
public int getResolution() {
return this.resolution;
}
/**
* Gets the preferred size.
*/

9
designer/src/com/fr/grid/GridColumnMouseHandler.java

@ -9,6 +9,7 @@ import java.awt.event.MouseEvent;
import javax.swing.SwingUtilities;
import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.selection.CellSelection;
@ -22,8 +23,15 @@ import com.fr.stable.ColumnRow;
*/
public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler {
private int resolution;
public GridColumnMouseHandler(GridColumn gridColumn) {
super(gridColumn);
this.resolution = gridColumn.resolution;
}
public void setResolution(int resolution){
this.resolution = resolution;
}
@Override
@ -86,7 +94,6 @@ public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler {
/**
* Checks whether is on zero separator line.
*
* @param evtX event x
*/
@Override
protected boolean isOnSeparatorLineIncludeZero(MouseEvent evt, double tmpWidth2, double tmpIncreaseWidth) {

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

@ -1,5 +1,7 @@
package com.fr.grid;
import com.fr.base.ScreenResolution;
import java.awt.Color;
@ -12,6 +14,8 @@ public abstract class GridHeader<T> extends BaseGridComponent {
private Color selectedForeground = Color.black;
private Color selectedBackground = new Color(253, 216, 153);
protected int resolution;
public GridHeader() {
//清除所有的Key Action.
this.getInputMap().clear();
@ -23,6 +27,14 @@ public abstract class GridHeader<T> extends BaseGridComponent {
initByConstructor();
}
public void setResolution(int resolution){
this.resolution = resolution;
}
public int getResolution(){
return this.resolution;
}
protected abstract void initByConstructor();
protected abstract T getDisplay(int index) ;

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

@ -23,10 +23,13 @@ public class GridRow extends GridHeader<Integer> {
private static final int MAX = 5;
private int resolution = ScreenResolution.getScreenResolution();
private GridRowMouseHandler gridRowMouseHandler;
@Override
protected void initByConstructor() {
GridRowMouseHandler gridRowMouseHandler = new GridRowMouseHandler(this);
resolution = ScreenResolution.getScreenResolution();
this.setResolution(resolution);
gridRowMouseHandler = new GridRowMouseHandler(this);
this.addMouseListener(gridRowMouseHandler);
this.addMouseMotionListener(gridRowMouseHandler);
this.updateUI();
@ -39,6 +42,11 @@ public class GridRow extends GridHeader<Integer> {
@Override
public void updateUI() {
this.removeMouseListener(gridRowMouseHandler);
this.removeMouseMotionListener(gridRowMouseHandler);
gridRowMouseHandler = new GridRowMouseHandler(this);
this.addMouseListener(gridRowMouseHandler);
this.addMouseMotionListener(gridRowMouseHandler);
this.setUI(new GridRowUI(resolution));
}
@ -46,6 +54,10 @@ public class GridRow extends GridHeader<Integer> {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
/**
* Gets the preferred size.

18
designer/src/com/fr/poly/PolyArea.java

@ -1,15 +1,29 @@
package com.fr.poly;
import javax.swing.JComponent;
public class PolyArea extends JComponent {
private PolyDesigner polyDesigner;
private int resolution;
public PolyArea(PolyDesigner polyDesigner) {
public PolyArea(PolyDesigner polyDesigner, int resolution) {
this.polyDesigner = polyDesigner;
setUI(new PolyDesignUI());
this.resolution = resolution;
this.setUI(new PolyDesignUI(resolution));
// setUI(new PolyDesignUI());
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
public PolyDesigner getPolyDesigner() {
return polyDesigner;
}

87
designer/src/com/fr/poly/PolyDesignUI.java

@ -10,6 +10,7 @@ import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.text.DecimalFormat;
import java.util.ArrayList;
@ -27,12 +28,14 @@ import com.fr.general.Inter;
import com.fr.page.PaperSettingProvider;
import com.fr.page.ReportSettingsProvider;
import com.fr.poly.creator.BlockCreator;
import com.fr.poly.creator.ECBlockCreator;
import com.fr.poly.model.AddedData;
import com.fr.poly.model.AddingData;
import com.fr.report.report.Report;
import com.fr.report.report.TemplateReport;
import com.fr.report.stable.ReportConstants;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.unit.UNIT;
/**
@ -44,13 +47,19 @@ public class PolyDesignUI extends ComponentUI {
private static final double SCROLL_POINT = 50;
private static final int SCROLL_DISTANCE = 15;
private static final int CREATORWIDTH = 30;
private static final int CREATORGEIGHT = 19;
private static final int TEN = 10;
private static final int HHUNDRED = 100;
private PolyDesigner designer;
private int resolution = ScreenResolution.getScreenResolution();
private int ten = 10;
private int hundred = 100;
private int resolution;
private float time;
public PolyDesignUI() {
public PolyDesignUI(int resolution) {
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
this.resolution = resolution;
}
/**
@ -83,6 +92,8 @@ public class PolyDesignUI extends ComponentUI {
@Override
public void paint(Graphics g, JComponent c) {
this.resolution = ((PolyArea)c).getResolution();
this.time = (float)resolution/ScreenResolution.getScreenResolution();
paintBackground(g, c);
Graphics2D g2d = (Graphics2D) g;
paintAddedData(g2d);
@ -100,20 +111,27 @@ public class PolyDesignUI extends ComponentUI {
BlockCreator creator = addedData.getAddedAt(i);
// richer:如果当前这个组件正在编辑,那么他是完全被他的编辑器所遮挡的,不需要画出来
if (creator == designer.getSelection()) {
paintPositionLine(g, creator.getX(), creator.getY(), designer.getHorizontalValue(), designer
.getVerticalValue());
if (creator.getEditor().isDragging()) {
creator.getEditor().paintAbsorptionline(g);
//如果与其他块重合了, 需要画出提示禁止重叠
changeForbiddenWindowVisibility(creator);
//到边缘地带自动滚动
scrollWhenCreatorAtCorner(creator);
}else{
creator.getEditor().hideForbiddenWindow();
}
if (creator instanceof ECBlockCreator){
int x = (int) ((creator.getX()-CREATORWIDTH)*time)+CREATORWIDTH;
int y = (int) ((creator.getY()-CREATORGEIGHT)*time)+CREATORGEIGHT;
paintPositionLine(g, x, y, (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time));
}else {
int x = (int) (creator.getX()*time);
int y = (int) (creator.getY()*time);
paintPositionLine(g, x, y, (int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time));
}
if (creator.getEditor().isDragging()) {
creator.getEditor().paintAbsorptionline(g);
//如果与其他块重合了, 需要画出提示禁止重叠
changeForbiddenWindowVisibility(creator);
//到边缘地带自动滚动
scrollWhenCreatorAtCorner(creator);
}else{
creator.getEditor().hideForbiddenWindow();
}
} else {
paintCreator(g, creator, creator.getX() - designer.getHorizontalValue(), creator.getY() - designer.getVerticalValue(),
creator.getWidth(), creator.getHeight());
paintCreator(g, creator, (int) (creator.getX()*time - designer.getHorizontalValue()*time), (int) (creator.getY()*time - designer.getVerticalValue()*time),
(int) (creator.getWidth()*time), (int) (creator.getHeight()*time));
}
}
}
@ -126,8 +144,8 @@ public class PolyDesignUI extends ComponentUI {
return;
}
int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX() - designer.getHorizontalValue());
int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY() - designer.getVerticalValue());
int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX()*time - designer.getHorizontalValue());
int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY()*time - designer.getVerticalValue());
creator.getEditor().showForbiddenWindow(x, y);
}
@ -183,16 +201,16 @@ public class PolyDesignUI extends ComponentUI {
private String convertUnit(int i) {
short unit = designer.getRulerLengthUnit();
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
if (unit == Constants.UNIT_MM) {
Double j = (i + 2) * 1.0 * Constants.HUNDRED_FU_PER_INCH / Constants.HUNDRED_FU_PER_MM / resolution;
return j.intValue() + Inter.getLocText("Unit_MM");
} else if (unit == Constants.UNIT_CM) {
Double j = (i + 2) * 1.0 * Constants.HUNDRED_FU_PER_INCH / Constants.HUNDRED_FU_PER_MM / resolution;
return new DecimalFormat("0.0").format(j.intValue() * 1.0 / ten) + Inter.getLocText("Unit_CM");
return new DecimalFormat("0.0").format(j.intValue() * 1.0 / TEN) + Inter.getLocText("Unit_CM");
} else if (unit == Constants.UNIT_INCH) {
Double j = i == 0 ? 0 : (i + 2) * 1.0 / resolution * hundred;
return new DecimalFormat("0.00").format(j.intValue() * 1.0 / hundred) + Inter.getLocText("Unit_INCH");
Double j = i == 0 ? 0 : (i + 2) * 1.0 / resolution * HHUNDRED;
return new DecimalFormat("0.00").format(j.intValue() * 1.0 / HHUNDRED) + Inter.getLocText("Unit_INCH");
} else if (unit == Constants.UNIT_PT) {
int j = i == 0 ? 0 : (i + 2) * UNIT.PT_PER_INCH / resolution;
return j + Inter.getLocText("Unit_PT");
@ -203,10 +221,10 @@ public class PolyDesignUI extends ComponentUI {
private void paintAddingData(Graphics g, AddingData addingData) {
BlockCreator comp = addingData.getCreator();
int x = addingData.getCurrentX();
int y = addingData.getCurrentY();
int width = comp.getWidth();
int height = comp.getHeight();
int x = (int) (addingData.getCurrentX()*time);
int y = (int) (addingData.getCurrentY()*time);
int width = (int) (comp.getWidth()*time);
int height = (int) (comp.getHeight()*time);
paintCreator(g, comp, x, y, width, height);
}
@ -214,9 +232,16 @@ public class PolyDesignUI extends ComponentUI {
ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>();
// richer:禁止双缓冲行为,否则会出现两个图像
ComponentUtils.disableBuffer(comp, dbcomponents);
Graphics clipg = g.create(x, y, width, height);
comp.paint(clipg);
clipg.dispose();
// Graphics clipg = g.create(x, y, width*resolution/ScreenResolution.getScreenResolution(), height*resolution/ScreenResolution.getScreenResolution());
//
BufferedImage img = CoreGraphHelper.createBufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = img.createGraphics();
comp.printAll(g2d);
g2d.dispose();
g.drawImage(img,x,y,width,height,null);
// comp.paint(clipg);
// clipg.dispose();
ComponentUtils.resetBuffer(dbcomponents);
}

62
designer/src/com/fr/poly/PolyDesigner.java

@ -3,14 +3,10 @@
*/
package com.fr.poly;
import java.awt.AWTEvent;
import java.awt.Adjustable;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
@ -36,16 +32,7 @@ import com.fr.design.designer.EditingState;
import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.AuthorityEditPane;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.ElementCasePaneAuthorityEditPane;
import com.fr.design.mainframe.FormScrollBar;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.ReportComponent;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.cell.QuickEditorRegion;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
@ -75,6 +62,7 @@ import com.fr.report.block.Block;
import com.fr.report.poly.PolyWorkSheet;
import com.fr.report.poly.TemplateBlock;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.StringUtils;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.OLDPIX;
@ -98,7 +86,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
public static enum SelectionType {
NONE, INNER, BLOCK
}
public JComponent polyArea;
private SelectionType selectedtype = SelectionType.NONE;
private AddingData addingData;
private AddedData addedData;
@ -108,16 +96,16 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
private int horizontalValue = 0;
private int verticalValue = 0;
private transient ArrayList<TemplateBlock> clip_board = new ArrayList<TemplateBlock>();
// richer:鼠标滚轮每滚动一下,PolyDesignPane的尺寸就改变ROTATIONS这么多
private static final int ROTATIONS = 50;
private JScrollBar verScrollBar;
private JScrollBar horScrollBar;
private JComponent polyArea;
private PolyComponetsBar polyComponetsBar = new PolyComponetsBar();
private JComponent[] toolBarComponent = null;
private int resolution = ScreenResolution.getScreenResolution();
private int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
private float time;
public PolyDesigner(PolyWorkSheet report) {
super(report);
@ -157,7 +145,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel ployareaPane = new JPanel(new PolyDesignerLayout());
polyArea = new PolyArea(this);
polyArea = new PolyArea(this, resolution);
ployareaPane.add(PolyDesignerLayout.Center, polyArea);
horScrollBar = new FormScrollBar(Adjustable.HORIZONTAL, this);
@ -181,6 +169,20 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
repaint();
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
public void updateUI(){
((PolyArea)this.polyArea).setResolution(resolution);
polyArea.repaint();
// this.polyArea = (JComponent) new PolyArea(this, resolution);
}
/**
* 是否含有聚和报表块
* @param targetComponent 目标组件
@ -250,13 +252,24 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
@Override
public void paintComponent(Graphics g) {
this.time = (float)resolution/ScreenResolution.getScreenResolution();
resetEditorComponentBounds();
LayoutUtils.layoutRootContainer(this);
g.setColor(Color.black);
GraphHelper.drawLine(g, 0, 0, this.getWidth(), 0);
GraphHelper.drawLine(g, 0, 0, 0, this.getHeight());
super.paintComponent(g);
}
private void resetEditorComponentBounds() {
if (selection != null) {
selection.setResolution(this.resolution);
selection.getEditor().setBounds((int) (selection.getEditorBounds().x*time), (int) (selection.getEditorBounds().y*time),
(int) (selection.getEditorBounds().width*time), (int) (selection.getEditorBounds().height*time));
LayoutUtils.layoutRootContainer(this);
}
}
/**
* 增加组件
* @param creator 组件
@ -368,12 +381,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
repaint();
}
private void resetEditorComponentBounds() {
if (selection != null) {
selection.getEditor().setBounds(selection.getEditorBounds());
LayoutUtils.layoutRootContainer(this);
}
}
/**
* @return

4
designer/src/com/fr/poly/creator/BlockCreator.java

@ -75,6 +75,10 @@ public abstract class BlockCreator<T extends TemplateBlock> extends JComponent i
LayoutUtils.layoutContainer(this);
}
public void setResolution(int resolution){
this.resolution = resolution;
}
//默认大小, 报表块默认3列6行, 图表块默认330*240
public abstract UnitRectangle getDefaultBlockBounds();

2
designer/src/com/fr/poly/creator/BlockEditor.java

@ -50,7 +50,7 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
public BlockEditor(PolyDesigner designer, BlockCreator<U> creator) {
this.designer = designer;
this.creator = creator;
this.resolution = creator.resolution;
this.initComponets();
this.addColumnRowListeners();

14
designer/src/com/fr/poly/creator/ChartBlockCreator.java

@ -3,13 +3,15 @@
*/
package com.fr.poly.creator;
import java.awt.Color;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.*;
import com.fr.base.ScreenResolution;
import com.fr.design.DesignState;
import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
@ -34,6 +36,7 @@ public class ChartBlockCreator extends BlockCreator<PolyChartBlock> {
private static final UNIT DEFAULT_WIDTH = FU.getInstance(12573000);
private static final UNIT DEFAULT_HEIGHT = FU.getInstance(9144000);
public ChartBlockCreator() {
}
@ -42,6 +45,10 @@ public class ChartBlockCreator extends BlockCreator<PolyChartBlock> {
super(block);
}
public void setResolution(int resolution){
this.resolution = resolution;
}
/**
* 初始化
* @return 初始化的控件.
@ -65,6 +72,7 @@ public class ChartBlockCreator extends BlockCreator<PolyChartBlock> {
}
/**
* 检测按钮状态
*

13
designer/src/com/fr/poly/creator/ChartBlockEditor.java

@ -5,6 +5,7 @@ package com.fr.poly.creator;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGetter;
@ -13,6 +14,7 @@ import com.fr.design.border.UIRoundedBorder;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.cell.QuickEditorRegion;
@ -25,6 +27,7 @@ import com.fr.poly.PolyDesigner.SelectionType;
import com.fr.poly.hanlder.ColumnOperationMouseHandler;
import com.fr.poly.hanlder.RowOperationMouseHandler;
import com.fr.report.poly.PolyChartBlock;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
@ -32,6 +35,7 @@ import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
/**
* @author richer
@ -43,6 +47,7 @@ public class ChartBlockEditor extends BlockEditor<MiddleChartComponent, PolyChar
private static Border buttonBorder;
private static String[][] chartsNames;
private static BaseChartNameID[] typeName = BaseChartGetter.getStaticAllChartBaseNames();
private int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
static {
buttonBorder = new UIRoundedBorder(new Color(149, 149, 149), 1, 5);
@ -60,8 +65,14 @@ public class ChartBlockEditor extends BlockEditor<MiddleChartComponent, PolyChar
public ChartBlockEditor(PolyDesigner designer, ChartBlockCreator creator) {
super(designer, creator);
this.resolution = creator.resolution;
//shine:和产品商量后决定把最上面一排切换按钮去掉
//this.initNorthBarComponent();
// this.initNorthBarComponent();
}
private void setResolution(int resolution){
this.resolution = resolution;
}
private void initNorthBarComponent() {

5
designer/src/com/fr/poly/creator/ECBlockEditor.java

@ -6,6 +6,7 @@ package com.fr.poly.creator;
import java.awt.Dimension;
import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
@ -70,6 +71,10 @@ public class ECBlockEditor extends BlockEditor<ECBlockPane, PolyECBlock> {
@Override
protected void initSize() {
resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
Dimension cornerSize = getCornerSize();
PolyECBlock block = getValue();
UnitRectangle ub = block.getBounds();

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

@ -1,11 +1,15 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.islider.UISlider;
import com.fr.design.gui.ispinner.UIBasicSpinner;
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.general.Inter;
@ -13,8 +17,6 @@ import javax.swing.*;
import javax.swing.border.MatteBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicSliderUI;
import java.awt.*;
import java.awt.event.*;
@ -29,6 +31,9 @@ public class JSliderPane extends JPanel {
private static final int SIX = 6;
private static final int TEN = 10;
private static final int ONEEIGHT = 18;
private static final int FONTSIZE = 14;
private static final int SPINNERWIDTH= 45;
private static final int SPINNERHEIGHT = 20;
private static final int TWOFIVE = 25;
private static final int FOURTEN = 40;
private static final int HALFHUNDRED = 50;
@ -37,11 +42,14 @@ public class JSliderPane extends JPanel {
private static final int THREEHUNDRED = 300;
private static final int FOURHUNDRED = 400;
private static final int DIALOGWIDTH = 150;
private static final int DIALOGHEIGHT = 200;
private static final int DIALOGHEIGHT = 240;
private static final int SHOWVALBUTTONWIDTH = 70;
private static final int SHOWVALBUTTONHEIGHTH = 25;
public int showValue = 100;
public double resolutionTimes = 1.0;
private static JSliderPane THIS;
private UITextField showVal;
private JSpinner showValSpinner;
private UISlider slider;
private int times;
private int sliderValue;
@ -59,6 +67,7 @@ public class JSliderPane extends JPanel {
private boolean isButtonOrIsTxt = true;
private PopupPane dialog;
private int upButtonX;
private JPanel dialogContentPanel;
public JSliderPane() {
@ -67,11 +76,18 @@ public class JSliderPane extends JPanel {
slider.setUI(new JSliderPaneUI(slider));
slider.addChangeListener(listener);
showVal = new UITextField();
showVal.setText("100%");
showVal.setPreferredSize(new Dimension(FOURTEN,ONEEIGHT));
showVal.getDocument().addDocumentListener(showValDocumentListener);
showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOURHUNDRED, 1));
showValSpinner.setEnabled(true);
showValSpinner.addChangeListener(showValSpinnerChangeListener);
showValSpinner.setPreferredSize(new Dimension(SPINNERWIDTH, SPINNERHEIGHT));
//MoMeak:控制只能输入10-400,但是用起来感觉不舒服,先注释掉吧
// JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0");
// showValSpinner.setEditor(editor);
// JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField();
// textField.setEditable(true);
// DefaultFormatterFactory factory = (DefaultFormatterFactory) textField .getFormatterFactory();
// NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter();
// formatter.setAllowsInvalid(false);
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveDown.png"));
upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveUp.png"));
downButton.setActionCommand("less");
@ -79,25 +95,20 @@ public class JSliderPane extends JPanel {
downButton.addActionListener(buttonActionListener);
upButton.addActionListener(buttonActionListener);
JPanel panel = new JPanel(new FlowLayout(1,1,0));
showValButton = new UIButton(showVal.getText());
showValButton = new UIButton(showValSpinner.getValue()+"%");
showValButton.setBorderPainted(false);
showValButton.setPreferredSize(new Dimension(HALFHUNDRED,TWOFIVE));
showValButton.setPreferredSize(new Dimension(SHOWVALBUTTONWIDTH,SHOWVALBUTTONHEIGHTH));
showValButton.addActionListener(showValButtonActionListener);
showValButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
popupDialog();
}
});
initUIRadioButton();
initPane();
JPanel panel = new JPanel(new FlowLayout(1,1,0));
panel.add(downButton);
panel.add(slider);
panel.add(upButton);
panel.add(showValButton);
this.add(panel,BorderLayout.NORTH);
this.setBounds(0,0,THREEHUNDRED,ONEEIGHT);
}
public static final JSliderPane getInstance() {
@ -116,6 +127,13 @@ public class JSliderPane extends JPanel {
twoFiveButton = new UIRadioButton("25%");
selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton"));
customButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_customButton"));
twoHundredButton.addItemListener(radioButtonItemListener);
oneHundredButton.addItemListener(radioButtonItemListener);
SevenFiveButton.addItemListener(radioButtonItemListener);
fiveTenButton.addItemListener(radioButtonItemListener);
twoFiveButton.addItemListener(radioButtonItemListener);
//TODO
// selfAdaptButton.addItemListener();
ButtonGroup bg=new ButtonGroup();// 初始化按钮组
bg.add(twoHundredButton);// 加入按钮组
@ -125,8 +143,53 @@ public class JSliderPane extends JPanel {
bg.add(twoFiveButton);
bg.add(selfAdaptButton);
bg.add(customButton);
customButton.setSelected(true);
}
private void initPane(){
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = { p, f };
double[] rowSize = { p,p,p,p,p,p,p};
Component[][] components = new Component[][]{
new Component[]{twoHundredButton,null},
new Component[]{oneHundredButton,null},
new Component[]{SevenFiveButton,null},
new Component[]{fiveTenButton,null},
new Component[]{twoFiveButton,null},
new Component[]{selfAdaptButton,null},
new Component[]{customButton,createSpinnerPanel()}
};
dialogContentPanel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
}
private JPanel createSpinnerPanel(){
JPanel spinnerPanel = new JPanel(new FlowLayout());
spinnerPanel.add(showValSpinner);
UILabel percent = new UILabel("%");
percent.setFont(new Font("Dialog", Font.PLAIN, FONTSIZE));
spinnerPanel.add(percent);
return spinnerPanel;
}
ActionListener showValButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
popupDialog();
}
};
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int val = (int) ((UIBasicSpinner)e.getSource()).getValue();
isButtonOrIsTxt = true;
resolutionTimes = divide(showValue,100,2);
refreshSlider(val);
refreshBottun(val);
}
};
//定义一个监听器,用于监听所有滑动条
ChangeListener listener = new ChangeListener()
@ -134,13 +197,13 @@ public class JSliderPane extends JPanel {
public void stateChanged( ChangeEvent event) {
//取出滑动条的值,并在文本中显示出来
if (!isButtonOrIsTxt){
JSlider source = (JSlider) event.getSource();
customButton.setSelected(true);
EventQueue.invokeLater(new Runnable() {
public void run() {
sliderValue = slider.getValue();
getTimes(sliderValue);
showValue = times;
showVal.setText(times + "%");
showValSpinner.setValue(times);
}
});
}else {
@ -149,28 +212,18 @@ public class JSliderPane extends JPanel {
}
};
DocumentListener showValDocumentListener = new DocumentListener() {
ItemListener radioButtonItemListener = new ItemListener() {
@Override
public void insertUpdate(DocumentEvent e) {
isButtonOrIsTxt = true;
resolutionTimes = divide(showValue,100,2);
refreshSlider();
refreshBottun();
}
@Override
public void removeUpdate(DocumentEvent e) {
// refreshSlider();
}
@Override
public void changedUpdate(DocumentEvent e) {
// refreshSlider();
public void itemStateChanged(ItemEvent e) {
JRadioButton temp=(JRadioButton)e.getSource();
if(temp.isSelected()){
showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%"))));
}
}
};
private void refreshSlider(){
showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%")));
private void refreshSlider(int val){
showValue = val;
if (showValue >HUNDRED){
slider.setValue((int)(showValue+TWOHUNDRED)/SIX);
}else if (showValue <HUNDRED){
@ -181,8 +234,8 @@ public class JSliderPane extends JPanel {
}
private void refreshBottun(){
showValButton.setText(showVal.getText());
private void refreshBottun(int val){
showValButton.setText(val+"%");
}
public double getResolutionTimes(){
@ -202,29 +255,30 @@ public class JSliderPane extends JPanel {
ActionListener buttonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%")));
showValue = (int) showValSpinner.getValue();
isButtonOrIsTxt = true;
if(e.getActionCommand().equals("less")){
int newDownVal = showValue - TEN;
if (newDownVal >= TEN ){
showValue = newDownVal;
showVal.setText(newDownVal + "%");
showValSpinner.setValue(newDownVal);
}else {
showValue = newDownVal;
showVal.setText(TEN + "%");
showValSpinner.setValue(TEN);
}
}
if(e.getActionCommand().equals("more")){
int newUpVal = showValue + TEN;
if (newUpVal <= FOURHUNDRED ){
showValue = newUpVal;
showVal.setText(newUpVal + "%");
showValSpinner.setValue(newUpVal);
}else {
showValue = newUpVal;
showVal.setText(FOURHUNDRED + "%");
showValSpinner.setValue(FOURHUNDRED);
}
}
isButtonOrIsTxt = true;
customButton.setSelected(true);
}
};
@ -241,38 +295,42 @@ public class JSliderPane extends JPanel {
}
public UITextField getShowVal(){
return this.showVal;
public JSpinner getShowVal(){
return this.showValSpinner;
}
public UIRadioButton getSelfAdaptButton(){
return this.selfAdaptButton;
}
private void popupDialog(){
Point btnCoords = upButton.getLocationOnScreen();
if (dialog == null){
dialog = new PopupPane(upButton,showVal);
dialog = new PopupPane(upButton,dialogContentPanel);
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() + SHOWVALBUTTONWIDTH , -DIALOGHEIGHT);
}
}else {
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +SHOWVALBUTTONWIDTH, -DIALOGHEIGHT);
} else {
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +SHOWVALBUTTONWIDTH, -DIALOGHEIGHT);
}
}
}
public static void main(String[] args)
{
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel)jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(JSliderPane.getInstance(),BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 80);
jf.setVisible(true);
// JFrame jf = new JFrame("test");
// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// JPanel content = (JPanel)jf.getContentPane();
// content.setLayout(new BorderLayout());
// content.add(JSliderPane.getInstance(),BorderLayout.CENTER);
// GUICoreUtils.centerWindow(jf);
// jf.setSize(400, 80);
// jf.setVisible(true);
}
}
@ -345,66 +403,25 @@ class JSliderPaneUI extends BasicSliderUI {
}
}
class Dialog extends JDialog {
// private Container container;
// private static final int UPLABELHEIGHT = 25;
// private static final int HALFHUNDRED = 50;
// private static final int DIALOGWIDTH = 150;
// private static final int DIALOGHEIGHT = 200;
// private static final int UPLABELWIDTH = 300;
// private int minHeight; // 对话框最小高度
// private JComponent contentPane;
// private JComponent centerPane;
// private UILabel upLabel;
// public Dialog(UIButton b,UITextField j) {
// super(DesignerContext.getDesignerFrame());
// container = getContentPane();
// setUndecorated(true);
// contentPane = new JPanel(new BorderLayout());
// centerPane = new JPanel(new BorderLayout());
// upLabel = new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce"));
// upLabel.setOpaque(true);
// upLabel.setPreferredSize(new Dimension(UPLABELWIDTH,UPLABELHEIGHT));
// upLabel.setBackground(Color.LIGHT_GRAY);
// upLabel.setBorder(BorderFactory.createLineBorder(Color.gray,1));
// upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray));
// centerPane.add(j,BorderLayout.NORTH);
// contentPane.add(upLabel,BorderLayout.NORTH);
// contentPane.add(centerPane,BorderLayout.CENTER);
//// contentPane.setBorder(BorderFactory.createLineBorder(Color.gray,1));
// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray));
//// contentPane.add(new JPanel())
// container.add(contentPane, BorderLayout.CENTER);
// minHeight = container.getPreferredSize().height;
// setSize(DIALOGWIDTH, DIALOGHEIGHT);
//// validate();
// Point btnCoords = b.getLocationOnScreen();
//
// this.setLocation(btnCoords.x - DIALOGWIDTH + b.getWidth() +HALFHUNDRED, btnCoords.y -DIALOGHEIGHT);
//// initListener();
//
// this.setVisible(true);
// }
}
class PopupPane extends JPopupMenu {
private JComponent contentPane;
private static final int UPLABELHEIGHT = 25;
private static final int HALFHUNDRED = 50;
private static final int DIALOGWIDTH = 150;
private static final int DIALOGHEIGHT = 200;
private static final int DIALOGHEIGHT = 240;
private static final int UPLABELWIDTH = 300;
private JComponent centerPane;
private UILabel upLabel;
PopupPane(UIButton b,UITextField j) {
PopupPane(UIButton b,JPanel dialogContentPanel) {
contentPane = new JPanel(new BorderLayout());
centerPane = new JPanel(new BorderLayout());
upLabel = new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce"));
upLabel = new UILabel(" " + Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce"));
upLabel.setOpaque(true);
upLabel.setPreferredSize(new Dimension(UPLABELWIDTH,UPLABELHEIGHT));
upLabel.setBackground(Color.LIGHT_GRAY);
upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray));
centerPane.add(j,BorderLayout.NORTH);
centerPane.add(dialogContentPanel,BorderLayout.NORTH);
contentPane.add(upLabel,BorderLayout.NORTH);
contentPane.add(centerPane,BorderLayout.CENTER);
// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray));

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

@ -1,9 +1,6 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.ConfigManager;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.*;
import com.fr.base.io.IOFile;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
@ -51,6 +48,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.undo.UndoManager;
import java.awt.*;
@ -82,6 +80,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
private long openTime = 0L; // 打开模板的时间点(包括新建模板)
private TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
private StringBuilder process = new StringBuilder(""); // 制作模板的过程
public int resolution = ScreenResolution.getScreenResolution();
public JTemplate(T t, String defaultFileName) {
this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true);
@ -144,6 +143,12 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
return undoState;
}
public abstract void setJTemplateResolution(int resolution);
public abstract int getJTemplateResolution();
;
/**
* 初始化权限细粒度撤销状态
*/
@ -217,6 +222,8 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
public abstract int getScale();
public abstract int selfAdaptUpdate();
protected abstract DesignModelAdapter<T, ?> createDesignModel();
/**

13
designer_chart/src/com/fr/design/chart/gui/ChartComponent.java

@ -13,6 +13,7 @@ import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartglyph.AxisGlyph;
import com.fr.design.chart.gui.active.ActiveGlyph;
import com.fr.design.chart.gui.active.ChartActiveGlyph;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeListener;
@ -41,7 +42,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
private int chartWidth = -1;
private int chartHeight = -1;
private Point point;
private int resolution = ScreenResolution.getScreenResolution();
private ActiveGlyph activeGlyph;
private boolean supportEdit = true;
@ -171,7 +172,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
g2d.setPaint(Color.white);
g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height);
g2d.setPaint(oldPaint);
g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2);
if (needRefreshChartGlyph()) {
@ -315,7 +316,13 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
//不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单
//其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边
//处理画图事件
Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution(), this, null);
resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,resolution, this, null);
g2d.drawImage(chartImage, 0, 0, null);
}
}

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

@ -23,6 +23,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.fr.base.ScreenResolution;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
@ -31,6 +32,7 @@ import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.frpane.UINumberSlidePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
@ -63,12 +65,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
//显示和设置表单界面大小的控件
private UINumberField widthPane;
private UINumberField heightPane;
private JSliderPane slidePane;
private JFormSliderPane slidePane;
private boolean isValid = true;
// 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER;
private int resolution = ScreenResolution.getScreenResolution();
private double screenValue;
private JSliderPane sliderPane;
public FormScrollBar getHorScrollBar() {
return horScrollBar;
@ -122,8 +124,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
// slidePane = new UINumberSlidePane(SLIDER_MIN, SLIDER_FLOAT);
// slidePane.setPreferredSize(new Dimension(260,20));
slidePane = JSliderPane.getInstance();
slidePane.setPreferredSize(new Dimension(300,20));
slidePane = JFormSliderPane.getInstance();
slidePane.setPreferredSize(new Dimension(350,20));
JPanel resizePane =TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{
@ -153,39 +155,26 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private void initTransparent() {
initCalculateSize();
slidePane.getShowVal().getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
// slidePane.getShowVal().getDocument()
double value = Integer.parseInt(slidePane.getShowVal().getText().substring(0, slidePane.getShowVal().getText().indexOf("%")));
value = value>SHOWVALMAX ? SHOWVALMAX : value;
value = value<SHOWVALMIN ? SHOWVALMIN : value;
reCalculateRoot(value, true);
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(form != null){
form.fireTargetModified();
}
}
@Override
public void removeUpdate(DocumentEvent e) {
slidePane.getShowVal().addChangeListener(showValSpinnerChangeListener);
}
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner)e.getSource()).getValue();
value = value>SHOWVALMAX ? SHOWVALMAX : value;
value = value<SHOWVALMIN ? SHOWVALMIN : value;
JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jf.resolution = (int) value;
jf.getFormDesign().setResolution((int) value);
jf.getFormDesign().getArea().resolution = (int) value;
reCalculateRoot(value, true);
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(form != null){
form.fireTargetModified();
}
@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();
// }
// }
// });
}
}
};
/**
* 返回当前的屏幕分辨率对应的百分比值

11
designer_form/src/com/fr/design/mainframe/FormDesigner.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.design.DesignState;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.AdapterBus;
@ -47,6 +48,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.bridge.StableFactory;
import javax.swing.*;
@ -103,6 +105,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
// 存储被选择组件和剪切板的model
private transient SelectionModel selectionModel;
private int resolution = ScreenResolution.getScreenResolution();
// 编辑状态的事件表
private CreatorEventListenerTable edit;
protected Action[] designerActions;
@ -1416,4 +1419,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
}
}
public void setResolution(int resolution){
this.resolution = resolution;
}
public int getResolution(){
return this.resolution;
}
}

26
designer_form/src/com/fr/design/mainframe/FormDesignerUI.java

@ -7,6 +7,7 @@ import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import javax.swing.JComponent;
@ -15,6 +16,7 @@ import javax.swing.plaf.ComponentUI;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.base.Utils;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.AdapterBus;
@ -31,6 +33,7 @@ import com.fr.design.utils.ComponentUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper;
/**
* FormDesigner的UI类是一个有状态的UI类它根据FormDesigner的当前状态画出
@ -42,6 +45,7 @@ public class FormDesignerUI extends ComponentUI {
private FormDesigner designer;
private SelectionModel selectionModel;
private Rectangle2D.Double back_or_selection_rect = new Rectangle2D.Double(0, 0, 0, 0);
private float time;
public FormDesignerUI() {
}
@ -63,6 +67,7 @@ public class FormDesignerUI extends ComponentUI {
@Override
public void paint(Graphics g, JComponent c) {
XCreator rootComponent = designer.getRootComponent();
this.time = (float)designer.getResolution()/ScreenResolution.getScreenResolution();
if (rootComponent != null) {
// 设计自适应界面
repaintFit(g, rootComponent, c);
@ -373,9 +378,17 @@ public class FormDesignerUI extends ComponentUI {
// 禁止双缓冲
ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg;
clipg = g.create(-designer.getArea().getHorizontalValue(), -designer.getArea().getVerticalValue() + designer.getParaHeight(), parent
.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().height
+ designer.getArea().getVerticalValue());
clipg = g.create(
-designer.getArea().getHorizontalValue(),
-designer.getArea().getVerticalValue() + designer.getParaHeight(),
parent.getSize().width + designer.getArea().getHorizontalValue(),
parent.getSize().height + designer.getArea().getVerticalValue());
// BufferedImage img = CoreGraphHelper.createBufferedImage(parent.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().height + designer.getArea().getVerticalValue(), BufferedImage.TYPE_INT_RGB);
// Graphics2D g2d = img.createGraphics();
// component.printAll(g2d);
// g2d.dispose();
// g.drawImage(img,-designer.getArea().getHorizontalValue(),-designer.getArea().getVerticalValue() + designer.getParaHeight(), (int) (parent.getSize().width*time + designer.getArea().getHorizontalValue()), (int) (parent.getSize().height*time + designer.getArea().getVerticalValue()),null);
designer.paintContent(clipg);
clipg.dispose();
@ -397,9 +410,10 @@ public class FormDesignerUI extends ComponentUI {
// 禁止双缓冲
ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg1;
clipg1 = g.create(-designer.getArea().getHorizontalValue(), -designer.getArea().getVerticalValue() , parent
.getSize().width + designer.getArea().getHorizontalValue(), designer.getParaHeight()
+ designer.getArea().getVerticalValue());
clipg1 = g.create(-designer.getArea().getHorizontalValue(),
-designer.getArea().getVerticalValue() ,
parent.getSize().width + designer.getArea().getHorizontalValue(),
designer.getParaHeight() + designer.getArea().getVerticalValue());
designer.paintPara(clipg1);
clipg1.dispose();

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

@ -1,10 +1,13 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution;
import com.fr.design.DesignState;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.cell.FloatElementsProvider;
import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
@ -26,6 +29,8 @@ import com.fr.design.mainframe.actions.FormMobileAttrAction;
import com.fr.design.mainframe.actions.TemplateParameterAction;
import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.mainframe.form.FormElementCasePaneDelegate;
import com.fr.design.mainframe.form.FormReportComponentComposite;
import com.fr.design.mainframe.templateinfo.JFormProcessInfo;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
@ -47,6 +52,9 @@ import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.grid.Grid;
import com.fr.grid.GridUtils;
import com.fr.report.ReportHelper;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.bridge.StableFactory;
@ -104,6 +112,16 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return processInfo;
}
@Override
public void setJTemplateResolution(int resolution) {
}
@Override
public int getJTemplateResolution() {
return 0;
}
@Override
protected boolean accept(Object o) {
return !(o instanceof FloatElementsProvider);
@ -246,7 +264,25 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override
public void setScale(int resolution) {
this.resolution = resolution;
ElementCasePane elementCasePane = ((FormReportComponentComposite)reportComposite).elementCaseDesigner.getEditingElementCasePane();
elementCasePane.setResolution(resolution);
elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution);
elementCasePane.getGrid().setResolution(resolution);
//更新Grid
Grid grid = elementCasePane.getGrid();
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(elementCasePane.getEditingElementCase());
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(elementCasePane.getEditingElementCase());
grid.setVerticalExtent(GridUtils.getExtentValue(0, rowHeightList, grid.getHeight(), resolution));
grid.setHorizontalExtent(GridUtils.getExtentValue(0, columnWidthList, grid.getWidth(), resolution));
elementCasePane.getGrid().updateUI();
//更新Column和Row
((DynamicScrollBar)elementCasePane.getVerticalScrollBar()).setDpi(resolution);
((DynamicScrollBar)elementCasePane.getHorizontalScrollBar()).setDpi(resolution);
elementCasePane.getGridColumn().setResolution(resolution);
elementCasePane.getGridColumn().updateUI();
elementCasePane.getGridRow().setResolution(resolution);
elementCasePane.getGridRow().updateUI();
}
@Override
@ -254,6 +290,30 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return 0;
}
@Override
public int selfAdaptUpdate() {
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
ElementCasePane elementCasePane = ((FormReportComponentComposite)reportComposite).elementCaseDesigner.getEditingElementCasePane();
ElementCasePane reportPane = elementCasePane.getGrid().getElementCasePane();
int column = reportPane.getSelection().getSelectedColumns()[0];
double columnLength = reportPane.getSelection().getSelectedColumns().length;
double columnExtent = reportPane.getGrid().getHorizontalExtent();
int row = reportPane.getSelection().getSelectedRows()[0];
double rowLength = reportPane.getSelection().getSelectedRows().length;
double rowExtent = reportPane.getGrid().getVerticalExtent();
if (columnLength == 0||rowLength == 0){
return resolution;
}
double time =(columnExtent/columnLength)<(rowExtent/rowLength) ? (columnExtent/columnLength) : (rowExtent/rowLength);
if (reportPane.isHorizontalScrollBarVisible()) {
reportPane.getVerticalScrollBar().setValue(row);
reportPane.getHorizontalScrollBar().setValue(column);
}
return (int) (time * elementCasePane.getGrid().getResolution());
}
/**
* 创建权限细粒度编辑面板
*

Loading…
Cancel
Save