Browse Source

REPORT-2897 9.0设计器修改

缩放条部分
master
MoMeak 7 years ago
parent
commit
6ad1e6adcf
  1. 6
      designer/src/com/fr/design/cell/bar/DynamicScrollBar.java
  2. 2
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  3. 66
      designer/src/com/fr/design/mainframe/JWorkBook.java
  4. 4
      designer/src/com/fr/design/mainframe/ReportComponent.java
  5. 2
      designer/src/com/fr/design/mainframe/ReportComponentCardPane.java
  6. 26
      designer/src/com/fr/design/mainframe/ReportComponentComposite.java
  7. 11
      designer/src/com/fr/design/present/BarCodePane.java
  8. 35
      designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java
  9. 4
      designer/src/com/fr/grid/Grid.java
  10. 20
      designer/src/com/fr/grid/GridColumn.java
  11. 9
      designer/src/com/fr/grid/GridColumnMouseHandler.java
  12. 12
      designer/src/com/fr/grid/GridHeader.java
  13. 14
      designer/src/com/fr/grid/GridRow.java
  14. 229
      designer_base/src/com/fr/design/mainframe/JSliderPane.java
  15. 2
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  16. 36
      designer_form/src/com/fr/design/mainframe/FormArea.java
  17. 5
      designer_form/src/com/fr/design/mainframe/JForm.java

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

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

2
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;

66
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<WorkBook, WorkBookUndoState> {
public void setScale(int resolution) {
//更新resolution
this.resolution = resolution;
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setResolution(resolution);
//更新Grid
Grid grid = reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid();
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(reportComposite.centerCardPane.editingComponet.elementCasePane.getEditingElementCase());
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(reportComposite.centerCardPane.editingComponet.elementCasePane.getEditingElementCase());
grid.setVerticalExtent(GridUtils.getExtentValue(0, rowHeightList, grid.getHeight(), resolution));
grid.setHorizontalExtent(GridUtils.getExtentValue(0, columnWidthList, grid.getWidth(), resolution));
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().updateUI();
//更新Column和Row
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridColumn().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridColumn().updateUI();
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridRow().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridRow().updateUI();
if (reportComposite.centerCardPane.editingComponet.elementCasePane != null){
reportComposite.centerCardPane.editingComponet.elementCasePane.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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -217,6 +217,8 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
public abstract int getScale();
public abstract int selfAdaptUpdate();
protected abstract DesignModelAdapter<T, ?> createDesignModel();
/**

36
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<SHOWVALMIN ? SHOWVALMIN : value;
reCalculateRoot(value, true);
@ -165,27 +168,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
if(form != null){
form.fireTargetModified();
}
}
@Override
public void removeUpdate(DocumentEvent e) {
}
@Override
public void changedUpdate(DocumentEvent e) {
}
});
// slidePane.addChangeListener(new ChangeListener() {
// public void stateChanged(ChangeEvent e) {
// double value = ((UINumberSlidePane) e.getSource()).getValue();
// reCalculateRoot(value, true);
// JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
// if(form != null){
// form.fireTargetModified();
// }
// }
// });
}
}
};
/**
* 返回当前的屏幕分辨率对应的百分比值

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

@ -254,6 +254,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return 0;
}
@Override
public int selfAdaptUpdate() {
return 0;
}
/**
* 创建权限细粒度编辑面板
*

Loading…
Cancel
Save