Browse Source

REPORT-2897 9.0设计器修改

缩放条部分
master
MoMeak 8 years ago
parent
commit
f59ff6bb40
  1. 12
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  2. 1
      designer/src/com/fr/design/mainframe/JWorkBook.java
  3. 54
      designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java
  4. 2
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  5. 29
      designer_form/src/com/fr/design/mainframe/FormArea.java
  6. 11
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  7. 26
      designer_form/src/com/fr/design/mainframe/FormDesignerUI.java
  8. 49
      designer_form/src/com/fr/design/mainframe/JForm.java

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

@ -209,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();
@ -344,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;
}
/**
* 所有的操作都必须在可见范围内否则不做任何操作
*

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

@ -345,6 +345,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
//更新resolution
this.resolution = resolution;
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

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;
}
/**

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

@ -80,7 +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(""); // 制作模板的过程
private int resolution = ScreenResolution.getScreenResolution();
public int resolution = ScreenResolution.getScreenResolution();
public JTemplate(T t, String defaultFileName) {
this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true);

29
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;
@ -64,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;
@ -123,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[][]{
@ -160,14 +161,18 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
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;
reCalculateRoot(value, true);
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(form != null){
form.fireTargetModified();
}
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();
}
}
};

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();

49
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;
@ -256,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
@ -266,7 +292,26 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override
public int selfAdaptUpdate() {
return 0;
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