From 6ad1e6adcf49779d83589cbd7f94e08183136714 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Fri, 21 Jul 2017 11:13:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/cell/bar/DynamicScrollBar.java | 6 + .../fr/design/mainframe/ElementCasePane.java | 2 - .../com/fr/design/mainframe/JWorkBook.java | 66 +++-- .../fr/design/mainframe/ReportComponent.java | 4 + .../mainframe/ReportComponentCardPane.java | 2 +- .../mainframe/ReportComponentComposite.java | 26 +- .../com/fr/design/present/BarCodePane.java | 11 + .../grid/AbstractGridHeaderMouseHandler.java | 35 +-- designer/src/com/fr/grid/Grid.java | 4 + designer/src/com/fr/grid/GridColumn.java | 20 +- .../com/fr/grid/GridColumnMouseHandler.java | 9 +- designer/src/com/fr/grid/GridHeader.java | 12 + designer/src/com/fr/grid/GridRow.java | 14 +- .../com/fr/design/mainframe/JSliderPane.java | 229 ++++++++++-------- .../com/fr/design/mainframe/JTemplate.java | 2 + .../src/com/fr/design/mainframe/FormArea.java | 36 +-- .../src/com/fr/design/mainframe/JForm.java | 5 + 17 files changed, 302 insertions(+), 181 deletions(-) diff --git a/designer/src/com/fr/design/cell/bar/DynamicScrollBar.java b/designer/src/com/fr/design/cell/bar/DynamicScrollBar.java index bf61f7a5e..11f8e51b0 100644 --- a/designer/src/com/fr/design/cell/bar/DynamicScrollBar.java +++ b/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(); diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index d55fcd447..17dfa8442 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePane.java +++ b/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; diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 5978a506f..0a7535067 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/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; @@ -70,6 +68,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; @@ -334,20 +333,51 @@ public class JWorkBook extends JTemplate { 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.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); + reportComposite.centerCardPane.polyDezi.updateUI(); + } +// reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setVerticalValue(10); + + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); + } + @Override + public int selfAdaptUpdate(){ + 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()); } @Override diff --git a/designer/src/com/fr/design/mainframe/ReportComponent.java b/designer/src/com/fr/design/mainframe/ReportComponent.java index 6ca268545..42342f24e 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponent.java +++ b/designer/src/com/fr/design/mainframe/ReportComponent.java @@ -27,9 +27,13 @@ import com.fr.design.selection.Selectedable; */ public abstract class ReportComponent extends TargetComponent implements Selectedable { protected E elementCasePane; +// protected P polyElementCasePane; public E getEditingElementCasePane() { return elementCasePane; } +// public P getEditingPolyElementCasePane() { +// return polyElementCasePane; +// } public ReportComponent(T t) { super(t); } diff --git a/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java b/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java index 54c7f7657..cc45cf5e9 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentCardPane.java +++ b/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()); diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index d51db1770..36418924b 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/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 { 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)); diff --git a/designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java b/designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java index 42f7417b5..b68ddd197 100644 --- a/designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java +++ b/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) { diff --git a/designer/src/com/fr/grid/Grid.java b/designer/src/com/fr/grid/Grid.java index 6bade0e2e..01a2bb1d8 100644 --- a/designer/src/com/fr/grid/Grid.java +++ b/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; + } + /** * 应用界面设置 * diff --git a/designer/src/com/fr/grid/GridColumn.java b/designer/src/com/fr/grid/GridColumn.java index eedf8bcaf..165a5727a 100644 --- a/designer/src/com/fr/grid/GridColumn.java +++ b/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 { - 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 { @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 { this.resolution = resolution; } + @Override + public int getResolution() { + return this.resolution; + } + /** * Gets the preferred size. */ diff --git a/designer/src/com/fr/grid/GridColumnMouseHandler.java b/designer/src/com/fr/grid/GridColumnMouseHandler.java index b7864bf05..2d93d01d2 100644 --- a/designer/src/com/fr/grid/GridColumnMouseHandler.java +++ b/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) { diff --git a/designer/src/com/fr/grid/GridHeader.java b/designer/src/com/fr/grid/GridHeader.java index 754257e2f..b0dca649d 100644 --- a/designer/src/com/fr/grid/GridHeader.java +++ b/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 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 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) ; diff --git a/designer/src/com/fr/grid/GridRow.java b/designer/src/com/fr/grid/GridRow.java index 4c42ce630..28a97e170 100644 --- a/designer/src/com/fr/grid/GridRow.java +++ b/designer/src/com/fr/grid/GridRow.java @@ -23,10 +23,13 @@ public class GridRow extends GridHeader { 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 { @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 { this.resolution = resolution; } + public int getResolution() { + return this.resolution; + } + /** * Gets the preferred size. diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index 18ab15a0b..c4cdf377f 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/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 = 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)); diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index a5023be82..309fac533 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -217,6 +217,8 @@ public abstract class JTemplate> ex public abstract int getScale(); + public abstract int selfAdaptUpdate(); + protected abstract DesignModelAdapter createDesignModel(); /** diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index 0d0e05f04..b7853183e 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -31,6 +31,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; @@ -153,11 +154,13 @@ 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("%"))); + 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 implements BaseJForm { return 0; } + @Override + public int selfAdaptUpdate() { + return 0; + } + /** * 创建权限细粒度编辑面板 * From f89951424a1b205101fa4070bb90840deda4996e Mon Sep 17 00:00:00 2001 From: MoMeak Date: Sun, 23 Jul 2017 23:40:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E8=81=9A=E5=90=88=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E7=BC=A9=E6=94=BE=E6=9D=A1=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JWorkBook.java | 64 ++++++++++---- .../mainframe/ReportComponentComposite.java | 2 +- designer/src/com/fr/poly/PolyArea.java | 18 +++- designer/src/com/fr/poly/PolyDesignUI.java | 87 ++++++++++++------- designer/src/com/fr/poly/PolyDesigner.java | 62 +++++++------ .../src/com/fr/poly/creator/BlockCreator.java | 4 + .../src/com/fr/poly/creator/BlockEditor.java | 2 +- .../fr/poly/creator/ChartBlockCreator.java | 14 ++- .../com/fr/poly/creator/ChartBlockEditor.java | 13 ++- .../com/fr/poly/creator/ECBlockEditor.java | 5 ++ .../com/fr/design/mainframe/JTemplate.java | 13 ++- .../fr/design/chart/gui/ChartComponent.java | 13 ++- .../src/com/fr/design/mainframe/JForm.java | 10 +++ 13 files changed, 219 insertions(+), 88 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 0a7535067..825136884 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -56,6 +56,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; @@ -147,6 +148,16 @@ public class JWorkBook extends JTemplate { return processInfo; } + @Override + public void setJTemplateResolution(int resolution) { + this.resolution = resolution; + } + + @Override + public int getJTemplateResolution() { + return this.resolution; + } + /** * 判断sheet权限 * @@ -353,6 +364,7 @@ public class JWorkBook extends JTemplate { } 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); @@ -361,23 +373,45 @@ public class JWorkBook extends JTemplate { } @Override public int selfAdaptUpdate(){ - 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){ + 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; } - 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()); } @Override diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index 36418924b..1b4fcdd1d 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -85,7 +85,7 @@ public class ReportComponentComposite extends JComponent { public void itemStateChanged(ItemEvent e) { if (jSliderContainer.getSelfAdaptButton().isSelected()){ int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate(); - jSliderContainer.getShowVal().setValue(resolution); + jSliderContainer.getShowVal().setValue(resolution*HUND/ScreenResolution.getScreenResolution()); } } }; diff --git a/designer/src/com/fr/poly/PolyArea.java b/designer/src/com/fr/poly/PolyArea.java index 07a79edc5..c9589f69f 100644 --- a/designer/src/com/fr/poly/PolyArea.java +++ b/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; } diff --git a/designer/src/com/fr/poly/PolyDesignUI.java b/designer/src/com/fr/poly/PolyDesignUI.java index e46a24310..58ed225b8 100644 --- a/designer/src/com/fr/poly/PolyDesignUI.java +++ b/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 dbcomponents = new ArrayList(); // 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); } diff --git a/designer/src/com/fr/poly/PolyDesigner.java b/designer/src/com/fr/poly/PolyDesigner.java index faa15a946..e2a25aeb6 100644 --- a/designer/src/com/fr/poly/PolyDesigner.java +++ b/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 clip_board = new ArrayList(); - // 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 extends JComponent i LayoutUtils.layoutContainer(this); } + public void setResolution(int resolution){ + this.resolution = resolution; + } + //默认大小, 报表块默认3列6行, 图表块默认330*240 public abstract UnitRectangle getDefaultBlockBounds(); diff --git a/designer/src/com/fr/poly/creator/BlockEditor.java b/designer/src/com/fr/poly/creator/BlockEditor.java index 2e058b0f4..070f3e3a0 100644 --- a/designer/src/com/fr/poly/creator/BlockEditor.java +++ b/designer/src/com/fr/poly/creator/BlockEditor.java @@ -50,7 +50,7 @@ public abstract class BlockEditor public BlockEditor(PolyDesigner designer, BlockCreator creator) { this.designer = designer; this.creator = creator; - + this.resolution = creator.resolution; this.initComponets(); this.addColumnRowListeners(); diff --git a/designer/src/com/fr/poly/creator/ChartBlockCreator.java b/designer/src/com/fr/poly/creator/ChartBlockCreator.java index ca8106ffa..93e25d21e 100644 --- a/designer/src/com/fr/poly/creator/ChartBlockCreator.java +++ b/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 { 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 { super(block); } + public void setResolution(int resolution){ + this.resolution = resolution; + } + /** * 初始化 * @return 初始化的控件. @@ -65,6 +72,7 @@ public class ChartBlockCreator extends BlockCreator { } + /** * 检测按钮状态 * diff --git a/designer/src/com/fr/poly/creator/ChartBlockEditor.java b/designer/src/com/fr/poly/creator/ChartBlockEditor.java index 8b0d90542..8996b58fb 100644 --- a/designer/src/com/fr/poly/creator/ChartBlockEditor.java +++ b/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 { @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(); diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 309fac533..121171b7a 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/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> ex private long openTime = 0L; // 打开模板的时间点(包括新建模板) private TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); private StringBuilder process = new StringBuilder(""); // 制作模板的过程 + private 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> ex return undoState; } + public abstract void setJTemplateResolution(int resolution); + + public abstract int getJTemplateResolution(); + + ; + /** * 初始化权限细粒度撤销状态 */ diff --git a/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java b/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java index 5ce350450..127f640d2 100644 --- a/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java +++ b/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); } } diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index e6288dc2f..2e6aefaeb 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -104,6 +104,16 @@ public class JForm extends JTemplate 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); From f59ff6bb4064135210d27be5c868eebe14eef08c Mon Sep 17 00:00:00 2001 From: MoMeak Date: Mon, 24 Jul 2017 15:17:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/ElementCasePane.java | 12 ++++- .../com/fr/design/mainframe/JWorkBook.java | 1 + .../form/FormReportComponentComposite.java | 54 ++++++++++++++++--- .../com/fr/design/mainframe/JTemplate.java | 2 +- .../src/com/fr/design/mainframe/FormArea.java | 29 +++++----- .../com/fr/design/mainframe/FormDesigner.java | 11 ++++ .../fr/design/mainframe/FormDesignerUI.java | 26 ++++++--- .../src/com/fr/design/mainframe/JForm.java | 49 ++++++++++++++++- 8 files changed, 155 insertions(+), 29 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index 17dfa8442..6682a6fa5 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 825136884..1fa6ee8d5 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 11bfbe476..d9ad0f35f 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 121171b7a..95614b212 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 b7853183e..1203bdf0d 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 259e1b65e..2cc0cabdf 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 2e6aefaeb..7cb1e0e01 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()); } /**