diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index 17dfa8442d..6682a6fa58 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePane.java @@ -209,7 +209,9 @@ public abstract class ElementCasePane 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 extends Tar } + public void setResolution(int resolution){ + this.resolution = resolution; + } + + public int getResolution(){ + return this.resolution; + } + /** * 所有的操作都必须在可见范围内,否则不做任何操作 * diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 8251368849..1fa6ee8d52 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -345,6 +345,7 @@ public class JWorkBook extends JTemplate { //更新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 diff --git a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java index 11bfbe476d..d9ad0f35f3 100644 --- a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java +++ b/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 targetModifiedList = new java.util.ArrayList(); /** @@ -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; } /** diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 121171b7a8..95614b2124 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -80,7 +80,7 @@ public abstract class JTemplate> 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); diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index b7853183e1..1203bdf0de 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/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 = valueSHOWVALMAX ? SHOWVALMAX : value; + value = value 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
implements TreeSelection } } + + public void setResolution(int resolution){ + this.resolution = resolution; + } + + public int getResolution(){ + return this.resolution; + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java b/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java index 259e1b65ef..2cc0cabdfc 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java +++ b/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(); diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 2e6aefaeb1..7cb1e0e01f 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/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 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 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()); } /**